cwitools.subtraction.psf_sub_all¶
-
cwitools.subtraction.psf_sub_all(inputfits, fit_rad=1.5, sub_rad=5.0, reg=None, pos=None, recenter=True, auto=7, wl_window=200, wmasks=[], slice_axis=2, method='2d', slice_rad=3)¶ Models and subtracts point-sources in a 3D data cube.
- Args:
inputfits (astrop FITS object): Input data cube/FITS. fit_rad (float): Inner radius, used for fitting PSF. sub_rad (float): Outer radius, used to subtract PSF. reg (str): Path to a DS9 region file containing sources to subtract. pos (float tuple): (x,y) 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.
- method (str): Method of PSF subtraction.
- ‘1d’: Subtract PSFs on slice-by-slice basis with 1D models. ‘2d’: Subtract PSFs using a 2D PSF model.
wmask (int tuple): Wavelength region to exclude from white-light images. slice_axis (int): Which axis represents the slices of the image.
For KCWI default data cubes, slice_axis = 2. For PCWI data cubes, slice_axis = 1. Only relevant if using 1d subtraction.- slice_rad (int): Number of slices from central slice over which to
- subtract PSF for each source when using 1d method. Default is 3.
- Returns:
- numpy.ndarray: PSF-subtracted data cube numpy.ndarray: PSF model cube
- Raises:
- FileNotFoundError: If region file is not found.
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))