Sediment calibration: Some refactoring and fix #6.

dev-brahim
Pierre-Antoine 2025-03-10 15:47:40 +01:00
parent 0ce60afd04
commit b7ae9dfe69
1 changed files with 53 additions and 75 deletions

View File

@ -1928,28 +1928,42 @@ class SedimentCalibrationTab(QWidget):
self.compute_zeta()
def compute_ks(self):
# --- Compute ks ---
psd_number_of_particles = (
self.inv_hc.compute_particle_size_distribution_in_number_of_particles(
num_sample=stg.sand_sample_target[0][1], r_grain=stg.radius_grain_sand,
frac_vol_cumul=stg.frac_vol_sand_cumul))
num_sample=stg.sand_sample_target[0][1],
r_grain=stg.radius_grain_sand,
frac_vol_cumul=stg.frac_vol_sand_cumul
)
)
ks_freq1 = self.inv_hc.ks(proba_num=psd_number_of_particles,
freq=stg.freq[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq1.currentIndex()],
C=stg.water_velocity)
ks_freq1 = self.inv_hc.ks(
proba_num=psd_number_of_particles,
freq=stg.freq[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq1.currentIndex()
],
C=stg.water_velocity
)
ks_freq2 = self.inv_hc.ks(proba_num=psd_number_of_particles,
freq=stg.freq[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq2.currentIndex()],
C=stg.water_velocity)
ks_freq2 = self.inv_hc.ks(
proba_num=psd_number_of_particles,
freq=stg.freq[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq2.currentIndex()
],
C=stg.water_velocity
)
stg.ks = [ks_freq1, ks_freq2]
print("\n************************************************************** \n")
print(f"ks for frequency of {stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex()]} : {ks_freq1} m/kg^0.5 \n")
print(f"ks for frequency of {stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()]} : {ks_freq2} m/kg^0.5")
logger.debug(
"ks for frequency of "
+ f"{stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex()]} : "
+ f"{ks_freq1} m/kg^0.5 \n"
)
logger.debug(
"ks for frequency of "
+ f"{stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()]} : " +
f"{ks_freq2} m/kg^0.5"
)
self.lineEdit_ks_freq1.clear()
self.lineEdit_ks_freq1.setText(str("%.5f" % ks_freq1))
@ -1958,8 +1972,6 @@ class SedimentCalibrationTab(QWidget):
self.lineEdit_ks_freq2.setText(str("%.5f" % ks_freq2))
def compute_sv(self):
# --- Compute sv ---
sv_freq1 = self.inv_hc.sv(ks=stg.ks[0], M_sand=stg.Ctot_sand[stg.sand_sample_target[0][1]])
sv_freq2 = self.inv_hc.sv(ks=stg.ks[1], M_sand=stg.Ctot_sand[stg.sand_sample_target[0][1]])
@ -1975,8 +1987,6 @@ class SedimentCalibrationTab(QWidget):
self.lineEdit_sv_freq2.setText(str("%.5f" % sv_freq2))
def compute_X(self):
# --- Compute exponent X ---
X_exponent = self.inv_hc.X_exponent(freq1=stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex()],
freq2=stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()],
sv_freq1=stg.sv[0], sv_freq2=stg.sv[1])
@ -1989,71 +1999,39 @@ class SedimentCalibrationTab(QWidget):
self.lineEdit_X.setText(str("%.2f" % X_exponent))
def compute_kt2D_kt3D(self):
# --- Compute kt2D, kt3D and depth_2D ---
for i in range(self.combobox_acoustic_data_choice.count()):
if stg.depth_cross_section[i].shape != (0,):
if stg.time_cross_section[i].shape != (0,):
if stg.kt_corrected != stg.kt_read:
stg.kt2D[i] = np.repeat(np.array([stg.kt_corrected]).transpose(),
stg.time_cross_section[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :], stg.depth_cross_section[i].shape[1], axis=1)
else:
stg.kt2D[i] = np.repeat(np.array([stg.kt_read]).transpose(),
stg.time_cross_section[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :], stg.depth_cross_section[i].shape[1], axis=1)
elif stg.time[i].shape != (0,):
if (stg.kt_corrected != stg.kt_read):
stg.kt2D[i] = np.repeat(np.array([stg.kt_corrected]).transpose(), stg.time[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :], stg.depth_cross_section[i].shape[1], axis=1)
else:
stg.kt2D[i] = np.repeat(np.array([stg.kt_read]).transpose(), stg.time[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :], stg.depth_cross_section[i].shape[1], axis=1)
depth_data = stg.depth_cross_section
elif stg.depth[i].shape != (0,):
depth_data = stg.depth
else:
continue
if stg.time_cross_section[i].shape != (0,):
if stg.time_cross_section[i].shape != (0,):
time_data = stg.time_cross_section
elif stg.time[i].shape != (0,):
time_data = stg.time
else:
continue
if (stg.kt_corrected != stg.kt_read):
if stg.kt_corrected != stg.kt_read:
kt_data = stg.kt_corrected
else:
kt_data = stg.kt_read
stg.kt2D[i] = np.repeat(np.array([stg.kt_corrected]).transpose(),
stg.time_cross_section[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :], stg.depth[i].shape[1], axis=1)
stg.kt2D[i] = np.repeat(
np.array([kt_data]).transpose(),
time_data[i].shape[1],
axis=1
)
else:
stg.kt2D[i] = np.repeat(np.array([stg.kt_read]).transpose(),
stg.time_cross_section[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :], stg.depth[i].shape[1], axis=1)
elif stg.time[i].shape != (0,):
if (stg.kt_corrected != stg.kt_read):
stg.kt2D[i] = np.repeat(np.array([stg.kt_corrected]).transpose(), stg.time[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :],
stg.depth[i].shape[1],
axis=1)
else:
stg.kt2D[i] = np.repeat(np.array([stg.kt_read]).transpose(), stg.time[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :], stg.depth[i].shape[1], axis=1)
stg.kt3D[i] = np.repeat(
stg.kt2D[i][:, np.newaxis, :],
depth_data[i].shape[1],
axis=1
)
def compute_J_cross_section(self):
for i in range(self.combobox_acoustic_data_choice.count()):
J_cross_section_freq1 = np.array([])