Changeset 21257 for trunk/ppSub/src/ppSubBackground.c
- Timestamp:
- Feb 1, 2009, 11:55:34 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ppSub/src/ppSubBackground.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubBackground.c
r21183 r21257 1 #ifdef HAVE_CONFIG_H2 #include <config.h>3 #endif4 5 #include <stdio.h>6 #include <pslib.h>7 #include <psmodules.h>8 #include <psphot.h>9 1 #include "ppSub.h" 10 2 11 // Copied fromppImageSubtractBackground()12 bool ppSubBackground(pm Readout *ro, pmConfig *config, const pmFPAview *view)3 // Based on ppImageSubtractBackground() 4 bool ppSubBackground(pmConfig *config, const pmFPAview *view) 13 5 { 14 6 psAssert(config, "Need configuration"); 15 7 psAssert(view, "Need view to chip"); 16 8 17 // The background model file may be defined, though the model hasn't been built 18 // If so, we will build it below. 19 bool status; // Status of lookup 20 pmFPAfile *modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL"); // Background model 21 if (!status) { 22 psError(PS_ERR_UNEXPECTED_NULL, true, "PSPHOT.BACKMDL file is not defined"); 23 return false; 24 } 9 bool status; // Status of metadata lookups 25 10 26 11 psMetadata *ppSubRecipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE); 27 12 psAssert(ppSubRecipe, "Need PPSUB recipe"); 13 28 14 psMetadata *psphotRecipe = psMetadataLookupPtr(NULL, config->recipes, PSPHOT_RECIPE); 29 psAssert(psphotRecipe, "Need PSPHOT recipe ");15 psAssert(psphotRecipe, "Need PSPHOT recipe for binning"); 30 16 31 psString maskBadStr = psMetadataLookupStr(NULL, ppSubRecipe, "MASK.BAD"); // Name of bits to mask for bad 32 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels 17 psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); 33 18 34 // user-defined masks to test for good/bad pixels (build from recipe list if not yet set)35 p sMetadataAddImageMask(psphotRecipe, PS_LIST_TAIL, "MASK.PSPHOT", PS_META_REPLACE, "user-defined mask", maskBad);19 // select the output readout 20 pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); 36 21 37 psImage *image = ro->image, *mask = ro->mask; // Image and mask of interest 22 // select the model readout, if it exist already; if not, generate it 23 pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL"); 38 24 39 pmReadout *modelRO = pmFPAviewThisReadout(view, modelFile->fpa); // Background model25 // if necessary, generate the background model 40 26 if (!modelRO) { 41 27 // Create the background model … … 44 30 return false; 45 31 } 46 modelRO = (modelFile->mode == PM_FPA_MODE_INTERNAL) ? modelFile->readout : 47 pmFPAviewThisReadout(view, modelFile->fpa);32 // select the model readout (should now exist) 33 modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL"); 48 34 if (!modelRO) { 49 35 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background model"); … … 54 40 "PSPHOT.BACKGROUND.BINNING"); // Binning for model 55 41 psImage *modelImage = modelRO->image; // Background model 42 43 psImage *image = outRO->image; // Image of interest 44 psImage *mask = outRO->mask; // Mask of interest 56 45 57 46 // Do the background subtraction
Note:
See TracChangeset
for help on using the changeset viewer.
