IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18005


Ignore:
Timestamp:
Jun 8, 2008, 2:47:42 PM (18 years ago)
Author:
eugene
Message:

another attempt to get the significance image right

File:
1 edited

Legend:

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

    r17870 r18005  
    88    float SIGMA_SMTH, NSIGMA_SMTH;
    99    bool status = false;
     10    bool guess = false;
    1011
    1112    // smooth the image and weight map
     
    1920      SIGMA_SMTH  = 0.5*(FWHM_X + FWHM_Y) / (2.0*sqrt(2.0*log(2.0)));
    2021      NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
     22      guess = false;
    2123    } else {
    2224      // if we do not know the FWHM, use the guess smoothing kernel supplied.
     
    2628      NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA");
    2729      PS_ASSERT (status, NULL);
     30      guess = true;
    2831    }
    2932    // record the actual smoothing sigma
     
    3538    psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth image: %f sec\n", psTimerMark ("smooth"));
    3639
    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.
     40    // Smooth the weight, applying the mask as we go.  The variance is smoothed by the PSF^2,
     41    // renomalized to maintain the input level of the variance.  We achieve this by smoothing
     42    // with a Gaussian with sigma = SIGMA_SMTH/sqrt(2) with unity normalization.  Note that
     43    // this process yields a smoothed image with correlated errors.  The pixel-to-pixel
     44    // variations in smooth_im will be decreased by a factor of 4*pi*SIGMA_SMTH^2, but for
     45    // measurements based on apertures comparable to or larger than the smoothing kernel, the
     46    // effective per-pixel variance is maintained.
    4347    psImage *smooth_wt = psImageCopy (NULL, readout->weight, PS_TYPE_F32);
    4448    psImageSmoothMaskF32 (smooth_wt, readout->mask, maskVal, SIGMA_SMTH/sqrt(2), NSIGMA_SMTH);
     
    6468
    6569    // 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 factors: 1) the relationship the peak value and the integrated flux, and 2) the
     71    // relationship between the per-pixel variance (var_i) and the total variance included in
     72    // the flux measurement (effective area).  These latter correction comes from: flux = Io *
    7073    // 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
     74    // = (Io/var_i) \pi sigma_o^2
    7275
    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)
     76    // in fact, because of the smoothing and the resulting correlated errors, the per-pixel
     77    // varience is a bit smaller than the value predicted here.  The total variance should be
     78    // \alpha 4\pi(\sigma_r_^2 + \sigma_s^2) where \alpha approaches 1 for \sigma_s / \sigma_r
     79    // << 1, and \alpha approaches 0.5 for \sigma_s / \sigma_r >> 1, with a value of 0.7
     80    // (actually 1/1.5) for \sigma_s = \sigma_r
    7781
    78     float factor = 8.0 * PS_SQR(M_PI) * pow(SIGMA_SMTH, 4.0);
     82    // if the smoothing kernel size is known to be the psf size (\sigma_s = \sigma_r), then we
     83    // can use the scaling factor of 1/1.5; otherwise, we want to be conservative and use \alpha
     84    // = 0.5.  Thus, for the guess smoothing kernel, (S/N)^2 = 3.0 (Io/var_i) \pi sigma_s^2 for
     85    // the guess case and (S/N)^2 = 2.0 (Io/var_i) \pi sigma_s^2 for the known case
     86
     87    // XXX hmm, somehow the simulations are coming up with 4pi, not 3pi (as if \alpha is 1/2.0,
     88    // not 1/1.5 for sigma_s = sigma_r...
     89
     90    float factor = guess ? 4.0 * M_PI * PS_SQR(SIGMA_SMTH) : 4.0 * M_PI * PS_SQR(SIGMA_SMTH);
    7991    // record the effective area and significance scaling factor
    8092    float effArea = 8.0 * M_PI * PS_SQR(SIGMA_SMTH);
Note: See TracChangeset for help on using the changeset viewer.