Changeset 17672 for branches/eam_branch_20080511/ppSim/src/ppSimUtils.c
- Timestamp:
- May 13, 2008, 4:56:38 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080511/ppSim/src/ppSimUtils.c
r17557 r17672 15 15 float dec0 = psMetadataLookupF32(NULL, recipe, "DEC"); // Boresight Dec (radians) 16 16 float pa = psMetadataLookupF32(NULL, recipe, "PA"); // Position angle (radians) 17 float scale = psMetadataLookupF32(NULL, recipe, " SCALE"); // plate scale in arcsec / pixel17 float scale = psMetadataLookupF32(NULL, recipe, "PIXEL.SCALE"); // plate scale in arcsec / pixel 18 18 scale *= M_PI / 3600.0 / 180.0; // convert plate scale to radians/pixel 19 19 20 int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y20 int binning = psMetadataLookupS32(NULL, recipe, "BINNING"); // Binning in x and y 21 21 22 22 float x0 = 0.0, y0 = 0.0; … … 95 95 } 96 96 97 char *ppSimTypeToString (ppSimType type) { 98 99 char *typeStr; 100 101 switch (type) { 102 case PPSIM_TYPE_BIAS: typeStr = psStringCopy ("BIAS"); break; 103 case PPSIM_TYPE_DARK: typeStr = psStringCopy ("DARK"); break; 104 case PPSIM_TYPE_FLAT: typeStr = psStringCopy ("FLAT"); break; 105 case PPSIM_TYPE_OBJECT: typeStr = psStringCopy ("OBJECT"); break; 106 default: 107 psAbort("Should never get here."); 108 } 109 return (typeStr); 110 } 111 112 ppSimType ppSimTypeFromString (char *typeStr) { 113 114 if (!strcasecmp (typeStr, "BIAS")) return PPSIM_TYPE_BIAS; 115 if (!strcasecmp (typeStr, "DARK")) return PPSIM_TYPE_DARK; 116 if (!strcasecmp (typeStr, "FLAT")) return PPSIM_TYPE_FLAT; 117 if (!strcasecmp (typeStr, "OBJECT")) return PPSIM_TYPE_OBJECT; 118 psAbort("Should never get here."); 119 } 120 97 121 bool ppSimUpdateConceptsFPA (pmFPA *fpa, pmConfig *config) { 98 122 … … 103 127 float expTime = psMetadataLookupF32(NULL, recipe, "EXPTIME"); // Exposure time 104 128 105 const char *filter = psMetadataLookupStr(NULL, config->arguments, "FILTER"); // Filter name129 const char *filter = psMetadataLookupStr(NULL, recipe, "FILTER"); // Filter name 106 130 if (!filter) { 107 131 filter = "NONE"; 108 132 } 109 133 110 ppSimType type = psMetadataLookupS32(NULL, config->arguments, "TYPE"); // Type of image to simulate 111 112 // Update FPA concepts 113 const char *typeStr; // Exposure type String 114 switch (type) { 115 case PPSIM_TYPE_BIAS: typeStr = "BIAS"; break; 116 case PPSIM_TYPE_DARK: typeStr = "DARK"; break; 117 case PPSIM_TYPE_FLAT: typeStr = "FLAT"; break; 118 case PPSIM_TYPE_OBJECT: typeStr = "OBJECT"; break; 119 default: 120 psAbort("Should never get here."); 121 } 122 123 psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.OBSTYPE", PS_META_REPLACE, 124 "Observation type", typeStr); 125 psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.OBJECT", PS_META_REPLACE, 126 "Observation name", typeStr); 127 psMetadataAddF32(fpa->concepts, PS_LIST_TAIL, "FPA.EXPTIME", PS_META_REPLACE, 128 "Exposure time (sec)", expTime); 134 char *typeStr = psMetadataLookupStr(NULL, recipe, "IMAGE.TYPE"); // Type of image to simulate 135 136 psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.OBSTYPE", PS_META_REPLACE, "Observation type", typeStr); 137 psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.OBJECT", PS_META_REPLACE, "Observation name", typeStr); 138 psMetadataAddF32(fpa->concepts, PS_LIST_TAIL, "FPA.EXPOSURE", PS_META_REPLACE, "Exposure time (sec)", expTime); 129 139 psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.FILTERID", PS_META_REPLACE, "Filter name", filter); 130 140 psMetadataAddStr(fpa->concepts, PS_LIST_TAIL, "FPA.FILTER", PS_META_REPLACE, "Filter name", filter); … … 139 149 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSIM_RECIPE); // Recipe 140 150 141 int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y151 int binning = psMetadataLookupS32(NULL, recipe, "BINNING"); // Binning in x and y 142 152 float expTime = psMetadataLookupF32(NULL, recipe, "EXPTIME"); // Exposure time 143 153 … … 153 163 return true; 154 164 } 165 166 bool ppSimRecipeValidation (pmConfig *config) { 167 168 bool status; 169 170 psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, PPSIM_RECIPE); // Recipe 171 172 int binning = psMetadataLookupS32(&status, recipe, "BINNING"); // Binning in x and y 173 if (binning <= 0) { 174 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Binning (%d) is non-positive.", binning); 175 exit(PS_EXIT_CONFIG_ERROR); 176 } 177 return true; 178 } 179 180 // Get a value from the command-line arguments and add it to recipe options 181 float ppSimArgToRecipeF32(bool *status, 182 psMetadata *options, // Target to which to add value 183 const char *recipeName, // Name for value in the recipe 184 psMetadata *arguments, // Command-line arguments 185 const char *argName // Argument name in the command-line arguments 186 ) 187 { 188 bool myStatus; 189 float value = psMetadataLookupF32(&myStatus, arguments, argName); // Value of interest 190 if (status) { *status = myStatus; } 191 if (isnan(value)) return value; 192 193 psMetadataAddF32(options, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, value); 194 return value; 195 } 196 197 // Get a value from the command-line arguments and add it to recipe options 198 int ppSimArgToRecipeS32(bool *status, 199 psMetadata *options, // Target to which to add value 200 const char *recipeName, // Name for value in the recipe 201 psMetadata *arguments, // Command-line arguments 202 const char *argName // Argument name in the command-line arguments 203 ) 204 { 205 bool myStatus; 206 int value = psMetadataLookupS32(&myStatus, arguments, argName); // Value of interest 207 if (status) { *status = myStatus; } 208 209 psMetadataAddS32(options, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, value); 210 return value; 211 } 212 213 // Get a value from the command-line arguments and add it to recipe options 214 char *ppSimArgToRecipeStr(bool *status, 215 psMetadata *options, // Target to which to add value 216 const char *recipeName, // Name for value in the recipe 217 psMetadata *arguments, // Command-line arguments 218 const char *argName // Argument name in the command-line arguments 219 ) 220 { 221 bool myStatus; 222 223 char *value = psMetadataLookupStr(&myStatus, arguments, argName); // Value of interest 224 if (status) { 225 *status = myStatus; 226 } 227 psMetadataAddStr(options, PS_LIST_TAIL, recipeName, PS_META_REPLACE, NULL, value); 228 return value; 229 } 230 231 float ppSimGetZeroPoint (psMetadata *recipe, char *filter) { 232 233 bool mdok; 234 float zp; 235 236 // use the filter to get the zeropoint from the recipe 237 psMetadataItem *zpItem = psMetadataLookup (recipe, "ZEROPTS"); 238 // check that item is multi... 239 240 psArray *entries = psListToArray (zpItem->data.list); 241 242 // search for matching filter 243 for (int i = 0; i < entries->n; i++) { 244 psMetadataItem *item = entries->data[i]; 245 psMetadata *entry = item->data.V; 246 247 char *filterName = psMetadataLookupStr (&mdok, entry, "FILTER"); 248 assert (filterName); 249 250 if (strcmp(filterName, filter)) continue; 251 252 zp = psMetadataLookupF32 (&mdok, entry, "ZERO_PT"); 253 assert (mdok); 254 psFree (entries); 255 return zp; 256 } 257 psFree (entries); 258 return NAN; 259 }
Note:
See TracChangeset
for help on using the changeset viewer.
