IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 3, 2009, 11:58:24 AM (17 years ago)
Author:
Paul Price
Message:

Committing changes in progress. Attempting to make ppSub spit out not just the regular subtracted image and sources, but the inverse with sources in the inverse (for the warp-warp difference). Does not compile yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/ppSub/src/ppSubArguments.c

    r23402 r23704  
    189189}
    190190
    191 bool ppSubArgumentsSetup(int argc, char *argv[], pmConfig *config)
    192 {
    193     //    int argnum;                         // Argument Number
     191bool ppSubArguments(int argc, char *argv[], pmConfig *config, ppSubData *data)
     192{
    194193    assert(config);
    195 
    196     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
    197     if (!recipe) {
    198         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);
    199         return false;
    200     }
    201 
    202194
    203195    psMetadata *arguments = config->arguments; // Command-line arguments
     
    212204    psMetadataAddStr(arguments, PS_LIST_TAIL, "-kernel", 0, "Precalculated kernel to apply", NULL);
    213205    psMetadataAddStr(arguments, PS_LIST_TAIL, "-stats", 0, "Statistics file", NULL);
    214     psMetadataAddF32(arguments, PS_LIST_TAIL, "-region", 0, "Size of iso-kernel region", NAN);
    215     psMetadataAddS32(arguments, PS_LIST_TAIL, "-size", 0, "Kernel half-size (pixels)", 0);
    216     psMetadataAddS32(arguments, PS_LIST_TAIL, "-order", 0, "Spatial polynomial order", -1);
    217     psMetadataAddStr(arguments, PS_LIST_TAIL, "-type", 0,
    218                      "Kernel type (ISIS|POIS|SPAM|FRIES|GUNK|RINGS)", NULL);
    219     psMetadataAddF32(arguments, PS_LIST_TAIL, "-penalty", 0, "Penalty for wideness", NAN);
    220     psMetadataAddStr(arguments, PS_LIST_TAIL, "-isis-widths", 0,
    221                      "ISIS Gaussian FWHMs (comma-separated)", NULL);
    222     psMetadataAddStr(arguments, PS_LIST_TAIL, "-isis-orders", 0,
    223                      "ISIS polynomial orders (comma-separated)", NULL);
    224     psMetadataAddS32(arguments, PS_LIST_TAIL, "-rings-order", 0, "RINGS polynomial order", -1);
    225     psMetadataAddS32(arguments, PS_LIST_TAIL, "-inner", 0, "SPAM and FRIES inner radius", -1);
    226     psMetadataAddS32(arguments, PS_LIST_TAIL, "-spam-binning", 0, "SPAM kernel binning", 0);
    227     psMetadataAddF32(arguments, PS_LIST_TAIL, "-spacing", 0, "Typical stamp spacing (pixels)", NAN);
    228     psMetadataAddS32(arguments, PS_LIST_TAIL, "-footprint", 0, "Stamp footprint half-size (pixels)", -1);
    229     psMetadataAddF32(arguments, PS_LIST_TAIL, "-source-radius", 0, "Source matching radius (pixels)", NAN);
    230     psMetadataAddS32(arguments, PS_LIST_TAIL, "-stride", 0, "Size of convolution patches (pixels)", -1);
    231     psMetadataAddF32(arguments, PS_LIST_TAIL, "-threshold", 0, "Minimum threshold for stamps (ADU)", NAN);
    232     psMetadataAddS32(arguments, PS_LIST_TAIL, "-iter", 0, "Number of rejection iterations", -1);
    233     psMetadataAddF32(arguments, PS_LIST_TAIL, "-rej", 0, "Rejection thresold (sigma)", NAN);
    234     psMetadataAddF32(arguments, PS_LIST_TAIL, "-sys", 0, "Relative systematic error in kernel", NAN);
    235     psMetadataAddImageMask(arguments,  PS_LIST_TAIL, "-mask-bad", 0, "Mask value for bad pixels", 0);
    236     psMetadataAddImageMask(arguments,  PS_LIST_TAIL, "-mask-poor", 0, "Mask value for poor pixels", 0);
    237     psMetadataAddF32(arguments,  PS_LIST_TAIL, "-poor-frac", 0, "Fraction of variance for poor pixels", NAN);
    238     psMetadataAddF32(arguments, PS_LIST_TAIL, "-badfrac", 0, "Maximum fraction of bad pixels to accept", 1.0);
    239     psMetadataAddBool(arguments,  PS_LIST_TAIL, "-reverse", 0, "Reverse sense of subtraction?", false);
    240     psMetadataAddBool(arguments,  PS_LIST_TAIL, "-generate-mask", 0, "Generate mask if not supplied?", false);
    241     psMetadataAddStr(arguments,  PS_LIST_TAIL, "-stamps", 0,
    242                      "Stamps filename; file has x,y on each line", NULL);
    243     psMetadataAddBool(arguments, PS_LIST_TAIL, "-opt", 0,
    244                       "Derive optimum parameters for ISIS kernels?", false);
    245     psMetadataAddF32(arguments, PS_LIST_TAIL, "-opt-min", 0, "Minimum value for optimum kernel search", NAN);
    246     psMetadataAddF32(arguments, PS_LIST_TAIL, "-opt-max", 0, "Minimum value for optimum kernel search", NAN);
    247     psMetadataAddF32(arguments, PS_LIST_TAIL, "-opt-step", 0, "Step value for optimum kernel search", NAN);
    248     psMetadataAddF32(arguments, PS_LIST_TAIL, "-opt-tol", 0, "Tolerance for optimum kernel search", NAN);
    249     psMetadataAddS32(arguments, PS_LIST_TAIL, "-opt-order", 0, "Maximum order for optimum kernel search", -1);
    250     psMetadataAddBool(arguments, PS_LIST_TAIL, "-dual", 0, "Dual convolution", false);
    251     psMetadataAddBool(arguments, PS_LIST_TAIL, "-photometry", 0, "Perform photometry?", false);
     206    psMetadataAddStr(arguments,  PS_LIST_TAIL, "-stamps", 0, "Stamps filename; x,y on each line", NULL);
    252207    psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads", 0);
    253     psMetadataAddS32(arguments, PS_LIST_TAIL, "-bin1", 0, "Binning factor for first level", 0);
    254     psMetadataAddS32(arguments, PS_LIST_TAIL, "-bin2", 0, "Binning factor for second level", 0);
    255208    psMetadataAddStr(arguments, PS_LIST_TAIL, "-dumpconfig", 0, "file to dump configuration to", NULL);
    256209    psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "Show diagnostic plots", NULL);
     
    302255    }
    303256
    304     if (psMetadataLookupBool(NULL, arguments, "-photometry")) {
    305         psMetadataAddBool(recipe, PS_LIST_TAIL, "PHOTOMETRY", PS_META_REPLACE, "Perform photometry?", true);
    306     }
    307 
    308     return true;
    309 }
    310 
    311 bool ppSubArgumentsParse(pmConfig *config)
    312 {
    313     assert(config);
    314 
    315     psMetadata *arguments = config->arguments; // Command-line arguments
    316 
    317     valueArgStr(arguments, "-stats",  "STATS",  arguments);
    318     valueArgStr(arguments, "-stamps", "STAMPS", arguments);
    319 
    320     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim
    321     if (!recipe) {
    322         psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSUB_RECIPE);
    323         goto ERROR;
    324     }
    325 
    326     VALUE_ARG_RECIPE_FLOAT("-region",        "REGION.SIZE",     F32);
    327     VALUE_ARG_RECIPE_INT("-size",            "KERNEL.SIZE",     S32, 0);
    328     VALUE_ARG_RECIPE_INT("-order",           "SPATIAL.ORDER",   S32, -1);
    329     VALUE_ARG_RECIPE_FLOAT("-spacing",       "STAMP.SPACING",   F32);
    330     VALUE_ARG_RECIPE_INT("-rings-order",     "RINGS.ORDER",     S32, -1);
    331     VALUE_ARG_RECIPE_INT("-inner",           "INNER",           S32, -1);
    332     VALUE_ARG_RECIPE_INT("-spam-binning",    "SPAM.BINNING",    S32, 0);
    333     VALUE_ARG_RECIPE_INT("-footprint",       "STAMP.FOOTPRINT", S32, -1);
    334     VALUE_ARG_RECIPE_FLOAT("-source-radius", "SOURCE.RADIUS",   F32);
    335     VALUE_ARG_RECIPE_INT("-stride",          "STRIDE",          S32, -1);
    336     VALUE_ARG_RECIPE_FLOAT("-threshold",     "STAMP.THRESHOLD", F32);
    337     VALUE_ARG_RECIPE_INT("-iter",            "ITER",            S32, -1);
    338     VALUE_ARG_RECIPE_FLOAT("-rej",           "REJ",             F32);
    339     VALUE_ARG_RECIPE_FLOAT("-sys",           "SYS",             F32);
    340     VALUE_ARG_RECIPE_FLOAT("-badfrac",       "BADFRAC",         F32);
    341     VALUE_ARG_RECIPE_FLOAT("-penalty",       "PENALTY",         F32);
    342     VALUE_ARG_RECIPE_FLOAT("-poor-frac",     "POOR.FRACTION",   F32);
    343     VALUE_ARG_RECIPE_INT("-bin1",            "BIN1",            S32, 0);
    344     VALUE_ARG_RECIPE_INT("-bin2",            "BIN2",            S32, 0);
    345 
    346     valueArgRecipeStr(arguments, recipe, "-mask-in",   "MASK.IN",  recipe);
    347     valueArgRecipeStr(arguments, recipe, "-mask-bad",  "MASK.BAD",  recipe);
    348     valueArgRecipeStr(arguments, recipe, "-mask-poor", "MASK.POOR", recipe);
    349 
    350     vectorArgRecipe(arguments, "-isis-widths", recipe, "ISIS.WIDTHS", recipe, PS_TYPE_F32);
    351     vectorArgRecipe(arguments, "-isis-orders", recipe, "ISIS.ORDERS", recipe, PS_TYPE_S32);
    352 
    353     psVector *widths = psMetadataLookupPtr(NULL, recipe, "ISIS.WIDTHS"); // ISIS Gaussian widths
    354     psVector *orders = psMetadataLookupPtr(NULL, recipe, "ISIS.ORDERS"); // ISIS Polynomial orders
    355     if (widths->n != orders->n) {
    356         psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Size of vectors for ISIS widths and orders do not match.");
    357         goto ERROR;
    358     }
    359 
    360     if (psMetadataLookupBool(NULL, arguments, "-opt") || psMetadataLookupBool(NULL, recipe, "OPTIMUM")) {
    361         psMetadataAddBool(recipe, PS_LIST_TAIL, "OPTIMUM", PS_META_REPLACE,
    362                           "Derive optimum parameters for ISIS kernels?", true);
    363         VALUE_ARG_RECIPE_FLOAT("-opt-min", "OPTIMUM.MIN",   F32);
    364         VALUE_ARG_RECIPE_FLOAT("-opt-max", "OPTIMUM.MAX",   F32);
    365         VALUE_ARG_RECIPE_FLOAT("-opt-step","OPTIMUM.STEP",  F32);
    366         VALUE_ARG_RECIPE_FLOAT("-opt-tol", "OPTIMUM.TOL",   F32);
    367         VALUE_ARG_RECIPE_INT("-opt-order", "OPTIMUM.ORDER", S32, -1);
    368     }
    369 
    370     psMetadataAddBool(arguments, PS_LIST_TAIL, "REVERSE", 0, "Reverse sense of subtraction",
    371                       psMetadataLookupBool(NULL, arguments, "-reverse"));
    372     psMetadataAddBool(recipe, PS_LIST_TAIL, "MASK.GENERATE", PS_META_REPLACE, "Generate mask if not supplied",
    373                       psMetadataLookupBool(NULL, arguments, "-generate-mask"));
    374     psMetadataAddBool(recipe, PS_LIST_TAIL, "DUAL", PS_META_REPLACE, "Dual convolution?",
    375                       psMetadataLookupBool(NULL, arguments, "-dual"));
    376 
    377     // Need to update this because it could have been overwritten by the camera's own recipe
    378     if (psMetadataLookupBool(NULL, arguments, "-photometry")) {
    379         psMetadataAddBool(recipe, PS_LIST_TAIL, "PHOTOMETRY", PS_META_REPLACE, "Perform photometry?", true);
     257    data->stamps = psMetadataLookupStr(NULL, arguments, "-stamps");
     258
     259    const char *statsName = psMetadataLookupStr(NULL, arguments, "-stats"); // Filename for statistics
     260    if (statsName && strlen(statsName) > 0) {
     261        psString resolved = pmConfigConvertFilename(statsName, config, true, true); // Resolved filename
     262        data->statsFile = fopen(resolved, "w");
     263        if (!data->statsFile) {
     264            psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);
     265            psFree(resolved);
     266            return false;
     267        }
     268        psFree(resolved);
    380269    }
    381270
     
    384273    }
    385274
    386     // Translate the kernel type
    387     psString type = psMetadataLookupStr(NULL, arguments, "-type"); // Name of kernel type
    388     if (!type || strlen(type) == 0) {
    389         type = psMetadataLookupStr(NULL, recipe, "KERNEL.TYPE");
    390         if (!type || strlen(type) == 0) {
    391             psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Unable to find KERNEL.TYPE specified.");
    392             goto ERROR;
    393         }
    394     }
    395     psMetadataAddStr(recipe, PS_LIST_TAIL, "KERNEL.TYPE", PS_META_REPLACE, "Type of kernel", type);
    396 
    397     psTrace("ppSub", 1, "Done reading command-line arguments\n");
    398 
    399     // XXX move this to ppSubArguments
    400     int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
     275    int threads = psMetadataLookupS32(NULL, arguments, "-threads"); // Number of threads
    401276    if (threads > 0) {
    402277        if (!psThreadPoolInit(threads)) {
     
    407282
    408283    return true;
    409 
    410 ERROR:
    411     return false;
    412 }
     284}
     285
     286
     287
     288    psTrace("ppSub", 1, "Done reading command-line arguments\n");
     289
     290    return true;
     291}
Note: See TracChangeset for help on using the changeset viewer.