IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23293


Ignore:
Timestamp:
Mar 12, 2009, 10:42:30 AM (17 years ago)
Author:
Paul Price
Message:

Get input files from the configuration dump, if supplied.

Location:
trunk/pswarp/src
Files:
3 edited

Legend:

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

    r23242 r23293  
    8787
    8888
    89     if (!pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list")) {
    90         psError(PSWARP_ERR_ARGUMENTS, true, "Missing -file (input) or -list (input)");
    91         return NULL;
    92     }
    93 
    94     // the mask and variance entries are optional (build from gain?)
    95     pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK",   "-mask",   "-masklist");
     89    pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list");
     90    pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK", "-mask", "-masklist");
    9691    pmConfigFileSetsMD (config->arguments, &argc, argv, "VARIANCE", "-variance", "-variancelist");
    9792
     
    105100
    106101    // output position is fixed
    107     psMetadataAddStr (config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "", argv[1]);
     102    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "", argv[1]);
    108103
    109104    // skycell position is fixed
    110105    array = psArrayAlloc(1);
    111     array->data[0] = psStringCopy (argv[2]);
    112     status = psMetadataAddPtr (config->arguments, PS_LIST_TAIL, "SKYCELL", PS_DATA_ARRAY, "", array);
    113     psFree (array);
     106    array->data[0] = psStringCopy(argv[2]);
     107    status = psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "SKYCELL", PS_DATA_ARRAY, "", array);
     108    psFree(array);
    114109
    115110    psTrace("pswarp", 1, "Done with pswarpArguments...\n");
    116     return (config);
     111    return config;
    117112}
    118113
  • trunk/pswarp/src/pswarpLoop.c

    r23170 r23293  
    8383    }
    8484
     85    if (!pswarpSetMaskBits(config)) {
     86        psError(PS_ERR_IO, false, "failed to set mask bits");
     87        return NULL;
     88    }
     89
    8590    // output mask bits
    8691    psImageMaskType maskValue = psMetadataLookupImageMask(&status, recipe, "MASK.OUTPUT");
  • trunk/pswarp/src/pswarpParseCamera.c

    r21368 r23293  
    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");
     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");
     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.