@@ -137,15 +137,15 @@ class BoxcarExtract(SpecreduceOperation):
137
137
138
138
Parameters
139
139
----------
140
- image : nddata-compatible image
140
+ image : `~astropy. nddata.NDData`-like or array-like, required
141
141
image with 2-D spectral image data
142
- trace_object : Trace
142
+ trace_object : Trace, required
143
143
trace object
144
- width : float
144
+ width : float, optional
145
145
width of extraction aperture in pixels
146
- disp_axis : int
146
+ disp_axis : int, optional
147
147
dispersion axis
148
- crossdisp_axis : int
148
+ crossdisp_axis : int, optional
149
149
cross-dispersion axis
150
150
151
151
Returns
@@ -171,15 +171,15 @@ def __call__(self, image=None, trace_object=None, width=None,
171
171
172
172
Parameters
173
173
----------
174
- image : nddata-compatible image
174
+ image : `~astropy. nddata.NDData`-like or array-like, required
175
175
image with 2-D spectral image data
176
- trace_object : Trace
176
+ trace_object : Trace, required
177
177
trace object
178
- width : float
178
+ width : float, optional
179
179
width of extraction aperture in pixels [default: 5]
180
- disp_axis : int
180
+ disp_axis : int, optional
181
181
dispersion axis [default: 1]
182
- crossdisp_axis : int
182
+ crossdisp_axis : int, optional
183
183
cross-dispersion axis [default: 0]
184
184
185
185
@@ -195,6 +195,14 @@ def __call__(self, image=None, trace_object=None, width=None,
195
195
disp_axis = disp_axis if disp_axis is not None else self .disp_axis
196
196
crossdisp_axis = crossdisp_axis if crossdisp_axis is not None else self .crossdisp_axis
197
197
198
+ # handle image processing based on its type
199
+ if isinstance (image , Spectrum1D ):
200
+ img = image .data
201
+ unit = image .unit
202
+ else :
203
+ img = image
204
+ unit = getattr (image , 'unit' , u .DN )
205
+
198
206
# TODO: this check can be removed if/when implemented as a check in FlatTrace
199
207
if isinstance (trace_object , FlatTrace ):
200
208
if trace_object .trace_pos < 1 :
@@ -204,16 +212,16 @@ def __call__(self, image=None, trace_object=None, width=None,
204
212
raise ValueError ("width must be positive" )
205
213
206
214
# weight image to use for extraction
207
- wimage = _ap_weight_image (
215
+ wimg = _ap_weight_image (
208
216
trace_object ,
209
217
width ,
210
218
disp_axis ,
211
219
crossdisp_axis ,
212
- image .shape )
220
+ img .shape )
213
221
214
222
# extract
215
- ext1d = np .sum (image * wimage , axis = crossdisp_axis )
216
- return _to_spectrum1d_pixels (ext1d * getattr ( image , 'unit' , u . DN ) )
223
+ ext1d = np .sum (img * wimg , axis = crossdisp_axis ) * unit
224
+ return _to_spectrum1d_pixels (ext1d )
217
225
218
226
219
227
@dataclass
@@ -225,7 +233,7 @@ class HorneExtract(SpecreduceOperation):
225
233
Parameters
226
234
----------
227
235
228
- image : `~astropy.nddata.NDData` or array-like, required
236
+ image : `~astropy.nddata.NDData`-like or array-like, required
229
237
The input 2D spectrum from which to extract a source. An
230
238
NDData object must specify uncertainty and a mask. An array
231
239
requires use of the ``variance``, ``mask``, & ``unit`` arguments.
@@ -288,7 +296,7 @@ def __call__(self, image=None, trace_object=None,
288
296
Parameters
289
297
----------
290
298
291
- image : `~astropy.nddata.NDData` or array-like, required
299
+ image : `~astropy.nddata.NDData`-like or array-like, required
292
300
The input 2D spectrum from which to extract a source. An
293
301
NDData object must specify uncertainty and a mask. An array
294
302
requires use of the ``variance``, ``mask``, & ``unit`` arguments.
@@ -341,6 +349,7 @@ def __call__(self, image=None, trace_object=None,
341
349
342
350
# handle image and associated data based on image's type
343
351
if isinstance (image , NDData ):
352
+ # (NDData includes Spectrum1D under its umbrella)
344
353
img = np .ma .array (image .data , mask = image .mask )
345
354
unit = image .unit if image .unit is not None else u .Unit ()
346
355
0 commit comments