wcs ValueError

169 views
Skip to first unread message

Mojtaba Namvar

unread,
Aug 15, 2021, 11:24:08 AM8/15/21
to astropy-dev

hello
I am trying the celestial coordinates of a pixel in an image processed by Astrometry.net. And when I try to implement the astropy.wcs .WCS function, I get the following error. Please advise what is the solution to this problem?

ValueError:
FITS WCS distortion paper lookup tables and SIP distortions only work
in 2 dimensions.  However, WCSLIB has detected 3 dimensions in the
core WCS keywords.  To use core WCS in conjunction with FITS WCS
distortion paper lookup tables or SIP distortion, you must select or
reduce these to 2 dimensions using the naxis kwarg.


Code I run in Python:

from astropy.wcs import WCS
from astropy.wcs import WCS
f = fits.open('new-image(2).fits')
w = WCS(f[0].header)
sky = w.pixel_to_world(30, 40)

Mojtaba Namvar

unread,
Aug 15, 2021, 4:02:12 PM8/15/21
to astropy-dev
This is my image url:


I tried to read astropy document but i can't understand how to fix it

John Swinbank

unread,
Aug 18, 2021, 11:52:31 AM8/18/21
to astropy-dev
Hi Mojtaba,

First of all, just to let you know that the astropy-dev mailing list is usually used for discussions of changes to the Astropy code itself, or for administrative discussion or announcements. You might have more luck with questions like this on the Users mailing list. Check out https://www.astropy.org/help.html for some pointers.

That said, I think the solution here is just that you want to tell Astropy to use the first two axes defined in your FITS file for the WCS. The following seems to work for me:

>>> from astropy.io import fits
>>> from astropy.wcs import WCS
>>> f = fits.open('new-image.fits')
>>> w = WCS(f[0].header, naxis=2)
>>> w.pixel_to_world(30, 40)
<SkyCoord (FK5: equinox=2000.0): (ra, dec) in deg
(308.05685016, 70.03994458)>

Hope that helps,

John
> --
> You received this message because you are subscribed to the Google Groups "astropy-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to astropy-dev...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/astropy-dev/dc1c771b-ad9c-4dd9-a8cc-da8a86cb324fn%40googlegroups.com.
signature.asc

Mojtaba Namvar

unread,
Aug 18, 2021, 6:00:27 PM8/18/21
to astropy-dev
Thank You so much
Reply all
Reply to author
Forward
0 new messages