Changeset 26894 for trunk/psphot/src/psphotLoadPSF.c
- Timestamp:
- Feb 10, 2010, 7:36:29 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotLoadPSF.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotLoadPSF.c
r18002 r26894 1 1 # include "psphotInternal.h" 2 2 3 // NOTE : pmPSF_IO.c functions must load the psf model onto the chip->analysis metadata because 4 // the I/O operation likely occurs before the readout exists. This implementation assumes that 5 // a single psf model is valid for the entire set of readouts (not valid for a time series of readouts) 6 7 // XXX for now (2010.01.27), the supporting programs do not define multiple PSPHOT.PSF.LOAD 8 // files to go with multiple PSPHOT.INPUT files. as a result, the implementation below is 9 // currently going to work for the case of a single input file, but will fail if we try with a 10 // stack of images. 11 3 12 // load an externally supplied psf model 4 pmPSF *psphotLoadPSF (pmConfig *config, const pmFPAview *view, psMetadata *recipe) { 13 bool psphotLoadPSFReadout (pmConfig *config, const pmFPAview *view, const char *outFilename, const char *inFilename, int index) { 14 15 bool status; 16 17 // find the currently selected readout 18 pmFPAfile *inFile = pmFPAfileSelectSingle(config->files, inFilename, index); // File of interest 19 if (inFile == NULL) { 20 psLogMsg ("psphot", 3, "no psf supplied for this chip"); 21 return true; 22 } 23 24 // find the currently selected readout 25 pmFPAfile *outFile = pmFPAfileSelectSingle(config->files, outFilename, index); // File of interest 26 if (outFile == NULL) { 27 psLogMsg ("psphot", 3, "no psf supplied for this chip"); 28 return true; 29 } 5 30 6 31 // find the currently selected chip 7 pmChip *chip = pmFPA fileThisChip (config->files, view, "PSPHOT.PSF.LOAD");8 if (!chip) return NULL;32 pmChip *chip = pmFPAviewThisChip (view, inFile->fpa); 33 if (!chip) return false; 9 34 10 35 // find the currently selected readout 11 pmReadout *readout = pmFPA fileThisReadout (config->files, view, "PSPHOT.PSF.LOAD");12 if (!readout) return NULL;36 pmReadout *readout = pmFPAviewThisReadout (view, outFile->fpa); 37 if (!readout) return false; 13 38 14 39 // check if a PSF model is supplied by the user 15 pmPSF *psf = psMetadataLookupPtr ( NULL, chip->analysis, "PSPHOT.PSF");40 pmPSF *psf = psMetadataLookupPtr (&status, chip->analysis, "PSPHOT.PSF"); 16 41 if (psf == NULL) { 17 42 psLogMsg ("psphot", 3, "no psf supplied for this chip"); 18 return NULL;43 return true; 19 44 } 20 45 21 if (!psphotPSFstats (readout, recipe, psf)) psAbort("cannot measure PSF shape terms"); 46 if (!psphotPSFstats (readout, psf)) { 47 psAbort("cannot measure PSF shape terms"); 48 } 22 49 23 50 psLogMsg ("psphot", 3, "using externally supplied PSF model for this readout"); 24 51 25 // we return a psf which can be free (and which may be removed from the metadata) 26 psMemIncrRefCounter (psf); 27 return psf; 52 // save PSF on readout->analysis 53 if (!psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_META_REPLACE | PS_DATA_UNKNOWN, "psphot psf model", psf)) { 54 psError (PSPHOT_ERR_UNKNOWN, false, "problem saving sources on readout"); 55 return false; 56 } 57 58 return true; 28 59 } 60 61 bool psphotLoadPSF (pmConfig *config, const pmFPAview *view) { 62 63 bool status = false; 64 65 // XXX PSPHOT.PSF.LOAD vs PSPHOT.INPUT -- see note at top 66 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 67 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 68 69 // loop over the available readouts 70 for (int i = 0; i < num; i++) { 71 72 // Generate the mask and weight images, including the user-defined analysis region of interest 73 if (!psphotLoadPSFReadout (config, view, "PSPHOT.INPUT", "PSPHOT.PSF.LOAD", i)) { 74 psError (PSPHOT_ERR_CONFIG, false, "failed to load PSF model for PSPHOT.PSF.LOAD entry %d", i); 75 return false; 76 } 77 } 78 return true; 79 }
Note:
See TracChangeset
for help on using the changeset viewer.
