- Timestamp:
- Sep 29, 2007, 12:01:01 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_070920/psModules/src/camera/pmFPAfileDefine.c
r14974 r15112 78 78 } 79 79 80 // Parse an option from a metadata, returning the appropriate integer value 81 static int parseOptionInt(const psMetadata *md, // Metadata containing the option 82 const char *name, // Option name 83 const char *source, // Description of source, for warning messages 84 int defaultValue // Default value 85 ) 86 { 87 psMetadataItem *item = psMetadataLookup(md, name); // Item with the value of interest 88 if (!item) { 89 psWarning("Unable to find value for %s in %s --- set to %d.", name, source, defaultValue); 90 return defaultValue; 91 } 92 int value = psMetadataItemParseS32(item); // Value of interst 93 if (value < 0) { 94 psWarning("Bad value for %s in %s (%d) --- set to %d.", name, source, value, defaultValue); 95 return defaultValue; 96 } 97 return value; 98 } 99 80 100 81 101 // define an input-type pmFPAfile, bind to the optional fpa if supplied … … 250 270 file->fpa = pmFPAConstruct(file->camera); 251 271 } 272 273 // Get compression scheme 274 const char *compName = psMetadataLookupStr(&status, data, "COMPRESSION"); // Name of compression scheme 275 if (compName && strcasecmp(compName, "NONE") != 0) { 276 psMetadata *compSchemes = psMetadataLookupMetadata(&status, camera, "COMPRESSION"); // Comp. schemes 277 if (!compSchemes) { 278 psWarning("Unable to find COMPRESSION in camera configuration --- compression disabled."); 279 goto COMPRESSION_DONE; 280 } 281 psMetadata *compression = psMetadataLookupMetadata(NULL, compSchemes, compName); // Compression info 282 if (!compression) { 283 psWarning("Unable to find %s in COMPRESSION in camera configuration --- compression disabled.", 284 compName); 285 goto COMPRESSION_DONE; 286 } 287 const char *typeString = psMetadataLookupStr(NULL, compression, "COMPRESSION"); // Compression type 288 if (!typeString || strlen(typeString)) { 289 psWarning("Can't find COMPRESSION in compression scheme %s --- compression disabled.", compName); 290 goto COMPRESSION_DONE; 291 } 292 psFitsCompressionType type = psFitsCompressionTypeFromString(typeString); // Compression type enum 293 294 psString source = NULL; // Source of options 295 psStringAppend(&source, "%s in COMPRESSION in camera %s", compName, cameraName); 296 psVector *tile = psVectorAlloc(3, PS_TYPE_S32); // Tile sizes 297 file->bitpix = parseOptionInt(compression, "BITPIX", source, 0); // Bits per pixel 298 tile->data.S32[0] = parseOptionInt(compression, "TILE.X", source, 0); // Tiling in x 299 tile->data.S32[1] = parseOptionInt(compression, "TILE.Y", source, 1); // Tiling in y 300 tile->data.S32[2] = parseOptionInt(compression, "TILE.Z", source, 1); // Tiling in z 301 int noise = parseOptionInt(compression, "NOISE", source, 16); // Noise bits 302 int hscale = parseOptionInt(compression, "HSCALE", source, 0); // Scaling for HCOMPRESS 303 int hsmooth = parseOptionInt(compression, "HSMOOTH", source, 0); // Smoothing for HCOMPRESS 304 psFree(source); 305 306 file->compression = psFitsCompressionAlloc(type, tile, noise, hscale, hsmooth); 307 psFree(tile); 308 } 309 COMPRESSION_DONE: 252 310 253 311 file->fileLevel = pmFPAPHULevel(format);
Note:
See TracChangeset
for help on using the changeset viewer.
