salvus.flow.collections.event_window_and_weight_set
Classes
EventWindowAndWeightSet
EventWindowAndWeightSetclass 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.
eventsalvus.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.filenamepathlib.Path — Path of the JSON file where it will be stored.receiver_fieldOptional[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_secondsOptional[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_typeOptional[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.
add_interval_window()
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.
receiver_namestr — Full name of the receiver.componentstr — The receiver component.window_start_time_in_secondsfloat — The start time of the window in seconds relative to time zero of the event.window_end_time_in_secondsfloat — The end time of the window in seconds relative to time zero of the event.window_weightfloat — Weight for the window. Should not be more than one.
add_interval_window_utc_datetime()
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.
receiver_namestr — Full name of the receiver.componentstr — The receiver component.window_start_timeobspy.core.utcdatetime.UTCDateTime — The start time of the window in seconds relative to time zero of the event.window_end_timeobspy.core.utcdatetime.UTCDateTime — The end time of the window in seconds relative to time zero of the event.window_weightfloat — Weight for the window. Should not be more than one.
clear()
clear()def clear(self) -> None:
...Remove all windows and set all weights to 1.
get_interval_window_statistics()
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.
get_latest_end_time()
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.
get_latest_utc_end_time()
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.
get_utc_datetime_windows_and_weights_for_receiver_component()
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.
receiver_namestr — The name of the receiver.componentstr — The component.
get_windows_and_weights_for_receiver_component()
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.
receiver_namestr — The name of the receiver.componentstr — The component.
temporal_weights_function()
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.
stobspy.core.stream.Stream — Anobspy.Streamobject with the data.receiversalvus.flow.simple_config.receiver._Base — The receiver object for the receiver.sourcesList[salvus.flow.simple_config.source._Base] — All sources for the event.
write()
write()def write(self, overwrite: bool = False) -> None:
...Serializes the currently collected windows to disc.
overwritebool — Overwite an existing file if this isTrue.