cwitools.subtraction.bg_sub¶
-
cwitools.subtraction.bg_sub(inputfits, method='polyfit', poly_k=1, median_window=31, zmasks=[(0, 0)], zunit='A')¶ Subtracts extended continuum emission / scattered light from a cube
- Args:
cubePath (str): Path to the data cube to be subtracted. method (str): Which method to use to model background
‘polyfit’: Fits polynomial to the spectrum in each spaxel (default.) ‘median’: Subtract the spatial median of each wavelength layer. ‘medfilt’: Model spectrum in each spaxel by median filtering it. ‘noiseFit’: Model noise in each z-layer and subtract mean.poly_k (int): The degree of polynomial to use for background modeling. median_window (int): The filter window size to use if median filtering. zmask (int tuple): Wavelength region to mask, given as tuple of indices. zunit (str): If using zmask, indices are given in these units.
‘A’: Angstrom (default) ‘px’: pixelssaveModel (bool): Set to TRUE to save background model cube. fileExt (str): File extension to use for output (Default: .bs.fits)
- Returns:
- NumPy.ndarray: Background-subtracted cube NumPy.ndarray: Cube containing background model which was subtracted.
Examples:
To model the background with 1D polynomials for each spaxel’s spectrum, using a quadratic polynomial (k=2):
>>> from cwitools import bg_subtract >>> from astropy.io import fits >>> myfits = fits.open("mydata.fits") >>> bgsub_cube, bgmodel_cube = bg_subtract(myfits, method='polfit', poly_k=2)