@@ -299,9 +299,10 @@ class HorneExtract(SpecreduceOperation):
299
299
The index of the image's cross-dispersion axis. [default: 0]
300
300
301
301
bkgrd_prof : `~astropy.modeling.Model` or None, optional
302
- A model for the image's background flux. If ``spatial_profile`` is set
303
- to ``interpolated_profile``, then ``bkgrd_prof`` must be set to None.
304
- [default: models.Polynomial1D(2)].
302
+ A model for the image's background flux when using the ``gaussian``
303
+ spatial profile. If ``spatial_profile`` is set to ``gaussian``, it defaults
304
+ to ``models.Polynomial1D(2)``. Note that the ``interpolated_profile`` option
305
+ does not support a background model, so ``bkgrd_prof`` must be left as ``None``.
305
306
306
307
spatial_profile : str or dict, optional
307
308
The shape of the object profile. The first option is 'gaussian' to fit
@@ -341,7 +342,7 @@ class HorneExtract(SpecreduceOperation):
341
342
342
343
image : NDData
343
344
trace_object : Trace
344
- bkgrd_prof : Model = field ( default = models . Polynomial1D ( 2 ))
345
+ bkgrd_prof : None | Model = None
345
346
spatial_profile : str | dict = "gaussian"
346
347
variance : np .ndarray = field (default = None )
347
348
mask : np .ndarray = field (default = None )
@@ -599,7 +600,10 @@ def __call__(
599
600
The index of the image's cross-dispersion axis.
600
601
601
602
bkgrd_prof : `~astropy.modeling.Model`, optional
602
- A model for the image's background flux.
603
+ A model for the image's background flux when using the ``gaussian``
604
+ spatial profile. If ``spatial_profile`` is set to ``gaussian``, it defaults
605
+ to ``models.Polynomial1D(2)``. Note that the ``interpolated_profile`` option
606
+ does not support a background model, so ``bkgrd_prof`` must be left as ``None``.
603
607
604
608
spatial_profile : str or dict, optional
605
609
The shape of the object profile. The first option is 'gaussian' to fit
@@ -665,6 +669,9 @@ def __call__(
665
669
n_bins_interpolated_profile = profile .get ("n_bins_interpolated_profile" , 10 )
666
670
interp_degree_interpolated_profile = profile .get ("interp_degree_interpolated_profile" , 1 )
667
671
672
+ if bkgrd_prof is None and profile_type == 'gaussian' :
673
+ bkgrd_prof = models .Polynomial1D (2 )
674
+
668
675
self .image = self ._parse_image (image , variance , mask , unit , disp_axis )
669
676
variance = self .image .uncertainty .represent_as (VarianceUncertainty ).array
670
677
mask = self .image .mask .astype (bool ) | (~ np .isfinite (self .image .data ))
@@ -690,16 +697,6 @@ def __call__(
690
697
else :
691
698
mean_cross_pix = np .broadcast_to (ncross // 2 , ndisp )
692
699
else : # interpolated_profile
693
- # for now, bkgrd_prof must be None because a compound model can't
694
- # be created with a interpolator + model. i think there is a way
695
- # around this, but will follow up later
696
- if bkgrd_prof is not None :
697
- raise ValueError (
698
- "When `spatial_profile`is `interpolated_profile`,"
699
- "`bkgrd_prof` must be None. Background should"
700
- " be fit and subtracted from `img` beforehand."
701
- )
702
-
703
700
# determine interpolation degree from input and make tuple if int
704
701
# this can also be moved to another method to parse the input
705
702
# 'spatial_profile' arg, eventually
0 commit comments