Mondaic
This API reference is not for the latest stable Salvus version.

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: Union[str, List[str]],
    event: Union[str, salvus.flow.collections.event.Event],
    receiver_field: str,
    component: str,
    sort_by: Optional[Callable] = None,
    filter_by: Optional[
        Callable[[salvus.flow.simple_config.receiver._Base], bool]
    ] = None,
    select_by: Optional[
        Callable[
            [
                List[
                    Tuple[
                        salvus.flow.simple_config.receiver._Base,
                        obspy.core.stream.Stream,
                    ]
                ],
                salvus.flow.collections.event_data.EventData,
            ],
            List[
                Tuple[
                    salvus.flow.simple_config.receiver._Base,
                    obspy.core.stream.Stream,
                ]
            ],
        ]
    ] = None,
    interleave: bool = False,
    colors: Optional[List[Any]] = None,
    alpha: Optional[float] = None,
    plot_using: Union[
        salvus.flow.collections.event_data.PlotProperties,
        matplotlib.axes._axes.Axes,
    ] = PlotProperties(width=11.5, height=6.33, dpi=100),
    data_selection_configuration: Optional[str] = None,
    fast_unsafe: bool = False,
) -> matplotlib.axes._axes.Axes: ...

Plot a, potentially interleaved, custom gather.

Parameters
  • data Union[str, List[str]] — Data name or list of data names to plot.
  • event Union[str, salvus.flow.collections.event.Event] — The event to use.
  • receiver_field str — The receiver field to plot.
  • component str — The component to plot.
  • sort_by Optional[Callable] — Callback function called with the receiver objects to determine the sorting. Works like the key callback for the standard Python sorted() method.
  • filter_by Optional[Callable[[salvus.flow.simple_config.receiver._Base], bool]] — 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 Optional[Callable[[List[Tuple[salvus.flow.simple_config.receiver._Base, obspy.core.stream.Stream]], salvus.flow.collections.event_data.EventData], List[Tuple[salvus.flow.simple_config.receiver._Base, obspy.core.stream.Stream]]]] — 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 Optional[List[Any]] — 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 Optional[float] — The opacity of all data, as used in Matplotlib. useful when setting interleave to false.
  • plot_using Union[salvus.flow.collections.event_data.PlotProperties, matplotlib.axes._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 Optional[str] — 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.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: Optional[str] = None,
    misfit_configuration: str,
    events: Union[
        str,
        salvus.flow.collections.event.Event,
        List[Union[str, salvus.flow.collections.event.Event]],
    ],
    bins: int = 10,
    merge_all_components: bool = False,
    show: bool = True,
) -> Optional[matplotlib.figure.Figure]: ...

Compute histograms of misfits.

Parameters
  • simulation_configuration_a str — Name of the simulation configuration whose misfits to plot.
  • simulation_configuration_b Optional[str] — 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 Union[str, salvus.flow.collections.event.Event, List[Union[str, salvus.flow.collections.event.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 Optional[matplotlib.figure.Figure]
shotgather()
def shotgather(
    self,
    data: Union[str, List[str]],
    event: Union[str, salvus.flow.collections.event.Event],
    receiver_field: str,
    component: str,
    colors: Optional[List[Any]] = None,
    sort_by: Optional[Callable] = None,
    filter_by: Optional[
        Callable[[salvus.flow.simple_config.receiver._Base], bool]
    ] = None,
    select_by: Optional[
        Callable[
            [
                List[
                    Tuple[
                        salvus.flow.simple_config.receiver._Base,
                        obspy.core.stream.Stream,
                    ]
                ],
                salvus.flow.collections.event_data.EventData,
            ],
            List[
                Tuple[
                    salvus.flow.simple_config.receiver._Base,
                    obspy.core.stream.Stream,
                ]
            ],
        ]
    ] = None,
    plot_using: Union[
        salvus.flow.collections.event_data.PlotProperties,
        matplotlib.axes._axes.Axes,
    ] = PlotProperties(width=11.5, height=6.33, dpi=100),
    data_selection_configuration: Optional[str] = None,
    fast_unsafe: bool = False,
) -> matplotlib.axes._axes.Axes: ...

Plot a, potentially interleaved, shotgather.

Parameters
  • data Union[str, List[str]] — Data name or list of data names to plot.
  • event Union[str, salvus.flow.collections.event.Event] — The event to use.
  • receiver_field str — The receiver field to plot.
  • component str — The component to plot.
  • colors Optional[List[Any]] — 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 Optional[Callable] — Callback function called with the receiver objects to determine the sorting. Works like the key callback for the standard Python sorted() method.
  • filter_by Optional[Callable[[salvus.flow.simple_config.receiver._Base], bool]] — 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 Optional[Callable[[List[Tuple[salvus.flow.simple_config.receiver._Base, obspy.core.stream.Stream]], salvus.flow.collections.event_data.EventData], List[Tuple[salvus.flow.simple_config.receiver._Base, obspy.core.stream.Stream]]]] — 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 Union[salvus.flow.collections.event_data.PlotProperties, matplotlib.axes._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 Optional[str] — 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.Axes
waveforms()
def waveforms(
    self,
    data: Union[str, List[str]],
    event: Union[str, salvus.flow.collections.event.Event],
    receiver_name: str,
    receiver_field: str,
    data_selection_configuration: Optional[str] = None,
    apply_data_selection_configuration: bool = False,
) -> 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 Union[str, List[str]] — One or more waveform names to plot.
  • event Union[str, salvus.flow.collections.event.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 Optional[str] — 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.
Returns List[str]