extract_region¶
- specutils.manipulation.extract_region(spectrum, region, return_single_spectrum=False)[source]¶
Extract a region from the input
Spectrum1Ddefined by the lower and upper bounds defined by theregioninstance. 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
regionhas multiple sections, whether to return a single spectrum instead of multipleSpectrum1Dobjects. The returned spectrum will be a unique, concatenated, spectrum of all sub-regions.
- Returns:
- spectrum:
Spectrum1Dor list ofSpectrum1D Excised spectrum, or list of spectra if the input region contained multiple subregions and
return_single_spectrumisFalse.
- 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
spectrumwith spectral_axis of[0.1, 0.2, 0.3, 0.4, 0.5, 0.6]*u.um.A
regiondefined asSpectralRegion(0.2*u.um, 0.5*u.um)
And we calculate
sub_spectrum = extract_region(spectrum, region), then thesub_spectrumspectral axis will be[0.2, 0.3, 0.4, 0.5] * u.um.If the
regiondoes not overlap with thespectrumthen an empty Spectrum1D object will be returned.