tardis.visualization.widgets.line_info module

Class to create and display Line Info Widget.

class tardis.visualization.widgets.line_info.LineInfoWidget(lines_data, line_interaction_analysis, spectrum_wavelength, spectrum_luminosity_density_lambda, virt_spectrum_wavelength, virt_spectrum_luminosity_density_lambda)[source]

Bases: object

Widget to explore atomic lines that produced features in the simulated spectrum.

It allows selection of a wavelength range in the spectrum to display a table giving the fraction of packets that experienced their last interaction with each species. Using toggle buttons, users can specify whether to filter the selected range by emitted or absorbed wavelengths of packets. Clicking on a row in the fractional species interactions table shows packet counts for each last line interaction of the selected species, which can be grouped in several ways using the dropdown menu.

Initialize the LineInfoWidget with line interaction and spectrum data.

Parameters
lines_datapd.DataFrame

Data about the atomic lines present in simulation model’s plasma

line_interaction_analysisdict of tardis.analysis.LastLineInteraction

Dictionary in which keys are the FILTER_MODES and values are the LastLineInteraction objects initialized with corresponding modes

spectrum_wavelengthastropy.Quantity

Wavelength values of a real spectrum, having unit of Angstrom

spectrum_luminosity_density_lambdaastropy.Quantity

Luminosity density lambda values of a real spectrum, having unit of (erg/s)/Angstrom

virt_spectrum_wavelengthastropy.Quantity

Wavelength values of a virtual spectrum, having unit of Angstrom

virt_spectrum_luminosity_density_lambdaastropy.Quantity

Luminosity density lambda values of a virtual spectrum, having unit of (erg/s)/Angstrom

COLORS = {'selection_area': 'lightpink', 'selection_border': 'salmon'}
FILTER_MODES = ('packet_out_nu', 'packet_in_nu')
FILTER_MODES_DESC = ('Emitted Wavelength', 'Absorbed Wavelength')
GROUP_MODES = ('both', 'exc', 'de-exc')
GROUP_MODES_DESC = ('Both excitation line (absorption) and de-excitation line (emission)', 'Only excitation line (absorption)', 'Only de-excitation line (emission)')
display()[source]

Display the fully-functional line info widget.

It puts together all component widgets nicely together and enables interaction between all the components.

Returns
ipywidgets.Box

Line info widget containing all component widgets

classmethod from_simulation(sim)[source]

Create an instance of LineInfoWidget from a TARDIS simulation object.

Parameters
simtardis.simulation.Simulation

TARDIS Simulation object produced by running a simulation

Returns
LineInfoWidget object
get_last_line_counts(selected_species, filter_mode='packet_out_nu', group_mode='both')[source]

Get packet counts of each last line interaction of a species.

Parameters
selected_speciesstr

Valid symbol of a species (e.g Si II) selected from the species data returned by get_species_interactions (see Notes section)

filter_modestr, optional

Filter mode of the LastLineInteraction object to use for fetching the data of last lines interacted (more details in Notes section). Allowed values are given by the class variable FILTER_MODES (default value is FILTER_MODES[0])

group_modestr, optional

Group mode to use for grouping last line interactions by excitation lines, de-excitation lines or both. Allowed values are given by the class variable GROUP_MODES (default value is GROUP_MODES[0] i.e. both)

Returns
pd.DataFrame

DataFrame containing last line interactions and corresponding packet counts.

Notes

This method depends on tardis.analysis.LastLineInteraction object for doing computations. So there is a member variable in this class - line_interaction_analysis which is a dictionary of such objects (each of them differ in how they filter the selected wavelength range). Thus we have to specify which object to use by specifying the filter_mode parameter.

This method should always be called after calling get_species_interactions method which sets a wavelength range on LastLineInteraction object. So selected_species should be one present within that range, otherwise it will result an error.

static get_middle_half_edges(arr)[source]

Get edges of the middle half range of an array.

Parameters
arrnp.array
Returns
list
get_species_interactions(wavelength_range, filter_mode='packet_out_nu')[source]

Get fractional species interactions in specified wavelength range.

Fractional species interactions means fraction of packets present in the specified wavelength range which experienced their last interaction with a species. The packets to consider are filtered by the specified filter mode.

Parameters
wavelength_rangelist-like or None

A list of two float values to specify the wavelength range - first for the range start and second for the range end. None specifies that no wavelength range is selected and will return empty dataframe

filter_modestr, optional

Filter mode of the LastLineInteraction object to use for filtering the selected wavelength range (more details in Notes section). Allowed values are given by the class variable FILTER_MODES (default value is FILTER_MODES[0])

Returns
pandas.DataFrame

Dataframe containing species symbols and corresponding fractions of packets interacting with them

Notes

This method depends on tardis.analysis.LastLineInteraction object for doing computations. So there is a member variable in this class - line_interaction_analysis which is a dictionary of such objects (each of them differ in how they filter the selected wavelength range). Thus we have to specify which object to use by specifying the filter_mode parameter.

plot_spectrum(wavelength, luminosity_density_lambda, virt_wavelength, virt_luminosity_density_lambda)[source]

Produce a plotly figure widget by plotting the spectrum of model.

Parameters
wavelengthastropy.Quantity

Wavelength values of a real spectrum, having unit of Angstrom

luminosity_density_lambdaastropy.Quantity

Luminosity density lambda values of a real spectrum, having unit of (erg/s)/Angstrom

virt_wavelengthastropy.Quantity

Wavelength values of a virtual spectrum, having unit of Angstrom

virt_luminosity_density_lambdaastropy.Quantity

Luminosity density lambda values of a virtual spectrum, having unit of (erg/s)/Angstrom

Returns
plotly.graph_objects.FigureWidget
static ui_control_description(text)[source]

Get description label of a UI control with increased font size.