- Timestamp:
- Jun 8, 2011, 2:41:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20110406/psLib/src/fits/psFitsImage.c
r31606 r31618 55 55 int psDatatype; // psLib data type 56 56 bool is_logscaled; // is this image log scaled using BOFFSET? 57 bool is_asinh; // is this image asinh scaled using BSOFTEN? 57 58 } p_psFitsReadInfo; 58 59 … … 129 130 130 131 // Check scale and zero 131 double bscale = 0.0, bzero = 0.0, boffset = NAN ; // Scale and zero point132 double bscale = 0.0, bzero = 0.0, boffset = NAN, bsoften = NAN; // Scale and zero point 132 133 if (fits_read_key_dbl(fits->fd, "BSCALE", &bscale, NULL, &status) && status != KEY_NO_EXIST) { 133 134 psFitsError(status, true, "Unable to read header."); … … 153 154 info->is_logscaled = false; 154 155 } 156 status = 0; 157 if (fits_read_key_dbl(fits->fd, "BSOFTEN", &bsoften, NULL, &status) && status != KEY_NO_EXIST) { 158 psFitsError(status, true, "Unable to read header."); 159 goto bad; 160 } 161 if (status == KEY_NO_EXIST) { 162 info->is_asinh = false; 163 } 164 else if (isfinite(bsoften)) { 165 info->is_asinh = true; 166 } 167 else { 168 info->is_asinh = false; 169 } 170 155 171 status = 0; 156 172 … … 262 278 double *bzero, // Zero point applied 263 279 double *boffset, // Log offset applied 280 double *bsoften, // asinh offset applied 264 281 long *blank, // Blank value (integer data) 265 282 psFitsFloat *floatType, // Type of custom floating-point … … 275 292 psAssert(bzero, "impossible"); 276 293 psAssert(boffset, "impossible"); 294 psAssert(bsoften, "impossible"); 277 295 psAssert(floatType, "impossible"); 278 296 psAssert(fits, "impossible"); … … 322 340 if (newScaleZero) { 323 341 // Choose an appropriate BSCALE and BZERO 324 if (!psFitsScaleDetermine(bscale, bzero, boffset, b lank, image, mask, maskVal, fits)) {342 if (!psFitsScaleDetermine(bscale, bzero, boffset, bsoften, blank, image, mask, maskVal, fits)) { 325 343 // We can't have the write dying for this reason --- try to save it somehow! 326 344 psWarning("Unable to determine BSCALE and BZERO for image --- refusing to quantise."); … … 348 366 } 349 367 350 return psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, rng);368 return psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, *bsoften, rng); 351 369 } 352 370 … … 487 505 status = 0; 488 506 fits_read_key_dbl(fits->fd, "BOFFSET", &boffset, NULL, &status); 489 psImage *newImage = psFitsScaleFromDisk(outImage,boffset); 507 psImage *newImage = psFitsScaleFromDisk(outImage,boffset,0.0); 508 psFree (outImage); 509 outImage = newImage; 510 } 511 else if (info->is_asinh) { 512 double bsoften; 513 int status; 514 status = 0; 515 fits_read_key_dbl(fits->fd, "BSOFTEN", &bsoften, NULL, &status); 516 psImage *newImage = psFitsScaleFromDisk(outImage,0.0,bsoften); 490 517 psFree (outImage); 491 518 outImage = newImage; … … 602 629 double bscale = NAN, bzero = NAN; // Scale and zero point to put in header 603 630 double boffset = NAN; // Log offset to put into header. 631 double bsoften = NAN; // Asinh softening parameter to put into header 604 632 long blank = 0; // Blank (undefined) value for image 605 633 psFitsFloat floatType; // Custom floating-point convention type 606 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &b lank, &floatType, fits, image,634 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, image, 607 635 mask, maskVal, NULL, true); // Image to write out 608 636 if (!diskImage) { … … 831 859 double bscale = NAN, bzero = NAN; // Scale and zero point to put in header 832 860 double boffset = NAN; // Log offset to put in header 861 double bsoften = NAN; // Asinh softening parameter to put in header 833 862 long blank = 0; // Blank (undefined) value for image 834 863 psFitsFloat floatType; // Custom floating-point convention type 835 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &b lank, &floatType, fits, input,864 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, input, 836 865 mask, maskVal, NULL, false); // Image to write out 837 866 if (!diskImage) {
Note:
See TracChangeset
for help on using the changeset viewer.
