ReferenceData

class sofia_redux.visualization.models.reference_model.ReferenceData[source]

Bases: object

Model and manage reference data.

This class is intended for use with the ReferenceWindow interface. The user does not interact with it directly.

Methods implemented here parse data from .txt or .csv files. These files may contain one or two columns. If two columns are provided, the first column must contain wavelength/wavenumber. Input files may optionally contain headers.

This class also implements the following features:
  • change axis units based on user selection.

  • reset labels and lines

Attributes:
line_listdict

Values are wavelengths and labels.

line_unitstr or astropy.units.Unit

Wavelength unit for reference lines.

enableddict

Keys are ref_line and ref_label. Values are boolean flags indicating whether lines and labels are displayed.

Methods Summary

add_line_list(filename)

Add new spectral lines.

convert_line_list_unit(target_unit[, names])

Convert line list data to new units.

get_visibility(target)

Get current visibility setting.

set_visibility(targets, state)

Set the visibility of lines and labels.

unload_data()

Reset the line_list, line_unit, and enabled flags.

Methods Documentation

add_line_list(filename: str) bool[source]

Add new spectral lines.

Reads in reference data from a file and sets the visibility for the corresponding labels and lines.

Wavelength units are currently assumed to be microns (um).

Parameters:
filenamestr

Name of the file containing reference data.

Returns:
bool

True if data is parsed successfully; False otherwise.

convert_line_list_unit(target_unit, names=None)[source]

Convert line list data to new units.

Parameters:
target_unitstr or astropy.units.Unit

Unit to convert to.

nameslist or dict

If list, return all wavelengths matching the name. If dict, matching wavelength values only are returned. Wavelengths should be specified in units before conversion.

Returns:
converteddict

If names is provided, matching lines are returned. Otherwise, the full line list is returned.

get_visibility(target: str) bool | None[source]

Get current visibility setting.

Parameters:
target{‘ref_line’, ‘ref_label’}

The target to examine (lines or labels).

Returns:
visibilitybool or None

Visibility for the specified target. If the target is not found, None is returned.

set_visibility(targets, state)[source]

Set the visibility of lines and labels.

Parameters:
targetslist of str or str

May be ‘all’, ‘ref_line’, or ‘ref_label’.

statebool

The visibility state to set.

unload_data()[source]

Reset the line_list, line_unit, and enabled flags.