trident.spectrum_generator.load_spectrum

trident.spectrum_generator.load_spectrum(filename, format='auto', instrument=None, lsf_kernel=None, line_database='lines.txt', ionization_table=None)[source]

Load a previously saved spectrum from disk.

Parameters

Filename

string

Filename of the saved spectrum.

Format

string

File format of the saved spectrum file. Valid values are: “auto”, “hdf5”, “fits”, and “ascii”. If you select “auto”, the code will attempt to auto-detect the file format from the extension of the data file: “.h5” or “.hdf5” -> hdf5, “.fits” or “.FITS” -> fits, all other -> ascii. Default: “auto”

Instrument

string, optional

The telescope+instrument combination to use for the loaded spectrum. Default: None

Lsf_kernel

string, optional

The filename for the LSF kernel to use for the loaded spectrum. Default: None

Line_database

string, optional

A text file listing the various lines to insert into the line database to use for the loaded spectrum. Default: None

Ionization_table

hdf5 file, optional

An HDF5 file used for computing the ionization fraction of the gas based on its density, temperature, metallicity, and redshift. Default: None

Example

Create a simple spectrum, save it to disk, and load it back as a new SpectrumGenerator object.

>>> import trident
>>> ray = trident.make_onezone_ray()
>>> sg = trident.SpectrumGenerator('COS')
>>> sg.make_spectrum(ray)
>>> sg.save_spectrum('spec.h5')
>>> sg_copy = trident.load_spectrum('spec.h5')