Identifying Spectrum1D FormatsΒΆ

specutils provides a convenience function, identify_spectrum_format, which attempts to guess the Spectrum1D file format from the list of registered formats, and essentially acts as a wrapper on identify_format.

This function is useful for identifying a spectrum file format without reading the whole file with the read method. It uses the same identification method as read however, so it provides a convenience of access outside of calling read without any change in underlying functionality. It returns the best guess as to a valid format from the list of Formats as given by get_formats.

For eample, to identify a SDSS MaNGA data cube file:

>>> from astropy.utils.data import download_file
>>> from specutils.io.registers import identify_spectrum_format
>>>
>>> url = 'https://dr17.sdss.org/sas/dr17/manga/spectro/redux/v3_1_1/8485/stack/manga-8485-1901-LOGCUBE.fits.gz'
>>> dd = download_file(url)  
>>> identify_spectrum_format(dd)  
'MaNGA cube'

or a JWST extracted 1d spectral file:

>>> from specutils.io.registers import identify_spectrum_format
>>> path = '/data/jwst/jw00626-o030_s00000_nirspec_f170lp-g235m_x1d.fits'
>>> identify_spectrum_format(path)  
'JWST x1d'