Changeset 17557 for trunk/ppSim/src/ppSimArguments.c
- Timestamp:
- May 7, 2008, 10:55:21 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ppSim/src/ppSimArguments.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/ppSimArguments.c
r16494 r17557 18 18 } 19 19 20 // Get a value from the command-line arguments or the recipe, and add it to the target 21 bool valueArgRecipe(pmConfig *config, // Configuration 22 psMetadata *arguments, // Command-line arguments 23 const char *argName, // Argument name in the command-line arguments 24 const psMetadata *recipe, // Recipe 20 // Get a value from the command-line arguments and add it to recipe options 21 bool valueArgRecipe(psMetadata *options, // Target to which to add value 25 22 const char *recipeName, // Name for value in the recipe 26 psMetadata *target // Target to which to add value 23 psMetadata *arguments, // Command-line arguments 24 const char *argName // Argument name in the command-line arguments 27 25 ) 28 26 { 29 float value = psMetadataLookupF32(NULL, arguments, argName); // Value of interest 30 if (isnan(value)) { 31 bool mdok; // Status of MD lookup 32 value = psMetadataLookupF32(&mdok, recipe, recipeName); 33 if (!mdok) { 34 psErrorStackPrint(stderr, "Unable to find %s in recipe %s", recipeName, PPSIM_RECIPE); 35 psFree((psPtr)arguments); 36 psFree(config); 37 exit(PS_EXIT_CONFIG_ERROR); 38 } 39 } 40 return psMetadataAddF32(target, PS_LIST_TAIL, recipeName, 0, NULL, value); 27 bool status; // Status of MD lookup 28 float value = psMetadataLookupF32(&status, arguments, argName); // Value of interest 29 if (isnan(value)) return true; 30 status = psMetadataAddF32(options, PS_LIST_TAIL, recipeName, 0, NULL, value); 31 return status; 41 32 } 42 33 34 // this function supplements the RECIPE:OPTIONS folder with command-line options 43 35 void ppSimArguments(int argc, char *argv[], pmConfig *config) 44 36 { 37 bool mdok; // Status of MD lookup 38 45 39 assert(config); 46 40 41 // save the following command-line options in the arguments structure 47 42 psMetadata *arguments = psMetadataAlloc(); // Command-line arguments 48 43 psMetadataAddStr(arguments, PS_LIST_TAIL, "-format", 0, "Camera format name", NULL); … … 68 63 psMetadataAddF32(arguments, PS_LIST_TAIL, "-starsdensity", 0, "Density of fake stars at magnitude", NAN); 69 64 psMetadataAddStr(arguments, PS_LIST_TAIL, "-psfclass", 0, "Type of PSF model", NULL); 65 psMetadataAddStr(arguments, PS_LIST_TAIL, "-galmodel", 0, "Type of Galaxy model", NULL); 70 66 psMetadataAddS32(arguments, PS_LIST_TAIL, "-bin", 0, "Binning in x and y", 1); 71 67 … … 92 88 } 93 89 90 // apply an alternate camera format 94 91 psString formatName = psMetadataLookupStr(NULL, arguments, "-format"); // Name of format 95 92 if (formatName) { … … 114 111 } 115 112 113 // specify the type of simulated image to produce 114 // XXX this should not be required if we supplied INPUT 116 115 const char *typeStr = psMetadataLookupStr(NULL, arguments, "-type"); // Exposure type 117 116 if (!typeStr) { … … 138 137 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "FILTER", 0, "Filter name", filter); 139 138 139 // save the following additional recipe values based on command-line options 140 // these options override the PPSIM recipe values loaded from recipe files 141 psMetadata *options = pmConfigRecipeOptions (config, PPSIM_RECIPE); 142 if (!options) { 143 psErrorStackPrint(stderr, "Unable to find recipe options for %s", PPSIM_RECIPE); 144 psFree(arguments); 145 psFree(config); 146 exit(PS_EXIT_CONFIG_ERROR); 147 } 148 140 149 float expTime; 141 150 if (type == PPSIM_TYPE_BIAS) { … … 148 157 } 149 158 } 150 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "EXPTIME", 0, "Exposure time (s)", expTime); 151 152 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSIM_RECIPE); // Recipe for ppSim 153 if (!recipe) { 154 psErrorStackPrint(stderr, "Unable to find recipe %s", PPSIM_RECIPE); 155 psFree(arguments); 156 psFree(config); 157 exit(PS_EXIT_CONFIG_ERROR); 158 } 159 160 valueArgRecipe(config, arguments, "-biaslevel", recipe, "BIAS.LEVEL", config->arguments); 161 valueArgRecipe(config, arguments, "-biasrange", recipe, "BIAS.RANGE", config->arguments); 162 valueArgRecipe(config, arguments, "-darkrate", recipe, "DARK.RATE", config->arguments); 163 valueArgRecipe(config, arguments, "-flatsigma", recipe, "FLAT.SIGMA", config->arguments); 164 valueArgRecipe(config, arguments, "-flatrate", recipe, "FLAT.RATE", config->arguments); 165 valueArgRecipe(config, arguments, "-shuttertime", recipe, "SHUTTER.TIME", config->arguments); 166 valueArgRecipe(config, arguments, "-skyrate", recipe, "SKY.RATE", config->arguments); 167 valueArgRecipe(config, arguments, "-starslum", recipe, "STARS.LUM", config->arguments); 168 valueArgRecipe(config, arguments, "-starsmag", recipe, "STARS.MAG", config->arguments); 169 valueArgRecipe(config, arguments, "-starsdensity", recipe, "STARS.DENSITY", config->arguments); 170 171 bool mdok; // Status of MD lookup 159 psMetadataAddF32(options, PS_LIST_TAIL, "EXPTIME", 0, "Exposure time (s)", expTime); 160 161 // these values all get moved from arguments to RECIPE:OPTIONS 162 valueArgRecipe(options, "BIAS.LEVEL", arguments, "-biaslevel"); 163 valueArgRecipe(options, "BIAS.RANGE", arguments, "-biasrange"); 164 valueArgRecipe(options, "DARK.RATE", arguments, "-darkrate"); 165 valueArgRecipe(options, "FLAT.SIGMA", arguments, "-flatsigma"); 166 valueArgRecipe(options, "FLAT.RATE", arguments, "-flatrate"); 167 valueArgRecipe(options, "SHUTTER.TIME", arguments, "-shuttertime"); 168 valueArgRecipe(options, "SKY.RATE", arguments, "-skyrate"); 169 valueArgRecipe(options, "STARS.LUM", arguments, "-starslum"); 170 valueArgRecipe(options, "STARS.MAG", arguments, "-starsmag"); 171 valueArgRecipe(options, "STARS.DENSITY", arguments, "-starsdensity"); 172 173 psMetadata *recipe = psMetadataLookupMetadata(&mdok, config->recipes, PPSIM_RECIPE); // Recipe 174 172 175 int biasOrder = psMetadataLookupS32(&mdok, recipe, "BIAS.ORDER"); // Overscan polynomial order 173 176 if (!mdok) { 174 177 psWarning("BIAS.ORDER(S32) is not set in the recipe %s --- assuming %d", PPSIM_RECIPE, biasOrder); 175 178 } 176 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "BIAS.ORDER", 0, 177 "Overscan polynomial order", biasOrder); 179 psMetadataAddS32(options, PS_LIST_TAIL, "BIAS.ORDER", 0, "Overscan polynomial order", biasOrder); 178 180 179 181 int binning = psMetadataLookupS32(NULL, arguments, "-bin"); // Binning in x and y … … 190 192 float ra0 = psMetadataLookupF32(NULL, arguments, "-ra"); // Right Ascension of boresight 191 193 float dec0 = psMetadataLookupF32(NULL, arguments, "-dec"); // Declination of boresight 192 float pa = psMetadataLookupF32(NULL, arguments, "-pa"); // Position angle193 float seeing = psMetadataLookupF32(NULL, arguments, "-seeing"); // Zero point194 float pa = psMetadataLookupF32(NULL, arguments, "-pa"); // Position angle 195 float seeing = psMetadataLookupF32(NULL, arguments, "-seeing"); // seeing (FWHM in arcsec) 194 196 195 197 // XXX scale and zp should be supplied by the config file (allow override, but this is camera-dependent) … … 199 201 } 200 202 201 float zp = psMetadataLookupF32(NULL, arguments, "-zp"); // Zero point203 float zp = psMetadataLookupF32(NULL, arguments, "-zp"); // Zero point 202 204 if (isnan(zp)) { 203 205 // use the filter to get the zeropoint from the recipe … … 234 236 } 235 237 236 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "RA", 0, "Boresight RA (radians)", ra0 * M_PI / 180.0); 237 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "DEC", 0, "Boresight Declination (radians)", dec0 * M_PI / 180.0); 238 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "PA", 0, "Boresight position angle (radians)",pa * M_PI / 180.0); 239 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "SEEING", 0, "Seeing sigma (pix)", seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale); 240 241 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "SCALE", 0, "Plate scale (arcsec/pix)", scale); 242 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "ZEROPOINT", 0, "Photometric zeropoint", zp); 243 psMetadataAddF32(config->arguments, PS_LIST_TAIL, "SKY.MAGS", 0, "sky surface brightness", skymags); 244 245 const char *psfClass = psMetadataLookupStr(NULL, arguments, "-psfclass"); // Filter name 238 psMetadataAddF32(options, PS_LIST_TAIL, "RA", 0, "Boresight RA (radians)", ra0 * M_PI / 180.0); 239 psMetadataAddF32(options, PS_LIST_TAIL, "DEC", 0, "Boresight Declination (radians)", dec0 * M_PI / 180.0); 240 psMetadataAddF32(options, PS_LIST_TAIL, "PA", 0, "Boresight position angle (radians)",pa * M_PI / 180.0); 241 242 // the user supplies FWHM in arcsec; here we convert to Sigma in pixels 243 psMetadataAddF32(options, PS_LIST_TAIL, "SEEING", 0, "Seeing SIGMA (pixels)", seeing / 2.0 / sqrt(2.0 * log(2.0)) / scale); 244 245 psMetadataAddF32(options, PS_LIST_TAIL, "SCALE", 0, "Plate scale (arcsec/pix)", scale); 246 psMetadataAddF32(options, PS_LIST_TAIL, "ZEROPOINT", 0, "Photometric zeropoint", zp); 247 psMetadataAddF32(options, PS_LIST_TAIL, "SKY.MAGS", 0, "sky surface brightness", skymags); 248 249 const char *psfClass = psMetadataLookupStr(NULL, arguments, "-psfclass"); // PSF model class 246 250 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "PSF.MODEL", 0, "PSF model class", psfClass); 251 252 const char *galModel = psMetadataLookupStr(NULL, arguments, "-galmodel"); // Galaxy model name 253 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "GALAXY.MODEL", 0, "Galaxy model", galModel); 247 254 } 248 255 … … 250 257 return; 251 258 } 259 260 /* the following elements come from the config->arguments: 261 262 PSPHOT.PSF 263 INPUT 264 TYPE 265 FILTER 266 BIAS.ORDER 267 BINNING 268 OUTPUT 269 PSF.MODEL 270 GALAXY.MODEL 271 272 all othr values should come from the recipe 273 */
Note:
See TracChangeset
for help on using the changeset viewer.
