- Timestamp:
- Jan 7, 2010, 5:07:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.
