IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 23, 2010, 9:02:41 PM (16 years ago)
Author:
Paul Price
Message:

Something was missing from the merge (probably because I tool r27400 out), so had to get it back.

File:
1 edited

Legend:

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

    r27403 r27427  
    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
     
    4648    }
    4749
    48     if (!target->mask) {
    49         target->mask = psImageAlloc(target->image->numCols, target->image->numRows, PS_TYPE_IMAGE_MASK);
     50    if (!outRO->mask) {
     51        outRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
     52    }
     53    if (!expRO->mask) {
     54        expRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
    5055    }
    5156
     
    6570        }
    6671
    67         // call: ppStackReadoutFinal(config, target, readouts, rejected)
     72        // call: ppStackReadoutFinal(config, outRO, readouts, rejected)
    6873        psThreadJob *job = psThreadJobAlloc("PPSTACK_FINAL_COMBINE"); // Job to start
    69         psArrayAdd(job->args, 1, target);
    7074        psArrayAdd(job->args, 1, thread);
    7175        psArrayAdd(job->args, 1, reject);
     
    108112        }
    109113        if (sumWeights > 0.0) {
    110             target->covariance = psImageCovarianceSum(covariances);
    111             psBinaryOp(target->covariance->image, target->covariance->image, "/",
     114            outRO->covariance = psImageCovarianceSum(covariances);
     115            psBinaryOp(outRO->covariance->image, outRO->covariance->image, "/",
    112116                       psScalarAlloc(sumWeights, PS_TYPE_F32));
    113             psImageCovarianceTransfer(target->variance, target->covariance);
     117            psImageCovarianceTransfer(outRO->variance, outRO->covariance);
    114118        }
    115119    } else {
    116         target->covariance = psImageCovarianceNone();
     120        outRO->covariance = psImageCovarianceNone();
    117121    }
    118122
     
    130134            wcsDone = true;
    131135            pmHDU *inHDU = pmHDUFromCell(inRO->parent); // Template HDU
    132             pmHDU *outHDU = pmHDUFromCell(target->parent); // Output HDU
    133             pmChip *outChip = target->parent->parent; // Output chip
     136            pmHDU *outHDU = pmHDUFromCell(outRO->parent); // Output HDU
     137            pmChip *outChip = outRO->parent->parent; // Output chip
    134138            pmFPA *outFPA = outChip->parent; // Output FPA
    135139            if (!outHDU || !inHDU) {
     
    154158    }
    155159
     160    // Set exposure time correctly
     161    {
     162        float exptime = 0.0;            // Summed exposure time
     163        for (int i = 0; i < options->num; i++) {
     164            if (options->inputMask) {
     165                continue;
     166            }
     167            exptime += options->exposures->data.F32[i];
     168        }
     169
     170        {
     171            psMetadataItem *item = psMetadataLookup(outRO->parent->concepts, "CELL.EXPOSURE");
     172            item->data.F32 = exptime;
     173        }
     174        {
     175            psMetadataItem *item = psMetadataLookup(outRO->parent->parent->parent->concepts, "FPA.EXPOSURE");
     176            item->data.F32 = exptime;
     177        }
     178    }
     179
    156180    // Put version information into the header
    157     pmHDU *hdu = pmHDUFromCell(target->parent);
     181    pmHDU *hdu = pmHDUFromCell(outRO->parent);
    158182    if (!hdu) {
    159183        psError(PPSTACK_ERR_PROG, false, "Unable to find HDU for output.");
     
    171195    psStringAppend(&name, "combined_image_final_%d.fits", pass);
    172196    pass++;
    173     ppStackWriteImage(name, NULL, target->image, config);
     197    ppStackWriteImage(name, NULL, outRO->image, config);
    174198    psStringSubstitute(&name, "mask", "image");
    175     ppStackWriteImage(name, NULL, target->mask, config);
     199    ppStackWriteImage(name, NULL, outRO->mask, config);
    176200    psStringSubstitute(&name, "variance", "mask");
    177     ppStackWriteImage(name, NULL, target->variance, config);
     201    ppStackWriteImage(name, NULL, outRO->variance, config);
    178202    psFree(name);
    179203
    180     pmStackVisualPlotTestImage(target->image, "combined_image_final.fits");
     204    pmStackVisualPlotTestImage(outRO->image, "combined_image_final.fits");
    181205#endif
    182206
Note: See TracChangeset for help on using the changeset viewer.