示例#1
0
def test_update_user_levels_raise():
    user_module = "pytomo3d.window.tests.which_does_not_make_sense"
    with pytest.raises(Exception) as errmsg:
        win.update_user_levels(user_module, None, None, None, None, None)

    assert "Could not import the user_function module" in str(errmsg)

    user_module = "pytomo3d.window.io"
    with pytest.raises(Exception) as errmsg:
        win.update_user_levels(user_module, None, None, None, None, None)
    assert "Given user module does not have a generate_user_levels method" \
        in str(errmsg)
示例#2
0
def test_update_user_levels_raise():
    user_module = "pytomo3d.window.tests.which_does_not_make_sense"
    with pytest.raises(Exception) as errmsg:
        win.update_user_levels(user_module, None, None, None,
                               None, None)

    assert "Could not import the user_function module" in str(errmsg)

    user_module = "pytomo3d.window.io"
    with pytest.raises(Exception) as errmsg:
        win.update_user_levels(user_module, None, None, None,
                               None, None)
    assert "Given user module does not have a generate_user_levels method" \
        in str(errmsg)
示例#3
0
def test_update_user_levels():
    obs_tr = read(obsfile)[0]
    syn_tr = read(synfile)[0]

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

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

    user_module = "pytomo3d.window.tests.user_module_example"
    config = win.update_user_levels(user_module, config, inv, cat, obs_tr,
                                    syn_tr)

    npts = obs_tr.stats.npts
    assert isinstance(config.stalta_waterlevel, np.ndarray)
    assert len(config.stalta_waterlevel) == npts
    assert isinstance(config.tshift_acceptance_level, np.ndarray)
    assert len(config.tshift_acceptance_level) == npts
    assert isinstance(config.dlna_acceptance_level, np.ndarray)
    assert len(config.dlna_acceptance_level) == npts
    assert isinstance(config.cc_acceptance_level, np.ndarray)
    assert len(config.cc_acceptance_level) == npts
    assert isinstance(config.s2n_limit, np.ndarray)
    assert len(config.s2n_limit) == npts
示例#4
0
def test_update_user_levels():
    obs_tr = read(obsfile)[0]
    syn_tr = read(synfile)[0]

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

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

    user_module = "pytomo3d.window.tests.user_module_example"
    config = win.update_user_levels(user_module, config, inv, cat,
                                    obs_tr, syn_tr)

    npts = obs_tr.stats.npts
    assert isinstance(config.stalta_waterlevel, np.ndarray)
    assert len(config.stalta_waterlevel) == npts
    assert isinstance(config.tshift_acceptance_level, np.ndarray)
    assert len(config.tshift_acceptance_level) == npts
    assert isinstance(config.dlna_acceptance_level, np.ndarray)
    assert len(config.dlna_acceptance_level) == npts
    assert isinstance(config.cc_acceptance_level, np.ndarray)
    assert len(config.cc_acceptance_level) == npts
    assert isinstance(config.s2n_limit, np.ndarray)
    assert len(config.s2n_limit) == npts