Changeset 35521
- Timestamp:
- May 6, 2013, 10:32:51 AM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130419/pswarp/src
- Files:
-
- 9 edited
-
Makefile.am (modified) (1 diff)
-
pswarp.h (modified) (2 diffs)
-
pswarpCleanup.c (modified) (1 diff)
-
pswarpLoop.c (modified) (6 diffs)
-
pswarpMakePSF.c (modified) (3 diffs)
-
pswarpMaskStats.c (modified) (1 diff)
-
pswarpParseCamera.c (modified) (2 diffs)
-
pswarpUpdateStatistics.c (modified) (1 diff)
-
pswarpVersion.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130419/pswarp/src/Makefile.am
r35512 r35521 39 39 pswarpErrorCodes.c \ 40 40 pswarpLoadAstrometry.c \ 41 pswarpMakePSF.c \ 41 42 pswarpMapGrid.c \ 42 43 pswarpMaskStats.c \ -
branches/eam_branches/ipp-20130419/pswarp/src/pswarp.h
r35512 r35521 22 22 #include <psmodules.h> 23 23 #include <psphot.h> 24 #include <ppStats.h> 24 25 25 26 #define THREADED 1 … … 198 199 199 200 bool pswarpTransformToTarget (pmFPA *output, pmReadout *input, pmConfig *config); 200 bool pswarpMakePSF (pm FPA *output);201 bool pswarpMakePSF (pmConfig *config, pmFPAfile *output, psMetadata *stats); 201 202 bool pswarpUpdateStatistics (pmFPA *output, psMetadata *stats, pmFPA *input, pmFPA *astrom, pmConfig *config); -
branches/eam_branches/ipp-20130419/pswarp/src/pswarpCleanup.c
r35515 r35521 19 19 // Ensure everything is written out, at every level 20 20 pswarpFileActivation(config, detectorFiles, false); 21 pswarpFileActivation(config, photFiles, false);22 21 pswarpFileActivation(config, independentFiles, false); 23 22 23 pswarpFileActivation(config, photFiles, true); 24 24 pswarpFileActivation(config, skycellFiles, true); 25 25 pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.SOURCES"); -
branches/eam_branches/ipp-20130419/pswarp/src/pswarpLoop.c
r35515 r35521 11 11 12 12 #include "pswarp.h" 13 #include <ppStats.h>14 13 #include "pswarpFileNames.h" // Lists of file rules used at different stages 15 16 #define WCS_NONLIN_TOL 0.001 // Non-linear tolerance for header WCS17 #define TESTING 0 // Testing output?18 14 19 15 // Loop over the inputs, warp them to the output skycell and then write out the output. … … 33 29 } 34 30 35 // XXX this should probably happen elsewhere (logically it belongs to file I/O, right?)31 // XXX move this to pswarpParseCamera? has to come after input mask header is read 36 32 if (!pswarpSetMaskBits(config)) { 37 33 psError(psErrorCodeLast(), false, "failed to set mask bits"); … … 70 66 return false; 71 67 } 72 73 // XXX NOTE : 'output' was a readout, now we need to loop over all output targets74 68 75 69 // ensure everyone is off except what we need below … … 79 73 pswarpFileActivation(config, skycellFiles, false); 80 74 81 // Turn on the source output --- we need to get rid of these so that we can measure the PSF82 // XXX NOTE : do not tackle source issues yet...83 // XXX pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.SOURCES");84 85 75 // the loops below load the input data 86 76 pswarpFileActivation(config, detectorFiles, true); … … 90 80 91 81 // pswarpFileActivation(config, independentFiles, true); 92 93 82 94 83 pmFPAview *view = pmFPAviewAlloc(0); … … 171 160 } 172 161 173 // XXXX turn these on later .. pswarpMakePSF (output); 174 // XXX have not yet written the output to disk 162 if (!pswarpMakePSF (config, output, stats)) { 163 psError(psErrorCodeLast(), false, "problem generating PSF."); 164 goto FAIL; 165 } 166 175 167 psFree(view); 176 168 return true; -
branches/eam_branches/ipp-20130419/pswarp/src/pswarpMakePSF.c
r35511 r35521 11 11 12 12 #include "pswarp.h" 13 #include <ppStats.h>14 #include "pswarpFileNames.h" // Lists of file rules used at different stages15 13 16 14 #define WCS_NONLIN_TOL 0.001 // Non-linear tolerance for header WCS … … 19 17 // We need a new PSF model for the warped frame. It would be good to generate this analytically, but 20 18 // that's going to be tricky. We have a list of sources, so we use those to redetermine the PSF model. 21 bool pswarpMakePSF (pmConfig *config) { 19 20 bool pswarpMakePSF (pmConfig *config, pmFPAfile *output, psMetadata *stats) { 21 22 bool status = false; 22 23 23 24 // load the recipe … … 28 29 } 29 30 30 if (psMetadataLookupBool(&mdok, recipe, "PSF")) { 31 pswarpFileActivation(config, photFiles, true); 32 if (!pswarpIOChecksBefore(config)) { 33 psError(psErrorCodeLast(), false, "Unable to read files."); 34 goto DONE; 35 } 31 if (!psMetadataLookupBool(&status, recipe, "PSF")) { 32 psLogMsg("pswarp", PS_LOG_INFO, "Skipping PSF measurement"); 33 return true; 34 } 36 35 37 // supply the readout and fpa of interest to psphot 38 pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT"); 39 pmFPACopy(photFile->fpa, outFPA); 36 // XXX What was being read here?? skip this for now 37 if (false && !pswarpIOChecksBefore(config)) { 38 psError(psErrorCodeLast(), false, "Unable to read files."); 39 return false; 40 } 40 41 41 pmFPAview *view = pmFPAviewAlloc(0); ///< View into skycell 42 view->chip = view->cell = view->readout = 0; 42 // supply the readout and fpa of interest to psphot 43 pmFPAfile *photFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.INPUT"); 44 pmFPACopy(photFile->fpa, output->fpa); 43 45 44 // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF) 45 psArray *sources = psphotLoadPSFSources (config, view); 46 if (!sources) { 47 psError(psErrorCodeLast(), false, "No sources supplied to measure PSF"); 48 goto DONE; 49 } 46 pmFPAview *view = pmFPAviewAlloc(0); ///< View into skycell 50 47 51 pmModelClassSetLimits(PM_MODEL_LIMITS_STRICT); 48 pmChip *chip; 49 while ((chip = pmFPAviewNextChip (view, photFile->fpa, 1)) != NULL) { 50 psTrace ("pswarpMakePSF", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 51 if (!chip->process || !chip->file_exists) { continue; } 52 52 53 // measure the PSF using these sources 54 if (!psphotReadoutFindPSF(config, view, "PSPHOT.INPUT", sources)) { 55 // This is likely a data quality issue 56 // XXX Split into multiple cases using error codes? 57 psErrorStackPrint(stderr, "Unable to determine PSF"); 58 psWarning("Unable to determine PSF --- suspect bad data quality."); 59 if (stats && psMetadataLookupS32(NULL, stats, "QUALITY") == 0) { 60 psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE, 61 "Unable to determine PSF", psErrorCodeLast()); 62 } 63 psErrorClear(); 64 psphotFilesActivate(config, false); 65 } 53 pmCell *cell; 54 while ((cell = pmFPAviewNextCell (view, photFile->fpa, 1)) != NULL) { 55 psTrace ("pswarpMakePSF", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 56 if (!cell->process || !cell->file_exists) { continue; } 66 57 67 // Ensure seeing is carried over 68 pmChip *photChip = pmFPAviewThisChip(view, photFile->fpa); // Chip with seeing 69 psMetadataItem *item = psMetadataLookup(outChip->concepts, "CHIP.SEEING"); // Concept with seeing 70 item->data.F32 = psMetadataLookupF32(NULL, photChip->concepts, "CHIP.SEEING"); 58 // process each of the readouts 59 pmReadout *readout; 60 while ((readout = pmFPAviewNextReadout(view, photFile->fpa, 1)) != NULL) { 61 if (!readout->data_exists) { 62 continue; 63 } 71 64 72 // XXX EAM : put this in a visualization function 73 #if (TESTING) 74 { 75 #define PSF_SIZE 20 ///< Half-size of PSF 76 #define PSF_FLUX 10000 ///< Central flux for PSF 77 pmChip *photChip = pmFPAviewThisChip(view, photFile->fpa); 78 pmPSF *psf = psMetadataLookupPtr(NULL, photChip->analysis, "PSPHOT.PSF"); 79 psImage *image = psImageAlloc(2 * PSF_SIZE + 1, 2 * PSF_SIZE + 1, PS_TYPE_F32); 80 psImageInit(image, 0); 81 pmModel *model = pmModelFromPSFforXY(psf, PSF_SIZE, PSF_SIZE, PSF_FLUX); 82 pmModelAdd(image, NULL, model, PM_MODEL_OP_FULL, 0); 83 psFree(model); 84 psFits *fits = psFitsOpen("psf.fits", "w"); 85 psFitsWriteImage(fits, NULL, image, 0, NULL); 86 psFitsClose(fits); 87 psFree(image); 88 } 89 #endif 65 // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF) 66 psArray *sources = psphotLoadPSFSources (config, view); 67 if (!sources) { 68 // psError(psErrorCodeLast(), false, "No sources supplied to measure PSF"); 69 psLogMsg ("psphot", 3, "no psf sources for this readout (%d %d %d)", view->chip, view->cell, view->readout); 70 continue; 71 } 90 72 91 psFree(view); 73 // XXX move above the loop 74 pmModelClassSetLimits(PM_MODEL_LIMITS_STRICT); 75 76 // measure the PSF using these sources 77 if (!psphotReadoutFindPSF(config, view, "PSPHOT.INPUT", sources)) { 78 // A failure is likely a data quality issue. raise a quality flag, but do not skip other readouts 79 // XXX Split into multiple cases using error codes? 80 psErrorStackPrint(stderr, "Unable to determine PSF for readout (%d %d %d)", view->chip, view->cell, view->readout); 81 psWarning("Unable to determine PSF --- suspect bad data quality : readout (%d %d %d)", view->chip, view->cell, view->readout); 82 if (stats) { 83 int currentQuality = psMetadataLookupS32(&status, stats, "QUALITY"); 84 if (currentQuality == 0) { 85 psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE, "Unable to determine PSF", psErrorCodeLast()); 86 } 87 } 88 psErrorClear(); 89 } 90 } 91 } 92 93 // Ensure seeing is carried over from the PSPHOT.INPUT chip to the output chip 94 pmChip *outChip = pmFPAviewThisChip(view, output->fpa); // Chip with seeing 95 psMetadataItem *item = psMetadataLookup(outChip->concepts, "CHIP.SEEING"); // Concept with seeing 96 item->data.F32 = psMetadataLookupF32(&status, chip->concepts, "CHIP.SEEING"); 92 97 } 98 99 // XXX test function found below 100 // pswarpMakePSF_test (); 101 102 psFree(view); 103 return true; 104 } 105 106 # if (0) 107 bool pswarpMakePSF_test () { 108 109 #define PSF_SIZE 20 ///< Half-size of PSF 110 #define PSF_FLUX 10000 ///< Central flux for PSF 111 pmChip *photChip = pmFPAviewThisChip(view, photFile->fpa); 112 pmPSF *psf = psMetadataLookupPtr(NULL, photChip->analysis, "PSPHOT.PSF"); 113 psImage *image = psImageAlloc(2 * PSF_SIZE + 1, 2 * PSF_SIZE + 1, PS_TYPE_F32); 114 psImageInit(image, 0); 115 pmModel *model = pmModelFromPSFforXY(psf, PSF_SIZE, PSF_SIZE, PSF_FLUX); 116 pmModelAdd(image, NULL, model, PM_MODEL_OP_FULL, 0); 117 psFree(model); 118 psFits *fits = psFitsOpen("psf.fits", "w"); 119 psFitsWriteImage(fits, NULL, image, 0, NULL); 120 psFitsClose(fits); 121 psFree(image); 93 122 return true; 94 123 } 95 124 # endif 96 -
branches/eam_branches/ipp-20130419/pswarp/src/pswarpMaskStats.c
r35512 r35521 1 1 #include "pswarp.h" 2 #include <ppStats.h>3 2 4 3 bool pswarpMaskStats(const pmReadout *readout, psMetadata *stats, const pmConfig *config) -
branches/eam_branches/ipp-20130419/pswarp/src/pswarpParseCamera.c
r35514 r35521 179 179 } 180 180 181 /// XXX re-enable after sources work 182 if (false && psMetadataLookupBool(&mdok, recipe, "PSF")) { 181 if (psMetadataLookupBool(&mdok, recipe, "PSF")) { 183 182 // This file, PSPHOT.INPUT, is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by 184 183 // psphotDefineFiles 185 pmFPAfile *psphotInput = pmFPAfileDefineSkycell(config, NULL, "PSPHOT.INPUT"); 184 // XXX old : pmFPAfile *psphotInput = pmFPAfileDefineSkycell(config, NULL, "PSPHOT.INPUT"); 185 pmFPAfile *psphotInput = pmFPAfileDefineOutputForFormat(config, NULL, "PSPHOT.INPUT", skycell->cameraName, skycell->formatName); 186 186 if (!psphotInput) { 187 187 psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT")); … … 189 189 } 190 190 psphotInput->src = psMemIncrRefCounter(output->fpa); 191 // specify the number of psphot input images 191 192 // specify the number of psphot input images (psphotReadout loops over all input images) 192 193 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1); 193 194 194 pmFPAfile *psphotInSources = pmFPAfileDefineSkycell(config, output->fpa, "PSPHOT.INPUT.CMF"); 195 // the input sources (read from the input astrometry file) are transformed (in pswarpLoop) to the readout->analysis 196 // entries of the output file PSWARP.OUTPUT.SOURCES, associated with the main output pmFPAfile PSWARP.OUTPUT 197 198 // the PSPHOT.INPUT.CMF is used to supply those sources to psphot (specifically psphotLoadPSFSources). 199 200 // pmFPAfile *psphotInSources = pmFPAfileDefineSkycell(config, output->fpa, "PSPHOT.INPUT.CMF"); 201 pmFPAfile *psphotInSources = pmFPAfileDefineOutputForFormat(config, output->fpa, "PSPHOT.INPUT.CMF", skycell->cameraName, skycell->formatName); 195 202 if (!psphotInSources) { 196 203 psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT.CMF")); -
branches/eam_branches/ipp-20130419/pswarp/src/pswarpUpdateStatistics.c
r35511 r35521 11 11 12 12 #include "pswarp.h" 13 #include <ppStats.h>14 13 15 14 // once the output fpa elements have been built, loop over the fpa and generate stats -
branches/eam_branches/ipp-20130419/pswarp/src/pswarpVersion.c
r28043 r35521 13 13 #include <config.h> 14 14 #endif 15 16 #include <stdio.h>17 #include <pslib.h>18 #include <psmodules.h>19 #include <psphot.h>20 #include <ppStats.h>21 15 22 16 #include "pswarp.h"
Note:
See TracChangeset
for help on using the changeset viewer.
