Skip to content

Commit

Permalink
add auto-correlation test
Browse files Browse the repository at this point in the history
Signed-off-by: Yiyu Ni <niyiyu@uw.edu>
  • Loading branch information
niyiyu committed Jul 6, 2024
1 parent 694e1bf commit e44919c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/noisepy/seis/noise_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def correlate(fft1_smoothed_abs, fft2, D, Nfft, dataS_t):
)

# check if we are in the case of autocorrelation
if np.all(fft1_smoothed_abs == fft2):
if np.all(np.abs(fft1_smoothed_abs) == np.abs(fft2)):
x_corr = False
else:
x_corr = True
Expand Down
Binary file added tests/data/acc/CIHEC__BHN___2022002.ms
Binary file not shown.
7 changes: 5 additions & 2 deletions tests/test_cross_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ def get_inventory(self, timespan: DateTimeRange, station: Station) -> obspy.Inve
@pytest.mark.parametrize("substack", [True, False])
@pytest.mark.parametrize("substack_len", [1, 2])
@pytest.mark.parametrize("inc_hours", [0, 24])
def test_correlation(rm_resp: RmResp, cc_method: CCMethod, substack: bool, substack_len: int, inc_hours: int):
@pytest.mark.parametrize("dpath", ["./data/cc", "./data/acc"])
def test_cross_correlation(
rm_resp: RmResp, cc_method: CCMethod, substack: bool, substack_len: int, inc_hours: int, dpath: str
):
config = ConfigParameters()
config.samp_freq = 1.0
config.rm_resp = rm_resp
Expand All @@ -90,7 +93,7 @@ def test_correlation(rm_resp: RmResp, cc_method: CCMethod, substack: bool, subst
if substack:
config.substack = substack
config.substack_len = substack_len * config.cc_len
path = os.path.join(os.path.dirname(__file__), "./data/cc")
path = os.path.join(os.path.dirname(__file__), dpath)

raw_store = SCEDCS3DataStore(path, MockCatalogMock())
ts = raw_store.get_timespans()
Expand Down

0 comments on commit e44919c

Please sign in to comment.