Exemple #1
0
def test_read_config():
    config_file = os.path.join(DATA_DIR, "27_60.BHZ.config.yaml")
    config = win.load_window_config_yaml(config_file)
    assert isinstance(config, pyflex.Config)
    assert config.max_period == 60.0
    assert config.min_period == 27.0
    assert config.stalta_waterlevel == 0.10
Exemple #2
0
def test_load_window_config_yaml():
    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = win.load_window_config_yaml(config_file)
    assert isinstance(config, pyflex.Config)
    assert config.max_period == 60.0
    assert config.min_period == 27.0
    assert config.stalta_waterlevel == 0.10
Exemple #3
0
def test_window_on_stream():
    obs_tr = read(obsfile)
    syn_tr = read(synfile)

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = win.load_window_config_yaml(config_file)
    config_dict = {"Z": config, "R": config, "T": config}

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = win.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)
    inv = read_inventory(staxml)

    windows = win.window_on_stream(obs_tr,
                                   syn_tr,
                                   config_dict,
                                   station=inv,
                                   event=cat,
                                   _verbose=False,
                                   figure_mode=False)
    assert len(windows) > 0
Exemple #4
0
def test_window_on_trace():
    obs_tr = read(obsfile).select(channel="*Z")[0]
    syn_tr = read(synfile).select(channel="*Z")[0]

    config_file = os.path.join(DATA_DIR, "27_60.BHZ.config.yaml")
    config = win.load_window_config_yaml(config_file)

    quakeml = os.path.join(DATA_DIR, "C201009031635A.xml")
    cat = readEvents(quakeml)

    windows = win.window_on_trace(obs_tr, syn_tr, config, station=inv,
                                  event=cat, _verbose=False,
                                  figure_mode=False)

    winfile_bm = os.path.join(DATA_DIR, "benchmark",
                              "IU.KBL..BHZ.window.json")
    with open(winfile_bm) as fh:
        windows_json = json.load(fh)
    for _win, _win_json_bm in zip(windows, windows_json):
        _win_bm = Window._load_from_json_content(_win_json_bm)
        assert _win == _win_bm
Exemple #5
0
def test_plot_window_figure(tmpdir):
    reset_matplotlib()

    obs_tr = read(obsfile).select(channel="*R")[0]
    syn_tr = read(synfile).select(channel="*R")[0]

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = win.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)
    inv = read_inventory(staxml)

    ws = WindowSelector(obs_tr, syn_tr, config, event=cat, station=inv)
    windows = ws.select_windows()

    assert len(windows) > 0

    win.plot_window_figure(str(tmpdir),
                           obs_tr.id,
                           ws,
                           True,
                           figure_format="png")
Exemple #6
0
def test_window_on_trace(tmpdir):
    obs_tr = read(obsfile).select(channel="*R")[0]
    syn_tr = read(synfile).select(channel="*R")[0]

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = win.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)

    inv = read_inventory(staxml)
    windows = win.window_on_trace(obs_tr,
                                  syn_tr,
                                  config,
                                  station=inv,
                                  event=cat,
                                  _verbose=False,
                                  figure_mode=False)

    filename = os.path.join(str(tmpdir), "window.txt")
    wrw.write_txtfile(windows, filename)

    filename = os.path.join(str(tmpdir), "window.json")
    wrw.write_jsonfile(windows, filename)
Exemple #7
0
def test_window_on_trace():
    obs_tr = read(obsfile).select(channel="*R")[0]
    syn_tr = read(synfile).select(channel="*R")[0]

    config_file = os.path.join(DATA_DIR, "window", "27_60.BHZ.config.yaml")
    config = win.load_window_config_yaml(config_file)

    cat = readEvents(quakeml)

    inv = read_inventory(staxml)
    windows = win.window_on_trace(obs_tr,
                                  syn_tr,
                                  config,
                                  station=inv,
                                  event=cat,
                                  _verbose=False,
                                  figure_mode=False)

    winfile_bm = os.path.join(DATA_DIR, "window", "IU.KBL..BHR.window.json")
    with open(winfile_bm) as fh:
        windows_json = json.load(fh)
    for _win, _win_json_bm in zip(windows, windows_json):
        _win_bm = Window._load_from_json_content(_win_json_bm)
        assert _win == _win_bm