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
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
as given by
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://dr15.sdss.org/sas/dr15/manga/spectro/redux/v2_4_3/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'