@@ -122,15 +122,15 @@ class BoxcarExtract(SpecreduceOperation):
122122
123123 Parameters
124124 ----------
125- image : nddata-compatible image
125+ image : `~astropy. nddata.NDData`-like or array-like, required
126126 image with 2-D spectral image data
127- trace_object : Trace
127+ trace_object : Trace, required
128128 trace object
129- width : float
129+ width : float, optional
130130 width of extraction aperture in pixels
131- disp_axis : int
131+ disp_axis : int, optional
132132 dispersion axis
133- crossdisp_axis : int
133+ crossdisp_axis : int, optional
134134 cross-dispersion axis
135135
136136 Returns
@@ -156,15 +156,15 @@ def __call__(self, image=None, trace_object=None, width=None,
156156
157157 Parameters
158158 ----------
159- image : nddata-compatible image
159+ image : `~astropy. nddata.NDData`-like or array-like, required
160160 image with 2-D spectral image data
161- trace_object : Trace
161+ trace_object : Trace, required
162162 trace object
163- width : float
163+ width : float, optional
164164 width of extraction aperture in pixels [default: 5]
165- disp_axis : int
165+ disp_axis : int, optional
166166 dispersion axis [default: 1]
167- crossdisp_axis : int
167+ crossdisp_axis : int, optional
168168 cross-dispersion axis [default: 0]
169169
170170
@@ -180,22 +180,30 @@ def __call__(self, image=None, trace_object=None, width=None,
180180 disp_axis = disp_axis if disp_axis is not None else self .disp_axis
181181 crossdisp_axis = crossdisp_axis if crossdisp_axis is not None else self .crossdisp_axis
182182
183+ # handle image processing based on its type
184+ if isinstance (image , Spectrum1D ):
185+ img = image .data
186+ unit = image .unit
187+ else :
188+ img = image
189+ unit = getattr (image , 'unit' , u .DN )
190+
183191 # TODO: this check can be removed if/when implemented as a check in FlatTrace
184192 if isinstance (trace_object , FlatTrace ):
185193 if trace_object .trace_pos < 1 :
186194 raise ValueError ('trace_object.trace_pos must be >= 1' )
187195
188196 # weight image to use for extraction
189- wimage = _ap_weight_image (
197+ wimg = _ap_weight_image (
190198 trace_object ,
191199 width ,
192200 disp_axis ,
193201 crossdisp_axis ,
194- image .shape )
202+ img .shape )
195203
196204 # extract
197205 ext1d = np .sum (image * wimage , axis = crossdisp_axis )
198- return _to_spectrum1d_pixels (ext1d * getattr ( image , ' unit' , u . DN ) )
206+ return _to_spectrum1d_pixels (ext1d * unit )
199207
200208
201209@dataclass
@@ -207,7 +215,7 @@ class HorneExtract(SpecreduceOperation):
207215 Parameters
208216 ----------
209217
210- image : `~astropy.nddata.NDData` or array-like, required
218+ image : `~astropy.nddata.NDData`-like or array-like, required
211219 The input 2D spectrum from which to extract a source. An
212220 NDData object must specify uncertainty and a mask. An array
213221 requires use of the ``variance``, ``mask``, & ``unit`` arguments.
@@ -270,7 +278,7 @@ def __call__(self, image=None, trace_object=None,
270278 Parameters
271279 ----------
272280
273- image : `~astropy.nddata.NDData` or array-like, required
281+ image : `~astropy.nddata.NDData`-like or array-like, required
274282 The input 2D spectrum from which to extract a source. An
275283 NDData object must specify uncertainty and a mask. An array
276284 requires use of the ``variance``, ``mask``, & ``unit`` arguments.
@@ -323,6 +331,7 @@ def __call__(self, image=None, trace_object=None,
323331
324332 # handle image and associated data based on image's type
325333 if isinstance (image , NDData ):
334+ # (NDData includes Spectrum1D under its umbrella)
326335 img = np .ma .array (image .data , mask = image .mask )
327336 unit = image .unit if image .unit is not None else u .Unit ()
328337
0 commit comments