IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 6, 2009, 6:52:51 PM (17 years ago)
Author:
Paul Price
Message:

Making ppSub inverse mode work. Seems to work now --- produces the correct output files for inverse mode on and off, photometry on and off.

Location:
branches/pap/ppSub/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap/ppSub/src

    • Property svn:ignore
      •  

        old new  
        1010stamp-h1
        1111ppSubKernel
         12ppSubErrorCodes.h
         13ppSubErrorCodes.c
  • branches/pap/ppSub/src/ppSubArguments.c

    r23704 r23719  
    3939    psLibFinalize();
    4040    exit(PS_EXIT_CONFIG_ERROR);
    41 }
    42 
    43 // Get a float-point value from the command-line or recipe, and add it to the arguments
    44 #define VALUE_ARG_RECIPE_FLOAT(ARGNAME, RECIPENAME, TYPE) { \
    45     ps##TYPE value = psMetadataLookup##TYPE(NULL, config->arguments, ARGNAME); \
    46     if (isnan(value)) { \
    47         bool mdok; \
    48         value = psMetadataLookup##TYPE(&mdok, recipe, RECIPENAME); \
    49         if (!mdok) { \
    50             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \
    51                 RECIPENAME, PPSUB_RECIPE); \
    52             goto ERROR; \
    53         } \
    54     } \
    55     psMetadataAdd##TYPE(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \
    56 }
    57 
    58 // Get an integer value from the command-line or recipe, and add it to the arguments
    59 #define VALUE_ARG_RECIPE_INT(ARGNAME, RECIPENAME, TYPE, UNSET) { \
    60     ps##TYPE value = psMetadataLookup##TYPE(NULL, config->arguments, ARGNAME); \
    61     if (value == UNSET) { \
    62         bool mdok; \
    63         value = psMetadataLookup##TYPE(&mdok, recipe, RECIPENAME); \
    64         if (!mdok) { \
    65             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s", \
    66                 RECIPENAME, PPSUB_RECIPE); \
    67             goto ERROR; \
    68         } \
    69     } \
    70     psMetadataAdd##TYPE(recipe, PS_LIST_TAIL, RECIPENAME, PS_META_REPLACE, NULL, value); \
    71 }
    72 
    73 /**
    74  * Get a string value from the command-line and add it to the target
    75  */
    76 static bool valueArgStr(psMetadata *arguments, // Command-line arguments
    77                         const char *argName, // Argument name in the command-line arguments
    78                         const char *mdName, // Name for value in the metadata
    79                         psMetadata *target // Target metadata to which to add value
    80                         )
    81 {
    82     psString value = psMetadataLookupStr(NULL, arguments, argName); // Value of interest
    83     if (value && strlen(value) > 0) {
    84         return psMetadataAddStr(target, PS_LIST_TAIL, mdName, PS_META_REPLACE, NULL, value);
    85     }
    86     return false;
    87 }
    88 
    89 /**
    90  * Get a string value from the command-line or recipe and add it to the target
    91  */
    92 static bool valueArgRecipeStr(psMetadata *arguments, // Command-line arguments
    93                               psMetadata *recipe, // Recipe
    94                               const char *argName, // Argument name in the command-line arguments
    95                               const char *mdName, // Name for value in the metadata and recipe
    96                               psMetadata *target // Target metadata to which to add value
    97                               )
    98 {
    99     bool mdok;                          // Status of MD lookup
    100     psString value = psMetadataLookupStr(&mdok, arguments, argName); // Value of interest
    101     if (!value) {
    102         value = psMetadataLookupStr(&mdok, recipe, mdName);
    103         if (!value) {
    104             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find %s in recipe %s",
    105                     mdName, PPSUB_RECIPE);
    106             return false;
    107         }
    108     }
    109     return psMetadataAddStr(target, PS_LIST_TAIL, mdName, PS_META_REPLACE, NULL, value);
    110 }
    111 
    112 /**
    113  * Get a vector from the command-line or recipe, and add it to the target
    114  */
    115 static bool vectorArgRecipe(psMetadata *arguments, // Command-line arguments
    116                             const char *argName, // Argument name in the command-line arguments
    117                             const psMetadata *recipe, // Recipe
    118                             const char *recipeName, // Name for value in the recipe
    119                             psMetadata *target, // Target to which to add value
    120                             psElemType type // Type for vector
    121     )
    122 {
    123     psVector *vector;                   // Vector
    124     psString string = psMetadataLookupStr(NULL, arguments, argName); // String from arguments
    125     if (string) {
    126         psArray *array = psStringSplitArray(string, ", ", false); // Array of strings
    127         vector = psVectorAlloc(array->n, type);
    128         for (int i = 0; i < array->n; i++) {
    129             const char *subString = array->data[i]; // String with a value
    130             char *end;                  // Ptr to end of string parsed
    131 
    132             switch (type) {
    133               case PS_TYPE_F32:
    134                 vector->data.F32[i] = strtof(subString, &end);
    135                 break;
    136               case PS_TYPE_S32: {
    137                   long value = strtol(subString, &end, 10);
    138                   if (value > PS_MAX_S32 || value < PS_MIN_S32) {
    139                       psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    140                               "%s list includes value beyond S32 representation: %s",
    141                               argName, string);
    142                       psFree(vector);
    143                       return false;
    144                   }
    145                   vector->data.S32[i] = value;
    146                   break;
    147               }
    148               default:
    149                 psAbort("Unsupported type: %x\n", type);
    150             }
    151             if (end == subString) {
    152                 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to decipher %s list: %s",
    153                         argName, string);
    154                 psFree(vector);
    155                 return false;
    156             }
    157         }
    158         psFree(array);
    159     } else {
    160         vector = psMetadataLookupPtr(NULL, recipe, recipeName);
    161         if (!psMemCheckVector(vector) || vector->type.type != type) {
    162             psError(PS_ERR_BAD_PARAMETER_TYPE, false, "%s in recipe %s is not a vector of type F32.",
    163                     recipeName, PPSUB_RECIPE);
    164             return false;
    165         }
    166         psMemIncrRefCounter(vector);
    167     }
    168 
    169     psMetadataAddVector(target, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, vector);
    170     psFree(vector);                     // Drop reference
    171 
    172     return true;
    17341}
    17442
     
    255123    }
    256124
    257     data->stamps = psMetadataLookupStr(NULL, arguments, "-stamps");
     125    data->stamps = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-stamps"));
    258126
    259127    const char *statsName = psMetadataLookupStr(NULL, arguments, "-stats"); // Filename for statistics
     
    281149    }
    282150
    283     return true;
    284 }
    285 
    286 
    287 
    288151    psTrace("ppSub", 1, "Done reading command-line arguments\n");
    289152
Note: See TracChangeset for help on using the changeset viewer.