IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13109


Ignore:
Timestamp:
May 1, 2007, 12:22:03 PM (19 years ago)
Author:
Paul Price
Message:

Adding error checking on astrometry read.

Location:
trunk/pswarp/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarpDataLoad.c

    r12771 r13109  
    6060    }
    6161    if (bilevelAstrometry) {
    62         pmAstromReadBilevelMosaic (input->fpa, phu->header);
     62        if (!pmAstromReadBilevelMosaic(input->fpa, phu->header)) {
     63            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input FPA.");
     64            psFree(view);
     65            return false;
     66        }
    6367    }
    6468
     
    7478        pmHDU *hdu = pmFPAviewThisHDU (view, astrom->fpa);
    7579        if (bilevelAstrometry) {
    76             pmAstromReadBilevelChip (chip, hdu->header);
     80            if (!pmAstromReadBilevelChip (chip, hdu->header)) {
     81                psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel chip astrometry for input FPA.");
     82                psFree(view);
     83                return false;
     84            }
    7785        } else {
    7886            // we use a default FPA pixel scale of 1.0
    79             pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0);
     87            if (!pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0)) {
     88                psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input FPA.");
     89                psFree(view);
     90                return false;
     91            }
    8092        }
    8193
  • trunk/pswarp/src/pswarpDefine.c

    r12826 r13109  
    6565    }
    6666    if (bilevelAstrometry) {
    67         pmAstromReadBilevelMosaic (skycell->fpa, phu->header);
    68         pmAstromReadBilevelChip (chip, hdu->header);
     67        if (!pmAstromReadBilevelMosaic (skycell->fpa, phu->header)) {
     68            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for skycell.");
     69            psFree(view);
     70            return false;
     71        }
     72        if (!pmAstromReadBilevelChip (chip, hdu->header)) {
     73            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel chip astrometry for skycell.");
     74            psFree(view);
     75            return false;
     76        }
    6977    } else {
    7078        // we use a default FPA pixel scale of 1.0
    71         pmAstromReadWCS (skycell->fpa, chip, hdu->header, 1.0);
     79        if (!pmAstromReadWCS (skycell->fpa, chip, hdu->header, 1.0)) {
     80            psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for skycell.");
     81            psFree(view);
     82            return false;
     83        }
    7284    }
    7385
  • trunk/pswarp/src/pswarpHeadersLoad.c

    r12528 r13109  
    22
    33// XXX this function should load all of the PSWARP.INPUT headers
    4 // it should examine the overlap between each chip in PSWARP.INPUT 
     4// it should examine the overlap between each chip in PSWARP.INPUT
    55// and the output (pswarpMatchRange) and select/de-select the chips
    6 // and/or cell which contribute pixels. 
     6// and/or cell which contribute pixels.
    77
    88// pswarpDataLoad should then load the pixel of the needed chips
     
    1919    pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSWARP.INPUT");
    2020    if (!input) {
    21         psError(PSWARP_ERR_CONFIG, true, "Can't find input data!\n");
    22         return false;
     21        psError(PSWARP_ERR_CONFIG, true, "Can't find input data!\n");
     22        return false;
    2323    }
    2424
     
    2626    pmFPAfile *astrom = psMetadataLookupPtr (NULL, config->files, "PSWARP.ASTROM");
    2727    if (!astrom) {
    28         astrom = input;
     28        astrom = input;
    2929    }
    30  
     30
    3131    // select the output readout
    3232    view = pmFPAviewAlloc (0);
     
    3636    pmReadout  *output = pmFPAfileThisReadout (config->files, view, "PSWARP.OUTPUT");
    3737    if (!output) {
    38         psError(PSWARP_ERR_CONFIG, true, "Can't find output data!\n");
    39         return false;
     38        psError(PSWARP_ERR_CONFIG, true, "Can't find output data!\n");
     39        return false;
    4040    }
    4141    psFree (view);
    4242
    4343    // de-activate PSWARP.SKYCELL and PSWARP.OUTPUT
    44     pmFPAfileActivate (config->files, false, "PSWARP.SKYCELL");
    45     pmFPAfileActivate (config->files, false, "PSWARP.OUTPUT");
     44    pmFPAfileActivate(config->files, false, "PSWARP.SKYCELL");
     45    pmFPAfileActivate(config->files, false, "PSWARP.OUTPUT");
    4646
    4747    view = pmFPAviewAlloc (0);
     
    5252    // find the FPA phu
    5353    bool bilevelAstrometry = false;
    54     pmHDU *phu = pmFPAviewThisPHU (view, astrom->fpa);
     54    pmHDU *phu = pmFPAviewThisPHU(view, astrom->fpa);
    5555    if (phu) {
    56         char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
    57         if (ctype) {
    58             bilevelAstrometry = !strcmp (&ctype[4], "-DIS");
    59         }
     56        char *ctype = psMetadataLookupStr (NULL, phu->header, "CTYPE1");
     57        if (ctype) {
     58            bilevelAstrometry = !strcmp(&ctype[4], "-DIS");
     59        }
    6060    }
    6161    if (bilevelAstrometry) {
    62         pmAstromReadBilevelMosaic (input->fpa, phu->header);
    63     }
     62        if (!pmAstromReadBilevelMosaic(input->fpa, phu->header)) {
     63            psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel mosaic astrometry for input.");
     64            psFree(view);
     65            return false;
     66        }
     67    }
    6468
    6569    // files associated with the science image
     
    6973        psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    7074        if (!chip->process || !chip->file_exists) { continue; }
    71         pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     75        pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    7276
    7377        // read WCS data from the corresponding header
    74         pmHDU *hdu = pmFPAviewThisHDU (view, astrom->fpa);
    75         if (bilevelAstrometry) {
    76             pmAstromReadBilevelChip (chip, hdu->header);
    77         } else {
    78             // we use a default FPA pixel scale of 1.0
    79             pmAstromReadWCS (input->fpa, chip, hdu->header, 1.0);
    80         }
     78        pmHDU *hdu = pmFPAviewThisHDU (view, astrom->fpa);
     79        if (bilevelAstrometry) {
     80            if (!pmAstromReadBilevelChip (chip, hdu->header)) {
     81                psError(PS_ERR_UNKNOWN, false, "Unable to read bilevel chip astrometry for input.");
     82                psFree(view);
     83                return false;
     84            }
     85        } else {
     86            // we use a default FPA pixel scale of 1.0
     87            if (!pmAstromReadWCS(input->fpa, chip, hdu->header, 1.0)) {
     88                psError(PS_ERR_UNKNOWN, false, "Unable to read WCS astrometry for input.");
     89                psFree(view);
     90                return false;
     91            }
     92        }
    8193
    82         while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
     94        while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
    8395            psTrace ("pswarp", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    8496            if (!cell->process || !cell->file_exists) { continue; }
    85             pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     97            pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    8698
    87             // process each of the readouts
    88             while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
    89                 pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
    90                 if (! readout->data_exists) { continue; }
     99            // process each of the readouts
     100            while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
     101                pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
     102                if (! readout->data_exists) { continue; }
    91103
    92                 // XXX Replace with a function to examine the overlap and turn on/off chips
    93                 // based on that result
    94                 // pswarpTransformReadout_Opt (output, readout, config);
     104                // XXX Replace with a function to examine the overlap and turn on/off chips
     105                // based on that result
     106                // pswarpTransformReadout_Opt (output, readout, config);
    95107
    96                 pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
    97             }
    98             pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
    99         }
    100         pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     108                pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     109            }
     110            pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
     111        }
     112        pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
    101113    }
    102114    pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
Note: See TracChangeset for help on using the changeset viewer.