How to use the specutils.spectra.spectral_region.SpectralRegion function in specutils

To help you get started, we’ve selected a few specutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spacetelescope / specviz / specviz / plugins / statistics / statistics_widget.py View on Github external
pos : `~astropy.units.Quantity`
            A tuple `~astropy.units.Quantity` with
            (min, max) range of roi.

        Returns
        -------
        None or `~specutils.utils.SpectralRegion`
        """
        if not isinstance(pos, u.Quantity):
            return None
        elif pos.unit == u.Unit("") or \
                pos[0] == pos[1]:
            return None
        elif pos[0] > pos[1]:
            pos = [pos[1], pos[0]] * pos.unit
        return SpectralRegion(*pos)
github spacetelescope / specviz / specviz / widgets / statistics.py View on Github external
pos : `~astropy.units.Quantity`
            A tuple `~astropy.units.Quantity` with
            (min, max) range of roi.

        Returns
        -------
        None or `~specutils.utils.SpectralRegion`
        """
        if not isinstance(pos, u.Quantity):
            return None
        elif pos.unit == u.Unit("") or \
                pos[0] == pos[1]:
            return None
        elif pos[0] > pos[1]:
            pos = [pos[1], pos[0]] * pos.unit
        return SpectralRegion(*pos)
github spacetelescope / specviz / specviz / plugins / statistics / statistics_widget.py View on Github external
def clip_region(spectrum, region):
    # If the region is out of data range return None:
    if region.lower > spectrum.spectral_axis.max() or \
            region.upper < spectrum.spectral_axis.min():
        return None

    # Clip region. There is currently no way to update
    # SpectralRegion lower and upper so we have to create
    # a new object here.
    lower = max(region.lower, spectrum.spectral_axis.min())
    upper = min(region.upper, spectrum.spectral_axis.max())

    return SpectralRegion(lower, upper)
github astropy / specutils / specutils / spectra / spectral_region.py View on Github external
def __getslice__(self, item):
        """
        Enable slicing of the SpectralRegion list.
        """
        return SpectralRegion(self._subregions[item])