Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing PC header values #9572

Open
drlaw1558 opened this issue Nov 8, 2019 · 1 comment
Open

Missing PC header values #9572

drlaw1558 opened this issue Nov 8, 2019 · 1 comment

Comments

@drlaw1558
Copy link

Description

Per the documentation at http://docs.astropy.org/en/latest/api/astropy.wcs.WCS.html#astropy.wcs.WCS.to_header
it seems like astropy wcs does not write out PC matrix header keywords when they differ from the unit matrix.

This can sometimes cause undesirable behaviour when reading in FITS files produced with astropy using other languages. The well-established extast.pro routine (part of the Goddard IDL library) for instance assumes a default value of zero for non-specified keywords. Since this has been the cornerstone of FITS WCS in IDL for many years it is integral to many data pipelines (e.g., SDSS MaNGA/eBOSS).

Expected behavior

Given a FITS file produced by astropy I would expect full WCS information to be attached in an unambiguous manner (i.e., not skipping keywords) such that they can be properly interpreted by other standard FITS libraries.

Actual behavior

Given a FITS file with CRPIX values outside the actual image footprint, and a PC matrix in which only PC1_1=-1 is provided, astropy routines assume that PC2_2=1 and correctly compute the RA/DEC values for any given pixel. IDL libraries however assume that PC2_2=0 and can return RA/DEC values that are in error by a degree or more. Simply adding PC2_2=1 to the header keywords completely fixes the issue.

Steps to Reproduce

No example steps provided, since the issue is the lack of keywords provided by astropy and the failure occurs when reading these files with other languages.

# Put your Python code snippet here.

System Details

Darwin-17.7.0-x86_64-i386-64bit
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
[Clang 4.0.1 (tags/RELEASE_401/final)]
Numpy 1.17.2
Scipy 1.3.1
astropy 4.0.dev25510

@nden
Copy link
Contributor

nden commented Nov 9, 2019

I would argue that the output header is already defined in an unambiguous manner. It uses the correct defaults defined by the FITS standard which also states that keywords with default values can be skipped.

astropy.wcs is creating a header from the corresponding routine in wcslib:

https://github.com/astropy/astropy/blob/master/cextern/wcslib/C/wcshdr.h#L1050

We can add the keywords in astropy.wcs.to_header but given that extast.pro is clearly not doing the correct thing why not fix the problem there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants