IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 30, 2008, 4:09:46 PM (18 years ago)
Author:
eugene
Message:

fix errors in calculation of sig image; API change: sig image is now actual S/N2

File:
1 edited

Legend:

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

    r17443 r17870  
    11# include "psphotInternal.h"
    22
    3 // In this function, we smooth the image, then search for the peaks
    4 // if FWMH_X,Y have been recorded, use them; otherwise use PEAKS_SMOOTH_SIGMA
     3// In this function, we smooth the image and weight, then generate the significance image :
     4// (S/N)^2.  If FWMH_X,Y have been recorded, use them, otherwise use PEAKS_SMOOTH_SIGMA for the
     5// smoothing kernel.
    56psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, const int pass, psMaskType maskVal) {
    67
     
    3435    psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth image: %f sec\n", psTimerMark ("smooth"));
    3536
    36     // smooth the weight, applying the mask as we go
     37    // Smooth the weight, applying the mask as we go.  The variance *should* be smoothed by the
     38    // PSF^2, which does not have unity normalization (variance decreases as we smooth).
     39    // Instead, we are smoothing with a Gaussian with sigma = SIGMA_SMTH/sqrt(2) with unity
     40    // normalization.  The resulting variance is a factor of 4*pi*SIGMA_SMTH^2 too large.  We
     41    // correct for this effect, and the effective area, in the calculation of the (S/N)^2 image
     42    // below.
    3743    psImage *smooth_wt = psImageCopy (NULL, readout->weight, PS_TYPE_F32);
    3844    psImageSmoothMaskF32 (smooth_wt, readout->mask, maskVal, SIGMA_SMTH/sqrt(2), NSIGMA_SMTH);
     
    5157    }
    5258
    53     // build the significance image on top of smooth_im
     59    // We have an input image with PSF size sigma_r.  We have smoothed it with a kernel of size
     60    // sigma_s.  The result is an image with PSF size sigma_o: sigma_o^2 = sigma_r^2 +
     61    // sigma_s^2.  Ideally, we are choosing sigma_s = sigma_r, in which case sigma_o^2 = 2
     62    // sigma_s^2.  If we do not know the input image PSF size (initial detection stage), then
     63    // we are assuming that sigma_r = sigma_s. 
     64
     65    // Build the significance image on top of smooth_im.  We need to correct the ratio im/wt by
     66    // two factors: 1) the error in the variance normalization above and 2) a factor to account
     67    // for the relationship the peak value and the integrated flux, and the relationship
     68    // between the per-pixel variance (var_i) and the total variance included in the flux
     69    // measurement (effective area).  These latter correction comes from: flux = Io *
     70    // 2\pi\sigma_o^2 and total variance = var_i * 4\pi\sigma_o^2, thus (S/N)^2 = flux^2 / var
     71    // = var_i \pi sigma_o^2
     72
     73    // thus:
     74    // (S/N)^2 = (im^2 / wt) * (\pi \sigma_o^2 * 4 \sigma_s^2)
     75    // (S/N)^2 = (im^2 / wt) * (\pi 2 \sigma_s^2 * 4 \sigma_s^2)
     76    // (S/N)^2 = (im^2 / wt) * (\pi 8 \sigma_s^4)
     77
     78    float factor = 8.0 * PS_SQR(M_PI) * pow(SIGMA_SMTH, 4.0);
     79    // record the effective area and significance scaling factor
     80    float effArea = 8.0 * M_PI * PS_SQR(SIGMA_SMTH);
     81    psMetadataAddF32  (recipe, PS_LIST_TAIL, "EFFECTIVE_AREA", PS_META_REPLACE, "Effective Area", effArea);
     82    psMetadataAddF32  (recipe, PS_LIST_TAIL, "SIGNIFICANCE_SCALE_FACTOR", PS_META_REPLACE, "Signicance scale factor", factor);
     83
    5484    for (int j = 0; j < smooth_im->numRows; j++) {
    5585        for (int i = 0; i < smooth_im->numCols; i++) {
     
    5888                smooth_im->data.F32[j][i] = 0.0;
    5989            } else {
    60                 smooth_im->data.F32[j][i] = PS_SQR(value) / smooth_wt->data.F32[j][i];
     90                smooth_im->data.F32[j][i] = factor * PS_SQR(value) / smooth_wt->data.F32[j][i];
    6191            }
    6292        }
     
    75105    return smooth_im;
    76106}
     107
Note: See TracChangeset for help on using the changeset viewer.