extract_region¶
- specutils.manipulation.extract_region(spectrum, region, return_single_spectrum=False)[source]¶
Extract a region from the input
Spectrum1D
defined by the lower and upper bounds defined by theregion
instance. The extracted region will be returned as a newSpectrum1D
.- Parameters:
- spectrum: `~specutils.Spectrum1D`
The spectrum object from which the region will be extracted.
- region: `~specutils.SpectralRegion`
The spectral region to extract from the original spectrum.
- return_single_spectrum: `bool`
If
region
has multiple sections, whether to return a single spectrum instead of multipleSpectrum1D
objects. The returned spectrum will be a unique, concatenated, spectrum of all sub-regions.
- Returns:
- spectrum:
Spectrum1D
or list ofSpectrum1D
Excised spectrum, or list of spectra if the input region contained multiple subregions and
return_single_spectrum
isFalse
.
- spectrum:
Notes
The region extracted is a discrete subset of the input spectrum. No interpolation is done on the left and right side of the spectrum.
The region is assumed to be a closed interval (as opposed to Python which is open on the upper end). For example:
- Given:
A
spectrum
with spectral_axis of[0.1, 0.2, 0.3, 0.4, 0.5, 0.6]*u.um
.A
region
defined asSpectralRegion(0.2*u.um, 0.5*u.um)
And we calculate
sub_spectrum = extract_region(spectrum, region)
, then thesub_spectrum
spectral axis will be[0.2, 0.3, 0.4, 0.5] * u.um
.If the
region
does not overlap with thespectrum
then an empty Spectrum1D object will be returned.