An issue in the HDU header information created by astropy.io.fits.GroupsHDU seen at least after v3.2.1
See original GitHub issueIt seems that the recent updates in astropy.io.fits cause some bugs in the generation of the GroupHDU’s header at astropy.io.fits.GroupsHDU.
Here, I would show what I got if I typed the example commands in the documentation. For this particular run, I’m using Python 3.7.3 in Anaconda 2019-7 installed from pyenv.
>>> import astropy
>>> astropy.version.version
'3.2.1'
>>> import numpy as np
>>> from astropy.io import fits
>>> imdata = np.arange(150.0).reshape(10, 1, 1, 3, 5)
>>> pdata1 = np.arange(10) + 0.1
>>> pdata2 = 42
>>> x = fits.GroupData(imdata, bitpix=-32,parnames=['abc', 'xyz', 'xyz'],pardata=[pdata1, pdata2, pdata2])
>>> hdu = fits.GroupsHDU(x)
>>> hdu.header
SIMPLE = T / conforms to FITS standard
BITPIX = 8 / array data type
NAXIS = 1 / number of array dimensions
NAXIS1 = 0
EXTEND = T
GROUPS = T / has groups
PCOUNT = 0 / number of parameters
GCOUNT = 1 / number of groups
Compared with the documentation, you can see that information of random parameters (PCOUNT, PTYPEX) is not correctely reflected in the header information.
I haven’t seen this issue at least until version “3.1” which I am using in another pc. Thus, it should be attributed to recent updates in astropy.io.fits module after this version. Here are the outputs for this particular version, which are consistent with the documentation.
>>> import astropy
>>> astropy.version.version
'3.1'
>>> import numpy as np
>>> from astropy.io import fits
>>> imdata = np.arange(150.0).reshape(10, 1, 1, 3, 5)
>>> pdata1 = np.arange(10) + 0.1
>>> pdata2 = 42
>>> x = fits.GroupData(imdata, bitpix=-32,parnames=['abc', 'xyz', 'xyz'],pardata=[pdata1, pdata2, pdata2])
>>> hdu = fits.GroupsHDU(x)
>>> hdu.header
SIMPLE = T / conforms to FITS standard
BITPIX = -32 / array data type
NAXIS = 5 / number of array dimensions
NAXIS1 = 0
NAXIS2 = 5
NAXIS3 = 3
NAXIS4 = 1
NAXIS5 = 1
EXTEND = T
GROUPS = T / has groups
PCOUNT = 3 / number of parameters
GCOUNT = 10 / number of groups
PTYPE1 = 'abc '
PTYPE2 = 'xyz '
PTYPE3 = 'xyz '
I believe this is not a critical issue, but it may cause a bug for many (radio) astronomy software packages handling popular uvfits formats. Indeed, I saw this was causing a problem in some radio astronomy software packages. I would appreciate if the function can be fixed.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@saimn Thank you very much! I confirmed that this indeed solved the issue.
@pllim Sure. Although I’m not sure if I can find the solution easily, I can take a look at source codes.