IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 23, 2010, 9:12:53 AM (16 years ago)
Author:
Paul Price
Message:

Pulling r27400 out of the trunk until it can be developed further (compression, make optional). Development will continue on branches/pap_stack/

File:
1 edited

Legend:

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

    r27400 r27402  
    1414//#define TESTING                         // Enable test output
    1515
    16 bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options,
    17                          pmConfig *config, bool safe, bool normalise, bool grow)
     16bool ppStackCombineFinal(pmReadout *target, ppStackThreadData *stack, psArray *covariances,
     17                         ppStackOptions *options, pmConfig *config, bool safe, bool normalise, bool grow)
    1818{
    1919    psAssert(stack, "Require stack");
     
    2121    psAssert(config, "Require configuration");
    2222
    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
     23    int numCols = target->image->numCols, numRows = target->image->numRows; // Size of image
    2624
    2725    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
     
    4543    }
    4644
    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);
     45    if (!target->mask) {
     46        target->mask = psImageAlloc(target->image->numCols, target->image->numRows, PS_TYPE_IMAGE_MASK);
    5247    }
    5348
     
    6762        }
    6863
    69         // call: ppStackReadoutFinal(config, outRO, readouts, rejected)
     64        // call: ppStackReadoutFinal(config, target, readouts, rejected)
    7065        psThreadJob *job = psThreadJobAlloc("PPSTACK_FINAL_COMBINE"); // Job to start
     66        psArrayAdd(job->args, 1, target);
    7167        psArrayAdd(job->args, 1, thread);
    7268        psArrayAdd(job->args, 1, reject);
     
    109105        }
    110106        if (sumWeights > 0.0) {
    111             outRO->covariance = psImageCovarianceSum(covariances);
    112             psBinaryOp(outRO->covariance->image, outRO->covariance->image, "/",
     107            target->covariance = psImageCovarianceSum(covariances);
     108            psBinaryOp(target->covariance->image, target->covariance->image, "/",
    113109                       psScalarAlloc(sumWeights, PS_TYPE_F32));
    114             psImageCovarianceTransfer(outRO->variance, outRO->covariance);
     110            psImageCovarianceTransfer(target->variance, target->covariance);
    115111        }
    116112    } else {
    117         outRO->covariance = psImageCovarianceNone();
     113        target->covariance = psImageCovarianceNone();
    118114    }
    119115
     
    131127            wcsDone = true;
    132128            pmHDU *inHDU = pmHDUFromCell(inRO->parent); // Template HDU
    133             pmHDU *outHDU = pmHDUFromCell(outRO->parent); // Output HDU
    134             pmChip *outChip = outRO->parent->parent; // Output chip
     129            pmHDU *outHDU = pmHDUFromCell(target->parent); // Output HDU
     130            pmChip *outChip = target->parent->parent; // Output chip
    135131            pmFPA *outFPA = outChip->parent; // Output FPA
    136132            if (!outHDU || !inHDU) {
     
    155151    }
    156152
    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 
    177153    // Put version information into the header
    178     pmHDU *hdu = pmHDUFromCell(outRO->parent);
     154    pmHDU *hdu = pmHDUFromCell(target->parent);
    179155    if (!hdu) {
    180156        psError(PPSTACK_ERR_PROG, false, "Unable to find HDU for output.");
     
    192168    psStringAppend(&name, "combined_image_final_%d.fits", pass);
    193169    pass++;
    194     ppStackWriteImage(name, NULL, outRO->image, config);
     170    ppStackWriteImage(name, NULL, target->image, config);
    195171    psStringSubstitute(&name, "mask", "image");
    196     ppStackWriteImage(name, NULL, outRO->mask, config);
     172    ppStackWriteImage(name, NULL, target->mask, config);
    197173    psStringSubstitute(&name, "variance", "mask");
    198     ppStackWriteImage(name, NULL, outRO->variance, config);
     174    ppStackWriteImage(name, NULL, target->variance, config);
    199175    psFree(name);
    200176
    201     pmStackVisualPlotTestImage(outRO->image, "combined_image_final.fits");
     177    pmStackVisualPlotTestImage(target->image, "combined_image_final.fits");
    202178#endif
    203179
Note: See TracChangeset for help on using the changeset viewer.