cwitools.coordinates.get_header1d

cwitools.coordinates.get_header1d(header3d)

Remove the spatial axes from a a 3D FITS Header.

Parameters:header3d (astropy.io.fits.Header) – Input 3D header.
Returns:1D Header object (wavelength axis only).
Return type:astropy.io.fits.Header

Example

If you wanted to collapse a cube to a spectrum and save it:

>>> from astropy.io import fits
>>> from cwitools import cubes
>>> import numpy as np
>>> mydata,header = fits.getdata("mydata.fits",header=True)
>>> myspec_data = np.sum(mydata,axis=(1,2)) #Sum over spatial axes
>>> myspec_header = cubes.get_header1d(header)
>>> myspec_fits = cubes.make_fits(myspec_data,myspec_header)
>>> myspec_fits.writeto("myspec.fits")

Note: example does not properly handle any physical unit conversion!