Required
event_data_objects| Type: | list[EventData] |
| Description: | A list of the event data objects to use. |
def plot_event_data_gathers(
event_data_objects: list[EventData],
receiver_field: str,
component: str,
event_data_labels: str | list[str] | 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,
interleave: bool = False,
colors: list[typing.Any] | None = None,
alpha: float | None = None,
plot_using: PlotProperties | mpl.axes.Axes = PlotProperties(
width=11.5, height=6.33, dpi=100
),
fast_unsafe: bool = False,
) -> mpl.axes.Axes: ...| Type: | list[EventData] |
| Description: | A list of the event data objects to use. |
| Type: | str |
| Description: | The receiver field to plot. |
| Type: | str |
| Description: | The component to plot. |
| Type: | str | list[str] | None |
| Default value: | None |
| Description: | Data name or list of data names to plot. This variable will simply be used for the labelling of the data in the event_data_objects list. If not specified, names will be generated from the event_data_objects list. |
| Type: | typing.Callable | None |
| Default value: | None |
| Description: | Callback function called with the receiver objects to determine the sorting. Works like the key callback for the standard Python sorted() method. |
| Type: | typing.Callable[[_Base], bool] | None |
| Default value: | None |
| Description: | 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. |
| Type: | typing.Callable[[list[tuple[_Base, obspy.Stream]], EventData], list[tuple[_Base, obspy.Stream]]] | None |
| Default value: | None |
| Description: | 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. |
| Type: | bool |
| Default value: | False |
| Description: | Whether or not to alternatingly plot data. If false, traces from all data will be plotted on top of each other. |
| Type: | list[typing.Any] | None |
| Default value: | None |
| Description: | 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. |
| Type: | float | None |
| Default value: | None |
| Description: | The opacity of all data, as used in Matplotlib. useful when setting interleave to false. |
| Type: | PlotProperties | mpl.axes.Axes |
| Default value: | PlotProperties(width=11.5, height=6.33, dpi=100) |
| Description: | The configuration of the axis to create or reuse. Will default to the standard size as defined in the PlotProperties dataclass. |
| Type: | bool |
| Default value: | False |
| Description: | Collect data on the largest instead of smallest time step. Will potentially alias data if largest time step of the event data objects 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. |
mpl.axes.Axesclass EventData(salvus.flow.collections.event.Event):
def __init__(
self,
event: Event,
data: pathlib.Path | dict | xr.Dataset | xr.DataArray,
data_hash: str | None = None,
path_to_meta_json: pathlib.Path | None = None,
path_to_job_info_json: pathlib.Path | None = None,
): ...| Type: | Event |
| Description: | The event object. |
| Type: | pathlib.Path | dict | xr.Dataset | xr.DataArray |
| Description: | Path to the actual waveform data or a dictionary describing the data. |
| Type: | str | None |
| Default value: | None |
| Description: | Uniquely identifying hash of that pieces of data. Might not always be available. |
| Type: | pathlib.Path | None |
| Default value: | None |
| Description: | Optionally specify the meta.json path of the run. Necessary if you later want to compute adjoint sources. |
| Type: | pathlib.Path | None |
| Default value: | None |
| Description: | Optionally specify the job_info.json path of the run. |
_Backends)-Access the actual data via a proxy that abstracts different file
formats.str)-Returns the file format, either `"hdf5"`, `"xarray"`, or `"asdf"`.bool)-Is the data from a Salvus simulation?dict | None)-Contents of the job_info.json file.dict | None)-Contents of the meta.json file.pathlib.Path | None)-Path to the meta.json file for the simulation that created the data.
Can be None for observed data.list[ReceiverChannel])-The receiver channels for this event.list[str])-Return a list of receiver names for this event.list[simple_config.receiver._Base])-The receivers for this event.list[simple_config.source._Base])-The sources for this event.EventData object from a folder containing Salvus
outputs.def from_output_folder(output_folder: pathlib.Path) -> EventData: ...| Type: | pathlib.Path |
| Description: | Folder where the output files are stored. |
EventData object from an HDF5 file containing Salvus
outputs.def from_output_hdf5_file(filename: pathlib.Path) -> EventData: ...| Type: | pathlib.Path |
| Description: | File where the output data are stored. |
def compute_data_hash(self) -> str: ...def delete_associated_job_and_data(self) -> None: ...def download_extra_outputs(
self,
data_types_to_download: (
typing.Collection[typing.Literal["volume", "surface"]]
| typing.Literal["volume", "surface"]
) = frozenset({"surface", "volume"}),
localpath: pathlib.Path | str | None = None,
) -> None: ...| Type: | typing.Collection[typing.Literal['volume', 'surface']] | typing.Literal['volume', 'surface'] |
| Default value: | frozenset({'surface', 'volume'}) |
| Description: | The data types to download. Defaults to downloading everything. |
| Type: | pathlib.Path | str | None |
| Default value: | None |
| Description: | By default, downloads will be stored next to the meta.json of the EventData object. If this is set to a folder (that must exist) it will instead download to that folder and only put symlinks in the meta.json file's folder. |
def expected_components_from_receiver(
receiver: simple_config.receiver._Base | dict, receiver_field: str
) -> list[str]: ...| Type: | simple_config.receiver._Base | dict |
| Description: | The receiver object or dictionary representation. |
| Type: | str |
| Description: | The receiver field. |
def get_associated_salvus_job(self) -> SalvusJob: ...get_waveform_data_xarray for similar
functionality. Get a data cube for a given field and component. Useful
for plotting shotgathers and wiggle plots.sort_by(), filter_by() and select_by(). In absence of these,
receivers will be sorted as in the event object, unless sort_by or
select_by are altering the sort order.def get_data_cube(
self,
receiver_field: str,
component: str,
sort_by: typing.Callable[[_Base], int] | None = None,
filter_by: typing.Callable[[_Base], bool] | None = None,
select_by: (
typing.Callable[
[list[tuple[_Base, obspy.core.stream.Stream]], EventData],
list[tuple[_Base, obspy.core.stream.Stream]],
]
| None
) = None,
ignore_deprecation: bool = False,
) -> tuple[np.ndarray, np.ndarray]: ...| Type: | str |
| Description: | Receiver field to retrieve. |
| Type: | str |
| Description: | The component to retrieve. Note that for legacy reasons, this is always converted to an uppercase string, to mirror ObsPy behaviour, which was case-insensitive. |
| Type: | typing.Callable[[_Base], int] | None |
| Default value: | None |
| Description: | Callback function called with the receiver objects to determine the sorting. Works like the key callback for the standard Python sorted() method. |
| Type: | typing.Callable[[_Base], bool] | None |
| Default value: | None |
| Description: | 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. |
| Type: | typing.Callable[[list[tuple[_Base, obspy.core.stream.Stream]], EventData], list[tuple[_Base, obspy.core.stream.Stream]]] | None |
| Default value: | None |
| Description: | 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 object. |
| Type: | bool |
| Default value: | False |
| Description: | Hide the deprecation warning. |
def get_receiver(self, receiver_name: str) -> simple_config.receiver._Base: ...| Type: | str |
| Description: | The name of the receiver. |
def get_receiver_channel(
self, receiver_channel_name: str
) -> ReceiverChannel: ...| Type: | str |
| Description: | The name of the receiver channel. |
.get_waveform_data() instead.def get_receiver_data(
self,
receiver_name: str,
receiver_field: str,
header: typing.Any | None = None,
_ignore_temporal_weights: bool = False,
_use_cache: bool = False,
) -> obspy.Stream: ...| Type: | str |
| Description: | The name of the receiver |
| Type: | str |
| Description: | The field to get. |
| Type: | typing.Any | None |
| Default value: | None |
| Description: | Manually set the tr.stats.header to that value. Sometimes useful to have access to extra meta data in the processing and data selection functions. |
| Type: | bool |
| Default value: | False |
| Description: | Ignore temporal weights, even if they are set. Useful mainly for plotting and debugging purposes. Don't set this if you are not aware of the consequences. |
| Type: | bool |
| Default value: | False |
| Description: | Utilize a cache for this function. Useful for certain use cases with repeated per-station access. |
def get_remote_extra_output_filenames(
self,
) -> dict[tuple[str, ...], pathlib.Path]: ...def get_time_axis_from_meta_json(
self,
output_type: typing.Literal[
"simulation", "point_data", "surface_data", "volume_data"
] = "simulation",
) -> TimeAxis: ...| Type: | typing.Literal['simulation', 'point_data', 'surface_data', 'volume_data'] |
| Default value: | 'simulation' |
| Description: | Optionally define for which output type the time axis is constructed. The output_type "simulation" will always output the time axis as used by SalvusCompute. The other variations will adhere to the sampling rates of the output data for the relevant type. |
def get_wavefield_output(
self,
output_type: typing.Literal["volume", "surface"],
field: str,
time_steps: slice = slice(None, None, None),
download_if_not_exists: bool = False,
delete_remote_data_after_download: bool = False,
) -> salvus.toolbox.helpers.wavefield_output.WavefieldOutput: ...| Type: | typing.Literal['volume', 'surface'] |
| Description: | The output type to get, "surface" or "volume". |
| Type: | str |
| Description: | The field to get. |
| Type: | slice |
| Default value: | slice(None, None, None) |
| Description: | The time step indices to read expressed as a Python slice object. |
| Type: | bool |
| Default value: | False |
| Description: | The data might not yet exist locally and only on a remote Salvus site. If that is the case, try to automatically download it. It will be stored in the same folder as the meta.json file for the simulation. |
| Type: | bool |
| Default value: | False |
| Description: | Delete the remote data and associated Salvus job after the download has succeeded. If set, this will delete all remote files for the current event, even if only a subset has been downloaded. |
def get_waveform_data(
self,
receiver_name: str,
receiver_field: str,
header: typing.Any | None = None,
enforce_regular_time_grid: bool = True,
time_axis: TimeAxis | None = None,
_ignore_temporal_weights: bool = False,
_use_cache: bool = False,
) -> obspy.Stream: ...| Type: | str |
| Description: | The name of the receiver or receiver channel |
| Type: | str |
| Description: | The field to get. |
| Type: | typing.Any | None |
| Default value: | None |
| Description: | Manually set the tr.stats.header to that value. Sometimes useful to have access to extra meta data in the processing and data selection functions. |
| Type: | bool |
| Default value: | True |
| Description: | Whether to check if a synthetic dataset that is subsampled during the simulation has an appropriate time axis. By default, SalvusCompute will always output the last time step of a simulation, even when the subsampling chosen wouldn't match that point. Setting this parameter to True will check the meta.json specifications and ensure that the final point is removed again if it doesn't match the regular grid of the time axis. |
| Type: | TimeAxis | None |
| Default value: | None |
| Description: | Optionally specify a time axis for the data. Can be useful when dealing with heterogeneous data sources, such as seismological data, where the time axis may not be uniform across different stations. |
| Type: | bool |
| Default value: | False |
| Description: | Ignore temporal weights, even if they are set. Useful mainly for plotting and debugging purposes. Don't set this if you are not aware of the consequences. |
| Type: | bool |
| Default value: | False |
| Description: | Utilize a cache for this function. Useful for certain use cases with repeated per-station access. |
def get_waveform_data_xarray(
self,
receiver_field: str,
enforce_regular_time_grid: bool = True,
include_receiver_channel_inputs: bool = False,
receiver_ids: list[str] | None = None,
time_axis: TimeAxis | None = None,
_ignore_temporal_weights: bool = False,
_header_template: xr.DataArray | None = None,
_use_cache: bool = False,
_extra_output: ExtraOutput | None = None,
_extra_output_force_is_observed: bool | None = None,
) -> xr.DataArray: ...| Type: | str |
| Description: | The field to get. |
| Type: | bool |
| Default value: | True |
| Description: | Whether to check if a synthetic dataset that is subsampled during the simulation has an appropriate time axis. By default, SalvusCompute will always output the last time step of a simulation, even when the subsampling chosen wouldn't match that point. Setting this parameter to True will check the meta.json specifications and ensure that the final point is removed again if it doesn't match the regular grid of the time axis. |
| Type: | bool |
| Default value: | False |
| Description: | Include the input receivers for receiver channels in the returned data array. By default, only the final receiver channel data will be included. |
| Type: | list[str] | None |
| Default value: | None |
| Description: | Optionally specify a list of receiver IDs to filter the data by. If this is set, only the data for the specified receivers will be returned. If this is None, all receivers will be returned. |
| Type: | TimeAxis | None |
| Default value: | None |
| Description: | An optional time axis to resample the data to. This will overwrite any potentially set temporal interpolation settings of the event data object. |
| Type: | bool |
| Default value: | False |
| Description: | Ignore temporal weights, even if they are set. Useful mainly for plotting and debugging purposes. Don't set this if you are not aware of the consequences. |
| Type: | xr.DataArray | None |
| Default value: | None |
| Description: | A data set to use as a template for the header. |
| Type: | bool |
| Default value: | False |
| Description: | Utilize a cache for this function. Useful for certain use cases with repeated per-station access. |
| Type: | ExtraOutput | None |
| Default value: | None |
| Description: | Optionally write intermediate data to disk. |
| Type: | bool | None |
| Default value: | None |
| Description: | Force the waveform data to be considered observed data for the purpose of the extra output. Salvus considers all data that has been computed with it as synthetic but for the synthetic inversions the "observed" data should be written as observed extra output. |
def has_receiver(self, receiver_name: str) -> bool: ...| Type: | str |
| Description: | Name of the receiver. |
def has_receiver_nsl(
self, network_code: str, station_code: str, location_code: str
) -> bool: ...| Type: | str |
| Description: | The network code. |
| Type: | str |
| Description: | The station code. |
| Type: | str |
| Description: | The location code. |
def plot(
self,
plot_types: typing.Iterable[str] = ("wiggles",),
receiver_field: str,
component: str,
sort_by: typing.Callable | None = None,
) -> None: ...| Type: | typing.Iterable[str] |
| Default value: | ('wiggles',) |
| Description: | How to plot the data. |
| Type: | str |
| Description: | The receiver field to plot. |
| Type: | str |
| Description: | The component to plot. |
| Type: | typing.Callable | None |
| Default value: | None |
| Description: | Callback function called with the receiver objects to determine the sorting. Works like the key callback for the standard Python sorted() method. |
da: An xarray.DataArray object with the data.sources: The source objects of this eventst: An obspy.Stream object with the data.receiver: The receiver object for the receiver.sources: All sources for the event.inv: An obspy.Inventory object for the station in case it is
stored in an ASDF file. Might be None.xarray.DataArray or
obspy.Stream. Both must contain exactly the same number of traces,
components and time steps as the input data.def register_processing_function(
self,
function: typing.Callable | None,
chain_to_existing_function: bool = False,
) -> None: ...| Type: | typing.Callable | None |
| Description: | Function to process data on the fly. Or None to unset it. |
| Type: | bool |
| Default value: | False |
| Description: | If True the new function will be chained to a possibly already pre-existing processing function. If this is False and there is an already pre-existing function it will raise. |
da: An xarray.DataArray object with the data.sources: All sources for the event.st: An obspy.Stream object with the data.receiver: The receiver object for the receiver.sources: All sources for the event.def compute_temporal_weights( da: xr.DataArray, sources: list[simple_config.source._Base], ) -> dict[str, list[dict]]: ... # Omit components which you want to ignore for the adjoint source # computation. weights = { "X": [ {"values": np.array([...]), "misfit_weight": 0.5}, {"values": np.array([...]), "misfit_weight": 0.5}, ], "Y": [ # If no "misfit_weight" is given, it defaults to 1.0. {"values": np.array([...])}, ]} return weights
def register_temporal_weights_function(
self, function: typing.Callable | None, extra_kwargs: dict | None = None
) -> None: ...| Type: | typing.Callable | None |
| Description: | Function to compute windows on the fly. Or None to unset it. |
| Type: | dict | None |
| Default value: | None |
| Description: | Extra keyword arguments to pass to the function. |
def set_temporal_interpolation(
self,
start_time_in_seconds: float,
sampling_rate_in_hertz: float,
npts: int,
lanczos_window_width: int = 12,
taper_in_samples: int = 5,
reference_time: float | None = None,
) -> None: ...| Type: | float |
| Description: | The new start time in seconds. Can be interpreted as a UNIX timestamp if so desired. |
| Type: | float |
| Description: | The new sampling rate in Hertz. |
| Type: | int |
| Description: | The new number of samples. |
| Type: | int |
| Default value: | 12 |
| Description: | The width in samples on either side to use when interpolating onto a new sample. |
| Type: | int |
| Default value: | 5 |
| Description: | In case padding with zeros is necessary each traces will be tapered to zero using this many samples at each end it is being padded at. Necessary to avoid introducing unresolved frequencies. |
| Type: | float | None |
| Default value: | None |
| Description: | Reference time as a UTC timestamp in seconds. Needs to be set for seismological data. |
def shallow_copy(self) -> EventData: ...def unset_temporal_interpolation(self) -> None: ...class PlotProperties(builtins.object):
def __init__(
self, width: float = 11.5, height: float = 6.33, dpi: float = 100
) -> None: ...| Type: | float |
| Default value: | 11.5 |
| Description: | The width of the figure in inches. This parameter determines the horizontal size of the plot. |
| Type: | float |
| Default value: | 6.33 |
| Description: | The height of the figure in inches. This parameter determines the vertical size of the plot. |
| Type: | float |
| Default value: | 100 |
| Description: | Dots per inch (DPI) for the figure. DPI is a measure of the resolution or quality of the plot. Higher DPI values result in smoother and more detailed output. |