trident.spectrum_generator.SpectrumGenerator.save_spectrum
- SpectrumGenerator.save_spectrum(filename='spectrum.h5', format=None)[source]
Save the current spectrum data to an output file. Unless specified, the output data format will be determined by the suffix of the filename provided (“h5”:HDF5, “fits”:FITS, all other:ASCII).
ASCII data is stored as a tab-delimited text file.
Parameters
- Filename
string, optional
Output filename for storing the data. Default: ‘spectrum.h5’
- Format
string, optional
Data format of the output file. Valid examples are “HDF5”, “FITS”, and “ASCII”. If None is set, selects based on suffix of filename. Default: None
Example
Save a spectrum to disk, load it from disk, and plot it.
>>> import trident >>> ray = trident.make_onezone_ray() >>> sg = trident.SpectrumGenerator('COS') >>> sg.make_spectrum(ray) >>> sg.save_spectrum('temp.h5') >>> sg.clear_spectrum() >>> sg.load_spectrum('temp.h5') >>> sg.plot_spectrum('temp.png')