LineList

class msaexp.utils.LineList(data=None)[source]

Bases: object

Tools for working with a table of lines

Examples

from msaexp.utils import LineList

ll = LineList()
fig = ll.demo()

(Source code, png, hires.png, pdf)

../_images/msaexp-utils-LineList-1.png

Attributes Summary

CLEAN_CENTER_KWARGS

LEFT_OFFSET_KWARGS

N

RIGHT_OFFSET_KWARGS

WHITE_BBOX

Methods Summary

add_to_axis(ax[, wave_pixels, bottom, top, ...])

Add vlines and labels to axis

demo([xlim])

Show a demonstration of various plot options

from_table(tab[, wave_column, to_angstroms, ...])

Generate from normal table with a list of line wavelengths

load_data([fill_color])

Load the data from msaexp/data/linelist.ecsv

select_lines([z, wave_range, prefixes, ...])

Get selection of lines within a wavelength range

spec_model(spec[, z, selected, fnu, use_ratios])

Make line models msaexp.spectrum.SpectrumSampler.fast_emission_line

Attributes Documentation

CLEAN_CENTER_KWARGS = {'bbox': {'alpha': 1.0, 'boxstyle': 'square,pad=0.3', 'ec': 'None', 'fc': 'w'}, 'ha': 'center', 'x_pad': 0.0}
LEFT_OFFSET_KWARGS = {'ha': 'right', 'x_pad': -0.005}
N
RIGHT_OFFSET_KWARGS = {'ha': 'left', 'x_pad': 0.005}
WHITE_BBOX = {'alpha': 1.0, 'boxstyle': 'square,pad=0.3', 'ec': 'None', 'fc': 'w'}

Methods Documentation

add_to_axis(ax, wave_pixels=None, bottom=0, top=1.0, x_pad=0, wfunc=<function min>, y_label=0.98, priorities=[3, 4, 5], label_priorities=None, label_prefixes=[], y_normalized=True, rotation=90, ha='center', va='top', lw=1.5, ls='-', fontsize=7, alpha=0.8, bbox={'alpha': 1.0, 'ec': 'None', 'fc': 'w'}, zorder=1, label_zorder=2, **kwargs)[source]

Add vlines and labels to axis

Parameters
axmatplotlib axis

Axis to draw labels in

bottomfloat, (array-like, array-like)

Lower limit of vlines to draw. If two arrays are provided, will interpolate the value value = np.interp(wave, *bottom)

topfloat, (array-like, array-like)

Upper limit of the vlines, with same interpolation options as bottom

x_padfloat

relative padding for text labels

wfuncfunc

Function to apply to the potential multiple entries for line complexes to specify where to draw the labels

y_labelfloat

Vertical location of the line text labels

prioritieslist

List of priorities to include from the linelist table

label_prioritieslist, None

List of priorities to include with text labels. If not provided, will be the same as priorities

label_prefixeslist

Prefix filtering for lines with text labels

y_normalizedbool

If True, the bottom, top and y_label values are calculated in the normalized frame of the plot extent, i.e., with 0 at the bottom and 1 at the top. Not used if values are interpolated.

lw, lsfloat, string

Linewidth and linestyle properties for the vlines

rotation, ha, va, fontsize, alpha, bbox, zorder

Text label properties

Returns
datatable

View of the linelist table with the selected lines

demo(xlim=[0.35, 0.51])[source]

Show a demonstration of various plot options

static from_table(tab, wave_column='wavelength', to_angstroms=1.0, color='0.5', priority=5, prefix='', ratio_column=None)[source]

Generate from normal table with a list of line wavelengths

load_data(fill_color='0.2')[source]

Load the data from msaexp/data/linelist.ecsv

select_lines(z=0, wave_range=[0, inf], prefixes=[], exclude_prefixes=[], priorities=[4, 5], floor=True, **kwargs)[source]

Get selection of lines within a wavelength range

Parameters
zfloat

Redshift

wave_range[float, float]

Observed-frame wavelength range. The script tries to automatically distinguish between wavelength units of Angstroms or microns assuming the latter if wave_range[1] < 500

prefixeslist

List of strings compared to the name column in the linelist using the test name.startswith(prefix)

prioritieslist

List of linelist priorities to include

floorbool

If true, ignore decimal part of the linelist priorities and just compare the integer values

Returns
selectedboolean array

Selection array on the listlist table that satisfy the selection criteria

x_scalefloat

Scale factor needed to put the “wavelength” column of the linelist in the frame of wave_range

spec_model(spec, z=0, selected=None, fnu=True, use_ratios=True, **kwargs)[source]

Make line models msaexp.spectrum.SpectrumSampler.fast_emission_line

Parameters
specSpectrumSampler

Spectrum object

zfloat

Redshift

selectedNone, array

Line selection array. If not provided, will pull from LineList.select_lines.

fnubool

Return in fnu units

use_ratiosbool

Use line ratio values. If False, normalize line flux to unity.

kwargsdict

Keyword arguments passed to LineList.select_lines and msaexp.spectrum.SpectrumSampler.fast_emission_line

Returns
resultdict

Model results:

  • templates: (Nline, Nwave) array. of line templates

  • names: line names

  • index: indices of the selected lines from the full linelist