Hello,
I’ve been trying a simple example with a fits file like this:
from astropy import wcs
from astropy.io import fits
# Load the FITS hdulist using astropy.io.fits
hdulist = fits.open('abell.fits')
# Parse the WCS keywords in the primary HDU
w = wcs.WCS(hdulist[0].header)
# Print out the "name" of the WCS, as defined in the FITS header
print(w.wcs.name)
# Print out all of the settings that were parsed from the header
w.wcs.print_contents()
And I get an error:
ValueError Traceback (most recent call last)
Cell In[34], line 8
5 hdulist = fits.open('abell.fits')
7 # Parse the WCS keywords in the primary HDU
----> 8 w = wcs.WCS(hdulist[0].header)
10 # Print out the "name" of the WCS, as defined in the FITS header
11 print(w.wcs.name)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\astropy\wcs\wcs.py:612, in WCS.__init__(self, header, fobj, key, minerr, relax, naxis, keysel, colsel, fix, translate_units, _do_set)
609 self.fix(translate_units=translate_units)
611 if _do_set:
--> 612 self.wcs.set()
614 for fd in close_fds:
615 fd.close()
ValueError: ERROR 5 in wcsset() at line 2775 of file cextern\wcslib\C\wcs.c:
Invalid parameter value.
ERROR 4 in linset() at line 737 of file cextern\wcslib\C\lin.c:
Failed to initialize distortion functions.
ERROR 3 in dssset() at line 2697 of file cextern\wcslib\C\dis.c:
Coefficient scale for DSS on axis 1 is zero..
Part of my fits header:
OBJCTRA = '16 35 53.453 ' /Object Right Ascension (J2000)
OBJCTDEC= '+66 14 01.11 ' /Object Declinaison (J2000)
RA = 2.48972721654300130E+002 /Telescope RA
DEC = 6.62336441336017145E+001 /Telescope DEC
CRVAL1 = 2.48972721654300130E+002 /approx coord. in RA
CRVAL2 = 6.62336441336017145E+001 /approx coord. in DEC
CDELT1 = 2.57895481677548606E-004 /ScaleX in deg/pix
CDELT2 = 2.57895481677548606E-004 /ScaleY in deg/pix
Any idea how to remedy this?
As an update, I solved the image using astrometry.net and downloaded the new fits file with all WCS data added.
Still doesn’t work.
from astropy import wcs
from astropy.io import fits
# Load the FITS hdulist using astropy.io.fits
img = fits.open('abell_solved_wcs.fits')
# Parse the WCS keywords in the primary HDU
w = wcs.WCS(img[0].header,img)
Error:
ValueError: ERROR 5 in wcsset() at line 2775 of file cextern\wcslib\C\wcs.c:
Invalid parameter value.
ERROR 4 in linset() at line 737 of file cextern\wcslib\C\lin.c:
Failed to initialize distortion functions.
ERROR 3 in dssset() at line 2697 of file cextern\wcslib\C\dis.c:
Coefficient scale for DSS on axis 1 is zero..