Changeset 10081 for trunk/psModules/src/camera/pmFPAfileFitsIO.c
- Timestamp:
- Nov 18, 2006, 1:43:28 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAfileFitsIO.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAfileFitsIO.c
r9950 r10081 61 61 } 62 62 63 // given an already-opened fits file, read the components corresponding 64 // to the specified view 65 bool pmFPAviewReadFitsImage (const pmFPAview *view, pmFPAfile *file) 66 { 67 PS_ASSERT_PTR_NON_NULL(view, false); 68 PS_ASSERT_PTR_NON_NULL(file, false); 69 70 bool status; 71 pmFPA *fpa = file->fpa; 72 psFits *fits = file->fits; 73 74 if (view->chip == -1) { 75 status = pmFPARead (fpa, fits, NULL); 76 return status; 63 64 // given an already-opened fits file, read the components corresponding to the specified view 65 static bool fpaViewReadFitsImage(const pmFPAview *view, // FPA view, specifying the level of interest 66 pmFPAfile *file, // FPA file of interest 67 bool (*fpaReadFunc)(pmFPA*, psFits*, psDB*), // Function to read FPA 68 bool (*chipReadFunc)(pmChip*, psFits*, psDB*), // Function to read chip 69 bool (*cellReadFunc)(pmCell*, psFits*, psDB*) // Function to read cell 70 ) 71 { 72 assert(view); 73 assert(file); 74 75 pmFPA *fpa = file->fpa; // FPA of interest 76 psFits *fits = file->fits; // FITS file from which to read 77 78 if (view->chip == -1) { 79 return fpaReadFunc(fpa, fits, NULL); 77 80 } 78 81 … … 81 84 return false; 82 85 } 83 pmChip *chip = fpa->chips->data[view->chip]; 84 85 if (view->cell == -1) { 86 status = pmChipRead (chip, fits, NULL); 87 return status; 86 pmChip *chip = fpa->chips->data[view->chip]; // Chip of interest 87 88 if (view->cell == -1) { 89 return chipReadFunc(chip, fits, NULL); 88 90 } 89 91 … … 92 94 return false; 93 95 } 94 pmCell *cell = chip->cells->data[view->cell]; 96 pmCell *cell = chip->cells->data[view->cell]; // Cell of interest 95 97 96 98 if (view->readout == -1) { 97 status = pmCellRead (cell, fits, NULL); 98 return status; 99 } 100 psError(PS_ERR_UNKNOWN, true, "Returning false"); 99 return cellReadFunc(cell, fits, NULL); 100 } 101 psError(PS_ERR_UNKNOWN, true, "Bad view: %d,%d", view->chip, view->cell); 101 102 return false; 102 103 … … 118 119 return true; 119 120 #endif 121 } 122 123 124 bool pmFPAviewReadFitsImage(const pmFPAview *view, pmFPAfile *file) 125 { 126 PS_ASSERT_PTR_NON_NULL(view, false); 127 PS_ASSERT_PTR_NON_NULL(file, false); 128 return fpaViewReadFitsImage(view, file, pmFPARead, pmChipRead, pmCellRead); 129 } 130 131 bool pmFPAviewReadFitsMask(const pmFPAview *view, pmFPAfile *file) 132 { 133 PS_ASSERT_PTR_NON_NULL(view, false); 134 PS_ASSERT_PTR_NON_NULL(file, false); 135 return fpaViewReadFitsImage(view, file, pmFPAReadMask, pmChipReadMask, pmCellReadMask); 136 } 137 138 bool pmFPAviewReadFitsWeight(const pmFPAview *view, pmFPAfile *file) 139 { 140 PS_ASSERT_PTR_NON_NULL(view, false); 141 PS_ASSERT_PTR_NON_NULL(file, false); 142 return fpaViewReadFitsImage(view, file, pmFPAReadWeight, pmChipReadWeight, pmCellReadWeight); 120 143 } 121 144 … … 126 149 // out data in an inconsistent fashion 127 150 // the calls below should recurse down the element to write out all components. 128 bool pmFPAviewWriteFitsImage (const pmFPAview *view, pmFPAfile *file) 129 { 130 PS_ASSERT_PTR_NON_NULL(view, false); 131 PS_ASSERT_PTR_NON_NULL(file, false); 132 133 pmFPA *fpa = file->fpa; 134 psFits *fits = file->fits; 151 static bool fpaViewWriteFitsImage(const pmFPAview *view, // FPA view, specifying the level of interest 152 pmFPAfile *file, // FPA file of interest 153 bool (*fpaWriteFunc)(pmFPA*, psFits*, psDB*, bool, bool), // Func for FPA 154 bool (*chipWriteFunc)(pmChip*, psFits*, psDB*, bool, bool), // Func for chip 155 bool (*cellWriteFunc)(pmCell*, psFits*, psDB*, bool) // Func for cell 156 ) 157 { 158 assert(view); 159 assert(file); 160 161 pmFPA *fpa = file->fpa; // FPA of interest 162 psFits *fits = file->fits; // FITS file 135 163 136 164 // pmFPAWrite takes care of all PHUs as needed 137 165 if (view->chip == -1) { 138 pmFPAWrite(fpa, fits, NULL, false, true); 139 return true; 166 return fpaWriteFunc(fpa, fits, NULL, false, true); 140 167 } 141 168 … … 144 171 return false; 145 172 } 146 pmChip *chip = fpa->chips->data[view->chip]; 147 148 if (view->cell == -1) { 149 pmChipWrite (chip, fits, NULL, false, true); 150 return true; 173 pmChip *chip = fpa->chips->data[view->chip]; // Chip of interest 174 175 if (view->cell == -1) { 176 return chipWriteFunc(chip, fits, NULL, false, true); 151 177 } 152 178 … … 155 181 return false; 156 182 } 157 pmCell *cell = chip->cells->data[view->cell]; 183 pmCell *cell = chip->cells->data[view->cell]; // Cell of interest 158 184 159 185 if (view->readout == -1) { 160 return pmCellWrite(cell, fits, NULL, false);161 } 162 psError(PS_ERR_UNKNOWN, true, " Returning false");186 return cellWriteFunc(cell, fits, NULL, false); 187 } 188 psError(PS_ERR_UNKNOWN, true, "Bad view: %d,%d", view->chip, view->cell); 163 189 return false; 164 190 … … 182 208 } 183 209 184 // this old code was used to write the blank by hand. 185 // pmFPAWrite now takes care of this choice. 186 # if 0 187 // do we need to write out a PHU for this entry? 188 if (file->phu == NULL) 189 { 190 pmHDU *hdu = pmFPAviewThisHDU (view, file->fpa); 191 pmHDU *phu = pmFPAviewThisPHU (view, file->fpa); 192 // if this hdu is the phu, the write function below will create the phu 193 if (hdu != phu) { 194 // we assume that the PHU is just a header 195 // header may not be defined for constructed images; make a dummy one 196 psMetadata *outhead = NULL; 197 if (phu->header) { 198 outhead = psMetadataCopy (NULL, phu->header); 199 } else { 200 outhead = psMetadataAlloc (); 201 } 202 psMetadataAdd (outhead, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true); 203 psFitsWriteBlank (file->fits, outhead, ""); 204 file->phu = phu->header; 205 psTrace ("pmFPAfile", 5, "wrote phu %s (type: %d)\n", file->filename, file->type); 206 psFree (outhead); 207 } 208 } 209 # endif 210 bool pmFPAviewWriteFitsImage(const pmFPAview *view, pmFPAfile *file) 211 { 212 PS_ASSERT_PTR_NON_NULL(view, false); 213 PS_ASSERT_PTR_NON_NULL(file, false); 214 return fpaViewWriteFitsImage(view, file, pmFPAWrite, pmChipWrite, pmCellWrite); 215 } 216 217 bool pmFPAviewWriteFitsMask(const pmFPAview *view, pmFPAfile *file) 218 { 219 PS_ASSERT_PTR_NON_NULL(view, false); 220 PS_ASSERT_PTR_NON_NULL(file, false); 221 return fpaViewWriteFitsImage(view, file, pmFPAWriteMask, pmChipWriteMask, pmCellWriteMask); 222 } 223 224 bool pmFPAviewWriteFitsWeight(const pmFPAview *view, pmFPAfile *file) 225 { 226 PS_ASSERT_PTR_NON_NULL(view, false); 227 PS_ASSERT_PTR_NON_NULL(file, false); 228 return fpaViewWriteFitsImage(view, file, pmFPAWriteWeight, pmChipWriteWeight, pmCellWriteWeight); 229 } 210 230 211 231 // given an already-opened fits file, read the components corresponding 212 232 // to the specified view 213 bool pmFPAviewFree FitsImage(const pmFPAview *view, pmFPAfile *file)233 bool pmFPAviewFreeData(const pmFPAview *view, pmFPAfile *file) 214 234 { 215 235 PS_ASSERT_PTR_NON_NULL(view, false); … … 270 290 } 271 291 292 #if 0 293 // Shouldn't need this --- when we want to free fringe data, we want to free the whole level, not just the 294 // table. 272 295 273 296 // Free the table within a cell … … 329 352 } 330 353 354 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
