lasif.window_selection¶
Window selection algorithm.
This module aims to provide a window selection algorithm suitable for calculating phase misfits between two seismic waveforms.
The main function is the select_windows() function. The selection process is a multi-stage process. Initially all time steps are considered to be valid in the sense as being suitable for window selection. Then a number of selectors is applied, progressively excluding more and more time steps.
copyright: | Lion Krischer (krischer@geophysik.uni-muenchen.de), 2013 |
---|---|
license: | GNU General Public License, Version 3 (http://www.gnu.org/copyleft/gpl.html) |
-
lasif.window_selection.
find_closest
(ref_array, target)[source]¶ For every value in target, find the index of ref_array to which the value is closest.
from http://stackoverflow.com/a/8929827/1657047
Parameters: - ref_array (
numpy.ndarray
) – The reference array. Must be sorted! - target (
numpy.ndarray
) – The target array.
>>> ref_array = np.arange(0, 20.) >>> target = np.array([-2, 100., 2., 2.4, 2.5, 2.6]) >>> find_closest(ref_array, target) array([ 0, 19, 2, 2, 3, 3])
- ref_array (
-
lasif.window_selection.
find_local_extrema
(data)[source]¶ Function finding local extrema. It can also deal with flat extrema, e.g. a flat top or bottom. In that case the first index of all flat values will be returned.
Returns a tuple of maxima and minima indices.
-
lasif.window_selection.
flatnotmasked_contiguous
(time_windows)[source]¶ Helper function enabling to loop over empty time windows.
-
lasif.window_selection.
select_windows
(data_trace, synthetic_trace, event_latitude, event_longitude, event_depth_in_km, station_latitude, station_longitude, minimum_period, maximum_period, min_cc=0.1, max_noise=0.1, max_noise_window=0.4, min_velocity=2.4, threshold_shift=0.3, threshold_correlation=0.75, min_length_period=1.5, min_peaks_troughs=2, max_energy_ratio=10.0, min_envelope_similarity=0.2, verbose=False, plot=False)[source]¶ Window selection algorithm for picking windows suitable for misfit calculation based on phase differences.
Returns a list of windows which might be empty due to various reasons.
This function is really long and a lot of things. For a more detailed description, please see the LASIF paper.
Parameters: - data_trace (
Trace
) – The data trace. - synthetic_trace (
Trace
) – The synthetic trace. - event_latitude (float) – The event latitude.
- event_longitude (float) – The event longitude.
- event_depth_in_km (float) – The event depth in km.
- station_latitude (float) – The station latitude.
- station_longitude (float) – The station longitude.
- minimum_period (float) – The minimum period of the data in seconds.
- maximum_period (float) – The maximum period of the data in seconds.
- min_cc (float) – Minimum normalised correlation coefficient of the complete traces.
- max_noise (float) – Maximum relative noise level for the whole trace. Measured from maximum amplitudes before and after the first arrival.
- max_noise_window (float) – Maximum relative noise level for individual windows.
- min_velocity (float) – All arrivals later than those corresponding to the threshold velocity [km/s] will be excluded.
- threshold_shift (float) – Maximum allowable time shift within a window, as a fraction of the minimum period.
- threshold_correlation (float) – Minimum normalised correlation coeeficient within a window.
- min_length_period (float) – Minimum length of the time windows relative to the minimum period.
- min_peaks_troughs (float) – Minimum number of extrema in an individual time window (excluding the edges).
- max_energy_ratio (float) – Maximum energy ratio between data and synthetics within a time window. Don’t make this too small!
- min_envelope_similarity (float) – The minimum similarity of the envelopes of both data and synthetics. This essentially assures that the amplitudes of data and synthetics can not diverge too much within a window. It is a bit like the inverse of the ratio of both envelopes so a value of 0.2 makes sure neither amplitude can be more then 5 times larger than the other.
- verbose (bool) – No output by default.
- plot (bool) – Create a plot of the algortihm while it does its work.
- data_trace (