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
Problem using WCS.pixel_to_world with WCS tab file #12095
Comments
Ah, trying to build the WCS from the header only raises the error File "/opt/lib/python3.9/site-packages/astropy/wcs/wcs.py", line 448, in __init__
tmp_wcsprm = _wcs.Wcsprm(header=tmp_header_bytes, key=key,
ValueError: HDUList is required to retrieve -TAB coordinates and/or indices. so you'll have to extract a minimal set of the Or could you try and insert in your astropy installation after the lines astropy/astropy/wcs/wcsapi/fitswcs.py Lines 587 to 589 in ed434a3
this code # Strip algorithm code
if '-' in scale:
scale, algorithm = scale.split('-')[0], scale.split('-')[-1]
warnings.warn(f'Ignoring unsupported algorithm '
f'{algorithm.upper()} for scale {scale.upper()}',
UserWarning) |
It took me a while but I finally managed to get one of these files in a much smaller size. I've placed them on this google drive folder.. The error should appear with both files (they have the same data, only one is transposed in the spectral/temporal dimension). In these example files the |
This seems to be an issue with the HighLevelWCS layer not the wcslib layer as this works:
|
So after a little investigation, I think the issue here is that this check: astropy/astropy/wcs/wcsapi/fitswcs.py Lines 659 to 660 in b6352e1
is not agnostic to the existence of |
@mcara , have you memorized the standards by now? 😆 |
it works 🥳 In [4]: w.pixel_to_world(0,0,0,0,0)
Out[4]:
[<SkyCoord (Helioprojective: obstime=2021-08-04T09:56:50.000, rsun=695700.0 km, observer=<HeliographicStonyhurst Coordinate (obstime=2021-08-04T09:56:50.000, rsun=695700.0 km): (lon, lat, radius) in (deg, deg, m)
(0.00174495, 6.02251189, 1.51772714e+11)>): (Tx, Ty) in arcsec
(244.35426644, 377.38281263)>,
<SpectralCoord
(observer: <ITRS Coordinate (obstime=59430.4188856662, location=(0., 0., 0.) km): (x, y, z) in m
(5327403., -1718726., 3051730.)
(v_x, v_y, v_z) in km / s
(0., 0., 0.)>
target: <Helioprojective Coordinate (obstime=2021-08-04T09:56:50.000, rsun=695700.0 km, observer=<HeliographicStonyhurst Coordinate (obstime=2021-08-04T09:56:50.000, rsun=695700.0 km): (lon, lat, radius) in (deg, deg, m)
(0.00174495, 6.02251189, 1.51772714e+11)>): (Tx, Ty, distance) in (arcsec, arcsec, kpc)
(0., 0., 1000.)
(d_Tx, d_Ty, d_distance) in (arcsec / s, arcsec / s, km / s)
(0., 0., 0.)>
observer to target (computed from above):
radial_velocity=-11980.853083640337 km / s
redshift=-0.03919626429118017)
485.92380808 nm>,
<Quantity 1.>,
<Time object: scale='utc' format='mjd' value=59430.41848821678>] |
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 This was reported upstream a few months ago. |
@mcara Using astropy 5.1.1, with the update above, still gives an error with the example files, but this time it is different:
Seems like it the value "UTC" should have been lowercased. If I try to set it to lowercase manually, I get yet a different error:
|
I think I fixed that in #13571 but it needs attention. |
Description
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):
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:This fails with an error:
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:Fails with:
I thought maybe the error was the double dash, so I did:
and then I get:
System Details
The text was updated successfully, but these errors were encountered: