IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14298


Ignore:
Timestamp:
Jul 18, 2007, 12:11:39 PM (19 years ago)
Author:
Paul Price
Message:

Write WCS for stack.

File:
1 edited

Legend:

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

    r14278 r14298  
    1010
    1111#define ARRAY_BUFFER 16                 // Number to add to array at a time
     12#define WCS_TOLERANCE 0.001             // Tolerance for WCS
    1213
    1314bool ppStackReadout(pmConfig *config, const pmFPAview *view)
     
    2627    pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); // Output cell
    2728    pmReadout *outRO = pmReadoutAlloc(outCell); // Output readout
     29    pmFPA *outFPA = outCell->parent->parent; // Output FPA
    2830
    2931    int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs
     
    3941    int fileNum = 0;                    // Number of file
    4042    float totExposure = 0.0;            // Total exposure time
     43    pmReadout *templateRO = NULL;       // Template readout, for copy WCS
    4144    while ((fileItem = psMetadataGetAndIncrement(fileIter))) {
    4245        assert(fileItem->type == PS_DATA_UNKNOWN);
     
    8992            ro->mask = psImageAlloc(ro->image->numCols, ro->image->numRows, PS_TYPE_MASK);
    9093            psImageInit(ro->mask, 0);
     94        }
     95
     96        if (fileNum == 0) {
     97            templateRO = ro;
    9198        }
    9299
     
    170177
    171178    outRO->data_exists = true;
    172     outRO->parent->data_exists = true;
    173     outRO->parent->parent->data_exists = true;
     179    outCell->data_exists = true;
     180    outCell->parent->data_exists = true;
     181
     182    // Copy astrometry over
     183    pmFPA *templateFPA = templateRO->parent->parent->parent; // Template FPA
     184    pmHDU *templateHDU = templateFPA->hdu; // Template HDU
     185    pmHDU *outHDU = outFPA->hdu; // Output HDU
     186    if (!outHDU || !templateHDU) {
     187        psWarning("Unable to find HDU at FPA level to copy astrometry.");
     188    } else {
     189        if (!pmAstromReadWCS(outFPA, outCell->parent, templateHDU->header, 1.0)) {
     190            psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry from input FPA.");
     191            psFree(stack);
     192            psFree(outRO);
     193            return false;
     194        }
     195        if (!pmAstromWriteWCS(outHDU->header, outFPA, outCell->parent, WCS_TOLERANCE)) {
     196            psError(PS_ERR_UNKNOWN, false, "Unable to write WCS astrometry to output FPA.");
     197            psFree(stack);
     198            psFree(outRO);
     199            return false;
     200        }
     201    }
    174202
    175203    psFree(stack);
Note: See TracChangeset for help on using the changeset viewer.