Ejemplo n.º 1
0
def test_all_pickers():
    streams = get_streams()
    picker_config = get_config(section="pickers")
    methods = ["ar", "baer", "power", "kalkan"]
    columns = ["Stream", "Method", "Pick_Time", "Mean_SNR"]
    df = pd.DataFrame(columns=columns)
    for stream in streams:
        print(stream.get_id())
        for method in methods:
            try:
                if method == "ar":
                    loc, mean_snr = pick_ar(stream,
                                            picker_config=picker_config)
                elif method == "baer":
                    loc, mean_snr = pick_baer(stream,
                                              picker_config=picker_config)
                elif method == "power":
                    loc, mean_snr = pick_power(stream,
                                               picker_config=picker_config)
                elif method == "kalkan":
                    loc, mean_snr = pick_kalkan(stream,
                                                picker_config=picker_config)
                elif method == "yeck":
                    loc, mean_snr = pick_yeck(stream)
            except BaseException:
                loc = -1
                mean_snr = np.nan
            row = {
                "Stream": stream.get_id(),
                "Method": method,
                "Pick_Time": loc,
                "Mean_SNR": mean_snr,
            }
            df = df.append(row, ignore_index=True)

    stations = df["Stream"].unique()
    cmpdict = {
        "TW.ECU.BN": "kalkan",
        "TW.ELD.BN": "power",
        "TW.EGF.BN": "ar",
        "TW.EAS.BN": "ar",
        "TW.EDH.BN": "ar",
        "TK.4304.HN": "ar",
        "TK.0921.HN": "ar",
        "TK.5405.HN": "ar",
        "NZ.HSES.HN": "baer",
        "NZ.WTMC.HN": "baer",
        "NZ.THZ.HN": "power",
    }
    for station in stations:
        station_df = df[df["Stream"] == station]
        max_snr = station_df["Mean_SNR"].max()
        maxrow = station_df[station_df["Mean_SNR"] == max_snr].iloc[0]
        method = maxrow["Method"]
        try:
            assert cmpdict[station] == method
        except Exception as e:
            pass
Ejemplo n.º 2
0
def test_all_pickers():
    streams = get_streams()
    picker_config = get_config(section='pickers')
    methods = ['ar', 'baer', 'power', 'kalkan']
    columns = ['Stream', 'Method', 'Pick_Time', 'Mean_SNR']
    df = pd.DataFrame(columns=columns)
    for stream in streams:
        print(stream.get_id())
        for method in methods:
            try:
                if method == 'ar':
                    loc, mean_snr = pick_ar(stream,
                                            picker_config=picker_config)
                elif method == 'baer':
                    loc, mean_snr = pick_baer(stream,
                                              picker_config=picker_config)
                elif method == 'power':
                    loc, mean_snr = pick_power(stream,
                                               picker_config=picker_config)
                elif method == 'kalkan':
                    loc, mean_snr = pick_kalkan(stream,
                                                picker_config=picker_config)
                elif method == 'yeck':
                    loc, mean_snr = pick_yeck(stream)
            except BaseException:
                loc = -1
                mean_snr = np.nan
            row = {
                'Stream': stream.get_id(),
                'Method': method,
                'Pick_Time': loc,
                'Mean_SNR': mean_snr
            }
            df = df.append(row, ignore_index=True)

    stations = df['Stream'].unique()
    cmpdict = {
        'TW.ECU.BN': 'kalkan',
        'TW.ELD.BN': 'power',
        'TW.EGF.BN': 'ar',
        'TW.EAS.BN': 'ar',
        'TW.EDH.BN': 'ar',
        'TK.4304.HN': 'ar',
        'TK.0921.HN': 'ar',
        'TK.5405.HN': 'ar',
        'NZ.HSES.HN': 'baer',
        'NZ.WTMC.HN': 'baer',
        'NZ.THZ.HN': 'power'
    }
    for station in stations:
        station_df = df[df['Stream'] == station]
        max_snr = station_df['Mean_SNR'].max()
        maxrow = station_df[station_df['Mean_SNR'] == max_snr].iloc[0]
        method = maxrow['Method']
        try:
            assert cmpdict[station] == method
        except Exception as e:
            pass
Ejemplo n.º 3
0
def signal_split(st, origin, model=None, 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.
        model (TauPyModel):
            TauPyModel object for computing travel times.
        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, model)
    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 BaseException:
                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

    # the user may have specified a p_arrival_shift value.
    # this is used to shift the P arrival time (i.e., the break between the
    # noise and signal windows).
    shift = 0.0
    if "p_arrival_shift" in picker_config:
        shift = picker_config["p_arrival_shift"]
        if tsplit + shift >= st[0].stats.starttime:
            tsplit += shift

    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