IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 5, 2008, 11:52:02 AM (18 years ago)
Author:
Paul Price
Message:

Adding configuration dumping. Required reorganisation of how recipe values get into the program. Formerly, the command-line and recipe values were parsed and the result was put on config->arguments. Now, we want whatever was altered by the command-line to be reflected in the recipe (which is dumped), so using the recipe as the storage. Not yet tested, but will do so soon.

File:
1 edited

Legend:

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

    r18770 r18920  
    4141        } \
    4242    } \
    43     psMetadataAdd##TYPE(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, value); \
     43    psMetadataAdd##TYPE(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \
    4444}
    4545
     
    5656        } \
    5757    } \
    58     psMetadataAdd##TYPE(config->arguments, PS_LIST_TAIL, RECIPENAME, 0, NULL, value); \
     58    psMetadataAdd##TYPE(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \
    5959}
    6060
     
    6868    psString value = psMetadataLookupStr(NULL, arguments, argName); // Value of interest
    6969    if (value && strlen(value) > 0) {
    70         return psMetadataAddStr(target, PS_LIST_TAIL, mdName, 0, NULL, value);
     70        return psMetadataAddStr(target, PS_LIST_TAIL, mdName, PS_META_REPLACE, NULL, value);
    7171    }
    7272    return false;
     
    9191        }
    9292    }
    93     return psMetadataAddStr(target, PS_LIST_TAIL, mdName, 0, NULL, value);
     93    return psMetadataAddStr(target, PS_LIST_TAIL, mdName, PS_META_REPLACE, NULL, value);
    9494}
    9595
     
    149149    }
    150150
    151     psMetadataAddVector(target, PS_LIST_TAIL, recipeName, 0, NULL, vector);
     151    psMetadataAddVector(target, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, vector);
    152152    psFree(vector);                     // Drop reference
    153153
     
    184184    psMetadataAddS32(arguments, PS_LIST_TAIL, "-size", 0, "Kernel half-size (pixels)", 0);
    185185    psMetadataAddS32(arguments, PS_LIST_TAIL, "-order", 0, "Spatial polynomial order", -1);
    186     psMetadataAddStr(arguments, PS_LIST_TAIL, "-type", 0, "Kernel type (ISIS|POIS|SPAM|FRIES|GUNK|RINGS)", NULL);
     186    psMetadataAddStr(arguments, PS_LIST_TAIL, "-type", 0,
     187                     "Kernel type (ISIS|POIS|SPAM|FRIES|GUNK|RINGS)", NULL);
    187188    psMetadataAddF32(arguments, PS_LIST_TAIL, "-penalty", 0, "Penalty for wideness", NAN);
    188     psMetadataAddStr(arguments, PS_LIST_TAIL, "-isis-widths", 0, "ISIS Gaussian FWHMs (comma-separated)", NULL);
    189     psMetadataAddStr(arguments, PS_LIST_TAIL, "-isis-orders", 0, "ISIS polynomial orders (comma-separated)", NULL);
     189    psMetadataAddStr(arguments, PS_LIST_TAIL, "-isis-widths", 0,
     190                     "ISIS Gaussian FWHMs (comma-separated)", NULL);
     191    psMetadataAddStr(arguments, PS_LIST_TAIL, "-isis-orders", 0,
     192                     "ISIS polynomial orders (comma-separated)", NULL);
    190193    psMetadataAddS32(arguments, PS_LIST_TAIL, "-rings-order", 0, "RINGS polynomial order", -1);
    191194    psMetadataAddS32(arguments, PS_LIST_TAIL, "-inner", 0, "SPAM and FRIES inner radius", -1);
     
    201204    psMetadataAddBool(arguments,  PS_LIST_TAIL, "-reverse", 0, "Reverse sense of subtraction?", false);
    202205    psMetadataAddBool(arguments,  PS_LIST_TAIL, "-generate-mask", 0, "Generate mask if not supplied?", false);
    203     psMetadataAddStr(arguments,  PS_LIST_TAIL, "-stamps", 0, "Stamps filename; file has x,y on each line", NULL);
    204     psMetadataAddBool(arguments, PS_LIST_TAIL, "-opt", 0, "Derive optimum parameters for ISIS kernels?", false);
     206    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-stamps", 0,
     207                     "Stamps filename; file has x,y on each line", NULL);
     208    psMetadataAddBool(arguments, PS_LIST_TAIL, "-opt", 0,
     209                      "Derive optimum parameters for ISIS kernels?", false);
    205210    psMetadataAddF32(arguments, PS_LIST_TAIL, "-opt-min", 0, "Minimum value for optimum kernel search", NAN);
    206211    psMetadataAddF32(arguments, PS_LIST_TAIL, "-opt-max", 0, "Minimum value for optimum kernel search", NAN);
     
    221226    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[3]);
    222227
    223     const char *inMask = psMetadataLookupStr(NULL, config->arguments, "-inmask"); // Name of input mask
     228    const char *inMask = psMetadataLookupStr(NULL, arguments, "-inmask"); // Name of input mask
    224229    if (inMask && strlen(inMask) > 0) {
    225230        fileList("INPUT.MASK", inMask, "Name of the input mask image", config);
    226231    }
    227     const char *inWeight = psMetadataLookupStr(NULL, config->arguments, "-inweight"); // Name of input weight
     232    const char *inWeight = psMetadataLookupStr(NULL, arguments, "-inweight"); // Name of input weight
    228233    if (inWeight && strlen(inWeight) > 0) {
    229234        fileList("INPUT.WEIGHT", inWeight, "Name of the input weight image", config);
    230235    }
    231236
    232     const char *refMask = psMetadataLookupStr(NULL, config->arguments, "-refmask"); // Name of reference mask
     237    const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask
    233238    if (refMask && strlen(refMask) > 0) {
    234239        fileList("REF.MASK", refMask, "Name of the reference mask image", config);
    235240    }
    236     const char *refWeight = psMetadataLookupStr(NULL, config->arguments, "-refweight"); // Name of ref weight
     241    const char *refWeight = psMetadataLookupStr(NULL, arguments, "-refweight"); // Name of ref weight
    237242    if (refWeight && strlen(refWeight) > 0) {
    238243        fileList("REF.WEIGHT", refWeight, "Name of the reference weight image", config);
    239244    }
    240245
    241     if (psMetadataLookupBool(NULL, config->arguments, "-photometry")) {
    242         psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PHOTOMETRY", 0, "Perform photometry?", true);
     246    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
     247    if (!recipe) {
     248        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);
     249        return false;
     250    }
     251
     252    if (psMetadataLookupBool(NULL, arguments, "-photometry")) {
     253        psMetadataAddBool(recipe, PS_LIST_TAIL, "PHOTOMETRY", PS_META_REPLACE, "Perform photometry?", true);
    243254    }
    244255
     
    250261    assert(config);
    251262
    252     valueArgStr(config->arguments, "-stats",  "STATS",  config->arguments);
    253     valueArgStr(config->arguments, "-stamps", "STAMPS", config->arguments);
     263    psMetadata *arguments = config->arguments; // Command-line arguments
     264
     265    valueArgStr(arguments, "-stats",  "STATS",  arguments);
     266    valueArgStr(arguments, "-stamps", "STAMPS", arguments);
    254267
    255268    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
     
    273286    VALUE_ARG_RECIPE_FLOAT("-penalty",    "PENALTY",         F32);
    274287
    275     valueArgRecipeStr(config->arguments, recipe, "-mask-bad",   "MASK.BAD",   config->arguments);
    276     valueArgRecipeStr(config->arguments, recipe, "-mask-blank", "MASK.BLANK", config->arguments);
    277 
    278     vectorArgRecipe(config->arguments, "-isis-widths", recipe, "ISIS.WIDTHS", config->arguments, PS_TYPE_F32);
    279     vectorArgRecipe(config->arguments, "-isis-orders", recipe, "ISIS.ORDERS", config->arguments, PS_TYPE_S32);
    280 
    281     psVector *widths = psMetadataLookupPtr(NULL, config->arguments, "ISIS.WIDTHS"); // ISIS Gaussian widths
    282     psVector *orders = psMetadataLookupPtr(NULL, config->arguments, "ISIS.ORDERS"); // ISIS Polynomial orders
     288    valueArgRecipeStr(arguments, recipe, "-mask-bad",   "MASK.BAD",   recipe);
     289    valueArgRecipeStr(arguments, recipe, "-mask-blank", "MASK.BLANK", recipe);
     290
     291    vectorArgRecipe(arguments, "-isis-widths", recipe, "ISIS.WIDTHS", recipe, PS_TYPE_F32);
     292    vectorArgRecipe(arguments, "-isis-orders", recipe, "ISIS.ORDERS", recipe, PS_TYPE_S32);
     293
     294    psVector *widths = psMetadataLookupPtr(NULL, recipe, "ISIS.WIDTHS"); // ISIS Gaussian widths
     295    psVector *orders = psMetadataLookupPtr(NULL, recipe, "ISIS.ORDERS"); // ISIS Polynomial orders
    283296    if (widths->n != orders->n) {
    284297        psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Size of vectors for ISIS widths and orders do not match.");
     
    286299    }
    287300
    288     if (psMetadataLookupBool(NULL, config->arguments, "-opt") ||
    289         psMetadataLookupBool(NULL, recipe, "OPTIMUM")) {
    290         psMetadataAddBool(config->arguments, PS_LIST_TAIL, "OPTIMUM", 0,
     301    if (psMetadataLookupBool(NULL, arguments, "-opt") || psMetadataLookupBool(NULL, recipe, "OPTIMUM")) {
     302        psMetadataAddBool(recipe, PS_LIST_TAIL, "OPTIMUM", PS_META_REPLACE,
    291303                          "Derive optimum parameters for ISIS kernels?", true);
    292304        VALUE_ARG_RECIPE_FLOAT("-opt-min", "OPTIMUM.MIN",   F32);
     
    297309    }
    298310
    299     psMetadataAddBool(config->arguments, PS_LIST_TAIL, "REVERSE", 0, "Reverse sense of subtraction",
    300                       psMetadataLookupBool(NULL, config->arguments, "-reverse"));
    301     psMetadataAddBool(config->arguments, PS_LIST_TAIL, "MASK.GENERATE", 0, "Generate mask if not supplied",
    302                       psMetadataLookupBool(NULL, config->arguments, "-generate-mask"));
    303     psMetadataAddBool(config->arguments, PS_LIST_TAIL, "DUAL", 0, "Dual convolution?",
    304                       psMetadataLookupBool(NULL, config->arguments, "-dual"));
    305 
    306     if (psMetadataLookupBool(NULL, config->arguments, "-renorm") ||
     311    psMetadataAddBool(arguments, PS_LIST_TAIL, "REVERSE", 0, "Reverse sense of subtraction",
     312                      psMetadataLookupBool(NULL, arguments, "-reverse"));
     313    psMetadataAddBool(recipe, PS_LIST_TAIL, "MASK.GENERATE", PS_META_REPLACE, "Generate mask if not supplied",
     314                      psMetadataLookupBool(NULL, arguments, "-generate-mask"));
     315    psMetadataAddBool(recipe, PS_LIST_TAIL, "DUAL", PS_META_REPLACE, "Dual convolution?",
     316                      psMetadataLookupBool(NULL, arguments, "-dual"));
     317
     318    if (psMetadataLookupBool(NULL, arguments, "-renorm") ||
    307319        psMetadataLookupBool(NULL, recipe, "RENORM")) {
    308         psMetadataAddBool(config->arguments, PS_LIST_TAIL, "RENORM", 0, "Renormalise weights?", true);
     320        psMetadataAddBool(recipe, PS_LIST_TAIL, "RENORM", PS_META_REPLACE, "Renormalise weights?", true);
    309321        VALUE_ARG_RECIPE_INT("-renorm-width", "RENORM.WIDTH", S32, 0);
    310322    }
    311323
    312     if (psMetadataLookupBool(NULL, config->arguments, "-photometry") ||
    313         psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) {
    314         psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PHOTOMETRY", PS_META_REPLACE,
    315                           "Perform photometry?", true);
     324    // Need to update this because it could have been overwritten by the camera's own recipe
     325    if (psMetadataLookupBool(NULL, arguments, "-photometry")) {
     326        psMetadataAddBool(recipe, PS_LIST_TAIL, "PHOTOMETRY", PS_META_REPLACE, "Perform photometry?", true);
    316327    }
    317328
    318329    // Translate the kernel type
    319     psString type = psMetadataLookupStr(NULL, config->arguments, "-type"); // Name of kernel type
     330    psString type = psMetadataLookupStr(NULL, arguments, "-type"); // Name of kernel type
    320331    if (!type || strlen(type) == 0) {
    321332        type = psMetadataLookupStr(NULL, recipe, "KERNEL.TYPE");
     
    325336        }
    326337    }
    327     pmSubtractionKernelsType kernelType = pmSubtractionKernelsTypeFromString(type); // Type of kernel
    328     if (kernelType == PM_SUBTRACTION_KERNEL_NONE) {
    329         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised kernel type: %s", type);
    330         goto ERROR;
    331     }
    332     psMetadataAddS32(config->arguments, PS_LIST_TAIL, "KERNEL.TYPE", 0, "Type of kernel", kernelType);
     338    psMetadataAddStr(recipe, PS_LIST_TAIL, "KERNEL.TYPE", PS_META_REPLACE, "Type of kernel", type);
    333339
    334340    psTrace("ppSub", 1, "Done reading command-line arguments\n");
     341
     342    // Dump configuration, now that's it's settled
     343    {
     344        pmConfigCamerasCull(config);
     345        pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,MASKS");
     346
     347        const char *outroot = psMetadataLookupStr(NULL, arguments, "OUTPUT"); // Output root name
     348        psAssert(outroot, "Should be there, we put it there!");
     349
     350        pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file
     351        pmConfigDump(config, input->fpa, outroot);
     352    }
     353
    335354    return true;
    336355
Note: See TracChangeset for help on using the changeset viewer.