Mondaic

salvus.project.components.visualization.visualization_component

salvus.project.components.visualization.visualization_component salvus project components visualization visualization_component

The visualization component of SalvusProject.

Classes

VisualizationComponent

class VisualizationComponent(builtins.object):
    def __init__(self, project: salvus.project.Project): ...

Project subclass dealing with all things related to visualizations.

Parameters
  • project salvus.project.Project — The project to attach the visualization component to.
Methods
custom_gather()
def custom_gather(
    self,
    data: str | list[str],
    event: str | Event,
    receiver_field: str,
    component: str,
    sort_by: typing.Callable | None = None,
    filter_by: typing.Callable[[_Base], bool] | None = None,
    select_by: (
        typing.Callable[
            [list[tuple[_Base, obspy.Stream]], EventData],
            list[tuple[_Base, obspy.Stream]],
        ]
        | None
    ) = None,
    interleave: bool = False,
    colors: list[typing.Any] | None = None,
    alpha: float | None = None,
    plot_using: PlotProperties | matplotlib.axes.Axes = PlotProperties(
        width=11.5, height=6.33, dpi=100
    ),
    data_selection_configuration: str | None = None,
    fast_unsafe: bool = False,
) -> matplotlib.axes.Axes: ...

Plot a, potentially interleaved, custom gather.

Parameters
  • data str | list[str] — Data name or list of data names to plot.
  • event str | Event — The event to use.
  • receiver_field str — The receiver field to plot.
  • component str — The component to plot.
  • sort_by typing.Callable | None — Callback function called with the receiver objects to determine the sorting. Works like the key callback for the standard Python sorted() method.
  • filter_by typing.Callable[[_Base], bool] | None — Callback function called with the receiver objects in internal Salvus format to determine the filtering. Works like the callback for the standard Python filter() method. For complex filter operations requiring all receivers, defer to the select_by method.
  • select_by typing.Callable[[list[tuple[_Base, obspy.Stream]], EventData], list[tuple[_Base, obspy.Stream]]] | None — Callback function called with a list of tuples in the receiver objects in both internal Salvus and ObsPy Stream format, as well as the EventData objects.
  • interleave bool — Whether or not to alternatingly plot data. If false, traces from all data will be plotted on top of each other.
  • colors list[typing.Any] | None — The colors for the individual traces. Must be exactly as many colors as data items. If not given, it will attempt to choose suitable colors.
  • alpha float | None — The opacity of all data, as used in Matplotlib. useful when setting interleave to false.
  • plot_using PlotProperties | matplotlib.axes.Axes — The configuration of the axis to create or reuse. Will default to the standard size as defined in the PlotProperties dataclass.
  • data_selection_configuration str | None — The data selection configuration to use.
  • fast_unsafe bool — Collect data on the largest instead of smallest time step. Will potentially alias data if largest time step of the data is larger than the highest relevant frequencies across the data, but does speed up plotting in cases where time axes are restrictive, e.g. simulations with relatively many time steps, which would normally lead to massive interpolation expense.
Returns matplotlib.axes.Axes
interval_window_statistics()
def interval_window_statistics(
    self, data_selection_configuration: str
) -> pandas.io.formats.style.Styler: ...

Styled table to get an overview of all picked windows for a given data selection configuration.

Parameters
  • data_selection_configuration str — The data selection configuration whose windows to plot.
Returns pandas.io.formats.style.Styler
misfit_histogram()
def misfit_histogram(
    self,
    simulation_configuration_a: str,
    simulation_configuration_b: str | None = None,
    misfit_configuration: str,
    events: str | Event | list[str | Event],
    bins: int = 10,
    merge_all_components: bool = False,
    show: bool = True,
) -> matplotlib.figure.Figure | None: ...

Compute histograms of misfits.

