IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 7, 2013, 12:01:01 PM (13 years ago)
Author:
eugene
Message:

pswarp can now take an input.mdc file with multiple input images listed to generate a warp for a collection

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpDefineLayout.c

    r35512 r35527  
    1414bool pswarpDefineLayout (pmConfig *config) {
    1515
    16     // place input astrometry transformations in 'input'
    17     pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT");
    18     if (!input) {
    19         psError(PSWARP_ERR_CONFIG, false, "Can't find input data!\n");
    20         return false;
    21     }
    22     // input astrometry may be embedded in 'input' or supplied separately
    23     pmFPAfile *astrom = psMetadataLookupPtr(NULL, config->files, "PSWARP.ASTROM");
    24     if (!astrom) {
    25         astrom = input;
    26     }
    27     if (!pswarpLoadAstrometry (input, astrom, config)) {
    28         psError(PSWARP_ERR_CONFIG, false, "problem loading input astrometry\n");
    29         return false;
    30     }
    31 
    32     pmFPAfile *output = psMetadataLookupPtr(NULL, config->files, "PSWARP.OUTPUT");
     16    bool status = false;
     17
     18    pmFPAfile *output = psMetadataLookupPtr(&status, config->files, "PSWARP.OUTPUT");
    3319    if (!output) {
    3420        psError(PSWARP_ERR_CONFIG, false, "Can't find output data!\n");
     
    3622    }
    3723    // select the input data sources
    38     pmFPAfile *skycell = psMetadataLookupPtr (NULL, config->files, "PSWARP.SKYCELL");
     24    pmFPAfile *skycell = psMetadataLookupPtr (&status, config->files, "PSWARP.SKYCELL");
    3925    if (!skycell) {
    4026        psError(PSWARP_ERR_CONFIG, false, "Can't find skycell data!\n");
     
    4632    }
    4733
    48     // given the input data, determine which output elements should be generated
    49     // and generate the appropriate images
    50 
    51     // find the R,D center for the skycell, use for common projection
    52     psProjection *frame = pswarpLocalFrame (skycell->fpa);
    53 
    54     // generate Lmin,max, Mmin,max for both datasets
    55     pswarpBounds *srcBounds = pswarpMakeBounds (input->fpa, frame);
    56     pswarpBounds *tgtBounds = pswarpMakeBounds (skycell->fpa, frame);
    57 
    58     // find the output (tgt) chips which overlap the input (src) chips
    59     pswarpFindOverlap (input->fpa, output->fpa, srcBounds, tgtBounds);
     34    // chips are not processed unless we have determined they overlap the inputs
     35    pmFPAExcludeChips (output->fpa);
     36
     37    int nInputs = psMetadataLookupS32(&status, config->arguments, "NUM_INPUTS");
     38    if (!status) {
     39        psError(PSWARP_ERR_DATA, true, "number of inputs is not defined (programming error)");
     40        return false;
     41    }
     42
     43    for (int i = 0; i < nInputs; i++) {
     44        // place input astrometry transformations in 'input'
     45        pmFPAfile *input = pmFPAfileSelectSingle(config->files, "PSWARP.INPUT", i);
     46        if (!input) {
     47            psError(PSWARP_ERR_CONFIG, false, "Can't find input data!\n");
     48            return false;
     49        }
     50
     51        // input astrometry may be embedded in 'input' or supplied separately
     52        pmFPAfile *astrom = pmFPAfileSelectSingle(config->files, "PSWARP.ASTROM", i);
     53        if (!astrom) {
     54            astrom = input;
     55        }
     56        if (!pswarpLoadAstrometry (input, astrom, config)) {
     57            psError(PSWARP_ERR_CONFIG, false, "problem loading input astrometry\n");
     58            return false;
     59        }
     60
     61        // given the input data, determine which output elements should be generated
     62        // and generate the appropriate images
     63
     64        // find the R,D center for the skycell, use for common projection
     65        psProjection *frame = pswarpLocalFrame (skycell->fpa);
     66
     67        // generate Lmin,max, Mmin,max for both datasets
     68        pswarpBounds *srcBounds = pswarpMakeBounds (input->fpa, frame);
     69        pswarpBounds *tgtBounds = pswarpMakeBounds (skycell->fpa, frame);
     70
     71        // find the output (tgt) chips which overlap the input (src) chips
     72        pswarpFindOverlap (input->fpa, output->fpa, srcBounds, tgtBounds);
     73        psFree (srcBounds);
     74        psFree (tgtBounds);
     75    }
    6076
    6177    // The loop below generates the output pixels. XXX Should this be deferred until we
     
    86102                return false;
    87103            }
    88             int numCols = psMetadataLookupS32(NULL, hdu->header, "NAXIS1"); ///< Number of columns
    89             int numRows = psMetadataLookupS32(NULL, hdu->header, "NAXIS2"); ///< Number of rows
     104            int numCols = psMetadataLookupS32(&status, hdu->header, "NAXIS1"); ///< Number of columns
     105            int numRows = psMetadataLookupS32(&status, hdu->header, "NAXIS2"); ///< Number of rows
    90106            if ((numCols == 0) || (numRows == 0)) {
    91107                psError(PSWARP_ERR_DATA, false, "skycell has invalid dimensions %d x %d", numCols, numRows);
     
    97113            pmReadout *readout = pmReadoutAlloc(cell); ///< output readout
    98114            readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
     115
    99116            psImageInit(readout->image, NAN);
    100117            psFree(readout);                // Drop reference
     
    129146# include "pswarpFileNames.h"
    130147
     148static int Nout = 0;
     149
    131150// XX function for tests
    132151bool pswarpDumpOutput (pmConfig *config) {
     
    144163    pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT");
    145164
     165    pmFPAview *view = pmFPAviewAlloc(0);
     166
    146167    pmChip *chip;
    147     pmFPAview *view = pmFPAviewAlloc(0);
    148     if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    149         psError(psErrorCodeLast(), false, "Unable to read files.");
    150         goto DONE;
    151     }
    152168    while ((chip = pmFPAviewNextChip (view, output->fpa, 1)) != NULL) {
    153169        psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    154170        if (!chip->process || !chip->file_exists) { continue; }
    155         if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    156             psError(psErrorCodeLast(), false, "Unable to read files.");
    157             goto DONE;
    158         }
     171
    159172        pmCell *cell;
    160173        while ((cell = pmFPAviewNextCell (view, output->fpa, 1)) != NULL) {
    161174            psTrace ("pswarp", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    162175            if (!cell->process || !cell->file_exists) { continue; }
    163             if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE) ||
    164                 !pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
    165                 psError(psErrorCodeLast(), false, "Unable to read files.");
    166                 goto DONE;
     176
     177            // process each of the readouts
     178            pmReadout *readout;
     179            while ((readout = pmFPAviewNextReadout(view, output->fpa, 1)) != NULL) {
     180                if (!readout->data_exists) {
     181                    continue;
     182                }
     183
     184                char name[64];
     185                snprintf (name, 64, "dumpwarp.%02d.fits", Nout);
     186                Nout ++;
     187               
     188                psphotSaveImage (NULL, readout->image, name);
    167189            }
    168190        }
Note: See TracChangeset for help on using the changeset viewer.