cwitools.extraction.bg_sub

cwitools.extraction.bg_sub(inputfits, method='polyfit', poly_k=1, median_window=31, wmasks=None, mask_reg=None, var=None)

Subtracts extended continuum emission / scattered light from a cube

Parameters:
  • inputfits (Astropy HDUList) – FITS object 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.
  • wmasks (int tuple) – Wavelength regions to exclude from white-light images.
  • mask_reg (str) – Path to a DS9 region file to use to exclude regions when using ‘median’ method of bg subtraction.
  • var (numpy.ndarray) – Variance cube associated with input data. NOTE: Variance is only formally propagated for ‘polyfit’. For other methods, the input variance is re-scaled empirically using reduction.variance.scale_variance.
Returns:

Background-subtracted cube numpy.ndarray: Cube containing background model which was subtracted. numpy.ndarray: (if var provided) Cube containing updated variance estimate

Return type:

numpy.ndarray