cwitools.extraction.cutout

cwitools.extraction.cutout(fits_in, pos, box_size, redshift=None, fill=0, unit='px', pos_type='img', cosmo=FlatLambdaCDM(name="WMAP9", H0=69.3 km / (Mpc s), Om0=0.286, Tcmb0=2.725 K, Neff=3.04, m_nu=[0. 0. 0.] eV, Ob0=0.0463))

Extract a spatial box around a central position from 2D or 3D data.

Returned data has same dimensions as input data. Return type (HDU/HDUList) also matches input type. First HDU is used if input is HDUList.

Parameters:
  • fits_in (astropy HDU or HDUList) – HDU or HDUList with 2D or 3D data.
  • pos (float tuple) – Center of cutout, given as (axis0, axis1) coordinate by default (if pos_type is set to’image’) or as an (RA,DEC) tuple, if pos_type is set to ‘radec’
  • box_size (float) – The size of the box, in units determined by `unit’.
  • redshift (float) – Cosmological redshift of the source. Required to get conversion to units of kiloparsec.
  • fill (string) – The fill value for box regions outside the image bounds. Default: 0.
  • unit (str) – The unit of the box_size argument ‘px’ - pixels ‘arcsec’ - arcseconds ‘pkpc’ - proper kiloparsecs (requires redshift) ‘ckpc’ - comoving kiloparsecs (requires redshift)
  • pos_type (str) – The type of coordinate given for the ‘pos’ argument. ‘radec’ - a tuple of (RA, DEC) coordinates, in decimal degrees ‘image’ - a tuple of image coordinates, in pixels
Returns:

HDU or HDUList The FITS with cutout data and header.

Examples

To extract a 2D region of size 250x250 pkpc^2 around the QSO from a pseudo-Narrowband image:

>>> from cwitools import imaging
>>> from cwitools import parameters
>>> from astropy.io import fits
>>> qso_nb_fits = fits.open("QSO_123.fits")
>>> target_params = parameters.load_params("QSO_123.param")
>>> qso_cutout = extraction.get_cutout(qso_nb_fits, target_params, 250)

This method assumes a 1:1 aspect ratio for the spatial axes of the input.