Parameters
  • simulation_configuration_a str — Name of the simulation configuration whose misfits to plot.
  • simulation_configuration_b str | None — Optionally plot misfits of a second configuration to be able to compare two configurations.
  • misfit_configuration str — The misfit configuration to use for the comparison.
  • events str | Event | list[str | Event] — The events to use. It will produce a cumulative histogram over the given events.
  • bins int — How many bins to use.
  • merge_all_components bool — If False, a separate histogram will be computed for each component, otherwise a single histogram will be computed by merging all misfit measurements.
  • show bool — If True the figure will be shown immediately. Otherwise the matplotlib figure object will be returned.
Returns matplotlib.figure.Figure | None
shotgather()
def shotgather(
    self,
    data: str | list[str],
    event: str | Event,
    receiver_field: str,
    component: str,
    colors: list[typing.Any] | None = None,
    sort_by: typing.Callable | None = None,
    filter_by: typing.Callable[[_Base], bool] | None = None,
    select_by: (
        typing.Callable[
            [list[tuple[_Base, obspy.Stream]], EventData],
            list[tuple[_Base, obspy.Stream]],
        ]
        | None
    ) = None,
    plot_using: PlotProperties | matplotlib.axes.Axes = PlotProperties(
        width=11.5, height=6.33, dpi=100
    ),
    data_selection_configuration: str | None = None,
    fast_unsafe: bool = False,
) -> matplotlib.axes.Axes: ...

Plot a, potentially interleaved, shotgather.

Parameters
  • data str | list[str] — Data name or list of data names to plot.
  • event str | Event — The event to use.
  • receiver_field str — The receiver field to plot.
  • component str — The component to plot.
  • colors list[typing.Any] | None — The colors for the individual traces. Must be exactly as many colors as data items. If not given, it will attempt to choose suitable colors.
  • sort_by typing.Callable | None — Callback function called with the receiver objects to determine the sorting. Works like the key callback for the standard Python sorted() method.
  • filter_by typing.Callable[[_Base], bool] | None — Callback function called with the receiver objects in internal Salvus format to determine the filtering. Works like the callback for the standard Python filter() method. For complex filter operations requiring all receivers, defer to the select_by method.
  • select_by typing.Callable[[list[tuple[_Base, obspy.Stream]], EventData], list[tuple[_Base, obspy.Stream]]] | None — Callback function called with a list of tuples in the receiver objects in both internal Salvus and ObsPy Stream format, as well as the EventData objects.
  • plot_using PlotProperties | matplotlib.axes.Axes — The configuration of the axis to create or reuse. Will default to the standard size as defined in the PlotProperties dataclass.
  • data_selection_configuration str | None — The data selection configuration to use.
  • fast_unsafe bool — Collect data on the largest instead of smallest time step. Will potentially alias data if largest time step of the data is larger than the highest relevant frequencies across the data, but does speed up plotting in cases where time axes are restrictive, e.g. simulations with relatively many time steps, which would normally lead to massive interpolation expense.
Returns matplotlib.axes.Axes
waveforms()
def waveforms(
    self,
    data: str | list[str],
    event: str | Event,
    receiver_name: str,
    receiver_field: str,
    data_selection_configuration: str | None = None,
    apply_data_selection_configuration: bool = False,
    _cache: dict | None = None,
) -> list[str]: ...

Single receiver but potentially multi-component wiggle plot.

Returns a list of error messages if one or more components of the data could not be retrieved.

Parameters
  • data str | list[str] — One or more waveform names to plot.
  • event str | Event — Event for which to plot waveforms.
  • receiver_name str — Receiver name for which to plot waveforms.
  • receiver_field str — The receiver field to plot.
  • data_selection_configuration str | None — Data selection configuration to apply.
  • apply_data_selection_configuration bool — If True, a potentially given data selection configuration will be applied, otherwise interval windows within the data selection configuration will just be plotted in the background.
  • _cache dict | None — A dictionary that will optionally be used to cache output. The caller is responsible for evicting/clearing the cache.
Returns list[str]

Used in tutorials