How to use the specutils.SpectrumList 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 astropy / specutils / specutils / io / default_loaders / sixdfgs_reader.py View on Github external
----------
    file_obj: str, file-like or HDUList
         FITS file name, object (provided from name by Astropy I/O Registry),
         or HDUList (as resulting from astropy.io.fits.open()).

    Returns
    -------
    data: SpectrumList
        The 6dF spectra that are represented by the data in this file.
    """
    if isinstance(file_obj, fits.hdu.hdulist.HDUList):
        hdulist = file_obj
    else:
        hdulist = fits.open(file_obj, **kwargs)

    specs = SpectrumList([_load_single_6dfgs_hdu(hdu) for hdu in hdulist[5:]])

    if not isinstance(file_obj, fits.hdu.hdulist.HDUList):
        hdulist.close()

    return specs
github spacetelescope / specviz / specviz / widgets / workspace.py View on Github external
def _create_loader_filters(self):
        # Create a dictionary mapping the registry loader names to the
        # qt-specified loader names
        def compose_filter_string(reader):
            """
            Generates the Qt loader string to pass to the file load dialog.
            """
            return ' '.join(['*.{}'.format(y) for y in reader.extensions]
                            if reader.extensions is not None else '*')

        loader_name_map = {
            '{} ({})'.format(
                x['Format'], compose_filter_string(
                    get_reader(x['Format'], SpectrumList))): x['Format']
            for x in io_registry.get_formats(SpectrumList) if x['Read'] == 'Yes'}

        # Include an auto load function that lets the io machinery find the
        # most appropriate loader to use
        auto_filter = 'Auto (*)'
        loader_name_map[auto_filter] = None

        filters = list(loader_name_map.keys())
        # Make sure that the "Auto (*)" loader shows up first. Being a bit
        # pedantic about this even though we can probably just rely on
        # dictionary ordering here.
        index = filters.index(auto_filter)
        filters.insert(0, filters.pop(index))

        return filters, loader_name_map
github spacetelescope / specviz / specviz / widgets / workspace.py View on Github external
def _get_matching_formats(self, file_path):
        return io_registry.identify_format(
            'read', SpectrumList, file_path, None, [], {})
github astropy / specutils / specutils / io / default_loaders / sixdfgs_reader.py View on Github external
             identifier=identify_6dfgs_combined_fits, dtype=SpectrumList,
             extensions=["fit", "fits"])
def sixdfgs_combined_fits_loader(file_obj, **kwargs):
    """
    Load the combined variant of a 6dF Galaxy Survey (6dFGS) file.

    6dFGS used the Six-degree Field instrument on the UK Schmidt Telescope
    (UKST) at the Siding Spring Observatory (SSO) near Coonabarabran,
    Australia. Further details can be found at http://www.6dfgs.net/, or
    https://docs.datacentral.org.au/6dfgs/. Catalogues and spectra were
    produced, with the spectra being provided as both fits tables and as fits
    images. This loads the combined variant of the spectra.

    Parameters
    ----------
    file_obj: str, file-like or HDUList
         FITS file name, object (provided from name by Astropy I/O Registry),
github spacetelescope / specviz / specviz / widgets / workspace.py View on Github external
def _create_loader_filters(self):
        # Create a dictionary mapping the registry loader names to the
        # qt-specified loader names
        def compose_filter_string(reader):
            """
            Generates the Qt loader string to pass to the file load dialog.
            """
            return ' '.join(['*.{}'.format(y) for y in reader.extensions]
                            if reader.extensions is not None else '*')

        loader_name_map = {
            '{} ({})'.format(
                x['Format'], compose_filter_string(
                    get_reader(x['Format'], SpectrumList))): x['Format']
            for x in io_registry.get_formats(SpectrumList) if x['Read'] == 'Yes'}

        # Include an auto load function that lets the io machinery find the
        # most appropriate loader to use
        auto_filter = 'Auto (*)'
        loader_name_map[auto_filter] = None

        filters = list(loader_name_map.keys())
        # Make sure that the "Auto (*)" loader shows up first. Being a bit
        # pedantic about this even though we can probably just rely on
        # dictionary ordering here.
        index = filters.index(auto_filter)
        filters.insert(0, filters.pop(index))

        return filters, loader_name_map