IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18289


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

Merging in dual convolution development branch.

Location:
trunk/ppSub
Files:
1 added
3 edited

Legend:

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

    r17813 r18289  
    186186    psMetadataAddS32(arguments, PS_LIST_TAIL, "-order", 0, "Spatial polynomial order", -1);
    187187    psMetadataAddStr(arguments, PS_LIST_TAIL, "-type", 0, "Kernel type (ISIS|POIS|SPAM|FRIES|GUNK|RINGS)", NULL);
     188    psMetadataAddF32(arguments, PS_LIST_TAIL, "-penalty", 0, "Penalty for wideness", NAN);
    188189    psMetadataAddStr(arguments, PS_LIST_TAIL, "-isis-widths", 0, "ISIS Gaussian FWHMs (comma-separated)", NULL);
    189190    psMetadataAddStr(arguments, PS_LIST_TAIL, "-isis-orders", 0, "ISIS polynomial orders (comma-separated)", NULL);
     
    260261    VALUE_ARG_RECIPE_FLOAT("-rej",        "REJ",             F32);
    261262    VALUE_ARG_RECIPE_FLOAT("-badfrac",    "BADFRAC",         F32);
     263    VALUE_ARG_RECIPE_FLOAT("-penalty",    "PENALTY",         F32);
    262264
    263265    valueArgRecipeStr(arguments, recipe, "-mask-bad",   "MASK.BAD",   config->arguments);
  • trunk/ppSub/src/ppSubCamera.c

    r17834 r18289  
    8282
    8383    // Output image
    84     pmFPAfile *output = pmFPAfileDefineSkycell(config, NULL, "PPSUB.OUTPUT");
     84    pmFPAfile *output = pmFPAfileDefineFromFile(config, input, 1, 1, "PPSUB.OUTPUT");
    8585    if (!output) {
    8686        psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT"));
     
    9494
    9595    // Output mask
    96     pmFPAfile *outMask = pmFPAfileDefineSkycell(config, output->fpa, "PPSUB.OUTPUT.MASK");
     96    pmFPAfile *outMask = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.MASK");
    9797    if (!outMask) {
    9898        psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.MASK"));
     
    107107    // Output weight
    108108    if (inputWeight && refWeight) {
    109         pmFPAfile *outWeight = pmFPAfileDefineSkycell(config, output->fpa, "PPSUB.OUTPUT.WEIGHT");
     109        pmFPAfile *outWeight = pmFPAfileDefineOutput(config, output->fpa, "PPSUB.OUTPUT.WEIGHT");
    110110        if (!outWeight) {
    111111            psError(PS_ERR_IO, false, _("Unable to generate output file from PPSUB.OUTPUT.WEIGHT"));
     
    119119    }
    120120
     121#if 0
    121122    if (!pmFPAAddSourceFromFormat(output->fpa, "Subtraction", output->format)) {
    122123        psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
    123124        return false;
    124125    }
     126#endif
    125127
    126128    pmFPAfile *sources = pmFPAfileDefineFromArgs(&status, config, "PPSUB.SOURCES", "PPSUB.SOURCES");
     
    153155
    154156        // Internal-ish file for getting the PSF from the matched addition
    155         pmFPAfile *psf = pmFPAfileDefineSkycell(config, psphot->fpa, "PSPHOT.PSF.LOAD");
     157        pmFPAfile *psf = pmFPAfileDefineOutputFromFile(config, output, "PSPHOT.PSF.LOAD");
    156158        if (!psf) {
    157159            psError(PS_ERR_IO, false, "Failed to build FPA from PSPHOT.PSF.LOAD");
  • 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.