1

I tried a simple example in astropy, like the one bellow:

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()

It errors with the following info:

--------------------------------------------------------------------------
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..

My fits file contains this data for wcs:

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

Can't tell what the problem is. From what I learned, CRVAL and CDELT should be enough, but maybe I'm missing some info in the fits header.

Adrian
  • 177
  • 9

0 Answers0