Background¶
- class specreduce.background.Background(image: ~astropy.nddata.nddata.NDData, traces: list = <factory>, width: float = 5, statistic: str = 'average', disp_axis: int = 1, crossdisp_axis: int = 0)[source]¶
Bases:
_ImageParser
Determine the background from an image for subtraction.
Example:
trace = FlatTrace(image, trace_pos) bg = Background.two_sided(image, trace, bkg_sep, width=bkg_width) subtracted_image = image - bg
- Parameters:
- image
NDData
-like or array-like image with 2-D spectral image data
- tracestrace, int, float (single or list)
Individual or list of trace object(s) (or integers/floats to define FlatTraces) to extract the background. If None, a FlatTrace at the center of the image (according to
disp_axis
) will be used.- widthfloat
width of extraction aperture in pixels
- statistic: string
statistic to use when computing the background. ‘average’ will account for partial pixel weights, ‘median’ will include all partial pixels.
- disp_axisint
dispersion axis
- crossdisp_axisint
cross-dispersion axis
- image
Attributes Summary
Deprecated since version 1.3.
Methods Summary
bkg_image
([image])Expose the background tiled to the dimension of
image
.bkg_spectrum
([image])Expose the 1D spectrum of the background.
one_sided
(image, trace_object, separation, ...)Determine the background from an image for subtraction above or below an input trace.
sub_image
([image])Subtract the computed background from
image
.sub_spectrum
([image])Expose the 1D spectrum of the background-subtracted image.
two_sided
(image, trace_object, separation, ...)Determine the background from an image for subtraction centered around an input trace.
Attributes Documentation
- bkg_array¶
Deprecated since version 1.3: The bkg_array attribute is deprecated and may be removed in a future version.
Methods Documentation
- bkg_image(image=None)[source]¶
Expose the background tiled to the dimension of
image
.- Parameters:
- image
NDData
-like or array-like, optional Image with 2-D spectral image data. Assumes cross-dispersion (spatial) direction is axis 0 and dispersion (wavelength) direction is axis 1. If None, will extract the background from
image
used to initialize the class. [default: None]
- image
- Returns:
Spectrum1D
object with same shape asimage
.
- bkg_spectrum(image=None)[source]¶
Expose the 1D spectrum of the background.
- Parameters:
- image
NDData
-like or array-like, optional Image with 2-D spectral image data. Assumes cross-dispersion (spatial) direction is axis 0 and dispersion (wavelength) direction is axis 1. If None, will extract the background from
image
used to initialize the class. [default: None]
- image
- Returns:
- spec
Spectrum1D
The background 1-D spectrum, with flux expressed in the same units as the input image (or u.DN if none were provided) and the spectral axis expressed in pixel units.
- spec
- classmethod one_sided(image, trace_object, separation, **kwargs)[source]¶
Determine the background from an image for subtraction above or below an input trace.
Example:
trace = FitTrace(image, guess=trace_pos) bg = Background.one_sided(image, trace, bkg_sep, width=bkg_width)
- Parameters:
- image
NDData
-like or array-like Image with 2-D spectral image data. Assumes cross-dispersion (spatial) direction is axis 0 and dispersion (wavelength) direction is axis 1.
- trace_object: `~specreduce.tracing.Trace`
estimated trace of the spectrum to center the background traces
- separation: float
separation from
trace_object
for the background, positive will be above the trace, negative below.- widthfloat
width of each background aperture in pixels
- statistic: string
statistic to use when computing the background. ‘average’ will account for partial pixel weights, ‘median’ will include all partial pixels.
- disp_axisint
dispersion axis
- crossdisp_axisint
cross-dispersion axis
- image
- sub_image(image=None)[source]¶
Subtract the computed background from
image
.- Parameters:
- imagenddata-compatible image or None
image with 2-D spectral image data. If None, will extract the background from
image
used to initialize the class.
- Returns:
Spectrum1D
object with same shape asimage
.
- sub_spectrum(image=None)[source]¶
Expose the 1D spectrum of the background-subtracted image.
- Parameters:
- imagenddata-compatible image or None
image with 2-D spectral image data. If None, will extract the background from
image
used to initialize the class.
- Returns:
- spec
Spectrum1D
The background 1-D spectrum, with flux expressed in the same units as the input image (or u.DN if none were provided) and the spectral axis expressed in pixel units.
- spec
- classmethod two_sided(image, trace_object, separation, **kwargs)[source]¶
Determine the background from an image for subtraction centered around an input trace.
Example:
trace = FitTrace(image, guess=trace_pos) bg = Background.two_sided(image, trace, bkg_sep, width=bkg_width)
- Parameters:
- image
NDData
-like or array-like Image with 2-D spectral image data. Assumes cross-dispersion (spatial) direction is axis 0 and dispersion (wavelength) direction is axis 1.
- trace_object: `~specreduce.tracing.Trace`
estimated trace of the spectrum to center the background traces
- separation: float
separation from
trace_object
for the background regions- widthfloat
width of each background aperture in pixels
- statistic: string
statistic to use when computing the background. ‘average’ will account for partial pixel weights, ‘median’ will include all partial pixels.
- disp_axisint
dispersion axis
- crossdisp_axisint
cross-dispersion axis
- image