Few corrections have been made on calibration, in particular, for the interpolation of the fine sediments profile. The user can invert several acoustic recording with a single calibration. There remains a prolem to display the plots, in particular, when the user switches from one to another acoustic data.

This commit is contained in:
brahim committed 2024-09-19 14:54:44 +02:00
1 parent bba389ae9d
commit 8c51ebc192
5 files changed
+1106 -752

No files matched your search

@@ -207,70 +207,134 @@ class AcousticInversionMethodHighConcentration():
# ------------- Computing interpolation of fine SSC data obtained from water sampling -------------
# ------------- collected at various depth in the vertical sample -------------
# def M_profile_SCC_fine_interpolated(self, sample_depth, M_profile, range_cells, r_bottom):
# res = np.zeros((len(range_cells),)) * np.nan
# for i in range(len(M_profile) - 1):
# # print(f"i = {i}")
# r_ini = sample_depth[i]
# # print(f"r_ini = {r_ini}")
# c_ini = M_profile[i]
# # print(f"c_ini = {c_ini}")
# r_end = sample_depth[i + 1]
# # print(f"r_end = {r_end}")
# c_end = M_profile[i + 1]
# # print(f"c_end = {c_end}")
#
# # Computing the linear equation
# a = (c_end - c_ini) / (r_end - r_ini)
# # print(f"a = {a}")
# b = c_ini - a * r_ini
# # print(f"b = {b}")
#
# # Finding the indices of r_ini and r_end in the interpolated array
# # print(f"range_cells = {range_cells}")
# loc = (range_cells >= r_ini) * (range_cells < r_end)
# # print(f"loc = {loc}")
# # print(f"loc shape = {len(loc)}")
#
# # Filling the array with interpolation values
# res[loc] = range_cells[loc] * a + b
# # print(res.shape)
# # print(f"res = {res}")
# # print(f"1. res.shape = {res.shape}")
#
# # Filling first and last values
# i = 0
# while np.isnan(res[i]):
# res[i] = M_profile[0]
# i += 1
#
# # Filling the last values
# i = -1
# while np.isnan(res[i]):
# res[i] = M_profile[-1]
# i += -1
# # print(f"res.shape = {res.shape}")
# # print(f"res = {res}")
# # print(f"r_bottom.shape = {r_bottom.shape}")
# # print(f" = {res}")
#
# if r_bottom.shape != (0,):
# res[np.where(range_cells > r_bottom)] = np.nan
#
# loc_point_lin_interp0 = range_cells[np.where((range_cells > sample_depth[0]) & (range_cells < sample_depth[-1]))]
# # print(f"range_cells : {range_cells}")
# # print(f"loc_point_lin_interp0 shape : {len(loc_point_lin_interp0)}")
# # print(f"loc_point_lin_interp0 : {loc_point_lin_interp0}")
# res0 = res[np.where((range_cells > sample_depth[0]) & (range_cells < sample_depth[-1]))]
#
# loc_point_lin_interp = loc_point_lin_interp0[np.where(loc_point_lin_interp0 > range_cells[0])]
# # print(f"loc_point_lin_interp shape : {len(loc_point_lin_interp)}")
# # print(f"loc_point_lin_interp : {loc_point_lin_interp}")
# res = res0[np.where(loc_point_lin_interp0 > range_cells[0])]
#
# # fig, ax = plt.subplots(nrows=1, ncols=1)
# # ax.plot(loc_point_lin_interp, res[:len(loc_point_lin_interp)], marker="*", mfc="blue")
# # ax.plot(sample_depth, M_profile, marker="o", mfc="k", mec="k")
# # plt.show()
#
# return (loc_point_lin_interp, res)
def M_profile_SCC_fine_interpolated(self, sample_depth, M_profile, range_cells, r_bottom):
res = np.zeros((len(range_cells),)) * np.nan
for i in range(len(M_profile) - 1):
# print(f"i = {i}")
r_ini = sample_depth[i]
# print(f"r_ini = {r_ini}")
c_ini = M_profile[i]
# print(f"c_ini = {c_ini}")
r_end = sample_depth[i + 1]
# print(f"r_end = {r_end}")
c_end = M_profile[i + 1]
# print(f"c_end = {c_end}")
l0 = sample_depth
print("l0 = ", l0)
l1 = [l0.index(x) for x in sorted(l0)]
print("l1 = ", l1)
l2 = [l0[k] for k in l1]
print("l2 = ", l2)
c1 = [list(M_profile)[j] for j in l1]
print("c1 = ", c1)
for i in range(len(c1) - 1):
# print("i = ", i)
r_ini = l2[i]
c_ini = c1[i]
r_end = l2[i + 1]
c_end = c1[i + 1]
print("r_ini ", r_ini, "c_ini ", c_ini, "r_end ", r_end, "c_end ", c_end)
# Computing the linear equation
a = (c_end - c_ini) / (r_end - r_ini)
# print(f"a = {a}")
b = c_ini - a * r_ini
# print(f"b = {b}")
print("range_cells ", (range_cells))
# Finding the indices of r_ini and r_end in the interpolated array
# print(f"range_cells = {range_cells}")
loc = (range_cells >= r_ini) * (range_cells < r_end)
# print(f"loc = {loc}")
# print(f"loc shape = {len(loc)}")
print("range_cells >= r_ini ", range_cells >= r_ini)
print("range_cells < r_end ", range_cells < r_end)
print("loc ", loc)
# Filling the array with interpolation values
res[loc] = range_cells[loc] * a + b
# print(res.shape)
# print(f"res = {res}")
# print(f"1. res.shape = {res.shape}")
print("a = ", a, "b = ", b)
print("res ", res)
# Filling first and last values
i = 0
while np.isnan(res[i]):
res[i] = M_profile[0]
res[i] = c1[0]
i += 1
# Filling the last values
i = -1
while np.isnan(res[i]):
res[i] = M_profile[-1]
res[i] = c1[-1]
i += -1
# print(f"res.shape = {res.shape}")
# print(f"res = {res}")
# print(f"r_bottom.shape = {r_bottom.shape}")
# print(f" = {res}")
if r_bottom.shape != (0,):
if r_bottom.size != 0:
res[np.where(range_cells > r_bottom)] = np.nan
loc_point_lin_interp0 = range_cells[np.where((range_cells > sample_depth[0]) & (range_cells < sample_depth[-1]))]
# print(f"range_cells : {range_cells}")
# print(f"loc_point_lin_interp0 shape : {len(loc_point_lin_interp0)}")
# print(f"loc_point_lin_interp0 : {loc_point_lin_interp0}")
res0 = res[np.where((range_cells > sample_depth[0]) & (range_cells < sample_depth[-1]))]
loc_point_lin_interp0 = range_cells[np.where((range_cells > l2[0]) & (range_cells < l2[-1]))]
res0 = res[np.where((range_cells > l2[0]) & (range_cells < l2[-1]))]
loc_point_lin_interp = loc_point_lin_interp0[np.where(loc_point_lin_interp0 > range_cells[0])]
# print(f"loc_point_lin_interp shape : {len(loc_point_lin_interp)}")
# print(f"loc_point_lin_interp : {loc_point_lin_interp}")
res = res0[np.where(loc_point_lin_interp0 > range_cells[0])]
loc_point_lin_interp = loc_point_lin_interp0[np.where(loc_point_lin_interp0 > l2[0])]
res = res0[np.where(loc_point_lin_interp0 > l2[0])]
# fig, ax = plt.subplots(nrows=1, ncols=1)
# ax.plot(loc_point_lin_interp, res[:len(loc_point_lin_interp)], marker="*", mfc="blue")
# ax.plot(sample_depth, M_profile, marker="o", mfc="k", mec="k")
# ax.plot(res[:len(loc_point_lin_interp)], -loc_point_lin_interp, marker="*", mfc="blue")
# ax.plot(c1, [-x for x in l2], marker="o", mfc="k", mec="k", ls="None")
# ax.set_xlabel("Concentration (g/L)")
# ax.set_ylabel("Depth (m)")
# plt.show()
return (loc_point_lin_interp, res)