Changeset 15112
- Timestamp:
- Sep 29, 2007, 12:01:01 PM (19 years ago)
- Location:
- branches/pap_branch_070920/psModules/src/camera
- Files:
-
- 4 edited
-
pmFPAfile.c (modified) (2 diffs)
-
pmFPAfile.h (modified) (4 diffs)
-
pmFPAfileDefine.c (modified) (2 diffs)
-
pmFPAfileIO.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_070920/psModules/src/camera/pmFPAfile.c
r14889 r15112 40 40 psFitsClose (file->fits); 41 41 } 42 psFree(file->compression); 42 43 43 44 psFree (file->filerule); … … 72 73 file->fpa = NULL; 73 74 file->fits = NULL; 75 file->compression = NULL; 76 file->bitpix = 0; 74 77 file->names = psMetadataAlloc(); 75 78 -
branches/pap_branch_070920/psModules/src/camera/pmFPAfile.h
r14889 r15112 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1.21 $ $Name: not supported by cvs2svn $7 * @date $Date: 2007-09- 19 21:37:58$6 * @version $Revision: 1.21.2.1 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-09-29 22:01:01 $ 8 8 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii 9 9 */ … … 51 51 } pmFPAfileState; 52 52 53 typedef struct 54 { 53 typedef struct { 55 54 pmFPAfileMode mode; // is this file read, written, or only used internally? 56 55 pmFPAfileType type; // what type of data is read from / written to disk? … … 63 62 64 63 pmFPA *fpa; // for I/O files, we carry a pointer to the complete fpa 65 psFits *fits; // for I/O files of fits type (IMAGE, CMP, CMF), we carry a file handle 64 psFits *fits; // for I/O files of fits type (IMAGE, CMP, CMF) we carry a file handle 65 psFitsCompression *compression; // Compression for FITS images 66 int bitpix; // Bits per pixel for output 66 67 67 68 bool wrote_phu; // have we written a PHU for this file? … … 93 94 psMetadata *format; // Camera format 94 95 psString formatName; // name of the camera format 95 } 96 pmFPAfile; 96 } pmFPAfile; 97 97 98 98 // allocate an empty pmFPAfile structure -
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); -
branches/pap_branch_070920/psModules/src/camera/pmFPAfileIO.c
r14938 r15112 688 688 } 689 689 690 // In some cases, we need to read the PHU after we've opened the file. This happens for 691 // the images supplied by the detrend database, which are only identified here (pmConfigConvertFilename). 690 if (file->compression && !psFitsCompressionApply(file->fits, file->compression)) { 691 psError(PS_ERR_UNKNOWN, false, "Unable to set compression options for %s (%s) (%d:%d:%d)\n", 692 file->filename, file->name, view->chip, view->cell, view->readout); 693 return false; 694 } 695 696 // In some cases, we need to read the PHU after we've opened the file. This happens for the images 697 // supplied by the detrend database, which are only identified here (pmConfigConvertFilename). 692 698 if (!pmFPAfileReadPHU (file, view, config)) { 693 psError (PS_ERR_IO, true, "error reading PHU for %s (%s) (%d:%d:%d)\n", file->filename, file->name, view->chip, view->cell, view->readout); 699 psError (PS_ERR_IO, true, "error reading PHU for %s (%s) (%d:%d:%d)\n", 700 file->filename, file->name, view->chip, view->cell, view->readout); 694 701 return false; 695 702 } … … 758 765 return false; 759 766 } 760 file->formatName = psStringCopy(config->formatName);767 file->formatName = psStringCopy(config->formatName); 761 768 762 769 } else { … … 795 802 case PM_FPA_FILE_WEIGHT: 796 803 case PM_FPA_FILE_FRINGE: 797 status = pmFPAviewFitsWritePHU (view, file, config);798 break;804 status = pmFPAviewFitsWritePHU (view, file, config); 805 break; 799 806 case PM_FPA_FILE_CMF: 800 status = pmSource_CMF_WritePHU (view, file, config);801 break;807 status = pmSource_CMF_WritePHU (view, file, config); 808 break; 802 809 case PM_FPA_FILE_PSF: 803 status = pmPSFmodelWritePHU (view, file, config);804 break;810 status = pmPSFmodelWritePHU (view, file, config); 811 break; 805 812 case PM_FPA_FILE_SX: 806 813 case PM_FPA_FILE_RAW:
Note:
See TracChangeset
for help on using the changeset viewer.
