99from astropy .stats import sigma_clip
1010from astropy .utils .decorators import deprecated_attribute
1111
12- from specreduce . compat import SPECUTILS_LT_2 , Spectrum
12+ from specutils import Spectrum
1313from specreduce .core import _ImageParser , MaskingOption , ImageLike
1414from specreduce .extract import _ap_weight_image
1515from specreduce .tracing import Trace , FlatTrace
@@ -375,12 +375,9 @@ def bkg_image(self, image=None) -> Spectrum:
375375 self ._orig_uncty_type
376376 )
377377
378- if SPECUTILS_LT_2 :
379- kwargs = {}
380- else :
381- kwargs = {"spectral_axis_index" : arr .ndim - 1 }
382378 return Spectrum (
383- arr * image .unit , spectral_axis = image .spectral_axis , uncertainty = uncertainty , ** kwargs
379+ arr * image .unit , spectral_axis = image .spectral_axis , uncertainty = uncertainty ,
380+ spectral_axis_index = arr .ndim - 1
384381 )
385382
386383 def bkg_spectrum (self , image = None , bkg_statistic = None ) -> Spectrum :
@@ -400,7 +397,7 @@ def bkg_spectrum(self, image=None, bkg_statistic=None) -> Spectrum:
400397
401398 Returns
402399 -------
403- `~specutils.Spectrum1D `
400+ `~specutils.Spectrum `
404401 The background 1D spectrum, with flux and uncertainty expressed
405402 in the same units as the input image (or DN if none were provided).
406403 """
@@ -436,17 +433,7 @@ def sub_image(self, image=None) -> Spectrum:
436433 uncertainty.
437434 """
438435 image = self ._parse_image (image )
439-
440- if not SPECUTILS_LT_2 :
441- return image - self .bkg_image (image )
442-
443- # a compare_wcs argument is needed for Spectrum.subtract() in order to
444- # avoid a TypeError from SpectralCoord when image's spectral axis is in
445- # pixels. it is not needed when image's spectral axis has physical units
446- kwargs = {"compare_wcs" : None } if image .spectral_axis .unit == u .pix else {}
447-
448- # https://docs.astropy.org/en/stable/nddata/mixins/ndarithmetic.html
449- return image .subtract (self .bkg_image (image ), ** kwargs )
436+ return image - self .bkg_image (image )
450437
451438 def sub_spectrum (self , image = None ) -> Spectrum :
452439 """
0 commit comments