Mondaic

salvus.project.configuration.data_selection_configuration

salvus.project.configuration.data_selection_configuration salvus project configuration data_selection_configuration

Data selection configuration.

Classes

DataSelectionConfiguration

class DataSelectionConfiguration(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        name: str,
        receiver_field: str,
        data_selection_function: str | typing.Callable | None = None,
        extra_kwargs_data_selection: dict | None = None,
    ): ...

Configure which pieces of the data to use and how much they influence the final misfits and adjoint sources and thus the result of any inversion.

At the base level this means to select pieces of waveforms that are “good enough” to do whatever needs to be done - usually to enable a physically meaningful comparison between observed and synthetic data.

Here this is done via so-called temporal weights which are just an array of weights, one for each sample in a waveform. This can be used to for example mute arrivals after the primary arrival. It can also be used to only select certain windows in the data by setting the temporal weights to zero in time ranges one wants to mask out. Each component on each receiver can have multiple temporal weight sets or windows - misfits and adjoint sources will be computed and summed for each individually. Salvus takes care that everything is consistent in the end.

Furthermore this class enables settings weights at up to three different levels. They will all default to 1.0 but can be set individually.

  • Receiver weights to for example reduce the importance of clustered receivers or increase the influence of far-offset receivers.
  • Component weights for each receiver to prioritize for example vertical component recordings.
  • Window weights. Individual weights for each windows/temporal weight array enables an even finer grained control of what information enters an inversion. Use cases are for example to give higher weights to certain phases or use the signal to noise ratio to steer individual weights.

Together all of this enables use cases ranging from single phase selection, FWI window picking, exponential damping of energy after the first arrival, arbitrarily complex geometrical receiver weighting schemes and many more.

Please note that weighting individual events or misfit configurations is not handled here - in the case of SalvusProject it is handled by the inverse problem configuration.

There are largely two options to steer this:

  • Provide a data selection function. It will be called on-the-fly everytime data is requested.
  • Create an EventWindowAndWeightSet for each event. These can store interval windows and weights which on-the-fly will be mapped and applied to the data.

If both exist for an event, the EventWindowAndWeightSet will be given preference.

Parameters
  • name str — Name of the data selection configuration.
  • receiver_field str — The receiver field for which the window set is valid.
  • data_selection_function str | typing.Callable | None — Data selection function. Does not have to be given.
  • extra_kwargs_data_selection dict | None — Optional extra keyword arguments that will be passed to the data selection function.
Attributes
data_selection_function typing.Callable | None

Get the data selection function, if any.

data_selection_function_str str | None

Get the data selection function as str, if any.

Methods
from_json()
def from_json(d: builtins.dict) -> Any: ...

Recreate the object from a dictionary serialization of its initialization parameters.

Parameters
  • d builtins.dict — Dictionary containing its init parameters and a few other things.
Returns Any
create_new_event_window_and_weight_set()
def create_new_event_window_and_weight_set(
    self,
    event: Event,
    window_taper_width_in_seconds: float,
    taper_type: str = "hanning",
) -> EventWindowAndWeightSet: ...
Parameters
  • event Event — The event for which to get it.
  • window_taper_width_in_seconds float — Taper width in seconds when the windows will be applied to the data. The taper width will never be larger than half a window length.
  • taper_type str — The type of taper to use. Currently only "hanning" is supported which will use the classical cosine bell Hann/Hanning window.
Returns EventWindowAndWeightSet
delete_event_window_and_weight_set()
def delete_event_window_and_weight_set(self, event: Event | str) -> None: ...

Delete the event specific window and weight set.

Parameters
  • event Event | str — The event for which to delete it.
Returns None
get_event_window_and_weight_set()
def get_event_window_and_weight_set(
    self, event: Event
) -> EventWindowAndWeightSet: ...

Get an existing event specific window and weight set for this window and weight set collection.

Parameters
  • event Event — The event for which to get it.
Returns EventWindowAndWeightSet
get_interval_window_statistics_table()
def get_interval_window_statistics_table(
    self, events: list[Event] | EventCollection
) -> pd.DataFrame: ...

Get a pandas DataFrame with the interval window statistics for each passed event.

If an event does not have an EventWindowAndWeightSet its row will be filled with NaNs. Useful to get a quick overview of the picked windows in a larger project.

Parameters
  • events list[Event] | EventCollection — List of events to check.
Returns pd.DataFrame
get_temporal_weights_function_for_event()
def get_temporal_weights_function_for_event(
    self, event: Event
) -> typing.Callable: ...

Get the temporal weights function for a given event.

If an EventWindowAndWeightSet is available for the given event it will return that ones temporal weight function. Otherwise it will return the data selection function.

If neither is set it will raise.

Parameters
  • event Event — The event to get it for.
Returns typing.Callable
has_event_window_and_weight_set()
def has_event_window_and_weight_set(self, event: Event | str) -> bool: ...

Check if this window and weight set has event specific windows for this event.

Parameters
  • event Event | str — Event for which to check.
Returns bool
list_event_window_and_weight_sets()
def list_event_window_and_weight_sets(self) -> list[str]: ...

Return a list of all event names that have an event specific window and weight set in this overarching window and weight set.

Returns list[str]
to_json()
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...

Serialize the object to dictionary that can be written to JSON.

Parameters
  • external_file_hash str | None — Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
  • timer Timer | None — Execution timer.
  • log_to_logger bool — Log timings to the logger.
  • comm int | None — MPI communicator, if any.
Returns dict

Used in tutorials