IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18649


Ignore:
Timestamp:
Jul 21, 2008, 3:22:57 PM (18 years ago)
Author:
Paul Price
Message:

Can't parse the arguments before setting up the camera --- camera-dependent recipes can't get updated.

Location:
trunk/ppSub/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/ppSub.c

    r16866 r18649  
    2222    }
    2323
    24     if (!ppSubArguments(argc, argv, config)) {
    25         psErrorStackPrint(stderr, "Error reading arguments.\n");
    26         exitValue = PS_EXIT_CONFIG_ERROR;
    27         goto die;
    28     }
    29 
    3024    if (!pmModelClassInit()) {
    3125        psErrorStackPrint(stderr, "Error initialising model classes.\n");
     
    3428    }
    3529
     30    if (!ppSubArgumentsSetup(argc, argv, config)) {
     31        psErrorStackPrint(stderr, "Error reading arguments.\n");
     32        exitValue = PS_EXIT_CONFIG_ERROR;
     33        goto die;
     34    }
     35
    3636    if (!ppSubCamera(config)) {
    3737        psErrorStackPrint(stderr, "Error setting up camera.\n");
     38        exitValue = PS_EXIT_CONFIG_ERROR;
     39        goto die;
     40    }
     41
     42    if (!ppSubArgumentsParse(config)) {
     43        psErrorStackPrint(stderr, "Error reading arguments.\n");
    3844        exitValue = PS_EXIT_CONFIG_ERROR;
    3945        goto die;
  • trunk/ppSub/src/ppSub.h

    r17784 r18649  
    44#define PPSUB_RECIPE "PPSUB"            /// Name of the recipe to use
    55
     6/// Setup the arguments parsing
     7bool ppSubArgumentsSetup(int argc, char *argv[], ///< Command-line arguments
     8                    pmConfig *config    ///< Configuration
     9    );
     10
    611/// Parse the arguments
    7 bool ppSubArguments(int argc, char *argv[], ///< Command-line arguments
    8                     pmConfig *config    ///< Configuration
     12bool ppSubArgumentsParse(pmConfig *config ///< Configuration
    913    );
    1014
  • trunk/ppSub/src/ppSubArguments.c

    r18289 r18649  
    3232// Get a float-point value from the command-line or recipe, and add it to the arguments
    3333#define VALUE_ARG_RECIPE_FLOAT(ARGNAME, RECIPENAME, TYPE) { \
    34     ps##TYPE value = psMetadataLookup##TYPE(NULL, arguments, ARGNAME); \
     34    ps##TYPE value = psMetadataLookup##TYPE(NULL, config->arguments, ARGNAME); \
    3535    if (isnan(value)) { \
    3636        bool mdok; \
     
    4747// Get an integer value from the command-line or recipe, and add it to the arguments
    4848#define VALUE_ARG_RECIPE_INT(ARGNAME, RECIPENAME, TYPE, UNSET) { \
    49     ps##TYPE value = psMetadataLookup##TYPE(NULL, arguments, ARGNAME); \
     49    ps##TYPE value = psMetadataLookup##TYPE(NULL, config->arguments, ARGNAME); \
    5050    if (value == UNSET) { \
    5151        bool mdok; \
     
    170170}
    171171
    172 bool ppSubArguments(int argc, char *argv[], pmConfig *config)
     172bool ppSubArgumentsSetup(int argc, char *argv[], pmConfig *config)
    173173{
    174174    assert(config);
     
    176176    pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL);
    177177
    178     psMetadata *arguments = psMetadataAlloc(); // Command-line arguments
     178    psMetadata *arguments = config->arguments; // Command-line arguments
    179179    psMetadataAddStr(arguments, PS_LIST_TAIL, "-inmask", 0, "Input mask image", NULL);
    180180    psMetadataAddStr(arguments, PS_LIST_TAIL, "-inweight", 0, "Input weight image", NULL);
     
    222222    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[3]);
    223223
    224     const char *inMask = psMetadataLookupStr(NULL, arguments, "-inmask"); // Name of input mask
     224    const char *inMask = psMetadataLookupStr(NULL, config->arguments, "-inmask"); // Name of input mask
    225225    if (inMask && strlen(inMask) > 0) {
    226226        fileList("INPUT.MASK", inMask, "Name of the input mask image", config);
    227227    }
    228     const char *inWeight = psMetadataLookupStr(NULL, arguments, "-inweight"); // Name of input weight
     228    const char *inWeight = psMetadataLookupStr(NULL, config->arguments, "-inweight"); // Name of input weight
    229229    if (inWeight && strlen(inWeight) > 0) {
    230230        fileList("INPUT.WEIGHT", inWeight, "Name of the input weight image", config);
    231231    }
    232232
    233     const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask
     233    const char *refMask = psMetadataLookupStr(NULL, config->arguments, "-refmask"); // Name of reference mask
    234234    if (refMask && strlen(refMask) > 0) {
    235235        fileList("REF.MASK", refMask, "Name of the reference mask image", config);
    236236    }
    237     const char *refWeight = psMetadataLookupStr(NULL, arguments, "-refweight"); // Name of reference weight
     237    const char *refWeight = psMetadataLookupStr(NULL, config->arguments, "-refweight"); // Name of ref weight
    238238    if (refWeight && strlen(refWeight) > 0) {
    239239        fileList("REF.WEIGHT", refWeight, "Name of the reference weight image", config);
    240240    }
    241241
    242     valueArgStr(arguments, "-stats",  "STATS",  config->arguments);
    243     valueArgStr(arguments, "-stamps", "STAMPS", config->arguments);
     242    return true;
     243}
     244
     245bool ppSubArgumentsParse(pmConfig *config)
     246{
     247    assert(config);
     248
     249    valueArgStr(config->arguments, "-stats",  "STATS",  config->arguments);
     250    valueArgStr(config->arguments, "-stamps", "STAMPS", config->arguments);
    244251
    245252    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
     
    263270    VALUE_ARG_RECIPE_FLOAT("-penalty",    "PENALTY",         F32);
    264271
    265     valueArgRecipeStr(arguments, recipe, "-mask-bad",   "MASK.BAD",   config->arguments);
    266     valueArgRecipeStr(arguments, recipe, "-mask-blank", "MASK.BLANK", config->arguments);
    267 
    268     vectorArgRecipe(arguments, "-isis-widths", recipe, "ISIS.WIDTHS", config->arguments, PS_TYPE_F32);
    269     vectorArgRecipe(arguments, "-isis-orders", recipe, "ISIS.ORDERS", config->arguments, PS_TYPE_S32);
     272    valueArgRecipeStr(config->arguments, recipe, "-mask-bad",   "MASK.BAD",   config->arguments);
     273    valueArgRecipeStr(config->arguments, recipe, "-mask-blank", "MASK.BLANK", config->arguments);
     274
     275    vectorArgRecipe(config->arguments, "-isis-widths", recipe, "ISIS.WIDTHS", config->arguments, PS_TYPE_F32);
     276    vectorArgRecipe(config->arguments, "-isis-orders", recipe, "ISIS.ORDERS", config->arguments, PS_TYPE_S32);
    270277
    271278    psVector *widths = psMetadataLookupPtr(NULL, config->arguments, "ISIS.WIDTHS"); // ISIS Gaussian widths
     
    276283    }
    277284
    278     if (psMetadataLookupBool(NULL, arguments, "-opt") || psMetadataLookupBool(NULL, recipe, "OPTIMUM")) {
     285    if (psMetadataLookupBool(NULL, config->arguments, "-opt") ||
     286        psMetadataLookupBool(NULL, recipe, "OPTIMUM")) {
    279287        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "OPTIMUM", 0,
    280288                          "Derive optimum parameters for ISIS kernels?", true);
     
    287295
    288296    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "REVERSE", 0, "Reverse sense of subtraction",
    289                       psMetadataLookupBool(NULL, arguments, "-reverse"));
     297                      psMetadataLookupBool(NULL, config->arguments, "-reverse"));
    290298    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "MASK.GENERATE", 0, "Generate mask if not supplied",
    291                       psMetadataLookupBool(NULL, arguments, "-generate-mask"));
     299                      psMetadataLookupBool(NULL, config->arguments, "-generate-mask"));
    292300    psMetadataAddBool(config->arguments, PS_LIST_TAIL, "DUAL", 0, "Dual convolution?",
    293                       psMetadataLookupBool(NULL, arguments, "-dual"));
    294 
    295     if (psMetadataLookupBool(NULL, arguments, "-renorm") || psMetadataLookupBool(NULL, recipe, "RENORM")) {
     301                      psMetadataLookupBool(NULL, config->arguments, "-dual"));
     302
     303    if (psMetadataLookupBool(NULL, config->arguments, "-renorm") ||
     304        psMetadataLookupBool(NULL, recipe, "RENORM")) {
    296305        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "RENORM", 0, "Renormalise weights?", true);
    297306        VALUE_ARG_RECIPE_INT("-renorm-width", "RENORM.WIDTH", S32, 0);
    298307    }
    299308
    300     if (psMetadataLookupBool(NULL, arguments, "-photometry") ||
     309    if (psMetadataLookupBool(NULL, config->arguments, "-photometry") ||
    301310        psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) {
    302311        psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PHOTOMETRY", 0, "Perform photometry?", true);
     
    304313
    305314    // Translate the kernel type
    306     psString type = psMetadataLookupStr(NULL, arguments, "-type"); // Name of kernel type
     315    psString type = psMetadataLookupStr(NULL, config->arguments, "-type"); // Name of kernel type
    307316    if (!type || strlen(type) == 0) {
    308317        type = psMetadataLookupStr(NULL, recipe, "KERNEL.TYPE");
     
    320329
    321330    psTrace("ppSub", 1, "Done reading command-line arguments\n");
    322     psFree(arguments);
    323331    return true;
    324332
    325333ERROR:
    326     psFree(arguments);
    327334    return false;
    328335}
    329 
    330 
Note: See TracChangeset for help on using the changeset viewer.