File: identify.rst

package info (click to toggle)
specutils 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,460 kB
  • sloc: python: 13,497; makefile: 111
file content (36 lines) | stat: -rw-r--r-- 1,550 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
==============================
Identifying Spectrum Formats
==============================

``specutils`` provides a convenience function,
`~specutils.io.registers.identify_spectrum_format`, which attempts to guess the
`~specutils.Spectrum` file format from the list of registered formats, and
essentially acts as a wrapper on `~astropy.io.registry.identify_format`.

This function is useful for identifying a spectrum file format without reading the
whole file with the  `~specutils.Spectrum.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 `~astropy.io.registry.get_formats`.

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

.. code-block:: python

    >>> 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)  # doctest: +REMOTE_DATA
    >>> identify_spectrum_format(dd)  # doctest: +REMOTE_DATA
    'MaNGA cube'

or a JWST extracted 1d spectral file:

.. code-block:: python

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