Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@data_loader("ECSV", identifier=identify_ecsv, dtype=Spectrum1D)
def generic_ecsv(file_name, column_mapping=None, **kwargs):
"""
Read a spectrum from an ECSV file, using generic_spectrum_from_table_loader()
to try to figure out which column is which.
The ECSV columns must have units, as `generic_spectrum_from_table_loader`
depends on this to determine the meaning of the columns. For manual
control over the column to spectrum mapping, use the ASCII loader.
Parameters
----------
file_name: str
The path to the ECSV file.
column_mapping : dict
A dictionary describing the relation between the ECSV file columns
and the arguments of the `Spectrum1D` class, along with unit
information. The dictionary keys should be the ECSV file column names
@data_loader(label="IPAC", identifier=ipac_identify, extensions=['txt', 'dat'])
def ipac_loader(file_name, column_mapping=None, **kwargs):
"""
Load spectrum from IPAC-style ASCII file
Parameters
----------
file_name: str
The path to the IPAC-style ASCII file.
column_mapping : dict
A dictionary describing the relation between the IPAC-style ASCII
file columns and the arguments of the `Spectrum1D` class, along with
unit information. The dictionary keys should be the IPAC-style ASCII
file column names while the values should be a two-tuple where the
first element is the associated `Spectrum1D` keyword argument, and the
second element is the unit for the IPAC-style ASCII file column::
@data_loader(label="SDSS-I/II spSpec", identifier=spSpec_identify, extensions=['fits'])
def spSpec_loader(file_obj, **kwargs):
"""
Loader for SDSS-I/II spSpec files.
Parameters
----------
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: Spectrum1D
The spectrum that is represented by the data in this table.
"""
if isinstance(file_obj, fits.hdu.hdulist.HDUList):
@data_loader("6dFGS-tabular",
identifier=identify_6dfgs_tabular_fits, dtype=Spectrum1D,
extensions=["fit", "fits"])
def sixdfgs_tabular_fits_loader(file_obj, **kwargs):
"""
Load the tabular 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 tabular variant of the spectra. Note that this does
not include uncertainties - uncertainties are only provided in the image
variants.
Parameters
@data_loader("wcs1d-fits", identifier=identify_wcs1d_fits,
dtype=Spectrum1D, extensions=['fits'])
def wcs1d_fits_loader(file_obj, spectral_axis_unit=None, flux_unit=None,
hdu_idx=0, **kwargs):
"""
Loader for single spectrum-per-HDU spectra in FITS files, with the spectral
axis stored in the header as FITS-WCS. The flux unit of the spectrum is
determined by the 'BUNIT' keyword of the HDU (if present), while the
spectral axis unit is set by the WCS's 'CUNIT'.
Parameters
----------
file_obj: str or file-like
FITS file name or object (provided from name by Astropy I/O Registry).
spectral_axis_unit: str or `~astropy.Unit`, optional
Units of the spectral axis. If not given (or None), the unit will be
inferred from the CUNIT in the WCS. Not that if this is providded it
@data_loader(label="ASCII", identifier=ascii_identify, extensions=['txt', 'ascii'])
def ascii_loader(file_name, column_mapping=None, **kwargs):
"""
Load spectrum from ASCII file.
Parameters
----------
file_name: str
The path to the ASCII file.
column_mapping : dict
A dictionary describing the relation between the ASCII file columns
and the arguments of the `Spectrum1D` class, along with unit
information. The dictionary keys should be the ASCII file column names
while the values should be a two-tuple where the first element is the
associated `Spectrum1D` keyword argument, and the second element is the
unit for the ASCII file column::
@data_loader(label="HST/COS", identifier=cos_identify)
def cos_spectrum_loader(file_name, **kwargs):
"""
Load file from COS spectral data into a spectrum object.
Parameters
----------
file_name: str
The path to the FITS file
Returns
-------
data: Spectrum1D
The data.
"""
name = os.path.basename(file_name)
@data_loader("tabular-fits", identifier=identify_tabular_fits,
dtype=Spectrum1D, extensions=['fits'])
def tabular_fits_loader(file_obj, column_mapping=None, hdu=1, **kwargs):
"""
Load spectrum from a FITS file.
Parameters
----------
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()).
hdu: int
The HDU of the fits file (default: 1st extension) to read from
column_mapping : dict
A dictionary describing the relation between the FITS file columns
and the arguments of the `Spectrum1D` class, along with unit
information. The dictionary keys should be the FITS file column names
@data_loader(label="APOGEE aspcapStar", identifier=aspcapStar_identify, extensions=['fits'])
def aspcapStar_loader(file_obj, **kwargs):
"""
Loader for APOGEE aspcapStar files.
Parameters
----------
file_obj: str or file-like
FITS file name or object (provided from name by Astropy I/O Registry).
Returns
-------
data: Spectrum1D
The spectrum that is represented by the data in this table.
"""
hdulist = fits.open(file_obj, **kwargs)
@data_loader(label="Generic FITS", identifier=fits_identify)
def simple_generic_loader(file_name, **kwargs):
"""
Basic FITS file loader
Presumption is the primary data is a table with columns 'flux'
and 'err'. The dispersion information is encoded in the FITS
header keywords.
Parameters
----------
file_name: str
The path to the FITS file
Returns
-------
data: Spectrum1D