IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 17, 2009, 12:08:50 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ppSub

  • branches/cnb_branches/cnb_branch_20090301/ppSub/src/ppSubMatchPSFs.c

    r21524 r23352  
    4949    bool mdok;                          // Status of MD lookup
    5050
     51    // Load pre-calculated kernel, if available
     52    pmReadout *kernelRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT.KERNEL"); // RO with kernel
     53
    5154    // Sources in image, used for stamps: these must be loaded from previous analysis stages
    52     pmReadout *sourcesRO = pmFPAfileThisReadout(config->files, view, "PPSUB.SOURCES"); // Readout with sources
    53     psArray *sources = NULL;            // Sources in image; used for stamps
    54     if (sourcesRO) {
    55         sources = psMetadataLookupPtr(&mdok, sourcesRO->analysis, "PSPHOT.SOURCES");
     55    psArray *inSources = psMetadataLookupPtr(&mdok, inRO->analysis, "PSPHOT.SOURCES"); // Input source list
     56    psArray *refSources = psMetadataLookupPtr(&mdok, refRO->analysis, "PSPHOT.SOURCES"); // Ref source list
     57
     58    psArray *sources = NULL;            // Merged list of sources
     59    if (inSources && refSources) {
     60        float radius = psMetadataLookupF32(NULL, recipe, "SOURCE.RADIUS"); // Matching radius
     61        psArray *lists = psArrayAlloc(2); // Source lists
     62        lists->data[0] = psMemIncrRefCounter(inSources);
     63        lists->data[1] = psMemIncrRefCounter(refSources);
     64        sources = pmSourceMatchMerge(lists, radius);
     65        psFree(lists);
     66        if (!sources) {
     67            psError(PS_ERR_UNKNOWN, false, "Unable to merge source lists");
     68            return false;
     69        }
     70    } else if (inSources) {
     71        sources = psMemIncrRefCounter(inSources);
     72    } else if (refSources) {
     73        sources = psMemIncrRefCounter(refSources);
    5674    }
     75
     76    psMetadataAddArray(inConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
     77                       "Merged source list", sources);
     78    psMetadataAddArray(refConv->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_META_REPLACE,
     79                       "Merged source list", sources);
     80    psFree(sources);                    // Drop reference
    5781
    5882    int footprint = psMetadataLookupS32(NULL, recipe, "STAMP.FOOTPRINT"); // Stamp half-size
     
    113137
    114138    // Match the PSFs
    115     if (!pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, stride, regionSize, spacing, threshold,
    116                             sources, stampsName, type, size, order, widths, orders, inner, ringsOrder,
    117                             binning, penalty, optimum, optWidths, optOrder, optThresh, iter, rej, sys,
    118                             maskVal, maskBad, maskPoor, poorFrac, badFrac, subMode)) {
    119         psError(PS_ERR_UNKNOWN, false, "Unable to match images.");
    120         return false;
     139    if (kernelRO) {
     140        if (!pmSubtractionMatchPrecalc(inConv, refConv, inRO, refRO, kernelRO->analysis,
     141                                       stride, sys, maskVal, maskBad, maskPoor, poorFrac, badFrac)) {
     142            psError(PS_ERR_UNKNOWN, false, "Unable to convolve images.");
     143            return false;
     144        }
     145    } else {
     146        if (!pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, stride, regionSize, spacing,
     147                                threshold, sources, stampsName, type, size, order, widths, orders, inner,
     148                                ringsOrder, binning, penalty, optimum, optWidths, optOrder, optThresh, iter,
     149                                rej, sys, maskVal, maskBad, maskPoor, poorFrac, badFrac, subMode)) {
     150            psError(PS_ERR_UNKNOWN, false, "Unable to match images.");
     151            return false;
     152        }
    121153    }
    122154
     
    129161
    130162    // XXX drop the pixels associated with inRO and refRO (now that we have inConv and refConf)
    131 
     163#ifdef TESTING
    132164    psphotSaveImage (NULL, inRO->image, "inRO.fits");
    133165    psphotSaveImage (NULL, refRO->image, "refRO.fits");
    134166    psphotSaveImage (NULL, inConv->image, "inConv.fits");
    135167    psphotSaveImage (NULL, refConv->image, "refConv.fits");
     168#endif
    136169
    137170    return true;
Note: See TracChangeset for help on using the changeset viewer.