IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 22, 2010, 8:34:28 PM (16 years ago)
Author:
Paul Price
Message:

Adding exposure map (both exposure time and number of inputs) to the outputs of ppStack. These are calculated both for the regular (convolved) and unconvolved stacks. These should compress pretty well, but I haven't enabled the compression yet. I also plan to add a weighted exposure time output.

File:
1 edited

Legend:

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

    r27319 r27400  
    1414//#define TESTING                         // Enable test output
    1515
    16 bool ppStackCombineFinal(pmReadout *target, ppStackThreadData *stack, psArray *covariances,
    17                          ppStackOptions *options, pmConfig *config, bool safe, bool normalise, bool grow)
     16bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options,
     17                         pmConfig *config, bool safe, bool normalise, bool grow)
    1818{
    1919    psAssert(stack, "Require stack");
     
    2121    psAssert(config, "Require configuration");
    2222
    23     int numCols = target->image->numCols, numRows = target->image->numRows; // Size of image
     23    pmReadout *outRO = options->outRO;                                      // Output readout
     24    pmReadout *expRO = options->expRO;                                      // Exposure readout
     25    int numCols = outRO->image->numCols, numRows = outRO->image->numRows; // Size of image
    2426
    2527    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
     
    4345    }
    4446
    45     if (!target->mask) {
    46         target->mask = psImageAlloc(target->image->numCols, target->image->numRows, PS_TYPE_IMAGE_MASK);
     47    if (!outRO->mask) {
     48        outRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
     49    }
     50    if (!expRO->mask) {
     51        expRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    4752    }
    4853
     
    6267        }
    6368
    64         // call: ppStackReadoutFinal(config, target, readouts, rejected)
     69        // call: ppStackReadoutFinal(config, outRO, readouts, rejected)
    6570        psThreadJob *job = psThreadJobAlloc("PPSTACK_FINAL_COMBINE"); // Job to start
    66         psArrayAdd(job->args, 1, target);
    6771        psArrayAdd(job->args, 1, thread);
    6872        psArrayAdd(job->args, 1, reject);
     
    105109        }
    106110        if (sumWeights > 0.0) {
    107             target->covariance = psImageCovarianceSum(covariances);
    108             psBinaryOp(target->covariance->image, target->covariance->image, "/",
     111            outRO->covariance = psImageCovarianceSum(covariances);
     112            psBinaryOp(outRO->covariance->image, outRO->covariance->image, "/",
    109113                       psScalarAlloc(sumWeights, PS_TYPE_F32));
    110             psImageCovarianceTransfer(target->variance, target->covariance);
     114            psImageCovarianceTransfer(outRO->variance, outRO->covariance);
    111115        }
    112116    } else {
    113         target->covariance = psImageCovarianceNone();
     117        outRO->covariance = psImageCovarianceNone();
    114118    }
    115119
     
    127131            wcsDone = true;
    128132            pmHDU *inHDU = pmHDUFromCell(inRO->parent); // Template HDU
    129             pmHDU *outHDU = pmHDUFromCell(target->parent); // Output HDU
    130             pmChip *outChip = target->parent->parent; // Output chip
     133            pmHDU *outHDU = pmHDUFromCell(outRO->parent); // Output HDU
     134            pmChip *outChip = outRO->parent->parent; // Output chip
    131135            pmFPA *outFPA = outChip->parent; // Output FPA
    132136            if (!outHDU || !inHDU) {
     
    151155    }
    152156
     157    // Set exposure time correctly
     158    {
     159        float exptime = 0.0;            // Summed exposure time
     160        for (int i = 0; i < options->num; i++) {
     161            if (options->inputMask) {
     162                continue;
     163            }
     164            exptime += options->exposures->data.F32[i];
     165        }
     166
     167        {
     168            psMetadataItem *item = psMetadataLookup(outRO->parent->concepts, "CELL.EXPOSURE");
     169            item->data.F32 = exptime;
     170        }
     171        {
     172            psMetadataItem *item = psMetadataLookup(outRO->parent->parent->parent->concepts, "FPA.EXPOSURE");
     173            item->data.F32 = exptime;
     174        }
     175    }
     176
    153177    // Put version information into the header
    154     pmHDU *hdu = pmHDUFromCell(target->parent);
     178    pmHDU *hdu = pmHDUFromCell(outRO->parent);
    155179    if (!hdu) {
    156180        psError(PPSTACK_ERR_PROG, false, "Unable to find HDU for output.");
     
    168192    psStringAppend(&name, "combined_image_final_%d.fits", pass);
    169193    pass++;
    170     ppStackWriteImage(name, NULL, target->image, config);
     194    ppStackWriteImage(name, NULL, outRO->image, config);
    171195    psStringSubstitute(&name, "mask", "image");
    172     ppStackWriteImage(name, NULL, target->mask, config);
     196    ppStackWriteImage(name, NULL, outRO->mask, config);
    173197    psStringSubstitute(&name, "variance", "mask");
    174     ppStackWriteImage(name, NULL, target->variance, config);
     198    ppStackWriteImage(name, NULL, outRO->variance, config);
    175199    psFree(name);
    176200
    177     pmStackVisualPlotTestImage(target->image, "combined_image_final.fits");
     201    pmStackVisualPlotTestImage(outRO->image, "combined_image_final.fits");
    178202#endif
    179203
Note: See TracChangeset for help on using the changeset viewer.