Changeset 31154 for trunk/psphot/src/psphotCullPeaks.c
- Timestamp:
- Apr 4, 2011, 1:12:39 PM (15 years ago)
- Location:
- trunk/psphot
- Files:
-
- 2 edited
-
. (modified) (2 props)
-
src/psphotCullPeaks.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot
- Property svn:ignore
-
old new 19 19 psphot-config 20 20 Doxyfile 21 a.out.dSYM
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
trunk/psphot/src/psphotCullPeaks.c
r27673 r31154 6 6 psErrorCode 7 7 psphotCullPeaks(const pmReadout *readout, // the image wherein lives the footprint 8 const pmReadout *signifR, // smoothed image and significance 8 9 const psMetadata *recipe, 9 10 psArray *footprints) { // array of pmFootprints … … 26 27 psAssert (status, "cannot find SKY_STDEV in readout->analysis"); 27 28 28 const float min_threshold = nsigma_min*skyStdev; 29 // the sky has been smoothed, so we need to scale down the raw sky stdev by this amount: 30 float scaleFactor = psMetadataLookupF32(&status, readout->analysis, "SIGNIFICANCE_SCALE_FACTOR"); 31 if (!status) scaleFactor = 1.0; 32 33 const float MIN_THRESHOLD = nsigma_min*skyStdev / sqrt(scaleFactor); 29 34 35 // for saturated stars, we should be somewhat more agressive about culling: instead of 36 // letting the height of the intervening col (saddle point) be set by the S/N of the image 37 // pixel, it should be set to a fraction of the saturation value. example for a 38 // near-saturation pixel: 39 // flux = 40k, sigma = 200 40 // nsigma_delta = 4.0, nsigma_min = 1.0, fPadding = 0.01, 41 // fStdev = 0.005, stdev_pad = 0.011*40k = 400 42 // threshold = 40k - 4*400 = 38400 43 // this gives too tight of a tolerance on the bright stars 44 // in practice, we should make the threshold much lower. 45 // below I am using 0.05 * saturation (eg, 2000 DN above sky in a GPC1 image) 46 47 float SATURATION = NAN; 48 49 // do not completely trust the values in the header... 50 float CELL_SATURATION = psMetadataLookupF32 (&status, readout->parent->concepts, "CELL.SATURATION"); 51 float MIN_SATURATION = psMetadataLookupF32 (&status, recipe, "DEBLEND_MIN_SATURATION"); 52 if (!status || !isfinite(MIN_SATURATION)) { 53 MIN_SATURATION = 40000.0; 54 } 55 if (!isfinite(CELL_SATURATION)) { 56 SATURATION = MIN_SATURATION; 57 } else { 58 SATURATION = PS_MAX(MIN_SATURATION, CELL_SATURATION); 59 } 60 float SAT_TEST_LEVEL = 0.50*SATURATION; 61 float SAT_THRESHOLD = 0.05*SATURATION; 62 63 # if (PM_PEAKS_CULL_WITH_SMOOTHED_IMAGE) 64 psLogMsg ("psphot", PS_LOG_INFO, "Culling peaks from footprints using the smoothed image"); 65 # else 66 psLogMsg ("psphot", PS_LOG_INFO, "Culling peaks from footprints using the raw (unsmoothed) image"); 67 # endif 68 30 69 for (int i = 0; i < footprints->n; i++) { 31 // if (i % 50 == 0) fprintf (stderr, "cull %d\n", i);32 70 pmFootprint *fp = footprints->data[i]; 71 if (fp->peaks == NULL) continue; 72 if (fp->peaks->n == 0) continue; 73 33 74 if (fp->npix > 30000) { 34 75 fprintf (stderr, "big footprint: %f %f to %f %f (%d pix)\n", fp->bbox.x0, fp->bbox.y0, fp->bbox.x1, fp->bbox.y1, fp->npix); 35 76 } 36 77 psTimerStart ("psphot.cull.footprints"); 37 if (pmFootprintCullPeaks(readout->image, readout->variance, fp, nsigma_delta, fPadding, min_threshold) != PS_ERR_NONE) { 78 79 pmPeak *brightPeak = fp->peaks->data[0]; 80 float max_threshold = SAT_TEST_LEVEL; 81 if (brightPeak->rawFlux > SAT_TEST_LEVEL) { 82 max_threshold = SAT_THRESHOLD; 83 brightPeak->type = PM_PEAK_SUSPECT_SATURATION; 84 } 85 86 # if (PM_PEAKS_CULL_WITH_SMOOTHED_IMAGE) 87 // New (post r30869) style of culling using the smoothed image and variance (S/N) 88 // if we cull using the significance image, then the definition of variance is different (thus the bool in arg 8) 89 if (pmFootprintCullPeaks(signifR->image, signifR->variance, fp, nsigma_delta, fPadding, MIN_THRESHOLD, max_threshold, true) != PS_ERR_NONE) { 38 90 return psError(PS_ERR_UNKNOWN, false, "Culling pmFootprint %d", fp->id); 39 91 } 92 # else 93 // Old (pre r30869) style of culling using the raw image and variance 94 if (pmFootprintCullPeaks(readout->image, readout->variance, fp, nsigma_delta, fPadding, MIN_THRESHOLD, max_threshold, false) != PS_ERR_NONE) { 95 return psError(PS_ERR_UNKNOWN, false, "Culling pmFootprint %d", fp->id); 96 } 97 # endif 98 40 99 float dtime = psTimerMark ("psphot.cull.footprints"); 41 100 if (dtime > 1.0) {
Note:
See TracChangeset
for help on using the changeset viewer.
