- Timestamp:
- Jul 17, 2014, 12:36:19 PM (12 years ago)
- Location:
- branches/eam_branches/ipp-ops-20130712
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psLib/src/fits/psFitsImage.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-ops-20130712
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-ops-20130712/psLib/src/fits/psFitsImage.c
r33645 r37068 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, … … 753 776 } 754 777 778 // If there is no options set, remove all our non-standard keywords, because no one asked for them. 779 if (!options) { 780 if (psMetadataLookup(header,"BOFFSET")) { 781 psMetadataRemoveKey(header,"BOFFSET"); 782 } 783 if (psMetadataLookup(header,"BSOFTEN")) { 784 psMetadataRemoveKey(header,"BSOFTEN"); 785 } 786 } 787 755 788 // write the header, if any. 756 789 if (header && !psFitsWriteHeaderImage(fits, header, createPHU)) { … … 830 863 } 831 864 } 865 832 866 if (psFitsError(status, true, "Could not write image to file.")) { 833 867 success = false; … … 846 880 INSERT_DONE: 847 881 psFree(diskImage); 882 848 883 if (compress) { 849 884 // Restore compression state … … 896 931 psImage *diskImage = imageToDiskRepresentation(&bscale, &bzero, &boffset, &bsoften, &blank, &floatType, fits, input, 897 932 mask, maskVal, NULL, false); // Image to write out 933 898 934 if (!diskImage) { 899 935 psError(PS_ERR_UNKNOWN, false, "Unable to convert image to desired disk format."); … … 922 958 goto UPDATE_DONE; 923 959 } 960 924 961 if (cfitsioBzero != 0.0) { 925 962 psAssert(bzero == 0.0 && bscale == 1.0, … … 969 1006 goto UPDATE_DONE; 970 1007 } 971 1008 972 1009 // We only want cfitsio to do the scale and zero if the type conversion requires it (e.g., input type is 973 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.
