IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 23, 2008, 12:43:11 PM (18 years ago)
Author:
Paul Price
Message:

Merging in dual convolution development branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSubReadout.c

    r17835 r18289  
    1212
    1313#define WCS_TOLERANCE 0.001             // Tolerance for WCS
    14 //#define TESTING                         // For test output
     14#define TESTING                         // For test output
    1515
    1616
     
    7373    int ringsOrder = psMetadataLookupS32(NULL, config->arguments, "RINGS.ORDER"); // RINGS polynomial order
    7474    int binning = psMetadataLookupS32(NULL, config->arguments, "SPAM.BINNING"); // Binning for SPAM kernel
     75    float penalty = psMetadataLookupF32(NULL, config->arguments, "PENALTY"); // Penalty for wideness
    7576    psMaskType maskBad = pmConfigMask(psMetadataLookupStr(NULL, config->arguments, "MASK.BAD"),
    7677                                    config); // Value to mask
     
    131132
    132133    if (!pmSubtractionMatch(inConv, refConv, inRO, refRO, footprint, regionSize, spacing, threshold, sources,
    133                             stampsName, type, size, order, widths, orders, inner, ringsOrder,
    134                             binning, optimum, optWidths, optOrder, optThresh, iter, rej, maskBad,
     134                            stampsName, type, size, order, widths, orders, inner, ringsOrder, binning,
     135                            penalty, optimum, optWidths, optOrder, optThresh, iter, rej, maskBad,
    135136                            maskBlank, badFrac, mode)) {
    136137        psError(PS_ERR_UNKNOWN, false, "Unable to match images.");
     
    184185#endif
    185186
    186     // "Subtract" the mask and weight map
     187    // Subtraction is: minuend - subtrahend
     188    pmReadout *minuend = inConv;
     189    pmReadout *subtrahend = refConv;
     190
     191    if (reverse) {
     192        pmReadout *temp = subtrahend;
     193        subtrahend = minuend;
     194        minuend = temp;
     195    }
     196
     197#ifdef TESTING
     198    {
     199        pmReadoutMaskApply(minuend, maskBlank);
     200        psFits *fits = psFitsOpen("minuend.fits", "w");
     201        psFitsWriteImage(fits, NULL, minuend->image, 0, NULL);
     202        psFitsClose(fits);
     203    }
     204    {
     205        pmReadoutMaskApply(subtrahend, maskBlank);
     206        psFits *fits = psFitsOpen("subtrahend.fits", "w");
     207        psFitsWriteImage(fits, NULL, subtrahend->image, 0, NULL);
     208            psFitsClose(fits);
     209    }
     210#endif
     211
    187212    outRO->mask = (psImage*)psBinaryOp(outRO->mask, inConv->mask, "|", refConv->mask);
    188     if (inConv->weight && refConv->weight) {
    189         outRO->weight = (psImage*)psBinaryOp(outRO->weight, inConv->weight, "+", refConv->weight);
    190     }
    191     outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true;
     213    outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true; // It'll be there soon
    192214
    193215    // Photometry is to be performed in two stages:
     
    198220    pmPSF *psf = NULL;                  // PSF for photometry
    199221    if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) {
    200         // We use a summed image as the basis for the PSF: this will have the maximum S/N.
    201         outRO->image = (psImage*)psBinaryOp(outRO->image, inConv->image, "+", refConv->image);
     222        outRO->image = psImageCopy(outRO->image, minuend->image, PS_TYPE_F32);
     223        if (minuend->weight) {
     224            outRO->weight = psImageCopy(outRO->weight, minuend->weight, PS_TYPE_F32);
     225        }
    202226
    203227        pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT");
     
    244268    }
    245269
    246     // Do the subtraction
    247     {
    248         // Subtraction is: minuend - subtrahend
    249         pmReadout *minuend = inConv;
    250         pmReadout *subtrahend = refConv;
    251 
    252         if (reverse) {
    253             pmReadout *temp = subtrahend;
    254             subtrahend = minuend;
    255             minuend = temp;
    256         }
    257 
    258         outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image);
    259 
    260 #ifdef TESTING
    261         {
    262             psFits *fits = psFitsOpen("minuend.fits", "w");
    263             psFitsWriteImage(fits, NULL, minuend->image, 0, NULL);
    264             psFitsClose(fits);
    265         }
    266         {
    267             psFits *fits = psFitsOpen("subtrahend.fits", "w");
    268             psFitsWriteImage(fits, NULL, subtrahend->image, 0, NULL);
    269             psFitsClose(fits);
    270         }
    271 #endif
    272 
    273         pmReadoutMaskApply(outRO, maskBlank);
    274     }
     270    // Do the actual subtraction
     271    outRO->image = (psImage*)psBinaryOp(outRO->image, minuend->image, "-", subtrahend->image);
     272    if (inConv->weight && refConv->weight) {
     273        outRO->weight = (psImage*)psBinaryOp(outRO->weight, inConv->weight, "+", refConv->weight);
     274    }
     275    outRO->data_exists = outCell->data_exists = outCell->parent->data_exists = true;
     276
     277    pmReadoutMaskApply(outRO, maskBlank);
    275278
    276279    psFree(inConv);
     
    304307    }
    305308
    306     psTraceSetLevel("psphot", 6);
    307 
    308309    // Photometry stage 2: find and measure sources on the subtracted image
    309310    if (psMetadataLookupBool(NULL, config->arguments, "PHOTOMETRY")) {
     
    314315        pmReadout *psfRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.PSF.LOAD");
    315316        if (!psfRO) {
    316             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PSPHOT.PSF.LOAD");
     317            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find readout for file PSPHOT.PSF.LOAD");
    317318            return false;
    318319        }
Note: See TracChangeset for help on using the changeset viewer.