IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 11, 2008, 6:12:42 PM (18 years ago)
Author:
Paul Price
Message:

Correcting stack variances for the imperfect convolution. Changed (again) the way the deviations are calculated; they're now straight chi2, which allows us to estimate how the variance factor needs to be changed in order to correct for it. Moving additional values into pmSubtractionKernels so that this can be calculated from a kernel that has been read in (very useful for debugging, also nice to have a record of the quality of the fit).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackMatch.c

    r19486 r19532  
    1515                     PM_SOURCE_MODE_CR_LIMIT) // Mask to apply to input sources
    1616
    17 //#define TESTING                         // Enable debugging output
     17#define TESTING                         // Enable debugging output
    1818
    1919
     
    4848#endif
    4949
    50 bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels,
     50bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels, float *chi2,
    5151                  const psArray *sources, const pmPSF *psf, psRandom *rng, const pmConfig *config)
    5252{
     
    111111                                                                PM_SUBTRACTION_ANALYSIS_KERNEL); // Kernels
    112112            float vf = pmSubtractionVarianceFactor(kernels, 0.0, 0.0, false); // Variance factor
    113             psMetadataItem *vfItem = psMetadataLookup(output->parent->concepts, "CELL.VARFACTOR");
     113            psMetadataItem *vfItem = psMetadataLookup(readout->parent->concepts, "CELL.VARFACTOR");
    114114            if (!isfinite(vf)) {
    115115                vf = 1.0;
     
    341341    assert((*regions)->n == (*kernels)->n);
    342342
     343    // Correct the variance for the chi^2
     344    {
     345        *chi2 = 0.0;
     346        int num = 0;                    // Number of measurements of chi^2
     347        psString regex = NULL;          // Regular expression
     348        psStringAppend(&regex, "^%s$", PM_SUBTRACTION_ANALYSIS_KERNEL);
     349        psMetadataIterator *iter = psMetadataIteratorAlloc(output->analysis, PS_LIST_HEAD, regex); // Iterator
     350        psFree(regex);
     351        psMetadataItem *item = NULL;// Item from iteration
     352        while ((item = psMetadataGetAndIncrement(iter))) {
     353            assert(item->type == PS_DATA_UNKNOWN);
     354            pmSubtractionKernels *kernels = item->data.V; // Convolution kernels
     355            *chi2 += kernels->mean;
     356            num++;
     357        }
     358        psFree(iter);
     359
     360        float vf = psMetadataLookupF32(NULL, readout->parent->concepts, "CELL.VARFACTOR"); // Variance factor
     361        *chi2 /= vf * num;
     362    }
     363
    343364    // Renormalise the variances if desired
    344365    if (renorm) {
Note: See TracChangeset for help on using the changeset viewer.