@@ -122,15 +122,15 @@ class BoxcarExtract(SpecreduceOperation):
122
122
123
123
Parameters
124
124
----------
125
- image : nddata-compatible image
125
+ image : `~astropy. nddata.NDData`-like or array-like, required
126
126
image with 2-D spectral image data
127
- trace_object : Trace
127
+ trace_object : Trace, required
128
128
trace object
129
- width : float
129
+ width : float, optional
130
130
width of extraction aperture in pixels
131
- disp_axis : int
131
+ disp_axis : int, optional
132
132
dispersion axis
133
- crossdisp_axis : int
133
+ crossdisp_axis : int, optional
134
134
cross-dispersion axis
135
135
136
136
Returns
@@ -156,15 +156,15 @@ def __call__(self, image=None, trace_object=None, width=None,
156
156
157
157
Parameters
158
158
----------
159
- image : nddata-compatible image
159
+ image : `~astropy. nddata.NDData`-like or array-like, required
160
160
image with 2-D spectral image data
161
- trace_object : Trace
161
+ trace_object : Trace, required
162
162
trace object
163
- width : float
163
+ width : float, optional
164
164
width of extraction aperture in pixels [default: 5]
165
- disp_axis : int
165
+ disp_axis : int, optional
166
166
dispersion axis [default: 1]
167
- crossdisp_axis : int
167
+ crossdisp_axis : int, optional
168
168
cross-dispersion axis [default: 0]
169
169
170
170
@@ -180,22 +180,30 @@ def __call__(self, image=None, trace_object=None, width=None,
180
180
disp_axis = disp_axis if disp_axis is not None else self .disp_axis
181
181
crossdisp_axis = crossdisp_axis if crossdisp_axis is not None else self .crossdisp_axis
182
182
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
+
183
191
# TODO: this check can be removed if/when implemented as a check in FlatTrace
184
192
if isinstance (trace_object , FlatTrace ):
185
193
if trace_object .trace_pos < 1 :
186
194
raise ValueError ('trace_object.trace_pos must be >= 1' )
187
195
188
196
# weight image to use for extraction
189
- wimage = _ap_weight_image (
197
+ wimg = _ap_weight_image (
190
198
trace_object ,
191
199
width ,
192
200
disp_axis ,
193
201
crossdisp_axis ,
194
- image .shape )
202
+ img .shape )
195
203
196
204
# extract
197
205
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 )
199
207
200
208
201
209
@dataclass
@@ -207,7 +215,7 @@ class HorneExtract(SpecreduceOperation):
207
215
Parameters
208
216
----------
209
217
210
- image : `~astropy.nddata.NDData` or array-like, required
218
+ image : `~astropy.nddata.NDData`-like or array-like, required
211
219
The input 2D spectrum from which to extract a source. An
212
220
NDData object must specify uncertainty and a mask. An array
213
221
requires use of the ``variance``, ``mask``, & ``unit`` arguments.
@@ -270,7 +278,7 @@ def __call__(self, image=None, trace_object=None,
270
278
Parameters
271
279
----------
272
280
273
- image : `~astropy.nddata.NDData` or array-like, required
281
+ image : `~astropy.nddata.NDData`-like or array-like, required
274
282
The input 2D spectrum from which to extract a source. An
275
283
NDData object must specify uncertainty and a mask. An array
276
284
requires use of the ``variance``, ``mask``, & ``unit`` arguments.
@@ -323,6 +331,7 @@ def __call__(self, image=None, trace_object=None,
323
331
324
332
# handle image and associated data based on image's type
325
333
if isinstance (image , NDData ):
334
+ # (NDData includes Spectrum1D under its umbrella)
326
335
img = np .ma .array (image .data , mask = image .mask )
327
336
unit = image .unit if image .unit is not None else u .Unit ()
328
337
0 commit comments