Changeset 18255
- Timestamp:
- Jun 20, 2008, 7:32:37 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageReplaceBackground.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageReplaceBackground.c
r18217 r18255 4 4 5 5 # include "ppImage.h" 6 7 enum {MODE_NONE, MODE_MODEL, MODE_VALUE}; 6 8 7 9 // In this function, we perform the psphot analysis routine for the chip-mosaicked images … … 19 21 } 20 22 21 // find the model data, if it exists yet (if not, we build it below)22 p mFPAfile *modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL");23 // select the appropriate recipe information 24 psMetadata *ppImageRecipe = psMetadataLookupPtr (&status, config->recipes, "PPIMAGE"); 23 25 24 // select the appropriate recipe information 25 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 26 // select the appropriate recipe information (needed by psphotModelBackground) 27 psMetadata *psphotRecipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 28 29 char *replaceSkyModeWord = psMetadataLookupStr (&status, ppImageRecipe, "REPLACE.MODE"); 30 float replaceSkyValue = 0.0; 31 32 int replaceSkyMode = MODE_NONE; 33 if (!strcasecmp (replaceSkyModeWord, "MODEL")) { 34 replaceSkyMode = MODE_MODEL; 35 } 36 if (!strcasecmp (replaceSkyModeWord, "VALUE")) { 37 replaceSkyMode = MODE_VALUE; 38 replaceSkyValue = psMetadataLookupF32 (&status, ppImageRecipe, "REPLACE.VALUE"); 39 } 40 psAssert (replaceSkyMode != MODE_NONE, "replace sky mode not defined"); 26 41 27 42 // define the mask value to be used in ppImage 28 43 psMaskType maskVal = options->satMask | options->badMask | options->flatMask | options->blankMask; 29 44 30 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 31 psMetadataAddU8 (recipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal); 45 pmFPAfile *modelFile = NULL; 46 if (replaceSkyMode == MODE_MODEL) { 47 // find the model data, if it exists yet (if not, we build it below) 48 modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL"); 32 49 33 float meanValue = psMetadataLookupF32 (&status, recipe, "SKY_MEAN"); 34 bool replaceSkyMean = psMetadataLookupBool (&status, recipe, "REPLACE.SKY_MEAN"); 50 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set) 51 psMetadataAddU8 (psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskVal); 52 } 35 53 36 54 // iterate over the cells and readout for this chip … … 45 63 46 64 // replace masked pixels with values from model (unbinning not needed) 47 48 // we are using this pmFPAfile as an I/O file: select readout or create49 65 pmReadout *modelReadout = NULL; 50 if (modelFile) { 51 modelReadout = pmFPAviewThisReadout (view, modelFile->fpa); 66 psImageBinning *binning = NULL; 67 psImage *model = NULL; 68 if (replaceSkyMode == MODE_MODEL) { 69 // we are using this pmFPAfile as an I/O file: select readout or create 70 if (modelFile) { 71 modelReadout = pmFPAviewThisReadout (view, modelFile->fpa); 72 } 73 if (!modelReadout) { 74 psphotModelBackground (config, view, "PPIMAGE.CHIP"); 75 modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL"); 76 assert (modelFile); 77 if (modelFile->mode == PM_FPA_MODE_INTERNAL) { 78 modelReadout = modelFile->readout; 79 } else { 80 modelReadout = pmFPAviewThisReadout (view, modelFile->fpa); 81 } 82 assert (modelReadout); 83 } 84 binning = psMetadataLookupPtr(&status, psphotRecipe, "PSPHOT.BACKGROUND.BINNING"); 85 model = modelReadout->image; 52 86 } 53 if (!modelReadout) {54 psphotModelBackground (config, view, "PPIMAGE.CHIP");55 modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL");56 assert (modelFile);57 if (modelFile->mode == PM_FPA_MODE_INTERNAL) {58 modelReadout = modelFile->readout;59 } else {60 modelReadout = pmFPAviewThisReadout (view, modelFile->fpa);61 }62 assert (modelReadout);63 }64 65 psImageBinning *binning = psMetadataLookupPtr(&status, recipe, "PSPHOT.BACKGROUND.BINNING");66 87 67 88 psImage *mask = readout->mask; 68 89 psImage *image = readout->image; 69 psImage *model = modelReadout->image;70 90 71 91 for (int iy = 0; iy < image->numRows; iy++) { 72 92 for (int ix = 0; ix < image->numCols; ix++) { 73 93 if (!(mask->data.U8[iy][ix] && maskVal)) continue; 74 if (replaceSkyM ean) {75 image->data.F32[iy][ix] = meanValue;94 if (replaceSkyMode == MODE_MODEL) { 95 image->data.F32[iy][ix] = psImageUnbinPixel_V2(ix, iy, model, binning); 76 96 } else { 77 image->data.F32[iy][ix] = psImageUnbinPixel_V2(ix, iy, model, binning);97 image->data.F32[iy][ix] = replaceSkyValue; 78 98 } 79 99 } … … 81 101 } 82 102 } 83 pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL"); 84 pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV"); 103 104 if (replaceSkyMode == MODE_MODEL) { 105 pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL"); 106 pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV"); 107 } 108 85 109 return true; 86 110 }
Note:
See TracChangeset
for help on using the changeset viewer.
