Changeset 13900 for trunk/psphot/src/psphotReadout.c
- Timestamp:
- Jun 19, 2007, 4:40:44 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotReadout.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotReadout.c
r13804 r13900 12 12 } 13 13 14 // Interpret the mask values 15 const char *maskValStr = psMetadataLookupStr(NULL, recipe, "MASKVAL"); // String with mask names 16 if (!maskValStr) { 17 psError(PSPHOT_ERR_CONFIG, false, "Missing recipe item: MASKVAL(STR)"); 18 return false; 19 } 20 psMaskType maskVal = pmConfigMask(maskValStr, config); // Mask values to mask against 21 psMaskType maskMark = pmConfigMask("MARK", config); // Mask value for marking 22 psMaskType maskSat = pmConfigMask("SAT", config); // Mask value for saturated pixels 23 psMaskType maskBad = pmConfigMask("BAD", config); // Mask value for bad pixels 24 14 25 // find the currently selected readout 15 26 pmReadout *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT"); … … 24 35 25 36 // generate mask & weight images if they don't already exit 26 psMaskType satMask = pmConfigMask("SAT", config);27 psMaskType badMask = pmConfigMask("BAD", config);28 37 if (!readout->mask) { 29 if (!pmReadoutGenerateMask(readout, satMask, badMask)) {30 psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask");31 return false;32 }38 if (!pmReadoutGenerateMask(readout, maskSat, maskBad)) { 39 psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask"); 40 return false; 41 } 33 42 } 34 43 if (!readout->weight) { 35 if (!pmReadoutGenerateWeight(readout, true)) {36 psError (PSPHOT_ERR_CONFIG, false, "trouble creating weight");37 return false;38 }44 if (!pmReadoutGenerateWeight(readout, true)) { 45 psError (PSPHOT_ERR_CONFIG, false, "trouble creating weight"); 46 return false; 47 } 39 48 } 40 49 … … 46 55 47 56 // I have a valid mask, now mask in the analysis region of interest 48 psphotMaskReadout (readout, recipe, config);57 psphotMaskReadout (readout, recipe, maskBad); 49 58 50 59 // run a single-model test if desired 51 psphotModelTest (readout, recipe );60 psphotModelTest (readout, recipe, maskVal, maskMark); 52 61 53 62 if (psTraceGetLevel("psphot") >= 5) { … … 62 71 63 72 // generate a background model (median, smoothed image) 64 if (!psphotImageMedian (config, view )) {73 if (!psphotImageMedian (config, view, maskVal)) { 65 74 return psphotReadoutCleanup (config, readout, recipe, NULL, NULL); 66 75 } … … 74 83 psArray *footprints = NULL; 75 84 if (useFootprints) { 76 footprints = psphotFindPeaks (readout, recipe, useFootprints, 1 );85 footprints = psphotFindPeaks (readout, recipe, useFootprints, 1, maskVal); 77 86 int growRadius = psMetadataLookupS32(NULL, recipe, "FOOTPRINT_GROW_RADIUS"); 78 87 if (growRadius > 0) { … … 85 94 peaks = pmFootprintArrayToPeaks(footprints); 86 95 } else { 87 peaks = psphotFindPeaks (readout, recipe, useFootprints, 1 );96 peaks = psphotFindPeaks (readout, recipe, useFootprints, 1, maskVal); 88 97 } 89 98 … … 97 106 98 107 // construct sources and measure basic stats 99 psArray *sources = psphotSourceStats (readout, recipe, peaks );108 psArray *sources = psphotSourceStats (readout, recipe, peaks, maskVal, maskMark); 100 109 if (!sources) return false; 101 110 psFree (peaks); … … 114 123 115 124 // classify sources based on moments, brightness 116 if (!psphotRoughClass (sources, recipe, true )) {125 if (!psphotRoughClass (sources, recipe, true, maskSat)) { 117 126 psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image"); 118 127 return psphotReadoutCleanup (config, readout, recipe, NULL, sources); … … 126 135 if (!psf) { 127 136 // use bright stellar objects to measure PSF 128 psf = psphotChoosePSF (readout, sources, recipe );137 psf = psphotChoosePSF (readout, sources, recipe, maskVal, maskMark); 129 138 if (psf == NULL) { 130 139 psLogMsg ("psphot", 3, "failure to construct a psf model"); … … 143 152 144 153 // construct an initial model for each object 145 psphotGuessModels (readout, sources, recipe, psf );154 psphotGuessModels (readout, sources, recipe, psf, maskVal); 146 155 147 156 // XXX test output of models … … 151 160 152 161 // linear PSF fit to peaks 153 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE );162 psphotFitSourcesLinear (readout, sources, recipe, psf, FALSE, maskVal); 154 163 if (dump) psphotSaveImage (NULL, readout->image, "image.v1.fits"); 155 164 … … 162 171 163 172 // non-linear PSF and EXT fit to brighter sources 164 psphotBlendFit (readout, sources, recipe, psf );173 psphotBlendFit (readout, sources, recipe, psf, maskVal); 165 174 if (dump) psphotSaveImage (NULL, readout->image, "image.v2.fits"); 166 175 167 176 // replace all sources 168 psphotReplaceAll (sources );177 psphotReplaceAll (sources, maskVal); 169 178 if (dump) psphotSaveImage (NULL, readout->image, "image.v3.fits"); 170 179 171 180 // linear PSF fit to remaining peaks 172 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE );181 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE, maskVal); 173 182 if (dump) psphotSaveImage (NULL, readout->image, "image.v4.fits"); 174 183 if (!strcasecmp (breakPt, "PASS1")) { … … 183 192 184 193 // add noise for subtracted objects 185 psphotAddNoise (readout, sources, recipe, true );194 psphotAddNoise (readout, sources, recipe, true, maskVal); 186 195 187 196 // find the peaks in the image 188 197 psArray *newPeaks; 189 198 if (useFootprints) { 190 psArray *newFootprints = psphotFindPeaks (readout, recipe, useFootprints, 2 );199 psArray *newFootprints = psphotFindPeaks (readout, recipe, useFootprints, 2, maskVal); 191 200 192 201 int growRadius = psMetadataLookupS32(NULL, recipe, "FOOTPRINT_GROW_RADIUS_2"); … … 209 218 psFree(mergedFootprints); 210 219 } else { 211 newPeaks = psphotFindPeaks(readout, recipe, useFootprints, 2 );220 newPeaks = psphotFindPeaks(readout, recipe, useFootprints, 2, maskVal); 212 221 } 213 222 214 223 // remove noise for subtracted objects 215 psphotAddNoise (readout, sources, recipe, false );224 psphotAddNoise (readout, sources, recipe, false, maskVal); 216 225 217 226 // define new sources based on the new peaks 218 psArray *newSources = psphotSourceStats (readout, recipe, newPeaks );227 psArray *newSources = psphotSourceStats (readout, recipe, newPeaks, maskVal, maskMark); 219 228 psFree (newPeaks); 220 229 221 230 // set source type 222 psphotRoughClass (newSources, recipe, false );231 psphotRoughClass (newSources, recipe, false, maskSat); 223 232 224 233 // create full input models 225 psphotGuessModels (readout, newSources, recipe, psf );234 psphotGuessModels (readout, newSources, recipe, psf, maskVal); 226 235 227 236 // replace all sources 228 psphotReplaceAll (sources );237 psphotReplaceAll (sources, maskVal); 229 238 if (dump) psphotSaveImage (NULL, readout->image, "image.v5.fits"); 230 239 … … 234 243 235 244 // linear PSF fit to remaining peaks 236 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE );245 psphotFitSourcesLinear (readout, sources, recipe, psf, TRUE, maskVal); 237 246 if (dump) psphotSaveImage (NULL, readout->image, "image.v6.fits"); 238 247 … … 243 252 244 253 // measure aperture photometry corrections 245 if (!psphotApResid (readout, sources, recipe, psf )) {254 if (!psphotApResid (readout, sources, recipe, psf, maskVal, maskMark)) { 246 255 psTrace ("psphot", 4, "failure on psphotApResid"); 247 256 psError(PSPHOT_ERR_PHOTOM, false, "Measure aperture photometry corrections"); … … 251 260 // calculate source magnitudes 252 261 pmReadout *background = psphotSelectBackground (config, view, false); 253 psphotMagnitudes(sources, recipe, psf, background );262 psphotMagnitudes(sources, recipe, psf, background, maskVal, maskMark); 254 263 255 264 // replace failed sources?
Note:
See TracChangeset
for help on using the changeset viewer.
