Changeset 31158 for trunk/ppStack/src/ppStackPrepare.c
- Timestamp:
- Apr 4, 2011, 1:16:41 PM (15 years ago)
- Location:
- trunk/ppStack
- Files:
-
- 2 edited
-
. (modified) (2 props)
-
src/ppStackPrepare.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack
- Property svn:ignore
-
old new 17 17 autom4te.cache 18 18 Doxyfile 19 a.out.dSYM
-
- Property svn:mergeinfo deleted
- Property svn:ignore
-
trunk/ppStack/src/ppStackPrepare.c
r30620 r31158 1 #include "ppStack.h" 2 3 #define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \ 4 PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \ 5 PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to sources 1 # include "ppStack.h" 2 3 # define RE_PHOTOMETER 0 4 5 # define PHOT_SOURCE_MASK (PM_SOURCE_MODE_FAIL | PM_SOURCE_MODE_SATSTAR | PM_SOURCE_MODE_BLEND | \ 6 PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \ 7 PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply to sources 6 8 7 9 bool ppStackInputPhotometer(const pmReadout *ro, const psArray *sources, const pmConfig *config) … … 13 15 psAssert(recipe, "We've thrown an error on this before."); 14 16 17 # if (RE_PHOTOMETER) 15 18 bool mdok; // Status of MD lookup 16 19 … … 38 41 psImageMaskType maskVal = pmConfigMaskGet(maskValStr, config); // Bits to mask 39 42 43 // Measure background 40 44 psImage *image = ro->image, *mask = ro->mask; // Image and mask from readout 41 42 // Measure background43 45 psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator 44 46 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics … … 52 54 psFree(stats); 53 55 psFree(rng); 54 55 // Photometer sources 56 int numCols = image->numCols, numRows = image->numRows; // Size of image56 # endif 57 58 // Examine the sources (photometer if RE_PHOTOMETER is set) 57 59 int numSources = sources->n; // Number of sources 58 60 int numGood = 0; // Number of good sources … … 64 66 continue; 65 67 } 66 float x = source->peak->xf, y = source->peak->yf; // Coordinates of source 68 69 // This code re-measures the magnitude in the assumption that the warp analysis failed It would 70 // be better to catch and correct such cases. In any case, we should check on the validity of 71 // this assumption (eg, compare the mean psf-ap offset) and raise an error on that? 72 73 # if (RE_PHOTOMETER) 74 75 int numCols = image->numCols, numRows = image->numRows; // Size of image 76 float x = source->peak->xf, y = source->peak->yf; // Coordinates of source 67 77 int xCentral = x + 0.5, yCentral = y + 0.5; // Central pixel 68 78 // Range of integration … … 96 106 } 97 107 } 108 # else 109 numGood++; 110 maxMag = PS_MAX(maxMag, source->psfMag); 111 # endif 98 112 } 99 113 psLogMsg("ppStack", PS_LOG_INFO, "Photometered %d good sources in image; max mag %f", numGood, maxMag); … … 217 231 } 218 232 } 233 234 bool mdok = false; 235 float maxFWHM = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.MAX"); // max allowed input fwhm 236 float clipFWHMnSig = psMetadataLookupF32(&mdok, recipe, "PSF.INPUT.CLIP.NSIGMA"); // sigma clipping of inputs 219 237 220 238 psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message … … 251 269 } 252 270 271 // reject any input images which exceed the specified max FWHM 272 if (isfinite(maxFWHM) && (options->inputSeeing->data.F32[i] > maxFWHM)) { 273 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_PSF; 274 psLogMsg("ppStack", PS_LOG_INFO, "PSF FWHM for image %d is too large (%f vs %f maxFWHM) --- rejected.", i, options->inputSeeing->data.F32[i], maxFWHM); 275 } 276 253 277 psStringAppend(&log, "Input %d: %f\n", i, options->inputSeeing->data.F32[i]); 254 278 } … … 257 281 } 258 282 psFree(log); 283 284 // We should have the ability to filter the input list based on the seeing: 285 // * reject above some max value and/or min value 286 // * reject images out-of-line with the rest of the images 287 288 // measure stats 289 psStats *fwhmStats = psStatsAlloc(PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 290 psVectorStats (fwhmStats, options->inputSeeing, NULL, options->inputMask, 0xff); 291 psLogMsg("ppStack", PS_LOG_INFO, "Input FWHMs : %f +/- %f", fwhmStats->clippedMean, fwhmStats->clippedStdev); 292 293 if (isfinite(clipFWHMnSig)) { 294 float fwhmLimit = fwhmStats->clippedMean + clipFWHMnSig * fwhmStats->clippedStdev; 295 fwhmLimit = isfinite(maxFWHM) ? PS_MIN (maxFWHM, fwhmLimit) : fwhmLimit; 296 for (int i = 0; i < num; i++) { 297 if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) continue; 298 if (options->inputSeeing->data.F32[i] > fwhmLimit) { 299 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = PPSTACK_MASK_PSF; 300 psLogMsg("ppStack", PS_LOG_INFO, "PSF FWHM for image %d is too large (%f vs %f fwhmLimit) --- rejected.", i, options->inputSeeing->data.F32[i], fwhmLimit); 301 } 302 } 303 } 259 304 260 305 // Generate target PSF
Note:
See TracChangeset
for help on using the changeset viewer.
