Changeset 21279
- Timestamp:
- Feb 3, 2009, 4:39:36 PM (17 years ago)
- Location:
- trunk/psModules/src/camera
- Files:
-
- 7 edited
-
pmFPAWrite.c (modified) (6 diffs)
-
pmFPAWrite.h (modified) (2 diffs)
-
pmFPAfile.c (modified) (1 diff)
-
pmFPAfile.h (modified) (2 diffs)
-
pmFPAfileFitsIO.c (modified) (1 diff)
-
pmHDU.c (modified) (1 diff)
-
pmHDU.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAWrite.c
r19385 r21279 107 107 if (writeBlank || writeImage) { 108 108 109 pmFPAUpdateNames(cell->parent->parent, cell->parent, cell);110 109 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 111 110 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; … … 157 156 158 157 if (writeBlank || writeImage) { 159 pmFPAUpdateNames(chip->parent, chip, NULL);160 158 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 161 159 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; … … 221 219 222 220 if (writeBlank || writeImage) { 223 pmFPAUpdateNames(fpa, NULL, NULL);224 221 pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | 225 222 PM_CONCEPT_SOURCE_DEFAULTS | PM_CONCEPT_SOURCE_DATABASE; … … 255 252 256 253 // Update the FPA.OBS, CHIP.NAME and CELL.NAME in the FITS header, if required 257 bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell) 258 { 259 pmHDU *hdu = pmHDUGetHighest(fpa, chip, cell); // Highest HDU, i.e., the PHU 260 if (!hdu) { 254 bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell, psS64 imageId, psS64 sourceId) 255 { 256 pmHDU *hduHigh = pmHDUGetHighest(fpa, chip, cell); // Highest HDU, i.e., the PHU 257 if (!hduHigh) { 258 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find PHU.\n"); 259 return false; 260 } 261 if (!hduHigh->header) { 262 hduHigh->header = psMetadataAlloc(); 263 } 264 if (!pmHDUWriteIdentifiers(hduHigh, imageId, sourceId)) { 265 psError(PS_ERR_UNKNOWN, false, "Unable to write identifiers to header."); 266 return false; 267 } 268 269 pmHDU *hduLow = pmHDUGetLowest(fpa, chip, cell); // Lowest HDU, i.e., the extension 270 if (!hduLow) { 261 271 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find HDU.\n"); 262 272 return false; 263 273 } 264 if (!hdu->header) { 265 hdu->header = psMetadataAlloc(); 266 } 274 if (!hduLow->header) { 275 hduLow->header = psMetadataAlloc(); 276 } 277 if (hduLow != hduHigh && !pmHDUWriteIdentifiers(hduLow, imageId, sourceId)) { 278 psError(PS_ERR_UNKNOWN, false, "Unable to write identifiers to header."); 279 return false; 280 } 281 267 282 bool mdok; // Status of MD lookup 268 psMetadata *fileData = psMetadataLookupMetadata(&mdok, hdu ->format, "FILE"); // File information283 psMetadata *fileData = psMetadataLookupMetadata(&mdok, hduHigh->format, "FILE"); // File information 269 284 if (!mdok || !fileData) { 270 285 psError(PS_ERR_UNKNOWN, true, "Unable to find FILE information in camera format.\n"); … … 275 290 if (mdok && fpaObsHdr && strlen(fpaObsHdr) > 0) { 276 291 const char *fpaObs = psMetadataLookupStr(NULL, fpa->concepts, "FPA.OBS"); 277 psMetadataAddStr(hdu ->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE,292 psMetadataAddStr(hduHigh->header, PS_LIST_TAIL, fpaObsHdr, PS_META_REPLACE, 278 293 "Observation identifier", fpaObs); 279 294 } … … 298 313 } 299 314 300 psMetadataAddStr(hdu->header, PS_LIST_TAIL, contentKey, PS_META_REPLACE, "Content of file", content); 315 psMetadataAddStr(hduHigh->header, PS_LIST_TAIL, contentKey, PS_META_REPLACE, 316 "Content of file", content); 301 317 psFree(content); // Drop reference 302 318 } -
trunk/psModules/src/camera/pmFPAWrite.h
r18163 r21279 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-06-17 22:16:38$6 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-04 02:39:36 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 165 165 ); 166 166 167 // XXX better name, please 168 bool pmFPAUpdateNames(pmFPA *fpa, pmChip *chip, pmCell *cell); 167 // Update the header before writing to be consistent 168 // 169 // XXX Would like a better name 170 bool pmFPAUpdateNames(pmFPA *fpa, ///< FPA 171 pmChip *chip, ///< Chip, or NULL 172 pmCell *cell, ///< Cell, or NULL 173 psS64 imageId, ///< Image identifier 174 psS64 sourceId ///< Source identifier 175 ); 169 176 170 177 /// @} -
trunk/psModules/src/camera/pmFPAfile.c
r19307 r21279 98 98 99 99 file->save = false; 100 101 file->imageId = 0; 102 file->sourceId = 0; 100 103 101 104 return file; -
trunk/psModules/src/camera/pmFPAfile.h
r19307 r21279 4 4 * @author EAM, IfA 5 5 * 6 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-09-02 19:06:16 $6 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-04 02:39:36 $ 8 8 * Copyright 2004-2005 Institute for Astronomy, University of Hawaii 9 9 */ … … 106 106 psMetadata *format; // Camera format 107 107 psString formatName; // name of the camera format 108 109 psS64 imageId, sourceId; // Image and source identifiers 108 110 } pmFPAfile; 109 111 -
trunk/psModules/src/camera/pmFPAfileFitsIO.c
r18601 r21279 178 178 pmChip *chip = pmFPAviewThisChip(view, fpa); // Chip of interest, or NULL 179 179 pmCell *cell = pmFPAviewThisCell(view, fpa); // Cell of interest, or NULL 180 if (!pmFPAUpdateNames(fpa, chip, cell )) {180 if (!pmFPAUpdateNames(fpa, chip, cell, file->imageId, file->sourceId)) { 181 181 psError(PS_ERR_UNKNOWN, false, "Unable to update names in header."); 182 182 return false; -
trunk/psModules/src/camera/pmHDU.c
r21183 r21279 243 243 return hduWrite(hdu, hdu->weights, hdu->masks, maskVal, fits); 244 244 } 245 246 bool pmHDUWriteIdentifiers(pmHDU *hdu, psS64 imageId, psS64 sourceId) 247 { 248 PS_ASSERT_PTR_NON_NULL(hdu, false); 249 250 // XXX Get header keyword name from camera configuration 251 252 psMetadataAddS64(hdu->header, PS_LIST_TAIL, "IMAGEID", PS_META_REPLACE, "Image identifier", imageId); 253 psMetadataAddS64(hdu->header, PS_LIST_TAIL, "SOURCEID", PS_META_REPLACE, "Source identifier", sourceId); 254 return true; 255 } 256 257 bool pmHDUReadIdentifiers(psS64 *imageId, psS64 *sourceId, const pmHDU *hdu) 258 { 259 PS_ASSERT_PTR_NON_NULL(hdu, false); 260 261 // XXX Get header keyword name from camera configuration 262 263 bool imageOK, sourceOK; // Status of MD lookups 264 *imageId = psMetadataLookupS64(&imageOK, hdu->header, "IMAGEID"); 265 *sourceId = psMetadataLookupS64(&sourceOK, hdu->header, "SOURCEID"); 266 267 return imageOK && sourceOK; 268 } -
trunk/psModules/src/camera/pmHDU.h
r19385 r21279 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $7 * @date $Date: 200 8-09-05 08:21:35$6 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2009-02-04 02:39:36 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 85 85 ); 86 86 87 88 /// Read identifiers from FITS header 89 bool pmHDUReadIdentifiers(psS64 *imageId, ///< Image identifer, returned 90 psS64 *sourceId, ///< Source identifier, returned 91 const pmHDU *hdu ///< HDU from which to read 92 ); 93 94 /// Write identifiers to FITS header 95 bool pmHDUWriteIdentifiers(pmHDU *hdu, ///< HDU to which to write 96 psS64 imageId, ///< Image identifer 97 psS64 sourceId ///< Source identifier 98 ); 99 87 100 /// @} 88 101 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
