Changeset 18649
- Timestamp:
- Jul 21, 2008, 3:22:57 PM (18 years ago)
- Location:
- trunk/ppSub/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSub.c
r16866 r18649 22 22 } 23 23 24 if (!ppSubArguments(argc, argv, config)) {25 psErrorStackPrint(stderr, "Error reading arguments.\n");26 exitValue = PS_EXIT_CONFIG_ERROR;27 goto die;28 }29 30 24 if (!pmModelClassInit()) { 31 25 psErrorStackPrint(stderr, "Error initialising model classes.\n"); … … 34 28 } 35 29 30 if (!ppSubArgumentsSetup(argc, argv, config)) { 31 psErrorStackPrint(stderr, "Error reading arguments.\n"); 32 exitValue = PS_EXIT_CONFIG_ERROR; 33 goto die; 34 } 35 36 36 if (!ppSubCamera(config)) { 37 37 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"); 38 44 exitValue = PS_EXIT_CONFIG_ERROR; 39 45 goto die; -
trunk/ppSub/src/ppSub.h
r17784 r18649 4 4 #define PPSUB_RECIPE "PPSUB" /// Name of the recipe to use 5 5 6 /// Setup the arguments parsing 7 bool ppSubArgumentsSetup(int argc, char *argv[], ///< Command-line arguments 8 pmConfig *config ///< Configuration 9 ); 10 6 11 /// Parse the arguments 7 bool ppSubArguments(int argc, char *argv[], ///< Command-line arguments 8 pmConfig *config ///< Configuration 12 bool ppSubArgumentsParse(pmConfig *config ///< Configuration 9 13 ); 10 14 -
trunk/ppSub/src/ppSubArguments.c
r18289 r18649 32 32 // Get a float-point value from the command-line or recipe, and add it to the arguments 33 33 #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); \ 35 35 if (isnan(value)) { \ 36 36 bool mdok; \ … … 47 47 // Get an integer value from the command-line or recipe, and add it to the arguments 48 48 #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); \ 50 50 if (value == UNSET) { \ 51 51 bool mdok; \ … … 170 170 } 171 171 172 bool ppSubArguments (int argc, char *argv[], pmConfig *config)172 bool ppSubArgumentsSetup(int argc, char *argv[], pmConfig *config) 173 173 { 174 174 assert(config); … … 176 176 pmConfigFileSetsMD(config->arguments, &argc, argv, "PPSUB.SOURCES", "-sources", NULL); 177 177 178 psMetadata *arguments = psMetadataAlloc(); // Command-line arguments178 psMetadata *arguments = config->arguments; // Command-line arguments 179 179 psMetadataAddStr(arguments, PS_LIST_TAIL, "-inmask", 0, "Input mask image", NULL); 180 180 psMetadataAddStr(arguments, PS_LIST_TAIL, "-inweight", 0, "Input weight image", NULL); … … 222 222 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[3]); 223 223 224 const char *inMask = psMetadataLookupStr(NULL, arguments, "-inmask"); // Name of input mask224 const char *inMask = psMetadataLookupStr(NULL, config->arguments, "-inmask"); // Name of input mask 225 225 if (inMask && strlen(inMask) > 0) { 226 226 fileList("INPUT.MASK", inMask, "Name of the input mask image", config); 227 227 } 228 const char *inWeight = psMetadataLookupStr(NULL, arguments, "-inweight"); // Name of input weight228 const char *inWeight = psMetadataLookupStr(NULL, config->arguments, "-inweight"); // Name of input weight 229 229 if (inWeight && strlen(inWeight) > 0) { 230 230 fileList("INPUT.WEIGHT", inWeight, "Name of the input weight image", config); 231 231 } 232 232 233 const char *refMask = psMetadataLookupStr(NULL, arguments, "-refmask"); // Name of reference mask233 const char *refMask = psMetadataLookupStr(NULL, config->arguments, "-refmask"); // Name of reference mask 234 234 if (refMask && strlen(refMask) > 0) { 235 235 fileList("REF.MASK", refMask, "Name of the reference mask image", config); 236 236 } 237 const char *refWeight = psMetadataLookupStr(NULL, arguments, "-refweight"); // Name of referenceweight237 const char *refWeight = psMetadataLookupStr(NULL, config->arguments, "-refweight"); // Name of ref weight 238 238 if (refWeight && strlen(refWeight) > 0) { 239 239 fileList("REF.WEIGHT", refWeight, "Name of the reference weight image", config); 240 240 } 241 241 242 valueArgStr(arguments, "-stats", "STATS", config->arguments); 243 valueArgStr(arguments, "-stamps", "STAMPS", config->arguments); 242 return true; 243 } 244 245 bool ppSubArgumentsParse(pmConfig *config) 246 { 247 assert(config); 248 249 valueArgStr(config->arguments, "-stats", "STATS", config->arguments); 250 valueArgStr(config->arguments, "-stamps", "STAMPS", config->arguments); 244 251 245 252 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSim … … 263 270 VALUE_ARG_RECIPE_FLOAT("-penalty", "PENALTY", F32); 264 271 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); 270 277 271 278 psVector *widths = psMetadataLookupPtr(NULL, config->arguments, "ISIS.WIDTHS"); // ISIS Gaussian widths … … 276 283 } 277 284 278 if (psMetadataLookupBool(NULL, arguments, "-opt") || psMetadataLookupBool(NULL, recipe, "OPTIMUM")) { 285 if (psMetadataLookupBool(NULL, config->arguments, "-opt") || 286 psMetadataLookupBool(NULL, recipe, "OPTIMUM")) { 279 287 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "OPTIMUM", 0, 280 288 "Derive optimum parameters for ISIS kernels?", true); … … 287 295 288 296 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "REVERSE", 0, "Reverse sense of subtraction", 289 psMetadataLookupBool(NULL, arguments, "-reverse"));297 psMetadataLookupBool(NULL, config->arguments, "-reverse")); 290 298 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")); 292 300 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")) { 296 305 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "RENORM", 0, "Renormalise weights?", true); 297 306 VALUE_ARG_RECIPE_INT("-renorm-width", "RENORM.WIDTH", S32, 0); 298 307 } 299 308 300 if (psMetadataLookupBool(NULL, arguments, "-photometry") ||309 if (psMetadataLookupBool(NULL, config->arguments, "-photometry") || 301 310 psMetadataLookupBool(NULL, recipe, "PHOTOMETRY")) { 302 311 psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PHOTOMETRY", 0, "Perform photometry?", true); … … 304 313 305 314 // Translate the kernel type 306 psString type = psMetadataLookupStr(NULL, arguments, "-type"); // Name of kernel type315 psString type = psMetadataLookupStr(NULL, config->arguments, "-type"); // Name of kernel type 307 316 if (!type || strlen(type) == 0) { 308 317 type = psMetadataLookupStr(NULL, recipe, "KERNEL.TYPE"); … … 320 329 321 330 psTrace("ppSub", 1, "Done reading command-line arguments\n"); 322 psFree(arguments);323 331 return true; 324 332 325 333 ERROR: 326 psFree(arguments);327 334 return false; 328 335 } 329 330
Note:
See TracChangeset
for help on using the changeset viewer.
