Changeset 26542
- Timestamp:
- Jan 7, 2010, 5:07:54 PM (16 years ago)
- Location:
- branches/eam_branches/20091201/psphot
- Files:
-
- 1 added
- 14 edited
-
doc/stack.txt (modified) (1 diff)
-
src/psphot.h (modified) (4 diffs)
-
src/psphotForcedReadout.c (modified) (3 diffs)
-
src/psphotMakePSFReadout.c (modified) (3 diffs)
-
src/psphotMaskReadout.c (modified) (4 diffs)
-
src/psphotModelBackground.c (modified) (5 diffs)
-
src/psphotOutput.c (modified) (2 diffs)
-
src/psphotParseCamera.c (modified) (1 diff)
-
src/psphotReadout.c (modified) (3 diffs)
-
src/psphotReadoutFindPSF.c (modified) (2 diffs)
-
src/psphotReadoutKnownSources.c (modified) (2 diffs)
-
src/psphotReadoutMinimal.c (modified) (2 diffs)
-
src/psphotStackParseCamera.c (modified) (1 diff)
-
src/psphotStackReadout.c (added)
-
src/psphotSubtractBackground.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/psphot/doc/stack.txt
r24583 r26542 1 2 20100107 : updates for stack processing 3 4 I am building a new version of psphot that operates on a set of 5 images (eg, multi-filter or multi-epoch). The assumptions are: 6 7 * each input image represents the same sky pixels : they are warped to a common frame. 8 * each image has been previously processed, with the background 9 subtracted (and the psf model determined?) 10 * all planes are / can be loaded into memory at once (otherwise I 11 need to add a lot of I/O layers) 12 13 psphot currently expects the pmFPAfile of interest to be available in 14 config->files with the name PSPHOT.INPUT. To update the code for 15 stacks, I am extending this concept with the pmFPAfileSelectSingle 16 API: config->files may contain multiple PSPHOT.INPUT entries, and 17 functions which access this file / these files need to specify 18 *which* image they want. The number of PSPHOT.INPUT entries is 19 saved in config->arguments as PSPHOT.INPUT.NUM (this can be 20 generated from the filerule PSPHOT.INPUT for extension). 21 22 As a result, we need a number of wrapper functions which loop over 23 all PSPHOT.INPUT.NUM entries and perform a particular operation on 24 one of the entries. Here are the functions which I have modified 25 in this way (function -> child) 26 27 * psphotAddPhotcode -> psphotAddPhotcodeReadout 28 * note that the photcode is now saved on readout->analysis 29 * psphotSetMaskAndVariance -> psphotSetMaskAndVarianceReadout 30 * psphotModelBackground -> psphotModelBackgroundReadoutFileIndex 31 * psphotSubtractBackground -> psphotSubtractBackgroundReadout 32 33 side notes on 34 35 * psphotModelBackground vs psphotBackgroundModel : I've renamed 36 psphotBackgroundModel (used only by ppStack for now) to 37 psphotModelBackgroundReadoutNoFile. I've also named the 38 single-readout version used by psphotModelBackground to 39 psphotModelBackgroundReadoutFileIndex. These two functions do the 40 same thing, but psphotModelBackgroundReadoutNoFile does not save 41 a pmFPAfile on config->files 42 1 43 2 44 20090606 : design notes on the multi-image photometry analysis -
branches/eam_branches/20091201/psphot/src/psphot.h
r26425 r26542 40 40 41 41 // psphotReadout functions 42 bool psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filename); 43 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename) ; 42 bool psphotModelBackground (pmConfig *config, const pmFPAview *view); 43 bool psphotModelBackgroundReadoutFileIndex (pmConfig *config, const pmFPAview *view, const char *filename, int index); 44 45 // Create a background model for a readout, without saving the result as a pmFPAfile on 46 // config->files. Otherwise identical to psphotModelBackgroundFileIndex. 47 psImage *psphotModelBackgroundReadoutNoFile(pmReadout *readout, const pmConfig *config); 48 49 // worker function for above background model functions 50 bool psphotModelBackgroundReadout(psImage *model, // Model image 51 psImage *modelStdev, // Model stdev image 52 psMetadata *analysis, // Analysis metadata for outputs 53 pmReadout *readout, // Readout for which to generate a background model 54 psImageBinning *binning, // Binning parameters 55 const pmConfig *config // Configuration 56 ); 44 57 45 58 psImageBinning *psphotBackgroundBinning(const psImage *, const pmConfig *); 59 60 61 62 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view); 63 bool psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index); 64 46 65 47 66 pmDetections *psphotFindDetections (pmDetections *detections, pmReadout *readout, psMetadata *recipe); … … 103 122 void psphotModelClassInit (void); 104 123 bool psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore, psImageMaskType maskVal); 105 bool psphotSetMaskAndVariance (pmConfig *config, pmReadout *readout, psMetadata *recipe); 124 bool psphotSetMaskAndVariance (pmConfig *config, const pmFPAview *view, psMetadata *recipe); 125 bool psphotSetMaskAndVarianceReadout (pmConfig *config, pmReadout *readout, psMetadata *recipe); 106 126 void psphotSourceFreePixels (psArray *sources); 107 127 … … 115 135 116 136 // output functions 117 bool psphotAddPhotcode (psMetadata *recipe, pmConfig *config, const pmFPAview *view, const char *filerule); 137 bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index); 138 bool psphotAddPhotcode (pmConfig *config, const pmFPAview *view); 139 118 140 bool psphotDumpMoments (psMetadata *recipe, psArray *sources); 119 141 psMetadata *psphotDefineHeader (psMetadata *recipe); … … 279 301 280 302 281 // Create a background model for a readout282 // Essentially identical to psphotModelBackground, but with a more convenient API for outsiders.283 psImage *psphotBackgroundModel(pmReadout *ro, // Readout for which to generate background model284 const pmConfig *config // Configuration285 );286 287 303 pmConfig *psphotForcedArguments(int argc, char **argv); 288 304 bool psphotForcedImageLoop (pmConfig *config); -
branches/eam_branches/20091201/psphot/src/psphotForcedReadout.c
r25981 r26542 20 20 21 21 // set the photcode for this image 22 if (!psphotAddPhotcode ( recipe, config, view, "PSPHOT.INPUT")) {22 if (!psphotAddPhotcode (config, view)) { 23 23 psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 24 24 return false; … … 34 34 35 35 // Generate the mask and weight images, including the user-defined analysis region of interest 36 psphotSetMaskAndVariance (config, readout, recipe);36 psphotSetMaskAndVariance (config, view, recipe); 37 37 if (!strcasecmp (breakPt, "NOTHING")) { 38 38 return psphotReadoutCleanup(config, readout, recipe, NULL, NULL, NULL); … … 43 43 44 44 // generate a background model (median, smoothed image) 45 if (!psphotModelBackground (config, view , "PSPHOT.INPUT")) {45 if (!psphotModelBackground (config, view)) { 46 46 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 47 47 } 48 if (!psphotSubtractBackground (config, view , "PSPHOT.INPUT")) {48 if (!psphotSubtractBackground (config, view)) { 49 49 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 50 50 } -
branches/eam_branches/20091201/psphot/src/psphotMakePSFReadout.c
r25982 r26542 19 19 20 20 // set the photcode for this image 21 if (!psphotAddPhotcode ( recipe, config, view, "PSPHOT.INPUT")) {21 if (!psphotAddPhotcode (config, view)) { 22 22 psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 23 23 return false; … … 33 33 34 34 // Generate the mask and weight images, including the user-defined analysis region of interest 35 psphotSetMaskAndVariance (config, readout, recipe);35 psphotSetMaskAndVariance (config, view, recipe); 36 36 if (!strcasecmp (breakPt, "NOTHING")) { 37 37 return psphotReadoutCleanup(config, readout, recipe, NULL, NULL, NULL); … … 42 42 43 43 // generate a background model (median, smoothed image) 44 if (!psphotModelBackground (config, view , "PSPHOT.INPUT")) {44 if (!psphotModelBackground (config, view)) { 45 45 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 46 46 } 47 if (!psphotSubtractBackground (config, view , "PSPHOT.INPUT")) {47 if (!psphotSubtractBackground (config, view)) { 48 48 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 49 49 } -
branches/eam_branches/20091201/psphot/src/psphotMaskReadout.c
r26523 r26542 2 2 3 3 // generate mask and variance if not defined, additional mask for restricted subregion 4 bool psphotSetMaskAndVariance (pmConfig *config, pmReadout *readout, psMetadata *recipe) {4 bool psphotSetMaskAndVarianceReadout (pmConfig *config, pmReadout *readout, psMetadata *recipe) { 5 5 6 6 bool status; … … 76 76 } 77 77 78 bool psphotS tackSetMaskAndVariance (pmConfig *config, const pmFPAview *view, psMetadata *recipe) {78 bool psphotSetMaskAndVariance (pmConfig *config, const pmFPAview *view, psMetadata *recipe) { 79 79 80 int num = psMetadataAddS32 (&status, config->arguments, "INPUTS.NUM"); 81 psAbort (!status, "programming error: must define INPUTS.NUM"); 80 bool status = false; 81 82 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 83 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 82 84 83 85 // loop over the available readouts … … 85 87 86 88 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", i); // File of interest 89 PS_ASSERT_PTR_NON_NULL (file, false); 87 90 88 91 // find the currently selected readout … … 91 94 92 95 // Generate the mask and weight images, including the user-defined analysis region of interest 93 psphotSetMaskAndVariance (config, readout, recipe); 96 if (!psphotSetMaskAndVarianceReadout (config, readout, recipe)) { 97 psError (PSPHOT_ERR_CONFIG, false, "failed to generate mask for PSPHOT.INPUT entry %d", i); 98 return false; 99 } 94 100 95 101 // display the image, weight, mask (ch 1,2,3) 96 102 psphotVisualShowImage (readout); 97 103 } 98 104 return true; 99 105 } -
branches/eam_branches/20091201/psphot/src/psphotModelBackground.c
r26523 r26542 30 30 31 31 // Generate the background model 32 static bool backgroundModel(psImage *model, // Model image 33 psImage *modelStdev, // Model stdev image 34 psMetadata *analysis, // Analysis metadata for outputs 35 pmReadout *readout, // Readout for which to generate a background model 36 psImageBinning *binning, // Binning parameters 37 const pmConfig *config // Configuration 38 ) 32 // generate the median in NxN boxes, clipping heavily 33 // linear interpolation to generate full-scale model 34 bool psphotModelBackgroundReadout(psImage *model, // Model image 35 psImage *modelStdev, // Model stdev image 36 psMetadata *analysis, // Analysis metadata for outputs 37 pmReadout *readout, // Readout for which to generate a background model 38 psImageBinning *binning, // Binning parameters 39 const pmConfig *config // Configuration 40 ) 39 41 { 40 42 psTimerStart ("psphot.background"); … … 328 330 } 329 331 330 // XXX these two functions are absurdly-named and very similar -- fix! 331 332 psImage *psphotBackgroundModel(pmReadout *ro, const pmConfig *config) 333 { 334 PM_ASSERT_READOUT_NON_NULL(ro, NULL); 335 PM_ASSERT_READOUT_IMAGE(ro, NULL); 332 // generate a background model for a single readout. do not save an associated pmFPAfile for possible output 333 psImage *psphotModelBackgroundReadoutNoFile(pmReadout *readout, const pmConfig *config) 334 { 335 PM_ASSERT_READOUT_NON_NULL(readout, NULL); 336 PM_ASSERT_READOUT_IMAGE(readout, NULL); 336 337 PS_ASSERT_PTR_NON_NULL(config, NULL); 337 338 338 psImageBinning *binning = psphotBackgroundBinning(r o->image, config); // Image binning parameters339 psImageBinning *binning = psphotBackgroundBinning(readout->image, config); // Image binning parameters 339 340 psImage *model = psImageAlloc(binning->nXruff, binning->nYruff, PS_TYPE_F32); // Background model 340 341 psImage *modelStdev = psImageAlloc(binning->nXruff, binning->nYruff, PS_TYPE_F32); // Standard deviation 341 342 342 if (! backgroundModel(model, modelStdev, ro->analysis, ro, binning, config)) {343 if (!psphotModelBackgroundReadout(model, modelStdev, readout->analysis, readout, binning, config)) { 343 344 psFree(model); 344 345 psFree(modelStdev); … … 346 347 return NULL; 347 348 } 348 349 349 psFree(modelStdev); 350 351 350 return model; 352 351 } 353 352 354 355 // generate the median in NxN boxes, clipping heavily 356 // linear interpolation to generate full-scale model 357 bool psphotModelBackground (pmConfig *config, const pmFPAview *view, const char *filename) 358 { 359 bool status = true; 360 353 // generate a background model for readout number index; save an associated pmFPAfile for possible output 354 bool psphotModelBackgroundReadoutFileIndex (pmConfig *config, const pmFPAview *view, const char *filename, int index) 355 { 361 356 // find the currently selected readout 362 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, filename); 357 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 358 PS_ASSERT_PTR_NON_NULL (file, false); 359 363 360 pmFPA *inFPA = file->fpa; 364 361 pmReadout *readout = pmFPAviewThisReadout(view, inFPA); … … 368 365 pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning); 369 366 370 if (! backgroundModel(model->image, modelStdev->image, model->analysis, readout, binning, config)) {367 if (!psphotModelBackgroundReadout(model->image, modelStdev->image, model->analysis, readout, binning, config)) { 371 368 psError(PS_ERR_UNKNOWN, false, "Unable to generate background model"); 372 369 return false; … … 378 375 379 376 // XXX supply filename or keep PSPHOT.INPUT fixed? 380 bool psphot StackModelBackground (pmConfig *config, const pmFPAview *view)381 { 382 bool status = true;383 384 int num = psMetadata AddS32 (&status, config->arguments, "INPUTS.NUM");385 psA bort (!status, "programming error: must define INPUTS.NUM");377 bool psphotModelBackground (pmConfig *config, const pmFPAview *view) 378 { 379 bool status = false; 380 381 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 382 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 386 383 387 384 // loop over the available readouts 388 385 for (int i = 0; i < num; i++) { 389 390 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", i); // File of interest 391 392 // find the currently selected readout 393 pmReadout *readout = pmFPAviewThisReadout (view, file->fpa); 394 PS_ASSERT_PTR_NON_NULL (readout, false); 395 396 psImageBinning *binning = psphotBackgroundBinning(readout->image, config); // Image binning parameters 397 pmReadout *model = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL", inFPA, binning); // this needs to be a MULTI like PSPHOT.INPUT 398 pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning); // this needs to be a MULTI like PSPHOT.INPUT 399 400 // XXX save results on model->analysis or readout->analysis?? 401 if (!backgroundModel(model->image, modelStdev->image, model->analysis, readout, binning, config)) { 402 psError(PS_ERR_UNKNOWN, false, "Unable to generate background model"); 386 if (!psphotModelBackgroundReadoutFileIndex(config, view, "PSPHOT.INPUT", i)) { 387 psError (PSPHOT_ERR_CONFIG, false, "failed to model background for PSPHOT.INPUT entry %d", i); 403 388 return false; 404 389 } 405 npass ++;406 390 } 407 391 return true; -
branches/eam_branches/20091201/psphot/src/psphotOutput.c
r26422 r26542 126 126 } 127 127 128 bool psphotAddPhotcode (psMetadata *recipe, pmConfig *config, const pmFPAview *view, const char *filerule) {129 130 bool status;131 132 pmFPAfile *input = psMetadataLookupPtr (&status, config->files, filerule); 133 PS_ASSERT (status, false);134 135 // determine PHOTCODE from fpa & view, overwrite in re cipe136 char *photcode = pmConceptsPhotcodeForView ( input, view);128 bool psphotAddPhotcodeReadout (pmConfig *config, const pmFPAview *view, const char *filerule, int index) { 129 130 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filerule, index); // File of interest 131 PS_ASSERT (file, false); 132 133 pmReadout *readout = pmFPAviewThisReadout (view, file->fpa); 134 135 // determine PHOTCODE from fpa & view, overwrite in readout->analysis 136 char *photcode = pmConceptsPhotcodeForView (file, view); 137 137 PS_ASSERT (photcode, false); 138 138 139 psMetadataAddStr (re cipe, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode);139 psMetadataAddStr (readout->analysis, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode); 140 140 psLogMsg ("psphot", 3, "PHOTCODE is %s", photcode); 141 141 142 142 psFree (photcode); 143 return true; 144 } 145 146 bool psphotAddPhotcode (pmConfig *config, const pmFPAview *view) { 147 148 bool status = false; 149 150 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 151 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 152 153 // loop over the available readouts 154 for (int i = 0; i < num; i++) { 155 if (!psphotAddPhotcodeReadout (config, view, "PSPHOT.INPUT", i)) { 156 psError (PSPHOT_ERR_CONFIG, false, "failed to add photcode to PSPHOT.INPUT entry %d", i); 157 return false; 158 } 159 } 143 160 return true; 144 161 } … … 181 198 // these values are saved in an output header stub - they are added to either the 182 199 // PHU header (CMP) or the MEF table header (CMF) 200 // XXX these are currently carried by the recipe -- this will not work in a Stack context 201 // XXX they should be place in the readout->analysis of the given image 183 202 psMetadata *psphotDefineHeader (psMetadata *recipe) { 184 203 -
branches/eam_branches/20091201/psphot/src/psphotParseCamera.c
r21458 r26542 39 39 return NULL; 40 40 } 41 // specify the number of psphot input images 42 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1); 41 43 42 44 // define the additional input/output files associated with psphot -
branches/eam_branches/20091201/psphot/src/psphotReadout.c
r25755 r26542 28 28 29 29 // set the photcode for this image 30 if (!psphotAddPhotcode ( recipe, config, view, "PSPHOT.INPUT")) {30 if (!psphotAddPhotcode (config, view)) { 31 31 psError (PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 32 32 return false; … … 42 42 43 43 // Generate the mask and weight images, including the user-defined analysis region of interest 44 psphotSetMaskAndVariance (config, readout, recipe);44 psphotSetMaskAndVariance (config, view, recipe); 45 45 if (!strcasecmp (breakPt, "NOTHING")) { 46 46 return psphotReadoutCleanup(config, readout, recipe, NULL, NULL, NULL); … … 51 51 52 52 // generate a background model (median, smoothed image) 53 if (!psphotModelBackground (config, view , "PSPHOT.INPUT")) {53 if (!psphotModelBackground (config, view)) { 54 54 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 55 55 } 56 if (!psphotSubtractBackground (config, view , "PSPHOT.INPUT")) {56 if (!psphotSubtractBackground (config, view)) { 57 57 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL, NULL); 58 58 } -
branches/eam_branches/20091201/psphot/src/psphotReadoutFindPSF.c
r26421 r26542 14 14 } 15 15 16 // set the photcode for th is image17 if (!psphotAddPhotcode( recipe, config, view, "PSPHOT.INPUT")) {16 // set the photcode for the PSPHOT.INPUT 17 if (!psphotAddPhotcode(config, view)) { 18 18 psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 19 19 return false; … … 25 25 26 26 // Generate the mask and variance images, including the user-defined analysis region of interest 27 psphotSetMaskAndVariance (config, readout, recipe);27 psphotSetMaskAndVariance (config, view, recipe); 28 28 29 29 // display the image, weight, mask (ch 1,2,3) -
branches/eam_branches/20091201/psphot/src/psphotReadoutKnownSources.c
r25755 r26542 15 15 16 16 // set the photcode for this image 17 if (!psphotAddPhotcode( recipe, config, view, "PSPHOT.INPUT")) {17 if (!psphotAddPhotcode(config, view)) { 18 18 psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 19 19 return false; … … 25 25 26 26 // Generate the mask and weight images, including the user-defined analysis region of interest 27 psphotSetMaskAndVariance (config, readout, recipe);27 psphotSetMaskAndVariance (config, view, recipe); 28 28 29 29 // display the image, weight, mask (ch 1,2,3) -
branches/eam_branches/20091201/psphot/src/psphotReadoutMinimal.c
r26424 r26542 25 25 26 26 // set the photcode for this image 27 if (!psphotAddPhotcode( recipe, config, view, "PSPHOT.INPUT")) {27 if (!psphotAddPhotcode(config, view)) { 28 28 psError(PSPHOT_ERR_CONFIG, false, "trouble defining the photcode"); 29 29 return false; … … 35 35 36 36 // Generate the mask and weight images, including the user-defined analysis region of interest 37 psphotSetMaskAndVariance (config, readout, recipe);37 psphotSetMaskAndVariance (config, view, recipe); 38 38 39 39 // display the image, weight, mask (ch 1,2,3) -
branches/eam_branches/20091201/psphot/src/psphotStackParseCamera.c
r26523 r26542 56 56 } 57 57 psMetadataRemoveKey(config->arguments, "FILENAMES"); 58 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, " INPUTS.NUM", PS_META_REPLACE, "number of inputs", nInputs);58 psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", nInputs); 59 59 60 60 // define the additional input/output files associated with psphot -
branches/eam_branches/20091201/psphot/src/psphotSubtractBackground.c
r26523 r26542 4 4 // generate the median in NxN boxes, clipping heavily 5 5 // linear interpolation to generate full-scale model 6 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view, const char *filename)6 bool psphotSubtractBackgroundReadout (pmConfig *config, const pmFPAview *view, const char *filename, int index) 7 7 { 8 8 bool status = true; … … 13 13 14 14 // find the currently selected readout 15 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, filename); 15 pmFPAfile *file = pmFPAfileSelectSingle(config->files, filename, index); // File of interest 16 16 17 pmFPA *inFPA = file->fpa; 17 18 pmReadout *readout = pmFPAviewThisReadout (view, inFPA); … … 19 20 psImage *mask = readout->mask; 20 21 21 // find the currently selected readout 22 pmReadout *model = pmFPAfileThisReadout (config->files, view, "PSPHOT.BACKMDL"); 22 // find the currently selected readout (XXX note that the model is saved on PSPHOT.BACKMDL regardless of 'filename' 23 pmFPAfile *modelFile = pmFPAfileSelectSingle(config->files, "PSPHOT.BACKMDL", index); // File of interest 24 assert (modelFile); 25 pmReadout *model = pmFPAviewThisReadout (view, modelFile->fpa); 23 26 assert (model); 24 27 … … 35 38 36 39 // select background pixels, from output background file, or create 40 // XXX for now, we will only allow a single background image to be generated 37 41 file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKGND"); 38 42 if (file) { … … 66 70 67 71 // back-sub image pixels, from output background file (don't create if not requested) 72 // XXX for now, we will only allow a single background-subtracted image to be generated 68 73 file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKSUB"); 69 74 if (file) { … … 113 118 } 114 119 115 // XXX supply filename or keep PSPHOT.INPUT fixed? 116 bool psphotStackSubtractBackground (pmConfig *config, const pmFPAview *view) 120 bool psphotSubtractBackground (pmConfig *config, const pmFPAview *view) 117 121 { 118 bool status = true;122 bool status = false; 119 123 120 int num = psMetadata AddS32 (&status, config->arguments, "INPUTS.NUM");121 psA bort (!status, "programming error: must define INPUTS.NUM");124 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 125 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 122 126 123 127 // loop over the available readouts 124 128 for (int i = 0; i < num; i++) { 125 126 pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PSPHOT.INPUT", i); // File of interest 127 128 // find the currently selected readout 129 pmReadout *readout = pmFPAviewThisReadout (view, file->fpa); 130 PS_ASSERT_PTR_NON_NULL (readout, false); 131 132 psImageBinning *binning = psphotBackgroundBinning(readout->image, config); // Image binning parameters 133 pmReadout *model = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL", inFPA, binning); // this needs to be a MULTI like PSPHOT.INPUT 134 pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning); // this needs to be a MULTI like PSPHOT.INPUT 135 136 // XXX save results on model->analysis or readout->analysis?? 137 // XXX need to create a worker function from the function above... 138 if (!backgroundModel(model->image, modelStdev->image, model->analysis, readout, binning, config)) { 139 psError(PS_ERR_UNKNOWN, false, "Unable to generate background model"); 129 if (!psphotSubtractBackgroundReadout (config, view, "PSPHOT.INPUT", i)) { 130 psError (PSPHOT_ERR_CONFIG, false, "failed to subtract background for PSPHOT.INPUT entry %d", i); 140 131 return false; 141 132 } 142 // display the backsub and backgnd images143 psphotVisualShowBackground (config, view, readout);144 145 npass ++;146 133 } 147 134 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
