aperiosoftware / astropy

Repository for the Astropy core package
www.astropy.org
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Report fitsio issues upstream #41

Open astrofrog opened 2 years ago

astrofrog commented 2 years ago

In the test suite we currently skip some tests due to issues in fitsio - we should report these upstream if possible.

astrofrog commented 2 years ago

Here is an issue I encountered but not clear if this is an astropy or fitsio issue:

import os
import fitsio
import numpy as np

os.remove('test.fits')

data = np.random.random((15, 15))

fts1 = fitsio.FITS('test.fits', 'rw')
fts1.write(data, compress='HCOMPRESS_1', qlevel=20, qmethod=2, tile_dims=(5, 5))

from astropy.io import fits
print(fits.open('test.fits', disable_image_compression=True)[1].data)

gives:

[([221, 153,   0,   0,   0,   5,   0,   0,   0,   5,   0,   0,   0,   0, 255, 255, 255, 248,   0,   0,   3, 224,   8,   8,   6, 246, 191, 173,  31, 166,   1,  43,  32,  18,  18,  60, 223, 253, 255, 123,   1,   8,  23, 128, 152,  30, 128,  72,  10, 159, 247, 252,  24,  94, 171, 220, 131, 144,  37,   2, 151, 253, 245, 243, 254, 251, 241, 250,   0,  64,  98,  22], 0.00956831, 20547788.20710866)
etc.

The last value is ZZERO and is huge. Changing qmethod to 1 (which is identical except for its treatment of zeros which there are none of here) gives:

[([221, 153,   0,   0,   0,   5,   0,   0,   0,   5,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   2,  80,   8,   7,   6, 250,  81, 255, 127, 192, 161, 145, 225, 254, 155, 240, 255, 224,  20,   8, 128, 120,  12, 192, 208,   6, 207, 248,  16, 191, 224,  34,   5, 128,  88,   9,  15, 251, 235, 235, 199, 251, 215, 192,   0,  32,   1,  14], 0.01499177, 0.01499177)