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

salvus.flow.collections.event_window_and_weight_set

Classes

EventWindowAndWeightSet

class EventWindowAndWeightSet(builtins.object):
    def __init__(
        self,
        event: salvus.flow.collections.event.Event,
        filename: pathlib.Path,
        receiver_field: Optional[str] = None,
        window_taper_width_in_seconds: Optional[float] = None,
        taper_type: Optional[str] = None,
    ):
        ...

Event specific window and weight set.

*In most cases this class will be used indirectly through SalvusProject.

Functionally it can store an arbitrary amount of windows per receiver and component. In addition it stores weights at the receiver, the component, and the level of individual windows.

Any receiver component that does not explicitly have a window assigned will be assumed to have no picked windows and will thus be ignored in any misfit and adjoint source computation.

It can store interval windows that have a start as well as an end time. In addition it can optionally store an absolute UTC reference time and if that is given, all window times are assumed to be relative to it. Convenience methods to directly operate with absolute times are provided.

When being applied to data this class will on-the-fly convert the windows to temporal weights with a taper being applied. Thus the weights will be zero outside the windows and taper to one from the window boundaries to window_taper_width_in_seconds distance from the window boundaries.

Parameters
  • event salvus.flow.collections.event.Event — The corresponding event object for this window and weight set. Needs to be passed every time as it is not serialized alongside the windows and weights.
  • filename pathlib.Path — Path of the JSON file where it will be stored.
  • receiver_field Optional[str] — The receiver field for which this window and weight set is valid. Only has to be specified if filename does not yet exist.
  • window_taper_width_in_seconds Optional[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 Optional[str] — The type of taper to use. Currently only "hanning" is supported which will use the classical cosine bell Hann/Hanning window. Will default to "hanning" if not given.
Methods
add_interval_window()
def add_interval_window(
    self,
    receiver_name: str,
    component: str,
    window_start_time_in_seconds: float,
    window_end_time_in_seconds: float,
    window_weight: float = 1.0,
) -> None:
    ...

Add an interval window to the window and weight set.

Parameters
  • receiver_name str — Full name of the receiver.
  • component str — The receiver component.
  • window_start_time_in_seconds float — The start time of the window in seconds relative to time zero of the event.
  • window_end_time_in_seconds float — The end time of the window in seconds relative to time zero of the event.
  • window_weight float — Weight for the window. Should not be more than one.
Returns None
add_interval_window_utc_datetime()
def add_interval_window_utc_datetime(
    self,
    receiver_name: str,
    component: str,
    window_start_time: obspy.core.utcdatetime.UTCDateTime,
    window_end_time: obspy.core.utcdatetime.UTCDateTime,
    window_weight: float = 1.0,
) -> None:
    ...

Add a UTCDateTime interval window to the window and weight set.

This only works if the event of the window and weight set has a set reference time.

Parameters
  • receiver_name str — Full name of the receiver.
  • component str — The receiver component.
  • window_start_time obspy.core.utcdatetime.UTCDateTime — The start time of the window in seconds relative to time zero of the event.
  • window_end_time obspy.core.utcdatetime.UTCDateTime — The end time of the window in seconds relative to time zero of the event.
  • window_weight float — Weight for the window. Should not be more than one.
Returns None
clear()
def clear(self) -> None:
    ...

Remove all windows and set all weights to 1.

Returns None
get_interval_window_statistics()
def get_interval_window_statistics(
    self,
) -> Dict[str, Union[float, int, NoneType]]:
    ...

Return a dictionary of statistics about the interval windows.

Returns Dict[str, Union[float, int, NoneType]]
get_latest_end_time()
def get_latest_end_time(self) -> float:
    ...

Returns the latest end time in seconds.

If a reference time is set this is defined relative to it.

Returns float
get_latest_utc_end_time()
def get_latest_utc_end_time(self) -> obspy.core.utcdatetime.UTCDateTime:
    ...

Returns the latest end time in seconds.

If a reference time is set this is defined relative to it.

Returns obspy.core.utcdatetime.UTCDateTime
get_utc_datetime_windows_and_weights_for_receiver_component()
def get_utc_datetime_windows_and_weights_for_receiver_component(
    self, receiver_name: str, component: str
) -> Dict[str, Any]:
    ...

Get the windows and weights for a specific receiver and component.

Parameters
  • receiver_name str — The name of the receiver.
  • component str — The component.
Returns Dict[str, Any]
get_windows_and_weights_for_receiver_component()
def get_windows_and_weights_for_receiver_component(
    self, receiver_name: str, component: str
) -> Dict[str, Any]:
    ...

Get the windows and weights for a specific receiver and component.

Parameters
  • receiver_name str — The name of the receiver.
  • component str — The component.
Returns Dict[str, Any]
temporal_weights_function()
def temporal_weights_function(
    self,
    st: obspy.core.stream.Stream,
    receiver: salvus.flow.simple_config.receiver._Base,
    sources: List[salvus.flow.simple_config.source._Base],
) -> Dict[str, Union[Dict[str, Dict[str, Any]], List[Dict[str, Any]]]]:
    ...

The temporal weights function for the window set.

This can be directly passed to an EventData object which will apply it.

Parameters
  • st obspy.core.stream.Stream — An obspy.Stream object with the data.
  • receiver salvus.flow.simple_config.receiver._Base — The receiver object for the receiver.
  • sources List[salvus.flow.simple_config.source._Base] — All sources for the event.
Returns Dict[str, Union[Dict[str, Dict[str, Any]], List[Dict[str, Any]]]]
write()
def write(self, overwrite: bool = False) -> None:
    ...

Serializes the currently collected windows to disc.

Parameters
  • overwrite bool — Overwite an existing file if this is True.
Returns None