cwitools.coordinates.get_header2d

cwitools.coordinates.get_header2d(header3d)

Remove the spectral axis from a 3D FITS Header

Parameters:header3d (astropy.io.fits.Header) – Input 3D header.
Returns:2D Header object (spatial axes only)
Return type:astropy.io.fits.Header

Example

If you wanted to collapse a cube to a 2D image and save it:

>>> from astropy.io import fits
>>> from cwitools import cubes
>>> import numpy as np
>>> mydata,header = fits.getdata("mydata.fits",header=True)
>>> image_data = np.sum(mydata,axis=(0)) #Sum over wavelength
>>> image_header = cubes.get_header2d(header)
>>> image_fits = cubes.make_fits(image_data,image_header)
>>> image_fits.writeto("image2D.fits")

Note again - this example doesn’t convert to surface-brightness or do any proper handling of units. That’s up to you!