WCS.dropaxis() does not update "NAXIS" keyword
See original GitHub issueWhen working with WCS.dropaxis()
I’ve encountered the following issue:
from astropy.io import fits
from astropy.wcs import WCS
# Define an example WCS reference header
header = fits.Header()
header['WCSAXES'] = 3
header['NAXIS'] = 3
header['NAXIS1'] = 100
header['NAXIS2'] = 100
header['NAXIS3'] = 3
header['CRPIX1'] = 100.5
header['CRPIX2'] = 100.5
header['CRPIX3'] = 0.5
header['CDELT1'] = -0.02
header['CDELT2'] = 0.02
header['CDELT3'] = 0.2
header['CTYPE1'] = 'RA---CAR'
header['CTYPE2'] = 'DEC--CAR'
header['CTYPE3'] = 'ENER-LOG'
header['CRVAL1'] = 0
header['CRVAL2'] = 0
header['CRVAL3'] = 1
wcs = WCS(header)
print(repr(wcs))
Returns:
WCS Keywords
Number of WCS axes: 3
CTYPE : 'RA---CAR' 'DEC--CAR' 'EN-LOG'
CRVAL : 0.0 0.0 1.0
CRPIX : 100.5 100.5 0.5
PC1_1 PC1_2 PC1_3 : 1.0 0.0 0.0
PC2_1 PC2_2 PC2_3 : 0.0 1.0 0.0
PC3_1 PC3_2 PC3_3 : 0.0 0.0 1.0
CDELT : -0.02 0.02 0.2
NAXIS : 100 100 3
If I now drop the third axis using wcs.dropaxis()
:
wcs = wcs.dropaxis(2)
print(repr(wcs))
print(wcs._naxis)
The axis is dropped correctly, however it is still present in the "NAXIS"
keyword of the repr
:
WCS Keywords
Number of WCS axes: 2
CTYPE : 'RA---CAR' 'DEC--CAR'
CRVAL : 0.0 0.0
CRPIX : 100.5 100.5
PC1_1 PC1_2 : 1.0 0.0
PC2_1 PC2_2 : 0.0 1.0
CDELT : -0.02 0.02
NAXIS : 100 100 3
[100, 100, 3]
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
WCS — Astropy v5.2
Extracts specific coordinate axes using sub() . If a header is provided, and naxis is not None , naxis will be passed to...
Read more >WCS — Astropy v1.0.4
Extracts specific coordinate axes using sub(). If a header is provided, and naxis is not None, naxis will be passed to sub() in...
Read more >STWCS Documentation - Read the Docs
This package provides support for WCS based distortion models and ... Normally all_world2pix() may not achieve the required accuracy if ...
Read more >WCS object trouble in changing coordinates with astropy 4.0
My code was working before I have update both python (now python 3.7.1) and ... wcs WCS Keywords Number of WCS axes: 4...
Read more >2. Reading IRIS files — A low-level guide to IRIS with Python
The IRIS level 2 FITS files are the standard science data product, and can be ... We do wcs.dropaxis(-1) because we do not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think we have any planned 4.x releases no more, so it is okay if you cannot test on 4.x. Thanks!
Hello, I have checked the snippet of code with the development version
And the output is
It looks to me that the problem is now solved, but I don’t know the code enough to understand when and where this was fixed.