Problem using WCS.pixel_to_world with WCS tab file
See original GitHub issueDescription
I am trying to use astropy to read a FITS file produced by the SSTRED pipeline from data taken at the Swedish 1-m Solar Telescope. The data can be read ok, but I have some trouble with the WCS object when trying to run operations such as pixel_to_world
.
Expected behavior
When running w.pixel_to_world()
, I expected to get an array with the world coordinates. Instead, I get an error.
Steps to Reproduce
Here is a minimal WCS header extracted from the actual object (original file is too large):
WCSAXES = 5 / Number of coordinate axes
CRPIX1 = 0.0 / Pixel coordinate of reference point
CRPIX2 = 0.0 / Pixel coordinate of reference point
CRPIX3 = 0.0 / Pixel coordinate of reference point
CRPIX4 = 1.0 / Pixel coordinate of reference point
CRPIX5 = 0.0 / Pixel coordinate of reference point
CDELT1 = 1.0 / [arcsec] Coordinate increment at reference poin
CDELT2 = 1.0 / [arcsec] Coordinate increment at reference poin
CDELT3 = 1.0 / [nm] Coordinate increment at reference point
CDELT4 = 1.0 / Coordinate increment at reference point
CDELT5 = 1.0 / [s] Coordinate increment at reference point
CUNIT1 = 'arcsec' / Units of coordinate increment and value
CUNIT2 = 'arcsec' / Units of coordinate increment and value
CUNIT3 = 'nm' / Units of coordinate increment and value
CUNIT5 = 's' / Units of coordinate increment and value
CTYPE1 = 'HPLN-TAB' / Coordinate type codeundefined projection
CTYPE2 = 'HPLT-TAB' / Coordinate type codeundefined projection
CTYPE3 = 'WAVE-TAB' / Vacuum wavelength
CTYPE4 = 'STOKES' / Coordinate type code
CTYPE5 = 'UTC--TAB' / Coordinate type code
CRVAL1 = 0.0 / [arcsec] Coordinate value at reference point
CRVAL2 = 0.0 / [arcsec] Coordinate value at reference point
CRVAL3 = 0.0 / [nm] Coordinate value at reference point
CRVAL4 = 1.0 / Coordinate value at reference point
CRVAL5 = 0.0 / [s] Coordinate value at reference point
PV1_3 = 1.0 / [deg] alias for LONPOLE (has precedence)
PV2_3 = 2.0 / projection parameter
PV3_3 = 3.0 / Coordinate transformation parameter
PV5_3 = 4.0 / Coordinate transformation parameter
PS1_0 = 'WCS-TAB ' / Coordinate transformation parameter
PS1_1 = 'HPLN+HPLT+WAVE+TIME' / Coordinate transformation parameter
PS1_2 = 'HPLN-INDEX' / Coordinate transformation parameter
PS2_0 = 'WCS-TAB ' / Coordinate transformation parameter
PS2_1 = 'HPLN+HPLT+WAVE+TIME' / Coordinate transformation parameter
PS2_2 = 'HPLT-INDEX' / Coordinate transformation parameter
PS3_0 = 'WCS-TAB ' / Coordinate transformation parameter
PS3_1 = 'HPLN+HPLT+WAVE+TIME' / Coordinate transformation parameter
PS5_0 = 'WCS-TAB ' / Coordinate transformation parameter
PS5_1 = 'HPLN+HPLT+WAVE+TIME' / Coordinate transformation parameter
LATPOLE = 90.0 / [deg] Native latitude of celestial pole
CNAME1 = 'Spatial X' / Axis name for labelling purposes
CNAME2 = 'Spatial Y' / Axis name for labelling purposes
CNAME3 = 'Wavelength' / Axis name for labelling purposes
CNAME5 = 'Time since DATEREF, increases with dim. 3 and 5' / Axis name for labe
CSYER1 = 60.0 / [arcsec] Systematic error in coordinate
CSYER2 = 60.0 / [arcsec] Systematic error in coordinate
TIMESYS = 'UTC' / Time scale
DATEREF = '2021-06-22T00:00:00.000000' / ISO-8601 fiducial time
MJDREF = 59387.0 / [d] MJD of fiducial time
DATE-OBS= '2021-06-22T16:10:31' / ISO-8601 time of observation
MJD-OBS = 59387.673969907 / [d] MJD of observation
DATE-BEG= '2021-06-22T16:10:33.61340' / ISO-8601 time at start of observation
MJD-BEG = 59387.674000155 / [d] MJD at start of observation
DATE-AVG= '2021-06-22T16:18:47.91310' / ISO-8601 time at midpoint of observation
MJD-AVG = 59387.679721216 / [d] MJD at midpoint of observation
DATE-END= '2021-06-22T16:27:36.28459' / ISO-8601 time at end of observation
MJD-END = 59387.685836627 / [d] MJD at end of observation
XPOSURE = 0.180015 / [s] Exposure (integration) time
OBSGEO-X= 5327403.0 / [m] observatory X-coordinate
OBSGEO-Y= -1718726.0 / [m] observatory Y-coordinate
OBSGEO-Z= 3051730.0 / [m] observatory Z-coordinate
NOTE: with only this header the WCS will be missing the -TAB data.
If I put that into an WCS object called w
, the first try is:
w.pixel_to_world(1, 1, 1, 1, 1)
This fails with an error:
NotImplementedError: SPECSYS= not yet supported
This seems to be an error with the original file, it is missing the SPECSYS
keyword adding it manually, I can proceed a little longer:
w.wcs.specsys = 'TOPOCENT'
w.pixel_to_world(1, 1, 1, 1, 1)
Fails with:
ValueError: Unrecognized time CTYPE=UTC--TAB
I thought maybe the error was the double dash, so I did:
w.wcs.ctype[-1] = 'UTC-TAB'
w.pixel_to_world(1, 1, 1, 1, 1)
and then I get:
InconsistentAxisTypesError: ERROR 4 in wcs_types() at line 3074 of file cextern/wcslib/C/wcs.c:
Table parameters set for non-table axis type.
System Details
Linux-3.10.0-1127.19.1.el7.x86_64-x86_64-with-glibc2.10
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0]
Numpy 1.20.2
astropy 4.3.1
Scipy 1.6.2
Matplotlib 3.4.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
I also would like to add that currently time axis does not work well with -TAB due to a bug in WCSLIB. I am not sure what are all the consequences of the bug but selecting temporal axis using
sub
may not work as expected.This was reported upstream a few months ago.
it works 🥳