def test_travel_time(): datafiles, origin = read_data_dir('geonet', 'us1000778i', '*.V1A') streams = [] for datafile in datafiles: streams += read_data(datafile) cmps = {'NZ.HSES.HN': 42.118045132851641, 'NZ.WTMC.HN': 40.77244584723671, 'NZ.THZ.HN': 42.025007954412246} for stream in streams: minloc, mean_snr = pick_travel(stream, origin) np.testing.assert_almost_equal(minloc, cmps[stream.get_id()])
def test_travel_time(): datafiles, origin = read_data_dir('geonet', 'us1000778i', '*.V1A') streams = [] for datafile in datafiles: streams += read_data(datafile) cmps = { 'NZ.HSES.HN': 42.126519010847467, 'NZ.WTMC.HN': 40.7867451470294, 'NZ.THZ.HN': 42.016420026730088 } for stream in streams: minloc, mean_snr = pick_travel(stream, origin) np.testing.assert_almost_equal(minloc, cmps[stream.get_id()])
def signal_split(st, origin, picker_config=None, config=None): """ This method tries to identifies the boundary between the noise and signal for the waveform. The split time is placed inside the 'processing_parameters' key of the trace stats. The P-wave arrival is used as the split between the noise and signal windows. Multiple picker methods are suppored and can be configured in the config file '~/.gmprocess/picker.yml Args: st (StationStream): Stream of data. origin (ScalarEvent): ScalarEvent object. picker_config (dict): Dictionary containing picker configuration information. config (dict): Dictionary containing system configuration information. Returns: trace with stats dict updated to include a stats['processing_parameters']['signal_split'] dictionary. """ if picker_config is None: picker_config = get_config(section='pickers') if config is None: config = get_config() loc, mean_snr = pick_travel(st, origin, picker_config=picker_config) if loc > 0: tsplit = st[0].stats.starttime + loc preferred_picker = 'travel_time' else: pick_methods = ['ar', 'baer', 'power', 'kalkan'] columns = ['Stream', 'Method', 'Pick_Time', 'Mean_SNR'] df = pd.DataFrame(columns=columns) for pick_method in pick_methods: try: if pick_method == 'ar': loc, mean_snr = pick_ar(st, picker_config=picker_config, config=config) elif pick_method == 'baer': loc, mean_snr = pick_baer(st, picker_config=picker_config, config=config) elif pick_method == 'power': loc, mean_snr = pick_power(st, picker_config=picker_config, config=config) elif pick_method == 'kalkan': loc, mean_snr = pick_kalkan(st, picker_config=picker_config, config=config) elif pick_method == 'yeck': loc, mean_snr = pick_kalkan(st) except Exception: loc = -1 mean_snr = np.nan row = { 'Stream': st.get_id(), 'Method': pick_method, 'Pick_Time': loc, 'Mean_SNR': mean_snr } df = df.append(row, ignore_index=True) max_snr = df['Mean_SNR'].max() if not np.isnan(max_snr): maxrow = df[df['Mean_SNR'] == max_snr].iloc[0] tsplit = st[0].stats.starttime + maxrow['Pick_Time'] preferred_picker = maxrow['Method'] else: tsplit = -1 if tsplit >= st[0].stats.starttime: # Update trace params split_params = { 'split_time': tsplit, 'method': 'p_arrival', 'picker_type': preferred_picker } for tr in st: tr.setParameter('signal_split', split_params) return st
def signal_split( st, origin, picker_config=None, config=None): """ This method tries to identifies the boundary between the noise and signal for the waveform. The split time is placed inside the 'processing_parameters' key of the trace stats. The P-wave arrival is used as the split between the noise and signal windows. Multiple picker methods are suppored and can be configured in the config file '~/.gmprocess/picker.yml Args: st (StationStream): Stream of data. origin (ScalarEvent): ScalarEvent object. picker_config (dict): Dictionary containing picker configuration information. config (dict): Dictionary containing system configuration information. Returns: trace with stats dict updated to include a stats['processing_parameters']['signal_split'] dictionary. """ if picker_config is None: picker_config = get_config(section='pickers') if config is None: config = get_config() loc, mean_snr = pick_travel(st, origin, picker_config=picker_config) if loc > 0: tsplit = st[0].stats.starttime + loc preferred_picker = 'travel_time' else: pick_methods = ['ar', 'baer', 'power', 'kalkan'] columns = ['Stream', 'Method', 'Pick_Time', 'Mean_SNR'] df = pd.DataFrame(columns=columns) for pick_method in pick_methods: try: if pick_method == 'ar': loc, mean_snr = pick_ar( st, picker_config=picker_config, config=config) elif pick_method == 'baer': loc, mean_snr = pick_baer( st, picker_config=picker_config, config=config) elif pick_method == 'power': loc, mean_snr = pick_power( st, picker_config=picker_config, config=config) elif pick_method == 'kalkan': loc, mean_snr = pick_kalkan(st, picker_config=picker_config, config=config) elif pick_method == 'yeck': loc, mean_snr = pick_kalkan(st) except Exception: loc = -1 mean_snr = np.nan row = {'Stream': st.get_id(), 'Method': pick_method, 'Pick_Time': loc, 'Mean_SNR': mean_snr} df = df.append(row, ignore_index=True) max_snr = df['Mean_SNR'].max() if not np.isnan(max_snr): maxrow = df[df['Mean_SNR'] == max_snr].iloc[0] tsplit = st[0].stats.starttime + maxrow['Pick_Time'] preferred_picker = maxrow['Method'] else: tsplit = -1 if tsplit >= st[0].stats.starttime: # Update trace params split_params = { 'split_time': tsplit, 'method': 'p_arrival', 'picker_type': preferred_picker } for tr in st: tr.setParameter('signal_split', split_params) return st