question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

An issue in the HDU header information created by astropy.io.fits.GroupsHDU seen at least after v3.2.1

See original GitHub issue

It 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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kazuakiyamacommented, Sep 12, 2019

@saimn Thank you very much! I confirmed that this indeed solved the issue.

1reaction
kazuakiyamacommented, Sep 2, 2019

@pllim Sure. Although I’m not sure if I can find the solution easily, I can take a look at source codes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Header Data Unit — Astropy v5.2
Header Data Units are the fundamental container structure of the FITS format consisting of a data member and its associated metadata in a...
Read more >
astropy.io.fits History
Fixed an issue where header wildcard matching (for example header['DATE*'] ) can be used to match any characters that might appear in a...
Read more >
FITS File Handling (astropy.io.fits)
The open function returns an object called an HDUList which is a list -like collection of HDU objects. An HDU (Header Data Unit)...
Read more >
FITS Headers — Astropy v5.2
When an HDU is created with a constructor (e.g., hdu = PrimaryHDU(data, header) ), the user may supply the header value from an...
Read more >
Source code for astropy.io.fits.hdu.groups
Licensed under a 3-clause BSD style license - see PYFITS.rst import sys import numpy as np from astropy.io.fits.column import FITS2NUMPY, ColDefs, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found