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 import download_file
>>> from import identify_spectrum_format
>>> url = ''
>>> dd = download_file(url)  
>>> identify_spectrum_format(dd)  
'MaNGA cube'

or a JWST extracted 1d spectral file:

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