From d3c8eb7b6a1d5fa16aa0c80c4ebe547a7bf6586a Mon Sep 17 00:00:00 2001 From: Marco Edoardo Santimaria Date: Mon, 26 May 2025 20:20:58 +0200 Subject: [PATCH 1/2] Fixes to tc_cross_workflow This commit fixes compatibility issues with modern version of python3, scipy version >= 1.15 and and numpy >= 2.2.6 --- tc_cross_correlation/normalization.py | 2 +- tc_cross_correlation/xcorr.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tc_cross_correlation/normalization.py b/tc_cross_correlation/normalization.py index a067a73..3d02a75 100755 --- a/tc_cross_correlation/normalization.py +++ b/tc_cross_correlation/normalization.py @@ -4,7 +4,7 @@ @author: abell5 """ -from scipy.signal import triang +from scipy.signal.windows import triang from numpy import sign, arange, zeros, absolute, true_divide, sum, floor, convolve, amax, logical_and import copy from obspy.signal import util diff --git a/tc_cross_correlation/xcorr.py b/tc_cross_correlation/xcorr.py index 4a1593e..0c9520f 100755 --- a/tc_cross_correlation/xcorr.py +++ b/tc_cross_correlation/xcorr.py @@ -7,7 +7,7 @@ from obspy.signal.util import next_pow_2 from scipy.fftpack import fft, ifft -from numpy import complex, conjugate, roll, copy +from numpy import complex64, conjugate, roll, copy def xcorrf(trace1, trace2, shift=None): """ @@ -26,7 +26,7 @@ def xcorrf(trace1, trace2, shift=None): # Always use 2**n-sized FFT, perform xcorr size = max(2 * shift + 1, (N1 + N2) // 2 + shift) nfft = next_pow_2(size) - print size + print(size) #Calculate fft of data1 and data2 IN1 = fft(data1, nfft) From 70504ad529d1400dee8efe8e0bb4c4766c06efb8 Mon Sep 17 00:00:00 2001 From: Marco Edoardo Santimaria Date: Wed, 11 Jun 2025 15:48:18 +0200 Subject: [PATCH 2/2] Added option to stream directory content when using CAPIO --- tc_cross_correlation/realtime_xcorr.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tc_cross_correlation/realtime_xcorr.py b/tc_cross_correlation/realtime_xcorr.py index ea3cea5..5b07c2c 100755 --- a/tc_cross_correlation/realtime_xcorr.py +++ b/tc_cross_correlation/realtime_xcorr.py @@ -30,10 +30,10 @@ def __init__(self): self._add_output('output', tuple_type=['number']) def process(self, inputs): store = [] - for dir in os.listdir(ROOT_DIR + 'DATA/'+ starttime): - for f in os.listdir(ROOT_DIR+'/DATA/'+ starttime +'/'+ dir): - file=ROOT_DIR+'DATA/'+ starttime + '/'+ dir+'/'+f - str1=np.load(file) + for dir in os.scandir(ROOT_DIR + 'DATA/' + starttime): + for f in os.scandir(ROOT_DIR + '/DATA/' + starttime + '/' + dir.name): + file = ROOT_DIR + 'DATA/' + starttime + '/' + dir.name + '/' + f.name + str1 = np.load(file) index = len(store) for i in range(index): self.write('output',[i, index, store[i], str1])