Changeset 16186 for trunk/psModules/src/camera/pmFPAfileDefine.c
- Timestamp:
- Jan 22, 2008, 5:10:51 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfileDefine.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileDefine.c
r15946 r16186 35 35 } 36 36 int value = psMetadataItemParseS32(item); // Value of interst 37 return value; 38 } 39 40 // Parse an option from a metadata, returning the appropriate float value 41 static float parseOptionFloat(const psMetadata *md, // Metadata containing the option 42 const char *name, // Option name 43 const char *source // Description of source, for warning messages 44 ) 45 { 46 psMetadataItem *item = psMetadataLookup(md, name); // Item with the value of interest 47 if (!item) { 48 psWarning("Unable to find value for %s in %s", name, source); 49 return NAN; 50 } 51 int value = psMetadataItemParseF32(item); // Value of interst 52 return value; 53 } 54 55 // Parse an option from a metadata, returning the appropriate double value 56 static double parseOptionDouble(const psMetadata *md, // Metadata containing the option 57 const char *name, // Option name 58 const char *source // Description of source, for warning messages 59 ) 60 { 61 psMetadataItem *item = psMetadataLookup(md, name); // Item with the value of interest 62 if (!item) { 63 psWarning("Unable to find value for %s in %s", name, source); 64 return NAN; 65 } 66 int value = psMetadataItemParseF64(item); // Value of interst 37 67 return value; 38 68 } … … 212 242 psMetadata *fitsTypes = psMetadataLookupMetadata(&status, camera, "FITS"); // The FITS schemes 213 243 if (!fitsTypes) { 214 psWarning("Unable to find FITS in camera configuration --- compression disabled.");215 goto COMPRESSION_DONE;244 psWarning("Unable to find FITS in camera configuration."); 245 goto FITS_OPTIONS_DONE; 216 246 } 217 247 psMetadata *scheme = psMetadataLookupMetadata(NULL, fitsTypes, fitsType); // FITS scheme 218 248 if (!scheme) { 219 psWarning("Unable to find %s in FITS in camera configuration --- compression disabled.", 220 fitsType); 221 goto COMPRESSION_DONE; 222 } 223 const char *typeString = psMetadataLookupStr(NULL, scheme, "COMP"); // Compression type 224 if (!typeString || strlen(typeString) == 0) { 225 psWarning("Can't find COMP in FITS scheme %s --- compression disabled.", fitsType); 226 goto COMPRESSION_DONE; 227 } 228 psFitsCompressionType type = psFitsCompressionTypeFromString(typeString); // Compression type enum 229 230 psString source = NULL; // Source of options 249 psWarning("Unable to find %s in FITS in camera configuration --- will use defaults.", fitsType); 250 goto FITS_OPTIONS_DONE; 251 } 252 253 psString source = NULL; // Source of options 231 254 psStringAppend(&source, "%s in FITS in camera %s", fitsType, cameraName); 232 file->bitpix = parseOptionInt(scheme, "BITPIX", source, 0); // Bits per pixel 255 256 psFitsOptions *options = file->options = psFitsOptionsAlloc(); // FITS I/O options 233 257 234 258 // Custom floating-point 235 const char *floatName = psMetadataLookupStr(NULL, scheme, "FLOAT"); // Name of custom float ing-point259 const char *floatName = psMetadataLookupStr(NULL, scheme, "FLOAT"); // Name of custom float 236 260 if (floatName) { 237 261 psString fullName = NULL; // Full name of custom floating-point 238 262 psStringAppend(&fullName, "FLOAT_%s", floatName); 239 file->floatType = psFitsFloatTypeFromString(fullName);263 options->floatType = psFitsFloatTypeFromString(fullName); 240 264 psFree(fullName); 241 265 } 242 266 243 psVector *tile = psVectorAlloc(3, PS_TYPE_S32); // Tile sizes 244 tile->data.S32[0] = parseOptionInt(scheme, "TILE.X", source, 0); // Tiling in x 245 tile->data.S32[1] = parseOptionInt(scheme, "TILE.Y", source, 1); // Tiling in y 246 tile->data.S32[2] = parseOptionInt(scheme, "TILE.Z", source, 1); // Tiling in z 247 int noise = parseOptionInt(scheme, "NOISE", source, 16); // Noise bits 248 int hscale = parseOptionInt(scheme, "HSCALE", source, 0); // Scaling for HCOMPRESS 249 int hsmooth = parseOptionInt(scheme, "HSMOOTH", source, 0); // Smoothing for HCOMPRESS 267 options->bitpix = parseOptionInt(scheme, "BITPIX", source, 0); // Bits per pixel 268 269 // Scaling options 270 bool mdok; // Status of MD lookup 271 const char *scalingString = psMetadataLookupStr(&mdok, scheme, "SCALING"); // Scaling name 272 if (scalingString) { 273 options->scaling = psFitsScalingFromString(scalingString); // Scaling method 274 275 switch (options->scaling) { 276 case PS_FITS_SCALE_NONE: 277 case PS_FITS_SCALE_RANGE: 278 // No options required 279 break; 280 case PS_FITS_SCALE_STDEV_POSITIVE: 281 case PS_FITS_SCALE_STDEV_NEGATIVE: 282 options->stdevNum = parseOptionFloat(scheme, "STDEV.NUM", source); // Padding to edge 283 if (!isfinite(options->stdevNum)) { 284 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Bad value for STDEV.NUM for %s", source); 285 psFree(source); 286 psFree(file); 287 return NULL; 288 } 289 // Flow through 290 case PS_FITS_SCALE_STDEV_BOTH: 291 options->stdevBits = parseOptionInt(scheme, "STDEV.BITS", source, 0); // Bits for stdev 292 if (options->stdevBits <= 0) { 293 psError(PS_ERR_BAD_PARAMETER_VALUE, false, "Bad value for STDEV.BITS (%d) for %s", 294 options->stdevBits, source); 295 psFree(source); 296 psFree(file); 297 return NULL; 298 } 299 break; 300 case PS_FITS_SCALE_MANUAL: 301 options->bscale = parseOptionDouble(scheme, "BSCALE", source); // Scaling 302 options->bzero = parseOptionDouble(scheme, "BZERO", source); // Zero point 303 break; 304 default: 305 psAbort("Should never get here."); 306 } 307 } 308 309 // Compression options 310 const char *compressString = psMetadataLookupStr(NULL, scheme, "COMPRESSION"); // Compression type 311 if (compressString) { 312 psFitsCompressionType type = psFitsCompressionTypeFromString(compressString); // Compression 313 psVector *tile = psVectorAlloc(3, PS_TYPE_S32); // Tile sizes 314 tile->data.S32[0] = parseOptionInt(scheme, "TILE.X", source, 0); // Tiling in x 315 tile->data.S32[1] = parseOptionInt(scheme, "TILE.Y", source, 1); // Tiling in y 316 tile->data.S32[2] = parseOptionInt(scheme, "TILE.Z", source, 1); // Tiling in z 317 int noise = parseOptionInt(scheme, "NOISE", source, 16); // Noise bits 318 int hscale = 0, hsmooth = 0;// Scaling and smoothing for HCOMPRESS 319 if (type == PS_FITS_COMPRESS_HCOMPRESS) { 320 hscale = parseOptionInt(scheme, "HSCALE", source, 0); 321 hsmooth = parseOptionInt(scheme, "HSMOOTH", source, 0); 322 } 323 324 file->compression = psFitsCompressionAlloc(type, tile, noise, hscale, hsmooth); 325 psFree(tile); 326 } 327 250 328 psFree(source); 251 252 file->compression = psFitsCompressionAlloc(type, tile, noise, hscale, hsmooth); 253 psFree(tile); 254 } 255 COMPRESSION_DONE: 329 } 330 FITS_OPTIONS_DONE: 256 331 257 332 file->fileLevel = pmFPAPHULevel(format); … … 971 1046 } 972 1047 file->detrend = results; 973 file->fileLevel = pmFPALevelFromName(results->level);974 if (file->fileLevel == PM_FPA_LEVEL_NONE) {1048 file->fileLevel = pmFPALevelFromName(results->level); 1049 if (file->fileLevel == PM_FPA_LEVEL_NONE) { 975 1050 psError (PS_ERR_IO, false, "invalid file level for selected detrend data"); 976 1051 return NULL; … … 1021 1096 // inherit the concepts from the src fpa: 1022 1097 pmFPACopyConcepts(file->fpa, file->src); 1023 1098 1024 1099 return file; 1025 1100 } … … 1233 1308 // pmFPAfile is being used internally. 1234 1309 pmReadout *pmFPAGenerateReadout(const pmConfig *config, // configuration information 1235 const pmFPAview *view, // select background for this entry1236 const char *name, // name of internal/external file1237 const pmFPA *fpa, // use this fpa to generate1238 const psImageBinning *binning) {1310 const pmFPAview *view, // select background for this entry 1311 const char *name, // name of internal/external file 1312 const pmFPA *fpa, // use this fpa to generate 1313 const psImageBinning *binning) { 1239 1314 pmReadout *readout = NULL; 1240 1315 … … 1246 1321 readout = pmFPAfileDefineInternal (config->files, name, binning->nXruff, binning->nYruff, PS_TYPE_F32); 1247 1322 return readout; 1248 } 1323 } 1249 1324 1250 1325 // if the mode is INTERNAL, it has been defined in a previous call. XXX This seems to require … … 1253 1328 readout = file->readout; 1254 1329 return readout; 1255 } 1330 } 1256 1331 1257 1332 // we are using this pmFPAfile as an I/O file: select readout or create
Note:
See TracChangeset
for help on using the changeset viewer.
