Cropping

cwitools.reduction.crop(inputfits, xcrop=None, ycrop=None, wcrop=None)

Crops an input data cube (FITS).

Parameters:
  • inputfits (astropy.io.fits.HDUList) – FITS file to be trimmed.
  • xcrop (int tuple) – Indices of range to crop x-axis to. Default: None.
  • ycrop (int tuple) – Indices of range to crop y-axis to. Default: None.
  • wcrop (int tuple) – Wavelength range (A) to crop cube to. Default: None.
Returns:

Trimmed FITS object with updated header.

Return type:

astropy.io.fits.HDUList

Examples

The parameter wcrop (wavelength crop) is in Angstrom, so to crop a data cube to the wavelength range 4200-4400A ,the usage would be:

>>> from astropy.io import fits
>>> from cwitools.reduction import crop
>>> myfits = fits.open("mydata.fits")
>>> myfits_cropped = crop(myfits,wcrop=(4200,4400))

Crop ranges for the x/y axes are given in image coordinates (px). They can be given either as straight-forward indices:

>>> crop(myfits, xcrop=(10,60))

Or using negative numbers to count backwards from the last index:

>>> crop(myfits, ycrop=(10,-10))