Beispiel #1
0
def test_calculate_adrjrc_on_trace_raises_if_syn_is_not_trace():
    obs, syn, win_time = setup_calculate_adjsrc_on_trace_args()
    config = load_config_multitaper()
    syn = []
    with pytest.raises(ValueError):
        adj.calculate_adjsrc_on_trace(obs, syn, win_time, config,
                                      adj_src_type="multitaper_misfit")
Beispiel #2
0
def test_calculate_adjsrc_on_trace_raises_bad_windows_shape():
    obs, syn, win_time = setup_calculate_adjsrc_on_trace_args()
    config = load_config_multitaper()
    win_time = []
    with pytest.raises(ValueError):
        adj.calculate_adjsrc_on_trace(obs, syn, win_time, config,
                                      adj_src_type="multitaper_misfit")
Beispiel #3
0
def test_waveform_adjoint():
    obs = read(obsfile).select(channel="*R")[0]
    syn = read(synfile).select(channel="*R")[0]

    with open(winfile) as fh:
        wins_json = json.load(fh)
    windows = []
    for _win in wins_json:
        windows.append(Window._load_from_json_content(_win))

    config_file = os.path.join(DATA_DIR, "adjoint",
                               "waveform.adjoint.config.yaml")
    config = adj.load_adjoint_config_yaml(config_file)

    win_time, _ = adj._extract_window_time(windows)

    adjsrc = adj.calculate_adjsrc_on_trace(
        obs, syn, win_time, config, adj_src_type="waveform_misfit",
        adjoint_src_flag=True, figure_mode=False)

    # tr_adj = adj._convert_adj_to_trace(adjsrc, syn.stats.starttime, syn.id)
    # tr.write("%s.sac" % syn.id, format="SAC")
    # plot_adjoint_source(adjsrc, win_time, obs, syn)

    assert adjsrc
Beispiel #4
0
def test_calculate_adjsrc_on_trace_traveltime_misfit_produces_adjsrc():
    obs, syn, win_time = setup_calculate_adjsrc_on_trace_args()
    config = load_config_traveltime()

    adjsrc = adj.calculate_adjsrc_on_trace(
        obs, syn, win_time, config, adj_src_type="cc_traveltime_misfit",
        adjoint_src_flag=True, figure_mode=False)
    assert adjsrc
Beispiel #5
0
def test_calculate_adjsrc_on_trace_figure_mode_none_figure_dir():
    obs, syn, win_time = setup_calculate_adjsrc_on_trace_args()
    config = load_config_multitaper()
    plt.switch_backend('agg')
    adjsrc = adj.calculate_adjsrc_on_trace(
        obs, syn, win_time, config, adj_src_type="multitaper_misfit",
        figure_mode=True)
    assert adjsrc