Changeset 37018
- Timestamp:
- Jul 16, 2014, 2:45:18 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140610/psLib/src/fits/psFitsImage.c
r36537 r37018 345 345 if (newScaleZero) { 346 346 // Choose an appropriate BSCALE and BZERO 347 if (!psFitsScaleDetermine(bscale, bzero, boffset, bsoften, blank, image, mask, maskVal, fits)) {348 // We can't have the write dying for this reason --- try to save it somehow!349 psWarning("Unable to determine BSCALE and BZERO for image --- refusing to quantise.");350 psErrorClear();351 return psMemIncrRefCounter((psImage*)image);352 }347 if (!psFitsScaleDetermine(bscale, bzero, boffset, bsoften, blank, image, mask, maskVal, fits)) { 348 // We can't have the write dying for this reason --- try to save it somehow! 349 psWarning("Unable to determine BSCALE and BZERO for image --- refusing to quantise."); 350 psErrorClear(); 351 return psMemIncrRefCounter((psImage*)image); 352 } 353 353 } else { 354 // Don't want to muck with the current BSCALE and BZERO. Get the current values and use those.355 int status = 0; // Status of cfitsio356 if (fits_read_key_dbl(fits->fd, "BSCALE", bscale, NULL, &status) && status != KEY_NO_EXIST) {354 // Don't want to muck with the current BSCALE and BZERO. Get the current values and use those. 355 int status = 0; // Status of cfitsio 356 if (fits_read_key_dbl(fits->fd, "BSCALE", bscale, NULL, &status) && status != KEY_NO_EXIST) { 357 357 psFitsError(status, true, "Unable to read header."); 358 358 return NULL; … … 371 371 } 372 372 373 return psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, *bsoften, rng); 373 // XXX this test triggers the pswarp memory corruption problem. you need to include "psThread.h" above to activate this 374 // for (int nx = 0; nx < 3; nx++) { 375 // psList *pending = psThreadGetPendingQueue(); 376 // if (pending && pending->head) { 377 // fprintf (stderr, "thread jobs are still pending...\n"); 378 // } 379 // // XXX can we mess up the memory? 380 // psImage *temp1 = psImageAlloc(image->numCols, image->numRows, PS_TYPE_F32); 381 // fprintf (stderr, "corruption check set 1\n"); 382 // psMemCheckCorruption (stderr, true); 383 // psImageInit (temp1, 2.0); 384 // psFree (temp1); 385 // fprintf (stderr, "corruption check set 2\n"); 386 // psMemCheckCorruption (stderr, true); 387 // } 388 389 // fprintf (stderr, "corruption check psFitsInsertImageWithMask\n"); 390 // psMemCheckCorruption (stderr, true); 391 392 psImage *out = psFitsScaleForDisk(image, fits, *bscale, *bzero, *boffset, *bsoften, rng); 393 return out; 374 394 } 375 395 … … 638 658 long blank = 0; // Blank (undefined) value for image 639 659 psFitsFloat floatType; // Custom floating-point convention type 640 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, image, 641 mask, maskVal, NULL, true); // Image to write out 660 661 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, 662 fits, image, mask, maskVal, NULL, true); // Image to write out 663 642 664 if (!diskImage) { 643 665 psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format."); … … 666 688 goto INSERT_DONE; 667 689 } 690 668 691 if (cfitsioBzero != 0.0) { 669 692 psAssert(bzero == 0.0 && bscale == 1.0, … … 840 863 } 841 864 } 865 842 866 if (psFitsError(status, true, "Could not write image to file.")) { 843 867 success = false; … … 856 880 INSERT_DONE: 857 881 psFree(diskImage); 882 858 883 if (compress) { 859 884 // Restore compression state … … 906 931 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, input, 907 932 mask, maskVal, NULL, false); // Image to write out 933 908 934 if (!diskImage) { 909 935 psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format."); … … 932 958 goto UPDATE_DONE; 933 959 } 960 934 961 if (cfitsioBzero != 0.0) { 935 962 psAssert(bzero == 0.0 && bscale == 1.0, … … 979 1006 goto UPDATE_DONE; 980 1007 } 981 1008 982 1009 // We only want cfitsio to do the scale and zero if the type conversion requires it (e.g., input type is 983 1010 // an unsigned integer type). In all other cases, we have already converted the image to use the
Note:
See TracChangeset
for help on using the changeset viewer.
