I have three WCS axes in a FITS image. I want to slice the axes and use only the first one. Note that though there are three axes, the WCS is superimposable. So there is no worry about a shift in WCS due to my selection of a particular axis.

I am attaching the description of WCS axes as well.

Number of WCS axes: 3
CTYPE : 'RA---TAN'  'DEC--TAN'  ''  
CRVAL : 181.6023  63.6321  0.0  
CRPIX : 128.5  128.5  0.0  
CD1_1 CD1_2 CD1_3  : -0.000138888888888889  0.0  0.0  
CD2_1 CD2_2 CD2_3  : 0.0  0.000138888888888889  0.0  
CD3_1 CD3_2 CD3_3  : 0.0  0.0  1.0  
NAXIS : 256  256  3

1 Answer 1


I'm not sure what your end goal is, but I think your easiest option is to use astropy.

import astropy.io.fits
import astropy.wcs

hdu_list = astropy.io.fits.open("/path/to/your/file.fits")

# Assuming your WCS header is the first header in the file
header = hdu_list[0].header

# Construct the WCS object
wcs = astropy.wcs.WCS(header)

# Drop the last two axes
wcs_new = WCS.dropaxis(2).dropaxis(1)


Lots more information can be found on the documentation for astropy.wcs

  • $\begingroup$ Thank you Roy. I was using astropy. I managed to just call the first array of WCS and use it for further analysis. $\endgroup$ Jan 25 at 4:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .