tsunami_ip_utils.viz package

Submodules

tsunami_ip_utils.viz._bar_plot module

Functionality related to matplotlib bar plots of contributions to integral indices.

class tsunami_ip_utils.viz._bar_plot._BarPlotter(integral_index_name, plot_redundant=False, **kwargs)[source]

Bases: _Plotter

Class for creating bar plots of contributions to integral indices on a nuclide-wise and nuclide-reaction-wise basis.

_fig: Figure

The figure object for the plot.

_axs: Axes

The axes object for the plot.

_index_name: str

The name of the integral index being plotted.

_create_plot(contributions, nested)[source]

Creates a bar plot of the given contributions to the integral index.

Parameters:
  • contributions (Union[Dict[str, ufloat], Dict[str, Dict[str, ufloat]]]) –

    • If nested is False, then this should be a dictionary of the form {nuclide: contribution}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index.

    • If nested is True, then this should be a dictionary of the form {nuclide: {reaction: contribution}}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index through the given reaction.

  • nested (bool) – Wether the contributions are on a reaction-wise basis or not.

_get_plot()[source]

Return the ‘plot’ object.

Return type:

Tuple[Figure, Axes]

Returns:

The plot object.

_abc_impl = <_abc._abc_data object>
_add_to_subplot(fig, position)[source]

Add the plot (corresponding to the class instance) to the given figure subplot at the given position.

Parameters:
  • fig – The figure to add the plot to.

  • position – The position of the subplot to add the plot to.

Return type:

Figure

Returns:

The figure with the plot added.

_barchart(contributions)[source]

Create a bar chart of the contributions to the integral index on a nuclide-wise basis.

Parameters:

contributions (Dict[str, ufloat]) – A dictionary of the form {nuclide: contribution}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index.

_nested_barchart(contributions)[source]

Create a bar chart of the contributions to the integral index on a nuclide-reaction-wise basis.

_style()[source]

Style the plot.

tsunami_ip_utils.viz._base_plotter module

class tsunami_ip_utils.viz._base_plotter._Plotter[source]

Bases: ABC

abstract _create_plot(data, nested)[source]
Return type:

None

abstract _add_to_subplot(fig, position)[source]

Add the plot (corresponding to the class instance) to the given figure subplot at the given position.

Parameters:
  • fig (Any) – The figure to add the plot to.

  • position (tuple) – The position of the subplot to add the plot to.

Return type:

Any

Returns:

The figure with the plot added.

abstract _get_plot()[source]

Return the ‘plot’ object.

Return type:

Any

Returns:

The plot object.

abstract _style()[source]

Style the plot.

Return type:

None

_abc_impl = <_abc._abc_data object>

tsunami_ip_utils.viz.matrix_plot module

This module contains the InteractiveMatrixPlot class, which is a wrapper around a Dash app that displays a matrix of interactive plots. The matrix is constructed from a 2D numpy array of plot objects, where each plot object is an instance of either tsunami_ip_utils.viz.scatter_plot.InteractiveScatterLegend or tsunami_ip_utils.viz.pie_plot.InteractivePieLegend. The matrix is displayed in a Dash app, where each plot object is displayed in a separate cell. The user can interact with the plots by clicking on the legend to hide or show traces. The user can also save the state of the interactive matrix plot to a pickle file and load it back later. The load_interactive_matrix_plot() function is a convenience function that loads an interactive matrix plot from a saved state pickle file.

tsunami_ip_utils.viz.matrix_plot._create_app(external_stylesheets)[source]
tsunami_ip_utils.viz.matrix_plot._create_column_headers(num_cols, labels=None)[source]

Create column headers for the matrix plot. Each column header is a div element with the text ‘Application i’ where i is the column index. The column headers are styled to be centered and have a border on the right and bottom.

Parameters:
  • num_cols (int) – Number of columns in the matrix plot.

  • labels (Optional[List[str]]) – List of labels for the columns of the matrix plot. Default is None.

Return type:

None

tsunami_ip_utils.viz.matrix_plot._create_row_label(i, label=None)[source]

Create a row label for the matrix plot. The row label is a div element with the text ‘Experiment i’ where i is the row index. The row label is styled to be centered and have a border on the right and bottom. The text is rotated -90 degrees to make it vertical.

Parameters:
  • i (int) – Row index of the matrix plot.

  • label (Optional[str]) – An optional label for the row (to use instead of Experiment i). Default is None.

Return type:

Div

Returns:

A div element representing the row label.

tsunami_ip_utils.viz.matrix_plot._create_plot_element(i, j, plot_object)[source]

Create a plot element based on the plot object. If the plot object is an instance of tsunami_ip_utils.viz.scatter_plot.InteractiveScatterLegend, or a plotly.graph_objects.Figure, the plot element is a dcc.Graph element. If the plot object is an instance of tsunami_ip_utils.viz.pie_plot.InteractivePieLegend, the plot element is an html.Iframe element.

Return type:

Union[Graph, Iframe]

tsunami_ip_utils.viz.matrix_plot._create_update_figure_callback(app, graph_id, app_instance)[source]
tsunami_ip_utils.viz.matrix_plot._generate_layout(app, rows)[source]

Generate the layout of the Dash app. The layout consists of an H1 element with the title ‘Matrix of Plots’, followed by a div element containing the rows of the matrix plot. The rows are displayed in a flex column with horizontal scrolling. The layout also includes a JavaScript script that listens for window resize events and resizes the Plotly plots accordingly.

Parameters:
  • app (Dash) – Dash app object.

  • rows (List[Div]) – List of div elements representing the rows of the matrix plot.

Return type:

None

class tsunami_ip_utils.viz.matrix_plot.InteractiveMatrixPlot(app, plot_objects_array, labels=None)[source]

Bases: object

Interactive matrix plot class that displays a matrix of interactive plots in a Dash app. The matrix is constructed from a 2D numpy array of plot objects, where each plot object is an instance of either tsunami_ip_utils.viz.scatter_plot.InteractiveScatterLegend or tsunami_ip_utils.viz.pie_plot.InteractivePieLegend. The matrix is displayed in a Dash app, where each plot object is displayed in a separate cell. The user can interact with the plots by clicking on the legend to hide or show traces. The user can also save the state of the interactive matrix plot to a pickle file and load it back later.

_app: Dash

Dash app object that displays the interactive matrix plot.

_plot_objects_array: ndarray

2D numpy array of plot objects to be displayed in the matrix plot.

_open_browser(port)[source]

Open the browser to display the interactive matrix plot.

Parameters:

port (int) – Port number of the Flask server.

Return type:

None

tsunami_ip_utils.viz.matrix_plot._interactive_matrix_plot(plot_objects_array, labels=None)[source]

Create an interactive matrix plot from a 2D numpy array of plot objects. This function creates a Dash app that displays the matrix plot. The matrix is constructed from the plot objects array, where each plot object is an instance of either tsunami_ip_utils.viz.scatter_plot.InteractiveScatterLegend or tsunami_ip_utils.viz.pie_plot.InteractivePieLegend. The matrix is displayed in a Dash app, where each plot object is displayed in a separate cell. The user can interact with the plots by clicking on the legend to hide or show traces.

Parameters:
  • plot_objects_array (ndarray) – 2D numpy array of plot objects to be displayed in the matrix plot.

  • labels (Optional[Dict[str, List]]) – Dictionary of lists containing the labels for the rows and columns of the matrix plot. Keys are 'applications' and 'experiments'. Default is None. Most commonly, this is the sdf filename for the given application/experiment.

Return type:

InteractiveMatrixPlot

Returns:

An instance of the InteractiveMatrixPlot class that wraps the Dash app displaying the matrix plot.

tsunami_ip_utils.viz.pie_plot module

Tools for creating pie charts of contributions to integral indices.

class tsunami_ip_utils.viz.pie_plot._PiePlotter(integral_index_name, plot_redudant=False, **kwargs)[source]

Bases: _Plotter

A class for creating static pie charts of contributions to integral indices.

_index_name: str

The name of the integral index whose contributions are being plotted (e.g. 'E' or 'c_k').

_plot_redundant: bool

Whether to plot redundant/irrelevant reactions in the pie chart.

_create_plot(contributions, nested)[source]

Creates a pie chart of the given contributions to the integral index.

Parameters:
  • contributions (Union[Dict[str, ufloat], Dict[str, Dict[str, ufloat]]]) –

    • If nested is False, then this should be a dictionary of the form {nuclide: contribution}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index.

    • If nested is True, then this should be a dictionary of the form {nuclide: {reaction: contribution}}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index through the given reaction.

  • nested (bool) – Wether the contributions are on a reaction-wise basis or not.

_add_to_subplot(fig, position)[source]

Add the plot (corresponding to the class instance) to the given figure subplot at the given position.

Parameters:
  • fig – The figure to add the plot to.

  • position – The position of the subplot to add the plot to.

Returns:

The figure with the plot added.

_get_plot()[source]

Return the ‘plot’ object.

Return type:

Tuple[Figure, Axes]

Returns:

The plot object.

_nested_pie_chart(contributions)[source]

Create a pie chart of the contributions to the integral index on a nuclide-reaction-wise basis.

Parameters:

contributions (Dict[str, Dict[str, ufloat]]) – A dictionary of the form {nuclide: {reaction: contribution}}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index through the given reaction.

_pie_chart(contributions)[source]

Create a pie chart of the contributions to the integral index on a nuclide-wise basis.

Parameters:

contributions (Dict[str, ufloat]) – A dictionary of the form {nuclide: contribution}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index.

_style()[source]

Style the plot.

_abc_impl = <_abc._abc_data object>
class tsunami_ip_utils.viz.pie_plot._InteractivePiePlotter(integral_index_name, plot_redundant=False, **kwargs)[source]

Bases: _Plotter

A class for creating interactive pie charts of contributions to integral indices.

_index_name: str

The name of the integral index whose contributions are being plotted (e.g. 'E' or 'c_k').

_plot_redundant: bool

Whether to plot redundant/irrelevant reactions in the pie chart.

_create_plot(contributions, nested)[source]

Creates an interactive pie chart of the given contributions to the integral index.

Parameters:
  • contributions (Union[Dict[str, ufloat], Dict[str, Dict[str, ufloat]]]) –

    • If nested is False, then this should be a dictionary of the form {nuclide: contribution}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index.

    • If nested is True, then this should be a dictionary of the form {nuclide: {reaction: contribution}}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index through the given reaction.

  • nested (bool) – Wether the contributions are on a reaction-wise basis or not.

_add_to_subplot(fig, position)[source]

Add the plot (corresponding to the class instance) to the given figure subplot at the given position.

Parameters:
  • fig – The figure to add the plot to.

  • position – The position of the subplot to add the plot to.

Returns:

The figure with the plot added.

_get_plot()[source]

Return the ‘plot’ object.

Return type:

Union[Figure, InteractivePieLegend]

Returns:

The plot object.

_create_sunburst_data(contributions)[source]

Create a pandas dataframe for a (not nested) sunburst chart of contributions.

Parameters:

contributions (Dict[str, ufloat]) – A dictionary of the form {nuclide: contribution}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index.

Return type:

DataFrame

Returns:

The dataframe for creating the sunburst chart.

_create_nested_sunburst_data(contributions)[source]

Create a pandas dataframe for a nested sunburst chart of contributions.

Parameters:

contributions (Dict[str, Dict[str, ufloat]]) – A dictionary of the form {nuclide: {reaction: contribution}}, where contribution is a ufloat object representing the contribution of the nuclide to the integral index through the given reaction.

Return type:

DataFrame

Returns:

The dataframe for creating the sunburst chart.

_style()[source]

Style the plot.

_abc_impl = <_abc._abc_data object>
class tsunami_ip_utils.viz.pie_plot.InteractivePieLegend(fig, df)[source]

Bases: object

A class for creating an interactive legend for a sunburst chart.

_app: Flask

The Flask webapp that will display the interactive legend.

_open_browser(port)[source]

Open the browser to display the interactive sunburst chart

Parameters:

port (int) – The port at which the Flask server is running.

tsunami_ip_utils.viz.plot_utils module

Various utility functions for creating interactive plots, including functions for generating plot objects from contributions and perturbations. These functions are used in the interactive plotting functions in the viz module.

tsunami_ip_utils.viz.plot_utils._find_free_port()[source]

Finds a free port on localhost for running a Flask/Dash server. This is done by creating a socket and binding it to an available port. The socket is then closed and the port number is returned.

Return type:

int

Returns:

A free port number.

tsunami_ip_utils.viz.plot_utils._determine_plot_type(contributions, plot_redundant_reactions)[source]

Determines whether the contributions are nuclide-wise or nuclide-reaction-wise and whether to plot redundant reactions or not. Then converts the contributions (list of dictionaries) to a dictionary of contributions keyed by isotope then by reaction type if necessary.

Parameters:
  • contributions (List[dict]) – List of dictionaries containing the contributions to the similarity parameter for each nuclide or nuclide-reaction pair.

  • plot_redundant_reactions (bool) – Whether to plot redundant reactions (or irrelevant reactions) when considering nuclide-reaction-wise contributions.

Return type:

Tuple[dict, bool]

Returns:

  • contributions

    Contributions to the similarity parameter keyed by isotope then by reaction type (if necessary).

  • nested_plot

    Whether the plot is nested by nuclide then by reaction type.

tsunami_ip_utils.viz.plot_utils._capture_html_as_image(html_file, output_image, matrix=False)[source]

Captures an HTML file as an image using Selenium WebDriver. This is useful for saving interactive plots as static images.

Parameters:
  • html_file (Path) – Path to the HTML file to capture.

  • output_image (Path) – Path to save the output image

  • matrix (bool) – Whether or not the html file is a matrix plot. If True, the function searches for a div element with a specific id to determine the necessary size of the webbrowser.

Return type:

None

tsunami_ip_utils.viz.scatter_plot module

Tools for creating interactive and static scatter plots with error bars, linear regression lines, and correlation coefficient calculations.

tsunami_ip_utils.viz.scatter_plot._replace_spearman_and_pearson(text, new_pearson, new_spearman)[source]

Replaces the Spearman and Pearson values in the given text with the new values provided using regex. This is useful for updating the correlation statistics in a scatter plot annotation interactively after the plot has been created.

Parameters:
  • text (str) – The text (scatter plot annotation) containing the Spearman and Pearson values to be updated. It is expected that the text contains the Spearman and Pearson values in the format "Spearman: <b>0.123456</b> Pearson: <b>0.123456</b>".

  • new_pearson (float) – The new Pearson correlation coefficient value to replace the old value in the text.

  • new_spearman (float) – The new Spearman rank correlation coefficient value to replace the old value in the text.

Return type:

str

Returns:

The updated text with the new Spearman and Pearson values.

tsunami_ip_utils.viz.scatter_plot._update_percent_difference(text, reference_value)[source]

Updates the percent difference in the given text with the new percent difference calculated using the new Pearson correlation coefficient value. This is useful for updating the percent difference in a scatter plot annotation interactively after the plot has been created. This is only valid for scatter plots generated by tsunami_ip_utils.comparisons.correlation_comparison() or other plots that have the percent difference in the annotation.

Parameters:
  • text (str) – The text (scatter plot annotation) containing the percent difference to be updated. It is expected that the text contains the percent difference in the format "Percent Difference: <b>0.123456</b>%" and the TSUNAMI-IP c_k value in the format "TSUNAMI-IP c_k: <b>0.123456+/-0.123456</b>".

  • reference_value (float) – The reference value to calculate the percent difference from. This is typically the (updated) Pearson correlation coefficient.

Return type:

Tuple[str, ufloat]

Returns:

  • updated_text

    The updated text with the new percent difference value.

  • percent_difference

    The new percent difference value with uncertainty.

class tsunami_ip_utils.viz.scatter_plot.EnhancedPlotlyFigure(*args, **kwargs)[source]

Bases: Figure

This class wraps a plotly express figure object (intended for a scatter plot) and adds additional attributes for the summary statistics and linear regression data. This class is intended to be used with the InteractiveScatterPlotter class.

class tsunami_ip_utils.viz.scatter_plot._ScatterPlot[source]

Bases: _Plotter

This class exists to add some additional functionality for calculating regressions and summary statistics that’s common to all types of scatter plots, interactive or otherwise

_regression: Any

A named tuple (scipy.stats Linregress object) containing the slope and intercept of the linear regression line as attributes slope and intercept respectively.

_pearson: float

The Pearson correlation coefficient.

_spearman: float

The Spearman rank correlation coefficient.

_summary_stats_text: str

A string containing the summary statistics for the scatter plot.

_get_summary_statistics(x, y)[source]

Calculates the Pearson correlation coefficient, Spearman rank correlation coefficient, and linear regression parameters for the given x and y datasets. The linear regression parameters are the slope and intercept of the regression line. The Pearson and Spearman coefficients are also stored in the class instance as ‘pearson’ and ‘spearman’ respectively. The slope and intercept are stored as ‘slope’ and ‘intercept’ respectively. The linear regression is stored as ‘regression’

Parameters:
  • x (Union[List, ndarray]) – The x values of the scatter plot.

  • y (Union[List, ndarray]) – The y values of the scatter plot.

Return type:

None

_abc_impl = <_abc._abc_data object>
class tsunami_ip_utils.viz.scatter_plot._ScatterPlotter(integral_index_name, nested, plot_redundant=False, **kwargs)[source]

Bases: _ScatterPlot

A class for creating static scatter plots with error bars, linear regression lines, and correlation coefficient calculations.

_nested: bool

Whether the contributions are nested or not. This is unused in this class.

_index_name: str

The name of the integral index (whose contributions) being plotted. This is used only for the title of the plot.

_plot_redundant: bool

Whether to plot redundant reactions or not. This is unused in this class.

_plot_type: str

Whether the plot is a matplolib or plotly plot. This is used to determine how to format the summary statistics text.

_create_plot(contribution_pairs, isotopes, reactions)[source]

Creates a static scatter plot with error bars, linear regression line, and correlation coefficient calculations.

Parameters:
  • contribution_pairs (List[ufloat]) – A list of pairs of contributions to the integral index from the application and experiment.

  • isotopes (List[str]) – The list of isotopes represented by each contribution pair. This has the same length and it ordered the same as the contribution_pairs.

  • reactions (List[str]) – The list of reactions represented by each contribution pair. This has the same length and it ordered the same as the contribution_pairs. Note if only nuclide-wise contributions are given, this list will be empty.

Return type:

None

Notes

The set of isotopes and reactions is only necessary for creating labels in interactive plots (e.g. those made by InteractiveScatterPlotter), but is included here for consistency.

_add_legend_with_scaling()[source]
_get_plot()[source]

Return the ‘plot’ object.

Return type:

Tuple[Figure, Axes]

Returns:

The plot object.

_add_to_subplot(fig, position)[source]

Add the plot (corresponding to the class instance) to the given figure subplot at the given position.

Parameters:
  • fig – The figure to add the plot to.

  • position – The position of the subplot to add the plot to.

Return type:

Figure

Returns:

The figure with the plot added.

_style()[source]

Style the plot.

_abc_impl = <_abc._abc_data object>
class tsunami_ip_utils.viz.scatter_plot._InteractiveScatterPlotter(integral_index_name, nested, plot_redundant=False, **kwargs)[source]

Bases: _ScatterPlot

A class for creating interactive scatter plots with error bars, linear regression lines, and correlation coefficient calculations.

_interactive_legend: bool

Whether to include an interactive legend in the plot. This is used to toggle the visibility of the traces in the plot and interactively recalculate the regression and summary statistics.

_nested: bool

Whether the contributions are nested or not. This is unused in this class.

_index_name: str

The name of the integral index (whose contributions) being plotted. This is used only for the title of the plot.

_plot_redundant: bool

Whether to plot redundant reactions or not. This is unused in this class.

_plot_type: str

Whether the plot is a matplolib or plotly plot. This is used to determine how to format the summary statistics text.

_create_plot(contribution_pairs, isotopes, reactions)[source]

Create an interactive scatter plot with error bars, linear regression line, and correlation coefficient calculations.

Parameters:
  • contribution_pairs (List[ufloat]) – A list of pairs of contributions to the integral index from the application and experiment.

  • isotopes (List[str]) – The list of isotopes represented by each contribution pair. This has the same length and it ordered the same as the contribution_pairs.

  • reactions (List[str]) – The list of reactions represented by each contribution pair. This has the same length and it ordered the same as the contribution_pairs.

Return type:

None

_add_regression_and_stats(df)[source]

Add the linear regression line and correlation statistics to the plot. This method is called after the plot has been created. This method can also update a comparison with a TSUNAMI-IP calculated \(c_k\) value if it exists in the annotation.

Parameters:

df (DataFrame) – The DataFrame containing the data for the scatter plot. This DataFrame should contain the columns 'Application <integral_index_name> Contribution' and 'Experiment <integral_index_name> Contribution'.

Return type:

None

_create_scatter_data(contribution_pairs, isotopes, reactions)[source]

Create a DataFrame from the given contribution pairs, isotopes, and reactions. This DataFrame is used to create the interactive scatter plot.

Parameters:
  • contribution_pairs (List[ufloat]) – A list of pairs of contributions to the integral index from the application and experiment.

  • isotopes (List[str]) – The list of isotopes represented by each contribution pair. This has the same length and it ordered the same as the contribution_pairs.

  • reactions (List[str]) – The list of reactions represented by each contribution pair. This has the same length and it ordered the same as the contribution_pairs.

Return type:

DataFrame

_add_to_subplot(fig, position)[source]

Add the plot (corresponding to the class instance) to the given figure subplot at the given position.

Parameters:
  • fig – The figure to add the plot to.

  • position – The position of the subplot to add the plot to.

Returns:

The figure with the plot added.

_get_plot()[source]

Return the ‘plot’ object.

Returns:

The plot object.

_abc_impl = <_abc._abc_data object>
_style()[source]

Style the plot.

class tsunami_ip_utils.viz.scatter_plot._PerturbationScatterPlotter(**kwargs)[source]

Bases: _ScatterPlot

Class for creating a matplotlib scatter plot using the nuclear data sampling method (where perturbed cross section libraries are used to calculate sample points on the scatter plot).

_abc_impl = <_abc._abc_data object>
_plot_type: str

Whether the plot is a matplolib or plotly plot. This is used to determine how to format the summary statistics text.

_create_plot(points)[source]

Create a matplotlib scatter plot with error bars, linear regression line, and correlation coefficient calculations.

Parameters:

points (List[Tuple[ufloat, ufloat]]) – A list of perturbation points, each computed from sampled perturbed cross section libraries. These points are generated using the tsunami_ip_utils.perturbations.generate_points() function.

Return type:

None

_get_plot()[source]

Return the ‘plot’ object.

Return type:

Tuple[Figure, Axes]

Returns:

The plot object.

_add_to_subplot(fig, position)[source]

Add the plot (corresponding to the class instance) to the given figure subplot at the given position.

Parameters:
  • fig – The figure to add the plot to.

  • position – The position of the subplot to add the plot to.

Return type:

Figure

Returns:

The figure with the plot added.

_style()[source]

Style the plot.

class tsunami_ip_utils.viz.scatter_plot._InteractivePerturbationScatterPlotter(**kwargs)[source]

Bases: _ScatterPlot

Class for creating an interactive scatter plot using the nuclear data sampling method (where perturbed cross section libraries are used to calculate sample points on the scatter plot).

_abc_impl = <_abc._abc_data object>
_plot_type: str

Whether the plot is a matplolib or plotly plot. This is used to determine how to format the summary statistics text.

_create_plot(points)[source]

Create an interactive perturbation scatter plot with error bars, linear regression line, and correlation coefficient.

Parameters:

points (List[Tuple[ufloat, ufloat]]) – A list of perturbation points, each computed from sampled perturbed cross section libraries. These points are generated using the tsunami_ip_utils.perturbations.generate_points() function.

Return type:

None

_add_regression_and_stats(df)[source]

Add the linear regression line and correlation statistics to the plot. This method is called after the plot has been created.

Parameters:

df (DataFrame) – The DataFrame containing the data for the scatter plot. This DataFrame should contain the columns 'Application' and 'Experiment'.

Return type:

None

_add_to_subplot(fig, position)[source]

Add the plot (corresponding to the class instance) to the given figure subplot at the given position.

Parameters:
  • fig – The figure to add the plot to.

  • position – The position of the subplot to add the plot to.

Returns:

The figure with the plot added.

_get_plot()[source]

Return the ‘plot’ object.

Returns:

The plot object.

_style()[source]

Style the plot.

class tsunami_ip_utils.viz.scatter_plot.InteractiveScatterLegend(interactive_scatter_plot, df)[source]

Bases: _InteractiveScatterPlotter

An implementation of an interactive legend (that automatically updates the regression and summary statistics following the exclusion of certain data in the scatter plot) for an interactive (Plotly) scatter plot.

_abc_impl = <_abc._abc_data object>
_interactive_scatter_plot: _InteractiveScatterPlotter

The interactive scatter plot object that the interactive legend is associated with.

_excluded_isotopes: List[str]

A list of isotopes that have been excluded from the scatter plot.

_app: Dash

The Dash application object for the interactive legend.

_plot_type: str

Whether the plot is a matplolib or plotly plot. This is used to determine how to format the summary statistics text.

_setup_callbacks()[source]

Set up the Dash callbacks for the interactive legend.

tsunami_ip_utils.viz.viz module

tsunami_ip_utils.viz.viz._prepare_contribution_pairs(application_contributions, experiment_contributions, plot_redundant_reactions, plot_dissimilar_nuclides)[source]

Prepares the contribution pairs for plotting by parsing the contributions into a form that’s easy to plot.

Parameters:
  • application_contributions (List[dict]) – List of dictionaries containing the contributions to the similarity parameter for the application.

  • experiment_contributions (List[dict]) – List of dictionaries containing the contributions to the similarity parameter for the experiment.

  • plot_redundant_reactions (bool) – Whether to plot redundant reactions (or irrelevant reactions) when considering nuclide-reaction-wise contributions.

  • plot_dissimilar_nuclides (bool) – Whether to plot points with an application or experiment contribution of zero. These points correspond to nuclides which are present in an application but not the experiment (or vice versa).

Return type:

Tuple[List[Tuple[ufloat, ufloat]], List[str], List[str], bool]

Returns:

A tuple containing the contribution pairs, isotopes, reactions, and whether the contributions are nested.

Module contents