Changeset 7295
- Timestamp:
- Jun 2, 2006, 9:50:48 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/fits/psFitsHeader.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFitsHeader.c
r7289 r7295 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1. 19$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-06-02 03:27:46$9 * @version $Revision: 1.20 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-06-02 19:50:48 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 254 254 psMetadataItem* item; // Item from iteration 255 255 int status = 0; // Status of cfitsio calls 256 bool simple = true; // If SIMPLE is T, then the file should conform to the FITS standard 256 257 while ((item = psListGetAndIncrement(iter))) { 258 // We allow the user to write SIMPLE, but it must be boolean 259 if (strcmp(item->name, "SIMPLE") == 0) { 260 if (item->type != PS_DATA_BOOL) { 261 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "SIMPLE in a FITS header must be of boolean type: " 262 "not %x --- assuming FALSE.\n", item->type); 263 int value = false; // Temporary 264 fits_update_key(fits->fd, TLOGICAL, "SIMPLE", &value, 265 "File does not conform to FITS standard", &status); 266 simple = false; 267 continue; 268 } else if (! item->data.B) { 269 simple = false; 270 } 271 } 272 257 273 // Check to see if the item should be ignored 258 // We ignore particular (required) keywords, because these are written by CFITSIO 259 // Furthermore, users tend to supply FITS headers that are wrong (e.g., after binning down the 260 // image, the NAXISn haven't been changed; or after converting to F32, the BITPIX hasn't been changed) 261 // so we'll take care of that for them. 262 bool writeKey = true; // Should we write this keyword? 263 for (int i = 0; noWriteFitsKeys[i] && writeKey; i++) { 264 if (strcmp(item->name, noWriteFitsKeys[i]) == 0) { 265 writeKey = false; 266 } 267 } 268 if (keyStarts) { 269 // Also block out TTYPEn, NAXISn, etc --- keywords that start with a certain sequence. 270 // We want to do this when writing an image or table, since it guarantees that the NAXISn etc 271 // that go in are correct. However, when we're writing a "blank" HDU (header only), we want to 272 // preserve NAXISn etc for reference, so we don't do this. 273 for (int i = 0; noWriteFitsKeyStarts[i] && writeKey; i++) { 274 if (strncmp(item->name, noWriteFitsKeyStarts[i], strlen(noWriteFitsKeyStarts[i])) == 0) { 274 if (simple) { 275 // We ignore particular (required) keywords, because these are written by CFITSIO 276 // Furthermore, users tend to supply FITS headers that are wrong (e.g., after binning down the 277 // image, the NAXISn haven't been changed; or after converting to F32, the BITPIX hasn't been 278 // changed) so we'll take care of that for them. 279 bool writeKey = true; // Should we write this keyword? 280 for (int i = 0; noWriteFitsKeys[i] && writeKey; i++) { 281 if (strcmp(item->name, noWriteFitsKeys[i]) == 0) { 275 282 writeKey = false; 276 283 } … … 280 287 continue; 281 288 } 282 } 283 284 // We allow the user to write SIMPLE, but it must be boolean 285 if (strcmp(item->name, "SIMPLE") == 0 && item->type != PS_DATA_BOOL) { 286 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "SIMPLE in a FITS header must be of boolean type: not " 287 "%x --- ignored.\n", item->type); 288 continue; 289 if (keyStarts) { 290 // Also block out TTYPEn, NAXISn, etc --- keywords that start with a certain sequence. 291 // We want to do this when writing an image or table, since it guarantees that the NAXISn etc 292 // that go in are correct. However, when we're writing a "blank" HDU (header only), we want 293 // to preserve NAXISn etc for reference, so we don't do this. 294 for (int i = 0; noWriteFitsKeyStarts[i] && writeKey; i++) { 295 if (strncmp(item->name, noWriteFitsKeyStarts[i], strlen(noWriteFitsKeyStarts[i])) == 0) { 296 writeKey = false; 297 } 298 } 299 if (!writeKey) { 300 // Don't write it; skip to the next key 301 continue; 302 } 303 } 289 304 } 290 305 … … 349 364 break; 350 365 default: // all other META types are ignored 366 psLogMsg(__func__, PS_LOG_WARN, "Attempt to write metadata type %x to FITS header ignored.\n", 367 item->type); 351 368 break; 352 369 }
Note:
See TracChangeset
for help on using the changeset viewer.
