Rename directory applicationCode -> src

This commit is contained in:
2025-01-31 11:35:37 +01:00
parent 443534663e
commit 18a8c7aa13
6 changed files with 0 additions and 0 deletions

14
src/util/Find_idx4Time.py Normal file
View File

@@ -0,0 +1,14 @@
import numpy as np
def Find_idx4Time(In_mat, t):
# In_mat: time array
# t = target time
In_mat = np.array(In_mat)
t = np.array(t)
if len(np.shape(t)) == 0:
return np.where(abs(In_mat - t) <= min(abs(In_mat - t)))[0][0]
else:
In_mat = In_mat.reshape((len(In_mat), 1))
t = t.reshape((1,len(t)))
target_time = np.matmul(np.ones((len(In_mat),1)), t)
diff_mat = target_time - In_mat
return np.where(abs(diff_mat) <= np.min(abs(diff_mat), axis = 0))