HorneExtract¶
- class specreduce.extract.HorneExtract(image: ~astropy.nddata.nddata.NDData, trace_object: ~specreduce.tracing.Trace, bkgrd_prof: ~astropy.modeling.core.Model = <Polynomial1D(2, c0=0., c1=0., c2=0.)>, spatial_profile: str = 'gaussian', variance: ~numpy.ndarray = None, mask: ~numpy.ndarray = None, unit: ~numpy.ndarray = None, disp_axis: int = 1, crossdisp_axis: int = 0)[source]¶
Bases:
SpecreduceOperation
Perform a Horne (a.k.a. optimal) extraction on a two-dimensional spectrum.
There are two options for fitting the spatial profile used for extraction - by default, a 1D gaussian is fit and as a uniform profile across the spectrum. Alternativley, the
self profile
option may be chosen - when this option is chosen, the spatial profile will be sampled at various locations (set by <>) and interpolated between to produce a smoothly varying spatial profile across the spectrum.If using the Gaussian option for the spatial profile, a background profile may be fit (but not subtracted) simultaneously to the data. By default, this is done with a 2nd degree polynomial. If using the
interpolated_profile
option, the background model must be set to None.- Parameters:
- image
NDData
-like or array-like, required The input 2D spectrum from which to extract a source. An NDData object must specify uncertainty and a mask. An array requires use of the
variance
,mask
, &unit
arguments.- trace_object
Trace
, required The associated 1D trace object created for the 2D image.
- disp_axisint, optional
The index of the image’s dispersion axis. [default: 1]
- crossdisp_axisint, optional
The index of the image’s cross-dispersion axis. [default: 0]
- bkgrd_prof
Model
or None, optional A model for the image’s background flux. If
spatial_profile
is set tointerpolated_profile
, thenbkgrd_prof
must be set to None. [default: models.Polynomial1D(2)].- spatial_profilestr or dict, optional
The shape of the object profile. The first option is ‘gaussian’ to fit a uniform 1D gaussian to the average of pixels in the cross-dispersion direction. The other option is ‘interpolated_profile’ - when this option is used, the profile is sampled in bins and these samples are interpolated between to construct a continuously varying, empirical spatial profile for extraction. For this option, if passed in as a string (i.e spatial_profile=’interpolated_profile’) the default values for the number of bins used (10) and degree of interpolation (linear in x and y, by default) will be used. To set these parameters, pass in a dictionary with the keys ‘n_bins_interpolated_profile’ (which accepts an integer number of bins) and ‘interp_degree’ (which accepts an int, or tuple of ints for x and y degree, respectively). [default: gaussian]
- variance
ndarray
, optional (Only used if
image
is not an NDData object.) The associated variances for each pixel in the image. Must have the same dimensions asimage
. If all zeros, the variance will be ignored and treated as all ones. If any zeros, those elements will be excluded via masking. If any negative values, an error will be raised. [default: None]- mask
ndarray
, optional (Only used if
image
is not an NDData object.) Whether to mask each pixel in the image. Must have the same dimensions asimage
. If blank, all non-NaN pixels are unmasked. [default: None]- unit
Unit
or str, optional (Only used if
image
is not an NDData object.) The associated unit for the data inimage
. If blank, fluxes are interpreted in DN. [default: None]
- image
Attributes Summary
Methods Summary
__call__
([image, trace_object, disp_axis, ...])Run the Horne calculation on a region of an image and extract a 1D spectrum.
Attributes Documentation
- spectrum¶
Methods Documentation
- __call__(image=None, trace_object=None, disp_axis=None, crossdisp_axis=None, bkgrd_prof=None, spatial_profile=None, n_bins_interpolated_profile=None, interp_degree_interpolated_profile=None, variance=None, mask=None, unit=None)[source]¶
Run the Horne calculation on a region of an image and extract a 1D spectrum.
- Parameters:
- image
NDData
-like or array-like, required The input 2D spectrum from which to extract a source. An NDData object must specify uncertainty and a mask. An array requires use of the
variance
,mask
, &unit
arguments.- trace_object
Trace
, required The associated 1D trace object created for the 2D image.
- disp_axisint, optional
The index of the image’s dispersion axis.
- crossdisp_axisint, optional
The index of the image’s cross-dispersion axis.
- bkgrd_prof
Model
, optional A model for the image’s background flux.
- spatial_profilestr or dict, optional
The shape of the object profile. The first option is ‘gaussian’ to fit a uniform 1D gaussian to the average of pixels in the cross-dispersion direction. The other option is ‘interpolated_profile’ - when this option is used, the profile is sampled in bins and these samples are interpolated between to construct a continuously varying, empirical spatial profile for extraction. For this option, if passed in as a string (i.e spatial_profile=’interpolated_profile’) the default values for the number of bins used (10) and degree of interpolation (linear in x and y, by default) will be used. To set these parameters, pass in a dictionary with the keys ‘n_bins_interpolated_profile’ (which accepts an integer number of bins) and ‘interp_degree’ (which accepts an int, or tuple of ints for x and y degree, respectively). [default: gaussian]
- variance
ndarray
, optional (Only used if
image
is not an NDData object.) The associated variances for each pixel in the image. Must have the same dimensions asimage
. If all zeros, the variance will be ignored and treated as all ones. If any zeros, those elements will be excluded via masking. If any negative values, an error will be raised.- mask
ndarray
, optional (Only used if
image
is not an NDData object.) Whether to mask each pixel in the image. Must have the same dimensions asimage
. If blank, all non-NaN pixels are unmasked.- unit
Unit
or str, optional (Only used if
image
is not an NDData object.) The associated unit for the data inimage
. If blank, fluxes are interpreted in DN.
- image
- Returns:
- spec_1d
Spectrum1D
The final, Horne extracted 1D spectrum.
- spec_1d