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

salvus.project.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: Optional[str, Callable] = 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 Optional[str, Callable] — Data selection function. Does not have to be given.
Attributes
data_selection_function Optional[Callable]

Get the data selection function, if any.

data_selection_function_str Optional[str]

Get the data selection function as str, if any.

Methods
from_json()
def from_json(d: Dict) -> Any: ...

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

Parameters
  • d 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: salvus.flow.collections.event.Event,
    window_taper_width_in_seconds: float,
    taper_type: str = "hanning",
) -> (
    salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet
): ...
Parameters
  • event salvus.flow.collections.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 salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet
delete_event_window_and_weight_set()
def delete_event_window_and_weight_set(
    self, event: Union[salvus.flow.collections.event.Event, str]
) -> None: ...

Delete the event specific window and weight set.

Parameters
  • event Union[salvus.flow.collections.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: salvus.flow.collections.event.Event
) -> (
    salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet
): ...

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

Parameters
  • event salvus.flow.collections.event.Event — The event for which to get it.
Returns salvus.flow.collections.event_window_and_weight_set.EventWindowAndWeightSet
get_interval_window_statistics_table()
def get_interval_window_statistics_table(
    self,
    events: Union[
        List[salvus.flow.collections.event.Event],
        salvus.flow.collections.event_collection.EventCollection,
    ],
) -> pandas.core.frame.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 Union[List[salvus.flow.collections.event.Event], salvus.flow.collections.event_collection.EventCollection] — List of events to check.
Returns pandas.core.frame.DataFrame
get_temporal_weights_function_for_event()
def get_temporal_weights_function_for_event(
    self, event: salvus.flow.collections.event.Event
) -> 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 salvus.flow.collections.event.Event — The event to get it for.
Returns Callable
has_event_window_and_weight_set()
def has_event_window_and_weight_set(
    self, event: Union[salvus.flow.collections.event.Event, str]
) -> bool: ...

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

Parameters
  • event Union[salvus.flow.collections.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) -> Dict: ...

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

Returns Dict