trident.spectrum_generator.SpectrumGenerator.plot_spectrum

SpectrumGenerator.plot_spectrum(filename='spectrum.png', lambda_limits=None, flux_limits=None, step=False, title=None, label=None, figsize=None, features=None, axis_labels=None)[source]

Plot the current spectrum and save to disk.

This is a convenience method that wraps the plot_spectrum standalone function for use with the data from the SpectrumGenerator itself.

Parameters

Filename

string, optional

Output filename of the plotted spectrum. Will be a png file. Default: ‘spectrum.png’

Lambda_limits

tuple or list of floats, optional

The minimum and maximum of the lambda range (x-axis) for the plot in angstroms. If specified as None, will use whole lambda range of spectrum. Example: (1200, 1400) for 1200-1400 Angstroms. Default: None

Flux_limits

tuple or list of floats, optional

The minimum and maximum of the flux range (y-axis) for the plot. If specified as None, limits are automatically from [0, 1.1*max(flux)]. Example: (0, 1) for normal flux range before postprocessing. Default: None

Step

boolean, optional

Plot the spectrum as a series of step functions. Appropriate for plotting processed and noisy data.

Title

string, optional

Optional title for plot Default: None

Label

string, optional

Label for spectrum to be plotted. Will automatically trigger a legend to be generated. Default: None

Features

dict, optional

Include vertical lines with labels to represent certain spectral features. Each entry in the dictionary consists of a key string to be overplot and the value float as to where in wavelength space it will be plot as a vertical line with the corresponding label.

Example: features={‘Ly a’ : 1216, ‘Ly b’ : 1026}

Default: None

Axis_labels

tuple of strings, optional

Optionally set the axis labels directly. If set to None, defaults to (‘Wavelength [$rmAA$]’, ‘Relative Flux’). Default: None

Example

Create a one-zone ray, and generate a COS spectrum from that ray. Plot the resulting spectrum highlighting the Lyman alpha feature.

>>> import trident
>>> ray = trident.make_onezone_ray()
>>> sg = trident.SpectrumGenerator('COS')
>>> sg.make_spectrum(ray)
>>> sg.plot_spectrum('spec_raw.png', features={'Ly a' : 1216})