Created
April 21, 2014 20:00
-
-
Save cdeil/11154616 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| from astropy.io import fits | |
| def test(filename='test.fits'): | |
| noise = np.random.normal(size=(1000, 1000)) | |
| chdu1 = fits.CompImageHDU(data=noise, compressionType='GZIP_1') | |
| # First make a test image with lossy compression and make sure it | |
| # wasn't compressed perfectly. This shouldn't happen ever, but just to | |
| # make sure the test non-trivial. | |
| chdu1.writeto(filename, clobber=True) | |
| with fits.open(filename) as h: | |
| assert np.abs(noise - h[1].data).max() > 0.0 | |
| del h | |
| chdu2 = fits.CompImageHDU(data=noise, compressionType='GZIP_1', | |
| quantizeLevel=0.0) # No quantization | |
| #with ignore_warnings(): | |
| chdu2.writeto(filename, clobber=True) | |
| with fits.open(filename) as h: | |
| assert (noise == h[1].data).all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment