DAS routines and modelling.
das
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1 KiB

1 year ago
import os.path as op
1 year ago
import numpy as num
import pytest
from lightguide import goldstein, rust
1 year ago
1 year ago
@pytest.fixture
def data():
import lightguide
1 year ago
das_dir = lightguide.__file__
1 year ago
return num.load(op.join(op.dirname(das_dir), "data", "data-DAS-gfz2020wswf.npy"))
1 year ago
@pytest.fixture
def data_big():
n = 8192
return num.random.uniform(size=(n, n)).astype(num.float32)
1 year ago
def test_taper():
1 year ago
window = goldstein.triangular_taper(32, 4)
1 year ago
assert window[32 // 2, 32 // 2] == 1.0
assert window.shape == (32, 32)
1 year ago
window_rust = rust.triangular_taper(32, 4)
num.testing.assert_almost_equal(window, window_rust)
# def test_benchmark_goldstein(benchmark, data):
# benchmark(goldstein.goldstein_filter, data, 32, 14, 0.5)
1 year ago
def test_benchmark_goldstein_rust(benchmark, data_big):
benchmark(rust.goldstein_filter, data_big, 32, 14, 0.5)
1 year ago
1 year ago
def asdtest_goldstein(data):
1 year ago
filtered_data = goldstein.goldstein_filter(data, 32, 14, 0.5)
filtered_data_rust = rust.goldstein_filter(data, 32, 14, 0.5)
1 year ago
1 year ago
num.testing.assert_allclose(filtered_data_rust, filtered_data)