Changeset 17660 for trunk/psLib/src/fits/psFitsImage.c
- Timestamp:
- May 13, 2008, 3:27:25 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/fits/psFitsImage.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFitsImage.c
r17447 r17660 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.2 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2008-0 4-17 23:43:02$9 * @version $Revision: 1.29 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2008-05-14 01:27:25 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 246 246 static psImage *imageToDiskRepresentation(double *bscale, // Scaling applied 247 247 double *bzero, // Zero point applied 248 long *blank, // Blank value (integer data) 248 249 psFitsFloat *floatType, // Type of custom floating-point 249 250 psFits *fits, // FITS file pointer … … 284 285 if (newScaleZero) { 285 286 // Choose an appropriate BSCALE and BZERO 286 if (!psFitsScaleDetermine(bscale, bzero, image, fits)) {287 if (!psFitsScaleDetermine(bscale, bzero, blank, image, fits)) { 287 288 // We can't have the write dying for this reason --- try to save it somehow! 288 289 psWarning("Unable to determine BSCALE and BZERO for image --- setting to 1.0, 0.0"); … … 365 366 psAssert(!output->parent, "impossible"); // No parents means the buffer is contiguous 366 367 368 void *nullValue = NULL; // Null value for data 369 float nullFloat = NAN; // Null value for floating point 370 double nullDouble = NAN; // Null value for double 371 switch (info->psDatatype) { 372 case PS_TYPE_F32: 373 nullValue = &nullFloat; 374 break; 375 case PS_TYPE_F64: 376 nullValue = &nullDouble; 377 break; 378 case PS_TYPE_U8: 379 case PS_TYPE_U16: 380 case PS_TYPE_U32: 381 case PS_TYPE_U64: 382 case PS_TYPE_S8: 383 case PS_TYPE_S16: 384 case PS_TYPE_S32: 385 case PS_TYPE_S64: 386 // Can't mark bad pixels any further than what is in the FITS image 387 break; 388 default: 389 psAbort("Unknown type: %x", info->psDatatype); 390 } 391 367 392 int anynull = 0; // Are there any NULLs in the data? 368 393 int status = 0; // cfitsio status 369 394 if (fits_read_subset(fits->fd, info->fitsDatatype, info->firstPixel, info->lastPixel, 370 info->increment, NULL, output->data.V[0], &anynull, &status) != 0) {395 info->increment, nullValue, output->data.V[0], &anynull, &status) != 0) { 371 396 psFitsError(status, true, "Reading FITS file failed."); 372 397 return false; … … 498 523 499 524 double bscale = 0.0, bzero = 0.0; // Scale and zero point to put in header (*already* applied to data) 525 long blank = 0; // Blank (undefined) value for image 500 526 psFitsFloat floatType; // Custom floating-point convention type 501 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, & floatType, fits, image,527 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &blank, &floatType, fits, image, 502 528 NULL, true); // Image to write out 503 529 if (!diskImage) { … … 576 602 } 577 603 604 if (blank != 0) { 605 // Some quantisation has taken place --- record the blank ("magic") pixel value 606 char *keyword = (psFitsCompressionGetType(fits) != PS_FITS_COMPRESS_NONE && 607 (!fits->options || fits->options->conventions.compression)) ? 608 "ZBLANK" : "BLANK"; // Keyword for recording blank pixel value 609 fits_write_key_lng(fits->fd, keyword, blank, "Value for undefined pixels", &status); 610 fits_set_imgnull(fits->fd, blank, &status); 611 if (psFitsError(status, true, "Could not write BLANK header to file.")) { 612 psFree(diskImage); 613 return false; 614 } 615 } 616 578 617 if (floatType != PS_FITS_FLOAT_NONE) { 579 618 psFitsFloatImageSet(fits, floatType); … … 629 668 630 669 double bscale = 0.0, bzero = 0.0; // Scale and zero point to put in header (*already* applied to data) 670 long blank = 0; // Blank (undefined) value for image 631 671 psFitsFloat floatType; // Custom floating-point convention type 632 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, & floatType, fits, input,672 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &blank, &floatType, fits, input, 633 673 NULL, false); // Image to write out 634 674 if (!diskImage) {
Note:
See TracChangeset
for help on using the changeset viewer.
