Changeset 34528 for trunk/psphot
- Timestamp:
- Oct 8, 2012, 12:06:06 PM (14 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 10 edited
-
psphot.h (modified) (1 diff)
-
psphotDefineFiles.c (modified) (2 diffs)
-
psphotMaskBackground.c (modified) (1 diff)
-
psphotModelBackground.c (modified) (1 diff)
-
psphotOutput.c (modified) (2 diffs)
-
psphotSkyReplace.c (modified) (1 diff)
-
psphotStack.c (modified) (1 diff)
-
psphotStackImageLoop.c (modified) (2 diffs)
-
psphotStackParseCamera.c (modified) (8 diffs)
-
psphotSubtractBackground.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphot.h
r34418 r34528 525 525 bool psphotSourceMemoryReadout(pmConfig *config, const pmFPAview *view, const char *filerule, int index); 526 526 527 const char * psphotGetFilerule(const char *baseRule); 528 extern bool psphotINpsphotStack; 529 527 530 #endif -
trunk/psphot/src/psphotDefineFiles.c
r33963 r34528 1 1 # include "psphotInternal.h" 2 3 bool psphotINpsphotStack = false; 2 4 3 5 // List of output files … … 181 183 return; 182 184 } 185 186 // psphotGetFilerule 187 // Since psphotStack processes multipe FPAs at a time it has a different file rule structure than regular psphot. 188 // For the background output files we define a function psphotGetFilerule which given a base psphot file rule 189 // returns the corresponding psphotStack rule *if* the program is psphotStack. That is indicated by a global 190 // boolean which defaults to false, and psphotStack only sets to true 191 192 const char *psphotGetFilerule(const char *psphotRule) { 193 const char *rule = psphotRule; 194 if (psphotINpsphotStack) { 195 if (!strcmp(psphotRule, "PSPHOT.BACKMDL")) { 196 rule = "PSPHOT.STACK.BACKMDL"; 197 } else if (!strcmp(psphotRule, "PSPHOT.BACKMDL.STDEV")) { 198 rule = "PSPHOT.STACK.BACKMDL.STDEV"; 199 } else if (!strcmp(psphotRule, "PSPHOT.BACKSUB")) { 200 rule = "PSPHOT.STACK.BACKSUB"; 201 } else if (!strcmp(psphotRule, "PSPHOT.BACKGND")) { 202 rule = "PSPHOT.STACK.BACKGND"; 203 } else { 204 psAssert(0, "unsupported file rule %s", psphotRule); 205 } 206 } 207 return rule; 208 } -
trunk/psphot/src/psphotMaskBackground.c
r31154 r34528 17 17 18 18 // find the currently selected readout (XXX note that the model is saved on PSPHOT.BACKMDL regardless of 'filename' 19 pmFPAfile *modelFile = pmFPAfileSelectSingle(config->files, "PSPHOT.BACKMDL", index); // File of interest19 pmFPAfile *modelFile = pmFPAfileSelectSingle(config->files, psphotGetFilerule("PSPHOT.BACKMDL"), index); // File of interest 20 20 assert (modelFile); 21 21 22 pmFPAfile *stdevFile = pmFPAfileSelectSingle(config->files, "PSPHOT.BACKMDL.STDEV", index);22 pmFPAfile *stdevFile = pmFPAfileSelectSingle(config->files, psphotGetFilerule("PSPHOT.BACKMDL.STDEV"), index); 23 23 assert (stdevFile); 24 24 -
trunk/psphot/src/psphotModelBackground.c
r33963 r34528 405 405 406 406 psImageBinning *binning = psphotBackgroundBinning(readout->image, config); // Image binning parameters 407 pmReadout *model = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL", inFPA, binning, index);408 pmReadout *modelStdev = pmFPAGenerateReadout(config, view, "PSPHOT.BACKMDL.STDEV", inFPA, binning, index);407 pmReadout *model = pmFPAGenerateReadout(config, view, psphotGetFilerule("PSPHOT.BACKMDL"), inFPA, binning, index); 408 pmReadout *modelStdev = pmFPAGenerateReadout(config, view, psphotGetFilerule("PSPHOT.BACKMDL.STDEV"), inFPA, binning, index); 409 409 410 410 if (!psphotModelBackgroundReadout(model->image, modelStdev->image, model->analysis, readout, binning, config, false)) { -
trunk/psphot/src/psphotOutput.c
r32695 r34528 34 34 35 35 36 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKMDL");36 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, psphotGetFilerule("PSPHOT.BACKMDL")); 37 37 if (!file) return NULL; 38 38 … … 45 45 bool status; 46 46 47 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKMDL.STDEV");47 pmFPAfile *file = psMetadataLookupPtr (&status, config->files, psphotGetFilerule("PSPHOT.BACKMDL.STDEV")); 48 48 if (!file) return NULL; 49 49 -
trunk/psphot/src/psphotSkyReplace.c
r31673 r34528 36 36 37 37 // select background pixels, from output background file, or create 38 pmReadout *background = pmFPAfileThisReadout (config->files, view, "PSPHOT.BACKGND");38 pmReadout *background = pmFPAfileThisReadout (config->files, view, psphotGetFilerule("PSPHOT.BACKGND")); 39 39 if (background == NULL) psAbort("background not defined"); 40 40 -
trunk/psphot/src/psphotStack.c
r34283 r34528 2 2 3 3 int main (int argc, char **argv) { 4 5 // Set flag to tell certain library functions that we are in the psphotStack program. 6 // (This is defined in psphotDefineFiles.c) 7 psphotINpsphotStack = true; 4 8 5 9 // uncomment to turn on memory dumps (move this to an option) -
trunk/psphot/src/psphotStackImageLoop.c
r34429 r34528 43 43 if (!needConvolved) { 44 44 pmFPAfileActivate (config->files, false, "PSPHOT.STACK.INPUT.CNV"); 45 pmFPAfileActivate (config->files, false, "PSPHOT.STACK.MASK.CNV"); 46 pmFPAfileActivate (config->files, false, "PSPHOT.STACK.VARIANCE.CNV"); 47 pmFPAfileActivate (config->files, false, "PSPHOT.STACK.PSF.CNV"); 45 48 } 46 49 … … 97 100 // drop all versions of the internal files 98 101 status = true; 99 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");100 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");101 status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");102 status &= pmFPAfileDropInternal (config->files, psphotGetFilerule("PSPHOT.BACKMDL")); 103 status &= pmFPAfileDropInternal (config->files, psphotGetFilerule("PSPHOT.BACKMDL.STDEV")); 104 status &= pmFPAfileDropInternal (config->files, psphotGetFilerule("PSPHOT.BACKGND")); 102 105 if (!status) { 103 106 psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files"); -
trunk/psphot/src/psphotStackParseCamera.c
r33913 r34528 14 14 return false; 15 15 } 16 17 // select the appropriate recipe information 18 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 19 bool savePSF = psMetadataLookupBool(&status, recipe, "SAVE.PSF"); 20 bool saveBackgroundModel = psMetadataLookupBool(&status, recipe, "SAVE.BACKMDL"); 21 bool saveBackground = psMetadataLookupBool(&status, recipe, "SAVE.BACKGND"); 22 bool saveBackSub = psMetadataLookupBool(&status, recipe, "SAVE.BACKSUB"); 23 bool saveResid = psMetadataLookupBool(&status, recipe, "SAVE.RESID"); 24 25 bool saveCnv = psMetadataLookupBool(&status, recipe, "SAVE.CNV"); 26 bool saveChisq = psMetadataLookupBool(&status, recipe, "SAVE.CHISQ"); 27 bool useRaw = psMetadataLookupBool(&status, recipe, "PSPHOT.STACK.USE.RAW"); 28 16 29 17 30 int nRaw = 0; … … 120 133 } 121 134 } 135 pmFPAfile *inputTemplate; 136 if (useRaw) { 137 inputTemplate = rawInputFile; 138 } else { 139 inputTemplate = cnvInputFile; 140 } 141 if (!inputTemplate) { 142 psError(PS_ERR_UNKNOWN, true, "cannot determinte inputTemplate: USE.RAW: %d\n", useRaw); 143 return false; 144 } 122 145 123 146 psString sources = psMetadataLookupStr(&status, input, "SOURCES"); // Name of mask … … 135 158 } 136 159 // generate an pmFPAimage for the output convolved image 137 // XXX output of these files should be optional138 160 { 139 161 // pmFPAfile *srcInputFile = rawInputFile ? rawInputFile : cnvInputFile; … … 143 165 return false; 144 166 } 145 outputImage->save = true;167 outputImage->save = saveCnv; 146 168 outputImage->fileID = stack_id; // this is used to generate output names 147 169 … … 155 177 return NULL; 156 178 } 157 outputMask->save = true;179 outputMask->save = saveCnv; 158 180 outputMask->fileID = stack_id; // this is used to generate output names 159 181 … … 167 189 return NULL; 168 190 } 169 outputVariance->save = true;191 outputVariance->save = saveCnv; 170 192 outputVariance->fileID = stack_id; // this is used to generate output names 171 193 … … 178 200 outsources->save = true; 179 201 outsources->fileID = stack_id; // this is used to generate output names 202 203 if (savePSF) { 204 pmFPAfile *output = pmFPAfileDefineOutputFromFile (config, inputTemplate, "PSPHOT.STACK.PSF.SAVE"); 205 if (!output) { 206 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.STACK.PSF.SAVE"); 207 return false; 208 } 209 output->save = true; 210 output->fileID = stack_id; 211 } 212 if (saveBackgroundModel) { 213 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN"); 214 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN"); 215 pmFPAfile *output = pmFPAfileDefineFromFile (config, inputTemplate, DX, DY, "PSPHOT.STACK.BACKMDL"); 216 if (!output) { 217 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.STACK.BACKMDL"); 218 return false; 219 } 220 221 output->save = true; 222 output->fileID = stack_id; 223 } 224 if (saveBackground) { 225 pmFPAfile *output = pmFPAfileDefineFromFile (config, inputTemplate, 1, 1, "PSPHOT.STACK.BACKGND"); 226 if (!output) { 227 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.STACK.STACK.BACKGND"); 228 return false; 229 } 230 output->save = true; 231 output->fileID = stack_id; 232 } 233 if (saveBackSub) { 234 pmFPAfile *output = pmFPAfileDefineFromFile (config, inputTemplate, 1, 1, "PSPHOT.STACK.BACKSUB"); 235 if (!output) { 236 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.STACK.STACK.BACKSUB"); 237 return false; 238 } 239 output->save = true; 240 output->fileID = stack_id; 241 } 242 if (saveResid) { 243 pmFPAfile *output = pmFPAfileDefineOutputFromFile (config, inputTemplate, "PSPHOT.STACK.RESID"); 244 if (!output) { 245 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.STACK.RESID"); 246 return false; 247 } 248 output->save = true; 249 output->fileID = stack_id; 250 } 180 251 } 181 252 } … … 191 262 } 192 263 193 // select the appropriate recipe information194 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);195 bool saveCnv = psMetadataLookupBool(&status, recipe, "SAVE.CNV");196 bool saveChisq = psMetadataLookupBool(&status, recipe, "SAVE.CHISQ");197 198 // loop over the available readouts199 for (int i = 0; i < nInputs; i++) {200 pmFPAfile *file = NULL;201 202 file = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.OUTPUT.IMAGE", i);203 file->save = saveCnv;204 205 file = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.OUTPUT.MASK", i);206 file->save = saveCnv;207 208 file = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.OUTPUT.VARIANCE", i);209 file->save = saveCnv;210 }211 212 264 // generate an pmFPAimage for the chisqImage 213 // XXX output of these files should be optional214 265 { 215 266 pmFPAfile *chisqImage = pmFPAfileDefineOutput(config, NULL, "PSPHOT.CHISQ.IMAGE"); -
trunk/psphot/src/psphotSubtractBackground.c
r32348 r34528 21 21 22 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 interest23 pmFPAfile *modelFile = pmFPAfileSelectSingle(config->files, psphotGetFilerule("PSPHOT.BACKMDL"), index); // File of interest 24 24 assert (modelFile); 25 25 … … 36 36 // select background pixels, from output background file, or create 37 37 // XXX for now, we will only allow a single background image to be generated 38 file = psMetadataLookupPtr (&status, config->files, "PSPHOT.BACKGND");38 file = psMetadataLookupPtr (&status, config->files, psphotGetFilerule("PSPHOT.BACKGND")); 39 39 if (file) { 40 40 // we are using PSPHOT.BACKGND as an I/O file: select readout or create … … 50 50 } 51 51 } else { 52 background = pmFPAfileDefineInternal (config->files, "PSPHOT.BACKGND", image->numCols, image->numRows, PS_TYPE_F32);52 background = pmFPAfileDefineInternal (config->files, psphotGetFilerule("PSPHOT.BACKGND"), image->numCols, image->numRows, PS_TYPE_F32); 53 53 } 54 54 psF32 **backData = background->image->data.F32;
Note:
See TracChangeset
for help on using the changeset viewer.
