IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 14, 2006, 6:33:17 AM (20 years ago)
Author:
eugene
Message:

mods to change from threshold above sky to S/N thresholds

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotFindPeaks.c

    r6379 r6427  
    22
    33// 2006.02.02 : no leaks
    4 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *config, psStats *sky) {
     4psArray *psphotFindPeaks (pmReadout *readout, psMetadata *config) {
    55
    66    bool  status = false;
     
    99    float threshold;
    1010
    11     // smooth the image
     11    // smooth the image and weight map
     12
     13    psphotSaveImage (NULL, readout->image, "image.fits");
    1214
    1315    psTimerStart ("psphot");
     
    1618    NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_SMOOTH_NSIGMA");
    1719
    18     psImage *smooth = psImageCopy (NULL, readout->image, PS_TYPE_F32);
    19     psphotSaveImage (NULL, smooth, "presmooth.fits");
     20    psImage *smooth_im = psImageCopy (NULL, readout->image, PS_TYPE_F32);
     21    psImageSmooth (smooth_im, SIGMA, NSIGMA);
     22    psLogMsg ("psphot", 4, "smooth image: %f sec\n", psTimerMark ("psphot"));
    2023
    21     psImageSmooth (smooth, SIGMA, NSIGMA);
    22     psLogMsg ("psphot", 4, "smooth: %f sec\n", psTimerMark ("psphot"));
     24    psphotSaveImage (NULL, smooth_im, "smooth_im.fits");
    2325
    24     psphotSaveImage (NULL, smooth, "smooth.fits");
     26    psImage *smooth_wt = psImageCopy (NULL, readout->weight, PS_TYPE_F32);
     27    psImageSmooth (smooth_wt, SIGMA, NSIGMA);
     28    psLogMsg ("psphot", 4, "smooth weight: %f sec\n", psTimerMark ("psphot"));
     29
     30    psphotSaveImage (NULL, smooth_wt, "smooth_wt.fits");
     31
     32    psTimerStart ("psphot");
     33    for (int j = 0; j < smooth_im->numRows; j++) {
     34        for (int i = 0; i < smooth_im->numCols; i++) {
     35            if (smooth_wt->data.F32[j][i] <= 0) continue;
     36            smooth_im->data.F32[j][i] = PS_SQR(smooth_im->data.F32[j][i]) / smooth_wt->data.F32[j][i];
     37        }
     38    }
     39    psLogMsg ("psphot", 4, "built S/N map: %f sec\n", psTimerMark ("psphot"));
    2540
    2641    psTimerStart ("psphot");
    2742
    2843    // set peak threshold
    29     NSIGMA    = psMetadataLookupF32 (&status, config, "PEAKS_NSIGMA_LIMIT");
    30    
    31     threshold = NSIGMA*sky->sampleStdev + sky->sampleMean;
    32     // threshold = NSIGMA*sky->sampleStdev;
     44    NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_NSIGMA_LIMIT");
     45    // threshold = NSIGMA*sky->sampleStdev + sky->sampleMean;
     46    threshold = PS_SQR(NSIGMA);
    3347    psLogMsg ("psphot", 4, "threshold: %f DN\n", threshold);
    3448
    3549    // find the peaks in the smoothed image
    36     psArray *peaks = pmFindImagePeaks (smooth, threshold);
     50    psArray *peaks = pmFindImagePeaks (smooth_im, threshold);
    3751    if (peaks == NULL) psAbort ("find peaks", "no peaks found");
    38     psFree (smooth);
     52    psFree (smooth_im);
     53    psFree (smooth_wt);
    3954
    4055    // optional dump of all peak data
Note: See TracChangeset for help on using the changeset viewer.