<jupyter_start><jupyter_text>The onset functionThis tutorial will cover the basic ideas and definitions behind the onset function, as well as showing the user how to create their own.*** Contents* [Onset function definitions](The-default-Onset-function---STA/LTA)* [Creating an Onset function](Creating-an-instance-of-the-onset-class)***The onset function is a continuous measure of the probability of a seismic phase onset being observed at a station. It is used to distill simplified waveform information from a continuous recording.We pad each timestep (as defined in sections 2.4 and 2.6) prior to calculation of the onset functions. The pre-pad, defined as the widest LTA window plus three times the widest STA window, and the post-pad, defined as the maximum travel time from any station to a point in the grid plus the widest LTA window, are required to ensure the onset function can be correctly calculated for the first and last samples in the timestep, respectively. An additional term, equal to 0.06 times the padded timestep, is added on either end in order to accommodate the cosine taper that is applied to the data prior to filtering. The data is filtered using a zero-phase Butterworth band-pass filter with user-defined low-pass and high-pass frequencies. For each station, the onset functions for the P- and S-phases are determined from the vertical and horizontal components, respectively.  The default Onset function - STA/LTAThe basic onset function used in QuakeMigrate is the ratio between the average value in a short-term window to that in a long-term window. A simple mathematical description can be found in Appendix A.The relative positioning of the STA and LTA windows can be chosen from the ‘classic’ (overlapping) or centred configurations.In the ‘classic’ configuration, the STA window is within the LTA window and the ratio is assigned to the end of the windows. This is less sensitive to data with sharp offsets due to instrument failures. This is the default configuration for Detect. In the centred configuration, the STA window is preceded by the LTA window and the ratio is assigned to the end of the LTA window (the start of the STA window). The resultant onset function is less phase-shifted (late) and is, strictly speaking, the form for which the Gaussian approximation described in Drew et al. (2013) is most appropriate. If the data quality allows it, a centred window should be used for Locate. $$O(t) = \frac{W_{L}\int_{0}^{Ws} |y(t+\tau)|d\tau}{W_{S}\int_{-W_{L}}^{0} |y(t+\tau)|d\tau}$$<jupyter_code>from QMigrate.signal import onset

# Create a new instance of Onset object
onset = onset.ClassicSTALTAOnset()
onset.p_bp_filter = [0.5, 2.49, 2]
onset.s_bp_filter = [0.5, 2.49, 2]
onset.p_onset_win = [0.2, 1.5]
onset.s_onset_win = [0.2, 1.5]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0652713728272437, 'fraction_numerical': 0.011706278822277403, 'mean_word_length': 4.766871165644171, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '611811', 'license': 'MIT', 'n_tokens_mistral': 790, 'n_tokens_neox': 738, 'n_words': 409, 'path': 'docs/source/tuts/Onset function.ipynb', 'repo_name': 'TomWinder/QuakeMigrate', 'size': '2819'}