cwitools.extraction.psf_sub_all

cwitools.extraction.psf_sub_all(inputfits, r_fit=1.5, r_sub=5.0, reg=None, pos=None, recenter=True, auto=7, wl_window=200, wmasks=None, var_cube=None, maskpsf=False)

Models and subtracts multiple point-sources in a 3D data cube.

Parameters:
  • inputfits (astrop FITS object) – Input data cube/FITS.
  • r_fit (float) – Inner radius, in arcsec, used for fitting PSF.
  • r_sub (float) – Outer radius, in arcsec, used to subtract PSF.
  • reg (str) – Path to a DS9 region file containing sources to subtract.
  • pos (float tuple) – Position of the source to subtract.
  • auto (float) – SNR above which to automatically detect/subtract sources. Note: One of the parameters reg, pos, or auto must be provided.
  • wl_window (int) – Size of white-light window (in Angstrom) to use. This is the window used to form a white-light image centered on each wavelength layer. Default: 200A.
  • wmasks (int tuple) – Wavelength regions to exclude from white-light images.
  • var_cube (numpy.ndarray) – Variance cube associated with input. Optional. Method returns propagated variance if given.
Returns:

PSF-subtracted data cube numpy.ndarray: PSF model cube numpy.ndarray: (if var_cube given) Propagated variance cube

Return type:

numpy.ndarray

Examples

To subtract point sources from an input cube using a DS9 region file:

>>> from astropy.io import fits
>>> from cwitools import psf_subtract
>>> myregfile = "mysources.reg"
>>> myfits = fits.open("mydata.fits")
>>> sub_cube, psf_model = psf_subtract(myfits, reg = myregfile)

To subtract using automatic source detection with photutils, and a source S/N ratio >5:

>>> sub_cube, psf_model = psf_subtract(myfits, auto = 5)

Or to subtract a single source from a specific location (x,y)=(21.1,34.6):

>>> sub_cube, psf_model = psf_subtract(myfits, pos=(21.1, 34.6))