IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 4, 2011, 1:12:39 PM (15 years ago)
Author:
eugene
Message:

use the smoothed image for footprint culling; use a more stringent culling for saturated stars; more tweaks to get sat stars to be fitted; various updates to psphotStack; unify psphotImageLoop varients; be a bit careful about number of stars in a PSF clump

Location:
trunk/psphot
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot

  • trunk/psphot/src/psphotCullPeaks.c

    r27673 r31154  
    66psErrorCode
    77psphotCullPeaks(const pmReadout *readout,   // the image wherein lives the footprint
     8                const pmReadout *signifR, // smoothed image and significance
    89                const psMetadata *recipe,
    910                psArray *footprints) {  // array of pmFootprints
     
    2627    psAssert (status, "cannot find SKY_STDEV in readout->analysis");
    2728
    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);
    2934   
     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
    3069    for (int i = 0; i < footprints->n; i++) {
    31         // if (i % 50 == 0) fprintf (stderr, "cull %d\n", i);
    3270        pmFootprint *fp = footprints->data[i];
     71        if (fp->peaks == NULL) continue;
     72        if (fp->peaks->n == 0) continue;
     73
    3374        if (fp->npix > 30000) {
    3475            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);
    3576        }
    3677        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) {
    3890            return psError(PS_ERR_UNKNOWN, false, "Culling pmFootprint %d", fp->id);
    3991        }
     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
    4099        float dtime = psTimerMark ("psphot.cull.footprints");
    41100        if (dtime > 1.0) {
Note: See TracChangeset for help on using the changeset viewer.