IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 17, 2009, 12:08:50 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/pswarp/src/pswarpParseCamera.c

    r21368 r23352  
    1111 */
    1212
    13 # include "pswarp.h"
     13#include "pswarp.h"
     14
     15// Define an input file
     16static pmFPAfile *defineInputFile(pmConfig *config,// Configuration
     17                                  pmFPAfile *bind,    // File to which to bind, or NULL
     18                                  char *filerule,     // Name of file rule
     19                                  char *argname,      // Argument name
     20                                  pmFPAfileType fileType // Type of file
     21    )
     22{
     23    bool status;
     24
     25    // look for the file on the RUN metadata
     26    pmFPAfile *file = pmFPAfileDefineFromRun(&status, config, filerule); // File to return
     27    if (!status) {
     28        psError(PSWARP_ERR_CONFIG, false, "Failed to load file definition for %s", filerule);
     29        return NULL;
     30    }
     31    if (!file) {
     32        // look for the file on the argument list
     33        if (bind) {
     34            file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname);
     35        } else {
     36            file = pmFPAfileDefineFromArgs(&status, config, filerule, argname);
     37        }
     38        if (!status) {
     39            psError(PSWARP_ERR_CONFIG, false, "Failed to load file definition for %s", filerule);
     40            return false;
     41        }
     42    }
     43
     44    if (!file) {
     45        return NULL;
     46    }
     47
     48    if (file->type != fileType) {
     49        psError(PSWARP_ERR_CONFIG, true, "%s is not of type %s", filerule, pmFPAfileStringFromType(fileType));
     50        return NULL;
     51    }
     52
     53    return file;
     54}
     55
     56
     57
    1458
    1559bool pswarpParseCamera(pmConfig *config)
    1660{
    17     bool status;
    18     bool mdok;                          ///< Status of MD lookup
    19     pmFPAfile *skycell = NULL;
    20     pmConfig *skyConfig = NULL;
     61    psAssert(config, "Require configuration");
    2162
    22     // the input image(s) are required arguments; they define the camera
    23     status = false;
    24     pmFPAfile *input = pmFPAfileDefineFromArgs(&status, config, "PSWARP.INPUT", "INPUT");
    25     if (!input || !status) {
     63    // The input image(s) is required: it defines the camera
     64    pmFPAfile *input = defineInputFile(config, NULL, "PSWARP.INPUT", "INPUT", PM_FPA_FILE_IMAGE);
     65    if (!input) {
    2666        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.INPUT");
    2767        return false;
    2868    }
    2969
    30     // the input image(s) are required arguments; they define the camera
    31     status = false;
    32     pmFPAfile *astrom = pmFPAfileDefineFromArgs(&status, config, "PSWARP.ASTROM", "ASTROM");
    33     if (!status) {
    34         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    35         return NULL;
    36     }
    37     if (astrom) {
    38         psLogMsg ("pswarp", 3, "using supplied astrometry\n");
    39     } else {
    40         psLogMsg ("pswarp", 3, "using header astrometry\n");
     70    pmFPAfile *astrom = defineInputFile(config, NULL, "PSWARP.ASTROM", "ASTROM", PM_FPA_FILE_CMF);
     71    psLogMsg("pswarp", PS_LOG_INFO, "Astrometry source: %s", astrom ? "supplied" : "header");
     72
     73    pmFPAfile *inMask = defineInputFile(config, input, "PSWARP.MASK", "MASK", PM_FPA_FILE_MASK);
     74    if (!inMask) {
     75        psLogMsg("pswarp", PS_LOG_INFO, "No mask supplied");
    4176    }
    4277
    43     // the mask is not required - but must conform to input camera
    44     pmFPAfile *inMask = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.MASK", "MASK");
    45     if (!status) {
    46         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    47         return NULL;
    48     }
    49     if (!inMask) {
    50         psLogMsg ("pswarp", 3, "no mask supplied\n");
     78    pmFPAfile *inVariance = defineInputFile(config, input, "PSWARP.VARIANCE", "VARIANCE",
     79                                            PM_FPA_FILE_VARIANCE);
     80    if (!inVariance) {
     81        psLogMsg("pswarp", PS_LOG_INFO, "No variance supplied");
    5182    }
    5283
    53     // loading the mask here should have invoked pmConfigMaskReadHeader()
    54     if (!pswarpSetMaskBits (config)) {
    55         psError(PS_ERR_IO, false, "failed to set mask bits");
    56         return NULL;
    57     }
    58 
    59     pmFPAfile *inVariance = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.VARIANCE", "VARIANCE");
    60     if (!status) {
    61         psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
    62         return NULL;
    63     }
    64     if (!inVariance) {
    65         psLogMsg ("pswarp", 3, "no variance supplied\n");
    66     }
    67 
    68     // the input skycell is a required argument: it defines the output image
     84    // The input skycell is a required argument: it defines the output image
    6985    // XXX we may need a different skycell structure here
    70     status = pswarpDefineSkycell(&skycell, &skyConfig, config, "PSWARP.SKYCELL", "SKYCELL");
     86    pmFPAfile *skycell = NULL;
     87    pmConfig *skyConfig = NULL;
     88    bool status = pswarpDefineSkycell(&skycell, &skyConfig, config, "PSWARP.SKYCELL", "SKYCELL");
    7189    if (!status) {
    7290        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.SKYCELL");
     
    8199        return false;
    82100    }
     101    output->save = true;
     102
    83103    pmFPAfile *outMask = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.MASK");
    84104    if (!outMask) {
     
    86106        return false;
    87107    }
    88 
    89     output->save = true;
    90108    outMask->save = true;
    91109
     
    108126    }
    109127
     128    bool mdok;                          // Status of MD lookup
    110129    if (psMetadataLookupBool(&mdok, config->arguments, "PSF")) {
    111130        // This file, PSPHOT.INPUT, is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by
     
    160179            }
    161180        }
    162         psFree (chips);
     181        psFree(chips);
    163182    }
    164183
Note: See TracChangeset for help on using the changeset viewer.