Changeset 6855
- Timestamp:
- Apr 13, 2006, 5:10:49 PM (20 years ago)
- Location:
- branches/rel10_ifa/psModules/src/astrom
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/astrom/pmHDU.c
r6834 r6855 6 6 #include "psAdditionals.h" 7 7 8 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 9 // File-static (private) functions 10 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 11 12 // Move to the appropriate extension in FITS file for HDU 13 static bool hduMove(pmHDU *hdu, // HDU with extname 14 psFits *fits // FITS file in which to move 15 ) 16 { 17 // Deal with the PHU case 18 if (strcasecmp(hdu->extname, "PHU") == 0 || hdu->phu) { 19 if (! psFitsMoveExtNum(fits, 0, false)) { 20 psError(PS_ERR_IO, false, "Unable to move to primary header!\n"); 21 return false; 22 } 23 hdu->phu = true; 24 return true; 25 } 26 27 if (! psFitsMoveExtName(fits, hdu->extname)) { 28 psError(PS_ERR_IO, false, "Unable to move to extension %s\n", hdu->extname); 29 return false; 30 } 31 // Now, just in case for some reason the PHU has an extension name that we've moved to.... 32 if (psFitsGetExtNum(fits) == 0) { 33 hdu->phu = true; 34 } else { 35 hdu->phu = false; 36 } 37 38 return true; 39 } 8 40 9 41 static void hduFree(pmHDU *hdu) … … 18 50 } 19 51 52 53 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 54 // Public functions 55 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 20 56 21 57 pmHDU *pmHDUAlloc(const char *extname // Extension name … … 46 82 } 47 83 84 bool pmHDUReadHeader(pmHDU *hdu, // HDU for which to read header 85 psFits *fits // FITS file from which to read 86 ) 87 { 88 assert(hdu); 89 assert(fits); 90 91 // Move to the appropriate extension 92 psTrace(__func__, 5, "Moving to extension %s...\n", hdu->extname); 93 if (!hduMove(hdu, fits)) { 94 return false; 95 } 96 97 if (!hdu->header) { 98 psTrace(__func__, 5, "Reading the header...\n"); 99 hdu->header = psFitsReadHeader(NULL, fits); 100 if (! hdu->header) { 101 psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname); 102 return false; 103 } 104 } 105 106 return true; 107 } 48 108 49 109 // Read the HDU … … 56 116 assert(fits); 57 117 58 // Move to the appropriate extension 59 psTrace(__func__, 5, "Moving to extension %s...\n", hdu->extname); 60 if (strcasecmp(hdu->extname, "PHU") == 0) { 61 if (! psFitsMoveExtNum(fits, 0, false)) { 62 psError(PS_ERR_IO, false, "Unable to move to primary header!\n"); 63 return false; 64 } 65 hdu->phu = true; 66 } else { 67 if (! psFitsMoveExtName(fits, hdu->extname)) { 68 psError(PS_ERR_IO, false, "Unable to move to extension %s\n", hdu->extname); 69 } 70 // Now, just in case for some reason the PHU has an extension name that we've moved to.... 71 if (psFitsGetExtNum(fits) == 0) { 72 hdu->phu = true; 73 } else { 74 hdu->phu = false; 75 } 76 } 77 78 // Read the header 79 if (! hdu->header) { 80 psTrace(__func__, 5, "Reading the header...\n"); 81 hdu->header = psFitsReadHeader(NULL, fits); 82 if (! hdu->header) { 83 psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname); 84 return false; 85 } 118 // Read the header; includes the move 119 if (!pmHDUReadHeader(hdu, fits)) { 120 return false; 86 121 } 87 122 -
branches/rel10_ifa/psModules/src/astrom/pmHDU.h
r6713 r6855 20 20 pmHDU *pmHDUAlloc(const char *extname); 21 21 22 // Read the header 23 bool pmHDUReadHeader(pmHDU *hdu, // HDU for which to read header 24 psFits *fits // FITS file from which to read 25 ); 26 22 27 // Read the HDU 23 28 bool pmHDURead(pmHDU *hdu, // HDU to read
Note:
See TracChangeset
for help on using the changeset viewer.
