Changeset 16186
- Timestamp:
- Jan 22, 2008, 5:10:51 PM (18 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 4 edited
-
pmFPAfile.c (modified) (12 diffs)
-
pmFPAfile.h (modified) (2 diffs)
-
pmFPAfileDefine.c (modified) (7 diffs)
-
pmFPAfileIO.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfile.c
r15929 r16186 74 74 file->fits = NULL; 75 75 file->compression = NULL; 76 file->bitpix = 0; 77 file->floatType = PS_FITS_FLOAT_NONE; 76 file->options = NULL; 78 77 file->names = psMetadataAlloc(); 79 78 … … 192 191 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 193 192 if (name != NULL) { 194 psStringSubstitute(&newName, name, "{CHIP.NAME}");193 psStringSubstitute(&newName, name, "{CHIP.NAME}"); 195 194 } 196 195 } … … 201 200 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.ID"); 202 201 if (name != NULL) { 203 psStringSubstitute(&newName, name, "{CHIP.ID}");202 psStringSubstitute(&newName, name, "{CHIP.ID}"); 204 203 } 205 204 } … … 220 219 char *name = psMetadataLookupStr (NULL, cell->concepts, "CELL.NAME"); 221 220 if (name != NULL) { 222 psStringSubstitute(&newName, name, "{CELL.NAME}");221 psStringSubstitute(&newName, name, "{CELL.NAME}"); 223 222 } 224 223 } … … 243 242 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTER"); 244 243 if (name && *name) { 245 psStringSubstitute(&newName, name, "{FILTER}");244 psStringSubstitute(&newName, name, "{FILTER}"); 246 245 } 247 246 } … … 251 250 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.FILTERID"); 252 251 if (name && *name) { 253 psStringSubstitute(&newName, name, "{FILTER.ID}");252 psStringSubstitute(&newName, name, "{FILTER.ID}"); 254 253 } 255 254 } … … 259 258 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT"); 260 259 if (name && *name) { 261 psStringSubstitute(&newName, name, "{CAMERA}");260 psStringSubstitute(&newName, name, "{CAMERA}"); 262 261 } 263 262 } … … 267 266 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.INSTRUMENT"); 268 267 if (name && *name) { 269 psStringSubstitute(&newName, name, "{INSTRUMENT}");268 psStringSubstitute(&newName, name, "{INSTRUMENT}"); 270 269 } 271 270 } … … 275 274 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.DETECTOR"); 276 275 if (name && *name) { 277 psStringSubstitute(&newName, name, "{DETECTOR}");276 psStringSubstitute(&newName, name, "{DETECTOR}"); 278 277 } 279 278 } … … 283 282 char *name = psMetadataLookupStr (NULL, fpa->concepts, "FPA.TELESCOPE"); 284 283 if (name && *name) { 285 psStringSubstitute(&newName, name, "{TELESCOPE}");284 psStringSubstitute(&newName, name, "{TELESCOPE}"); 286 285 } 287 286 } … … 340 339 if (view->cell >= inChip->cells->n) { 341 340 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld", 342 view->cell, inChip->cells->n);341 view->cell, inChip->cells->n); 343 342 return false; 344 343 } … … 387 386 if (view->cell >= inChip->cells->n) { 388 387 psError(PS_ERR_IO, true, "Requested cell == %d>= inChip->cells->n == %ld", 389 view->cell, inChip->cells->n);388 view->cell, inChip->cells->n); 390 389 return false; 391 390 } -
trunk/psModules/src/camera/pmFPAfile.h
r15930 r16186 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1.2 5$ $Name: not supported by cvs2svn $7 * @date $Date: 200 7-12-27 02:07:16$6 * @version $Revision: 1.26 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2008-01-23 03:10:51 $ 8 8 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii 9 9 */ … … 65 65 psFits *fits; // for I/O files of fits type (IMAGE, CMP, CMF) we carry a file handle 66 66 psFitsCompression *compression; // Compression for FITS images 67 int bitpix; // Bits per pixel for output 68 psFitsFloat floatType; // Custom floating-point 67 psFitsOptions *options; // FITS I/O options 69 68 70 69 bool wrote_phu; // have we written a PHU for this file? -
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 -
trunk/psModules/src/camera/pmFPAfileIO.c
r15912 r16186 685 685 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "CLASSID"); // Menu of class IDs 686 686 if (!status || !menu) { 687 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration");688 return false;689 } 690 const char *rule = psMetadataLookupStr(&status, menu, file->detrend->level); // Rule for class_id691 if (!status || !rule || strlen(rule) == 0) {692 psError(PS_ERR_IO, false, "Unable to find %s in CLASSID in camera configuration", file->detrend->level);693 return false;694 } 695 classId = pmFPAfileNameFromRule(rule, file, view);696 if (!classId) {697 psError(PS_ERR_IO, false, "error converting CLASSID rule to name: %s\n", rule);698 return false;699 }687 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 688 return false; 689 } 690 const char *rule = psMetadataLookupStr(&status, menu, file->detrend->level); // Rule for class_id 691 if (!status || !rule || strlen(rule) == 0) { 692 psError(PS_ERR_IO, false, "Unable to find %s in CLASSID in camera configuration", file->detrend->level); 693 return false; 694 } 695 classId = pmFPAfileNameFromRule(rule, file, view); 696 if (!classId) { 697 psError(PS_ERR_IO, false, "error converting CLASSID rule to name: %s\n", rule); 698 return false; 699 } 700 700 psTrace ("psModules.camera", 6, "looking for detrend (%s, %s)\n", file->detrend->detID, classId); 701 701 psFree (file->filename); … … 751 751 } 752 752 753 // XXX these are probably only needed for WRITE files753 // XXX these are probably only needed for WRITE files 754 754 if (file->compression) { 755 755 psTrace("psModules.camera", 7, "Setting compression for %s (%s)\n", file->filename, file->name); … … 761 761 } 762 762 763 file->fits->floatType = file->floatType; 764 file->fits->bitpix = file->bitpix; 763 file->fits->options = psMemIncrRefCounter(file->options); 765 764 766 765 // In some cases, we need to read the PHU after we've opened the file. This happens for the images
Note:
See TracChangeset
for help on using the changeset viewer.
