Trouble Returning WCS from FITS Image

68 Views Asked by At

I am using astropy to load a FITS image and retrieve the WCS from it.

from astropy.io import fits
from astropy.wcs import WCS

with fits.open('hst_A2744_f606w_drz.fits') as hdul:
    wcs = WCS(hdul[1])
    print(wcs)

Which Returns

WCS Keywords

Number of WCS axes: 2
CTYPE : 'RA---TAN'  'DEC--TAN'
CRVAL : 3.587755699764648  -30.39711750881429
CRPIX : 3000.4999999998081  2989.499999999809
CD1_1 CD1_2  : -1.3888888888888e-05  0.0
CD2_1 CD2_2  : 0.0  1.3888888888889599e-05
NAXIS : 6000  5978

My goal is to return CRVAL as either a string, tuple, or array like this: (3.587755699764648, -30.39711750881429)

I've tried accessing it as wcs['CTYPE'] and wcs[CTYPE], and wcs.CTYPE but all return errors.

1

There are 1 best solutions below

0
On

You want WCS.wcs

and specifically WCS.wcs.crval (or WCS.wcs.ctype since in your question you wrote you want the CRVAL values but you showed attempts to find the CTYPE values).