From cea9e3549890be6d1b4ba003cc9c1a3465ea2612 Mon Sep 17 00:00:00 2001 From: brahim Date: Thu, 6 Mar 2025 10:18:46 +0100 Subject: [PATCH 1/5] acoustic data loader file is cleaned from useless commented lines and useless print --- Model/acoustic_data_loader.py | 77 ----------------------------------- 1 file changed, 77 deletions(-) diff --git a/Model/acoustic_data_loader.py b/Model/acoustic_data_loader.py index 423185e..5748736 100644 --- a/Model/acoustic_data_loader.py +++ b/Model/acoustic_data_loader.py @@ -5,35 +5,25 @@ import pandas as pd import matplotlib.pyplot as plt from matplotlib.colors import LogNorm -# path_BS_raw_data = "/home/bmoudjed/Documents/2 Data/Confluence_Rhône_Isere_2018/Acoustic_data/20180107123500.aqa" -# path_BS_raw_data = "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/" \ -# "Data/AcousticNoise_data/20180107121600.aqa" - class AcousticDataLoader: def __init__(self, path_BS_raw_data: str): self.path_BS_raw_data = path_BS_raw_data - print(self.path_BS_raw_data) # --- Load Backscatter acoustic raw data with RawAquascatData class --- self._data_BS = RawAquascatData(self.path_BS_raw_data) - print(self._data_BS.V.shape) self._BS_raw_data = np.swapaxes(self._data_BS.V, 0, 1) - print(f"BS raw data shape = {self._BS_raw_data.shape}") self._freq = self._data_BS.Freq - print(f"freq shape = {self._freq.shape}") self._freq_text = self._data_BS.freqText self._r = np.repeat(np.transpose(self._data_BS.r), self._freq.shape[0], axis=0) - print(f"r shape = {self._r.shape}") self._time = np.repeat( np.transpose(np.array([t / self._data_BS.PingRate for t in range(self._data_BS.NumProfiles)])[:, np.newaxis]), self._freq.shape[0], axis=0) - print(f"time shape = {self._time.shape}") self._date = self._data_BS.date.date() self._hour = self._data_BS.date.time() @@ -48,97 +38,30 @@ class AcousticDataLoader: self._gain_rx = self._data_BS.RxGain.tolist() self._gain_tx = self._data_BS.TxGain.tolist() - # print((self._cell_size)) - # print((self._nb_pings_averaged_per_profile)) - - # print(self._r[0, :][1] - self._r[1, :][0]) - # print(type(self._nb_cells), self._nb_cells) - - # self._snr = np.array([]) - # self._snr_reshape = np.array([]) - # self._time_snr = np.array([]) - - # print(type(self._gain_tx)) - - # print(["BS - " + f for f in self._freq_text]) - # print(self._time.shape[0]*self._r.shape[0]*4) - - # print(self._time[np.where(np.floor(self._time) == 175)]) - # print(np.where((self._time) == 155)[0][0]) - - # fig, ax = plt.subplots(nrows=1, ncols=1) - # # ax.pcolormesh(self._time[0, :2200], -self._r[0, :], (self._BS_raw_data[0, :, :2200]), - # # cmap='viridis', - # # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[0, :, :2200]))) # , shading='gouraud') - # ax.pcolormesh(range(self._BS_raw_data.shape[2]), range(self._BS_raw_data.shape[1]), self._BS_raw_data[2, :, :], cmap='viridis', - # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[:, 0, :]))) # , shading='gouraud') - # ax.set_xticks([]) - # ax.set_yticks([]) - # plt.show() - - # --- Plot vertical profile for bottom detection --- - # fig2, ax2 = plt.subplots(nrows=1, ncols=1, layout="constrained") - # ax2.plot(self._BS_raw_data[0, :, 1], -self._r[0], "k.-") - # plt.show() - - # fig, ax = plt.subplots(nrows=1, ncols=1) - # ax.plot(self._BS_raw_data[:, 0, 100] , self._r) - # ax.set_ylim(2, 20) - # plt.show() - - # print(self.reshape_BS_raw_cross_section()[0, 0]) - # self.reshape_BS_raw_cross_section() - # self.reshape_r() - # self.reshape_t() - # self.compute_r_2D() - def reshape_BS_raw_data(self): BS_raw_cross_section = np.reshape(self._BS_raw_data, (self._r.shape[1] * self._time.shape[1], self._freq.shape[0]), order="F") - print(BS_raw_cross_section.shape) return BS_raw_cross_section def reshape_r(self): - # r = np.reshape(np.repeat(self._r[0, :], self._time.shape[0], axis=1), - # self._r.shape[0]*self._time.shape[0], - # order="F") r = np.zeros((self._r.shape[1] * self._time.shape[1], self._freq.shape[0])) for i, _ in enumerate(self._freq): for j in range(self._time.shape[1]): r[j*self._r.shape[1]:(j+1)*self._r.shape[1], i] = self._r[i, :] - - # r[:, i] = np.repeat(self._r[i, :], self._time.shape[1]) - print(r.shape) return r def compute_r_2D(self): r2D = np.zeros((self._freq.shape[0], self._r.shape[1], self._time.shape[1])) for f, _ in enumerate(self._freq): r2D[f, :, :] = np.repeat(np.transpose(self._r[f, :])[:, np.newaxis], self._time.shape[1], axis=1) - print(r2D.shape) return r2D def reshape_t(self): - # t = np.reshape(np.repeat(self._time, self._r.shape[0]), (self._time.shape[0]*self._r.shape[0], 1)) t = np.zeros((self._r.shape[1] * self._time.shape[1], self._freq.shape[0])) for i, _ in enumerate(self._freq): t[:, i] = np.repeat(self._time[i, :], self._r.shape[1]) - print(t.shape) return t - # def concatenate_data(self): - # self.reshape_t() - # self.reshape_BS_raw_cross_section() - # # print(self.reshape_t().shape) - # # print(se.lf.reshape_BS_raw_cross_section().shape) - # df = pd.DataFrame(np.concatenate((self.reshape_t(), self.reshape_BS_raw_cross_section()), axis=1), - # columns=["time"] + self._freq_text) - # return df - - -# if __name__ == "__main__": -# AcousticDataLoader(path_BS_raw_data) - From 65a9422f711a9bc8622421d0f8f10b5bc4a9c10d Mon Sep 17 00:00:00 2001 From: brahim Date: Thu, 6 Mar 2025 10:23:27 +0100 Subject: [PATCH 2/5] acoustic inversion method high concentration file is cleaned from useless commented lines and useless print --- ...tic_inversion_method_high_concentration.py | 247 +----------------- 1 file changed, 3 insertions(+), 244 deletions(-) diff --git a/Model/acoustic_inversion_method_high_concentration.py b/Model/acoustic_inversion_method_high_concentration.py index 83482b3..b2a2cbd 100644 --- a/Model/acoustic_inversion_method_high_concentration.py +++ b/Model/acoustic_inversion_method_high_concentration.py @@ -21,7 +21,6 @@ # -*- coding: utf-8 -*- -import matplotlib.pyplot as plt import numpy as np import settings as stg from Model.GrainSizeTools import demodul_granulo, mix_gaussian_model @@ -58,17 +57,6 @@ class AcousticInversionMethodHighConcentration(): (np.log(10) / 20) * (freq * 1e-3) ** 2 return alpha - # ---------- Conmpute FBC ---------- - # def compute_FCB(self): - # # print(self.BS_averaged_cross_section_corr.V.shape) - # # print(self.r_2D.shape) - # FCB = np.zeros((256, 4, 1912)) - # for f in range(4): - # # print(self.alpha_w_function(self.Freq[f], self.temperature)) - # FCB[:, f, :] = np.log(self.BS_averaged_cross_section_corr.V[:, f, :]) + np.log(self.r_3D[:, f, :]) + \ - # np.log(2 * self.alpha_w_function(self.Freq[f], self.temperature) * self.r_3D[:, f, :]) - # return FCB - # --- Gaussian mixture --- def compute_particle_size_distribution_in_number_of_particles(self, num_sample, r_grain, frac_vol_cumul): min_demodul = 1e-6 @@ -82,15 +70,6 @@ class AcousticInversionMethodHighConcentration(): sample_demodul.demodul_data_list[2].sigma_list, sample_demodul.demodul_data_list[2].w_list) - # N_modes = 3 - # sample_demodul.print_mode_data(N_modes) - # sample_demodul.plot_interpolation() - # sample_demodul.plot_modes(N_modes) - - # print(f"mu_list : {sample_demodul.demodul_data_list[3 - 1].mu_list}") - # print(f"sigma_list : {sample_demodul.demodul_data_list[3 - 1].sigma_list}") - # print(f"w_list : {sample_demodul.demodul_data_list[3 - 1].w_list}") - proba_vol_demodul = proba_vol_demodul / np.sum(proba_vol_demodul) ss = np.sum(proba_vol_demodul / np.exp(resampled_log_array) ** 3) proba_num = proba_vol_demodul / np.exp(resampled_log_array) ** 3 / ss @@ -106,23 +85,9 @@ class AcousticInversionMethodHighConcentration(): x = k * a f = (x ** 2 * (1 - 0.25 * np.exp(-((x - 1.5) / 0.35) ** 2)) * (1 + 0.6 * np.exp(-((x - 2.9) / 1.15) ** 2))) / ( 42 + 28 * x ** 2) - # print(f"form factor = {f}") return f - # def ks(self, num_sample_sand, radius_grain_sand, frac_vol_sand_cumul, freq, C): def ks(self, proba_num, freq, C): - # --- Calcul de la fonction de form --- - # form_factor = self.form_factor_function_MoateThorne2012(a, freq) - # print(f"form_factor shape = {form_factor}") - # print(f"form_factor = {form_factor}") - - #--- Particle size distribution --- - # proba_num = ( - # self.compute_particle_size_distribution_in_number_of_particles( - # num_sample=num_sample_sand, r_grain=radius_grain_sand, frac_vol_cumul=frac_vol_sand_cumul[num_sample_sand])) - - # print(f"proba_num : {proba_num}") - # --- Compute k_s by dividing two integrals --- resampled_log_array = np.log(np.logspace(-10, -2, 3000)) a2f2pdf = 0 @@ -132,28 +97,17 @@ class AcousticInversionMethodHighConcentration(): a2f2pdf += a**2 * self.form_factor_function_MoateThorne2012(a, freq, C)**2 * proba_num[i] a3pdf += a**3 * proba_num[i] - # print("form factor ", self.form_factor_function_MoateThorne2012(a, freq, C)) - # print(f"a2f2pdf = {a2f2pdf}") - # print(f"a3pdf = {a3pdf}") - ks = np.sqrt(a2f2pdf / a3pdf) - # ks = np.array([0.04452077, 0.11415143, 0.35533713, 2.47960051]) - # ks = ks0[ind] return ks # ------------- Computing sv ------------- # def sv(self, ks, M_sand): - # print(f"ks = {ks}") - # print(f"M_sand = {M_sand}") sv = (3 / (16 * np.pi)) * (ks ** 2) * M_sand - # sv = np.full((stg.r.shape[1], stg.t.shape[1]), sv0) return sv # ------------- Computing X ------------- # def X_exponent(self, freq1, freq2, sv_freq1, sv_freq2): - # X0 = [3.450428714146802, 3.276478927777019, 3.6864638665972893, 0] - # X = X0[ind] X = np.log(sv_freq1 / sv_freq2) / np.log(freq1 / freq2) return X @@ -174,165 +128,43 @@ class AcousticInversionMethodHighConcentration(): gain = 10 ** ((RxGain + TxGain) / 20) # Computing Kt kt = kt_ref * gain * np.sqrt(tau * cel / (tau_ref * c_ref)) # 1D numpy array - # kt = np.reshape(kt0, (1, 2)) # convert to 2d numpy array to compute J_cross_section - # print(f"kt = {kt}") - # kt_2D = np.repeat(np.array([kt]), stg.r.shape[1], axis=0) - # print("kt 2D ", kt_2D) - # print("kt 2D shape ", kt_2D.shape) - # # kt_3D = np.zeros((kt_2D.shape[1], kt_2D.shape[0], stg.t.shape[1])) - # # for k in range(kt_2D.shape[1]): - # # kt_3D[k, :, :] = np.repeat(kt_2D, stg.t.shape[1], axis=1)[:, k * stg.t.shape[1]:(k + 1) * stg.t.shape[1]] - # kt_3D = np.repeat(kt_2D.transpose()[:, :, np.newaxis], stg.t.shape[1], axis=2) - # # print("kt 3D ", kt_3D) - # print("kt 3D shape ", kt_3D.shape) - return kt # ------------- Computing J_cross_section ------------- # def j_cross_section(self, BS, r2D, kt): - # J_cross_section = np.zeros((1, BS.shape[1], BS.shape[2])) # 2 because it's a pair of frequencies - # print("BS.shape", BS.shape) - # print("r2D.shape", r2D.shape) - # print("kt.shape", kt.shape) - - # if stg.ABS_name == "Aquascat 1000R": - # print("--------------------------------") - # print("BS : ", BS) - # print("BS min : ", np.nanmin(BS)) - # print("BS max : ", np.nanmax(BS)) - # print("r2D : ", r2D) - # print("kt shape : ", kt.shape) - # print("kt : ", kt) - # print("--------------------------------") - # for k in range(1): - # J_cross_section[k, :, :] = (3 / (16 * np.pi)) * ((BS[k, :, :]**2 * r2D[k, :, :]**2) / kt[k, :, :]**2) J_cross_section = (3 / (16 * np.pi)) * ((BS**2 * r2D**2) / kt**2) - # J_cross_section[J_cross_section == 0] = np.nan - # print("J_cross_section.shape", J_cross_section.shape) - # elif stg.ABS_name == "UB-SediFlow": - # for k in range(1): - # J_cross_section[k, :, :] = (3 / (16 * np.pi)) * ((BS[k, :, :]**2 * r2D[0, :, :]**2) / kt[k, :, :]**2) - # print("compute j_cross_section finished") return J_cross_section # ------------- Computing alpha_s ------------- # def alpha_s(self, sv, j_cross_section, depth, alpha_w): alpha_s = (np.log(sv / j_cross_section) / (4 * depth)) - alpha_w - print("----------------------------") - print(f"sv = {sv}") - print(f"j_cross_section = {j_cross_section}") - print(f"depth = {depth}") - print(f"alpha_w = {alpha_w}") - print(f"(np.log(sv / j_cross_section) / (4 * depth)) = {(np.log(sv / j_cross_section) / (4 * depth))}") - print(f"alpha_s {alpha_s}") - return alpha_s - # ------------- 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) + # ------------- Computing interpolation of fine SSC ------------- def M_profile_SCC_fine_interpolated(self, sample_depth, M_profile, range_cells, r_bottom): + '''Computing interpolation of fine SSC data obtained from water sampling + collected at various depth in the vertical sample''' res = np.zeros((len(range_cells),)) * np.nan - print("range_cells ", range_cells.shape) 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) b = c_ini - a * r_ini - print("range_cells ", (range_cells)) # Finding the indices of r_ini and r_end in the interpolated array loc = (range_cells >= r_ini) * (range_cells < r_end) - 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("a = ", a, "b = ", b) - - print("res ", res) - # Filling first and last values i = 0 while np.isnan(res[i]): @@ -346,9 +178,6 @@ class AcousticInversionMethodHighConcentration(): i += -1 if r_bottom.size != 0: - print("res ", res.shape) - print("range_cells ", len(range_cells)) - # print("r_bottom ", len(r_bottom)) res[np.where(range_cells > r_bottom)] = np.nan loc_point_lin_interp0 = range_cells[np.where((range_cells > l2[0]) & (range_cells < l2[-1]))] @@ -357,13 +186,6 @@ class AcousticInversionMethodHighConcentration(): 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(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) # ------------- Computing zeta ------------- # @@ -372,39 +194,6 @@ class AcousticInversionMethodHighConcentration(): delta_r = r[1] - r[0] zeta = alpha_s / (np.sum(np.array(M_profile_fine)*delta_r)) - # print(f"np.sum(M_profile_fine*delta_r) : {np.sum(M_profile_fine*delta_r)}") - # zeta0 = np.array([0.021, 0.035, 0.057, 0.229]) - # zeta = zeta0[ind] - # zeta0 = np.array([0.04341525, 0.04832906, 0.0847188, np.nan]) - # zeta = zeta0[[ind1, ind2]] - - # for k in range(3): - # for p in range(3): - # if np.isnan(ind_X_min_around_sample[p, k]): - # zeta_list_exp.append(np.nan) - # else: - # ind_X_min = int(ind_X_min_around_sample[p, k]) - # ind_X_max = int(ind_X_max_around_sample[p, k]) - # ind_r_min = int(ind_r_min_around_sample[p, k]) - # ind_r_max = int(ind_r_max_around_sample[p, k]) - # - # R_temp = R_cross_section[ind_r_min:ind_r_max, :, ind_X_min:ind_X_max] - # J_temp = J_cross_section[ind_r_min:ind_r_max, :, ind_X_min:ind_X_max] - # aw_temp = aw_cross_section[ind_r_min:ind_r_max, :, ind_X_min:ind_X_max] - # sv_temp_1 = np.repeat([sv_list_temp[3 * k + p]], np.shape(R_temp)[0], axis=0) - # sv_temp = np.swapaxes(np.swapaxes(np.repeat([sv_temp_1], np.shape(R_temp)[2], axis=0), 1, 0), 2, 1) - # ind_depth = np.where(R_cross_section[:, 0, 0] >= M_list_temp[k][0, p + 1])[0][0] - # # Using concentration profile - # zeta_temp = alpha_s / ((1 / M_list_temp[k][0, p + 1]) * (R_cross_section[0, 0, 0] * M_list_temp[k][1, 0] + - # delta_r * np.sum(M_interpolate_list[k][:ind_depth]))) - # zeta_temp = (1 / (4 * R_temp) * - # np.log(sv_temp / J_temp) - aw_temp) / ((1 / M_list_temp[k][0, p + 1]) * - # (R_cross_section[0, 0, 0] * M_list_temp[k][ - # 1, 0] + - # delta_r * np.sum( - # M_interpolate_list[k][:ind_depth]))) - # zeta_list_exp.append(np.mean(np.mean(zeta_temp, axis=0), axis=1)) - return zeta # ------------- Computing VBI ------------- # @@ -415,21 +204,6 @@ class AcousticInversionMethodHighConcentration(): water_attenuation_freq1, water_attenuation_freq2, X): - # print('self.zeta_exp[ind_j].shape', self.zeta_exp[ind_j]) - # print('np.log(self.j_cross_section[:, ind_i, :]).shape', np.log(self.j_cross_section[:, ind_i, :]).shape) - # print('self.r_3D[:, ind_i, :]', self.r_3D[:, ind_i, :].shape) - # print('self.water_attenuation[ind_i]', self.water_attenuation[ind_i]) - # print('self.x_exp[0.3-1 MHz]', self.x_exp['0.3-1 MHz'].values[0]) - # print("start computing VBI") - # print("================================") - # print(f"zeta_freq2 : {zeta_freq2}") - # print(f"j_cross_section_freq1 : {j_cross_section_freq1.shape}") - # print(f"r2D : {r2D.shape}") - # print(f"water_attenuation_freq1 : {water_attenuation_freq1}") - # print(f"freq1 : {freq1}") - # print(f"X : {X}") - # print("================================") - logVBI = ((zeta_freq2 * np.log(j_cross_section_freq1 * np.exp(4 * r2D * water_attenuation_freq1) / (freq1 ** X)) - @@ -438,31 +212,16 @@ class AcousticInversionMethodHighConcentration(): (freq2 ** X))) / (zeta_freq2 - zeta_freq1)) - # logVBI = (freq2**2 * np.log(j_cross_section_freq1 / freq1**X) - - # freq1**2 * np.log(j_cross_section_freq2 / freq2**X)) / (freq2**2 - freq1**2) - - # logVBI = (( np.full((stg.r.shape[1], stg.t.shape[1]), zeta_freq2) * - # np.log(j_cross_section_freq1 * np.exp(4 * r2D * np.full((stg.r.shape[1], stg.t.shape[1]), water_attenuation_freq1)) / - # (freq1 ** X)) - - # np.full((stg.r.shape[1], stg.t.shape[1]), zeta_freq1) * - # np.log(j_cross_section_freq2 * np.exp(4 * r2D * np.full((stg.r.shape[1], stg.t.shape[1]), water_attenuation_freq2)) / - # (freq2 ** X))) / - # (zeta_freq2 - zeta_freq1)) - - print("compute VBI finished") - return np.exp(logVBI) # ------------- Computing SSC fine ------------- # def SSC_fine(self, zeta, r2D, VBI, freq, X, j_cross_section, alpha_w): SSC_fine = (1/zeta) * ( 1/(4 * r2D) * np.log((VBI * freq**X) / j_cross_section) - alpha_w) - print("compute SSC fine finished") return SSC_fine # ------------- Computing SSC sand ------------- # def SSC_sand(self, VBI, freq, X, ks): SSC_sand = (16 * np.pi * VBI * freq ** X) / (3 * ks**2) - print("compute SSC sand finished") return SSC_sand From 6d4fb5fae658eaa87cb3668d5e62066b2b1b39d4 Mon Sep 17 00:00:00 2001 From: MOUDJED Brahim Date: Fri, 7 Mar 2025 12:14:46 +0100 Subject: [PATCH 3/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f85c9eb..7b84acc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # AcouSed - +**Acou**stic Backscattering for Concentration of Suspended **Sed**iments in Rivers ## Getting started From 2ec55848605587da4e95ca648ad971e9962eec52 Mon Sep 17 00:00:00 2001 From: MOUDJED Brahim Date: Fri, 7 Mar 2025 17:19:16 +0100 Subject: [PATCH 4/5] Update README.md --- README.md | 54 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7b84acc..604f329 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,30 @@ # AcouSed -**Acou**stic Backscattering for Concentration of Suspended **Sed**iments in Rivers +AcouSed for **Acou**stic Backscattering for Concentration of Suspended **Sed**iments in Rivers is a software developped by INRAE, in collaboation with CNR. -## Getting started +![](icons/Logo-INRAE.jpg) + +It is divided in six tabs: +- Acoustic data : acoustic raw data are downloaded and visualised +- Signal preprocessing : acoustic raw signal is preprocessed with filters +- Sample data : fine and sand sediments samples data are downloaded and visualised +- Calibration : calibration parameter are computed +- Inversion : inversion method is calculated to provide fine and sand sediments fields + + + +## User Manual To make it easy for you to get started with GitLab, here's a list of recommended next steps. Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! -## Add your files -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: -``` -cd existing_repo -git remote add origin https://gitlab.irstea.fr/brahim/acoused.git -git branch -M main -git push -uf origin main -``` +## Support files + +- [ ] [Acoustic inversion method diagram](https://forgemia.inra.fr/theophile.terraz/acoused/-/blob/main/Acoustic_Inversion_theory.pdf?ref_type=heads) +- [ ] [Tutorial AQUAscat software : AQUAtalk](https://forgemia.inra.fr/theophile.terraz/acoused/-/blob/main/Tutorial_AQUAscat_software.pdf?ref_type=heads) ## Integrate with your tools @@ -82,11 +88,27 @@ For people who want to make changes to your project, it's helpful to have some d You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +## Acknowledgment +This study was conducted within the [Rhône Sediment Observatory](https://observatoire-sediments-rhone.fr/) (OSR), a multi-partner research program funded through the Plan Rhône by the European Regional Development Fund (ERDF), Agence de l’Eau RMC, CNR, EDF and three regional councils (Auvergne-Rhône-Alpes, PACA and Occitanie). It was then also support by CNR. ## License -For open source projects, say how it is licensed. -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +AcouSed +Copyright (C) 2024 - INRAE + +This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with this program. If not, see . + +## Contacts + +If you have any questions or suggestions, please contact us to celine.berni@inrae.fr and/or jerome.lecoz@inrae.fr. + +## References + +- [ ] [Adrien Vergne thesis (2018)](https://theses.fr/2018GREAU046) +- [ ] [Vergne A., Le Coz J., Berni C., & Pierrefeu G. (2020), Water Resources Research, 56(2)](https://doi.org/10.1029/2019WR024877) +- [ ] [Vergne A., Berni C., Le Coz J., & Tencé F., (2021), Water Resources Research, 57(9)](https://doi.org/10.1029/2021WR029589) + From 2ffb9a21e6af75af022083a733a28091175668d7 Mon Sep 17 00:00:00 2001 From: brahim Date: Mon, 10 Mar 2025 10:16:03 +0100 Subject: [PATCH 5/5] read table for open cleaned --- Model/read_table_for_open.py | 38 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Model/read_table_for_open.py b/Model/read_table_for_open.py index 7e5e075..188316c 100644 --- a/Model/read_table_for_open.py +++ b/Model/read_table_for_open.py @@ -76,7 +76,7 @@ class ReadTableForOpen: for k in range(len(stg.acoustic_data)): print("hello") - query = f'''SELECT acoustic_data, acoustic_file, ABS_name, path_BS_noise_data, filename_BS_noise_data, + query = f'''SELECT acoustic_data, acoustic_file, ABS_name, path_BS_noise_data, filename_BS_noise_data, noise_method, noise_value, data_preprocessed FROM AcousticFile WHERE (acoustic_data = {k})''' data = cur.execute(query).fetchall() print("data acoustic file", data) @@ -101,8 +101,8 @@ class ReadTableForOpen: stg.hour = [0]*len(stg.acoustic_data) for i in range(len(stg.acoustic_data)): print("i = ", i) - query1 = f'''SELECT acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles, - NbProfilesPerSeconds, NbCells, CellSize, PulseLength, NbPingsPerSeconds, NbPingsAveragedPerProfile, + query1 = f'''SELECT acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles, + NbProfilesPerSeconds, NbCells, CellSize, PulseLength, NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx FROM Measure WHERE (acoustic_data = {i})''' data1 = cur.execute(query1).fetchall() @@ -140,16 +140,16 @@ class ReadTableForOpen: print("len stg.acoustic_data ", len(stg.acoustic_data)) for j in range(len(stg.acoustic_data)): print(f"j = {j}") - query2 = f'''SELECT acoustic_data, time, depth, BS_raw_data, + query2 = f'''SELECT acoustic_data, time, depth, BS_raw_data, time_reshape, depth_reshape, BS_raw_data_reshape, - time_cross_section, depth_cross_section, - BS_cross_section, BS_stream_bed, + time_cross_section, depth_cross_section, + BS_cross_section, BS_stream_bed, depth_bottom, val_bottom, ind_bottom, - time_noise, depth_noise, BS_noise_raw_data, + time_noise, depth_noise, BS_noise_raw_data, SNR_raw_data, SNR_cross_section, SNR_stream_bed, - BS_raw_data_pre_process_SNR, BS_raw_data_pre_process_average, - BS_cross_section_pre_process_SNR, BS_cross_section_pre_process_average, - BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average, BS_mean + BS_raw_data_pre_process_SNR, BS_raw_data_pre_process_average, + BS_cross_section_pre_process_SNR, BS_cross_section_pre_process_average, + BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average, BS_mean FROM BSRawData WHERE (acoustic_data = {j})''' data2 = cur.execute(query2).fetchall() @@ -270,10 +270,10 @@ class ReadTableForOpen: # +++++++++++++++++++++++ for s in range(len(stg.acoustic_data)): - query3 = f'''SELECT acoustic_data, temperature, + query3 = f'''SELECT acoustic_data, temperature, tmin_index, tmin_value, tmax_index, tmax_value, rmin_index, rmin_value, rmax_index, rmax_value, - freq_bottom_detection_index, freq_bottom_detection_value, + freq_bottom_detection_index, freq_bottom_detection_value, SNR_filter_value, Nb_cells_to_average_BS_signal FROM Settings WHERE (acoustic_data = {s})''' @@ -293,10 +293,10 @@ class ReadTableForOpen: # --- Table Sediment File --- # +++++++++++++++++++++++++++ - query4 = f'''SELECT path_fine, filename_fine, radius_grain_fine, path_sand, filename_sand, radius_grain_sand, - time_column_label, distance_from_bank_column_label, depth_column_label, - Ctot_fine_column_label, D50_fine_column_label, - Ctot_sand_column_label, D50_sand_column_label + query4 = f'''SELECT path_fine, filename_fine, radius_grain_fine, path_sand, filename_sand, radius_grain_sand, + time_column_label, distance_from_bank_column_label, depth_column_label, + Ctot_fine_column_label, D50_fine_column_label, + Ctot_sand_column_label, D50_sand_column_label from SedimentsFile''' data4 = cur.execute(query4).fetchall() @@ -321,10 +321,10 @@ class ReadTableForOpen: # --- Table Sediment Data --- # +++++++++++++++++++++++++++ - query5 = f'''SELECT sample_fine_name, sample_fine_index, distance_from_bank_fine, depth_fine, time_fine, + query5 = f'''SELECT sample_fine_name, sample_fine_index, distance_from_bank_fine, depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine, frac_vol_fine, frac_vol_fine_cumul, - sample_sand_name, sample_sand_index, distance_from_bank_sand, depth_sand, time_sand, - Ctot_sand, Ctot_sand_per_cent, D50_sand, frac_vol_sand, frac_vol_sand_cumul + sample_sand_name, sample_sand_index, distance_from_bank_sand, depth_sand, time_sand, + Ctot_sand, Ctot_sand_per_cent, D50_sand, frac_vol_sand, frac_vol_sand_cumul from SedimentsData''' data5 = cur.execute(query5).fetchall()