Compare commits
2 Commits
4a8b318ea4
...
0b10926978
| Author | SHA1 | Date |
|---|---|---|
|
|
0b10926978 | |
|
|
fbda28eb86 |
|
|
@ -67,7 +67,9 @@ class SedimentCalibrationTab(QWidget):
|
||||||
self._setup_widgets()
|
self._setup_widgets()
|
||||||
|
|
||||||
def _path_icon(self, icon):
|
def _path_icon(self, icon):
|
||||||
return os.path.join("icons", icon)
|
return os.path.join(
|
||||||
|
os.path.dirname(__file__), "..", "icons", icon
|
||||||
|
)
|
||||||
|
|
||||||
def _setup_icons(self):
|
def _setup_icons(self):
|
||||||
self.icon_folder = QIcon(self._path_icon("folder.png"))
|
self.icon_folder = QIcon(self._path_icon("folder.png"))
|
||||||
|
|
@ -2065,119 +2067,128 @@ class SedimentCalibrationTab(QWidget):
|
||||||
|
|
||||||
stg.alpha_s = [alpha_s_freq1, alpha_s_freq2]
|
stg.alpha_s = [alpha_s_freq1, alpha_s_freq2]
|
||||||
|
|
||||||
logger.debug(f"\u03B1s for frequency of freq1 : {alpha_s_freq1:.2f} /m \n")
|
logger.debug(
|
||||||
logger.debug(f"\u03B1s for frequency of freq2 : {alpha_s_freq2:.2f} /m")
|
f"\u03B1s for frequency of freq1 : {alpha_s_freq1:.2f} / m"
|
||||||
|
)
|
||||||
|
logger.debug(
|
||||||
|
f"\u03B1s for frequency of freq2 : {alpha_s_freq2:.2f} / m"
|
||||||
|
)
|
||||||
|
|
||||||
self.lineEdit_alphas_freq1.clear()
|
self.lineEdit_alphas_freq1.clear()
|
||||||
self.lineEdit_alphas_freq1.setText(str("%.5f" % alpha_s_freq1))
|
self.lineEdit_alphas_freq1.setText(f"{alpha_s_freq1:.5f}")
|
||||||
|
|
||||||
self.lineEdit_alphas_freq2.clear()
|
self.lineEdit_alphas_freq2.clear()
|
||||||
self.lineEdit_alphas_freq2.setText(str("%.5f" % alpha_s_freq2))
|
self.lineEdit_alphas_freq2.setText(f"{alpha_s_freq2:.5f}")
|
||||||
|
|
||||||
|
title = "Alpha computation error"
|
||||||
|
icon = self._path_icon("no_approved.png")
|
||||||
|
|
||||||
if (alpha_s_freq1 < 0) or (alpha_s_freq2 < 0):
|
if (alpha_s_freq1 < 0) or (alpha_s_freq2 < 0):
|
||||||
|
text = "Sediment sound attenuation is negative !"
|
||||||
msgBox = QMessageBox()
|
|
||||||
msgBox.setWindowTitle("Alpha computation error")
|
|
||||||
msgBox.setIconPixmap(QPixmap(self._path_icon("no_approved.png")).scaledToHeight(32, Qt.SmoothTransformation))
|
|
||||||
msgBox.setText("Sediment sound attenuation is negative !")
|
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
|
||||||
msgBox.exec()
|
|
||||||
|
|
||||||
elif isinf(alpha_s_freq1) or isinf(alpha_s_freq2):
|
elif isinf(alpha_s_freq1) or isinf(alpha_s_freq2):
|
||||||
|
text = "Sediment sound attenuation is infinite !"
|
||||||
msgBox = QMessageBox()
|
|
||||||
msgBox.setWindowTitle("Alpha computation error")
|
|
||||||
msgBox.setIconPixmap(
|
|
||||||
QPixmap(self._path_icon("no_approved.png")).scaledToHeight(32, Qt.SmoothTransformation))
|
|
||||||
msgBox.setText("Sediment sound attenuation is infinite !")
|
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
|
||||||
msgBox.exec()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
title = "Alpha computation validation"
|
||||||
|
icon = self._path_icon("approved.png")
|
||||||
|
text = "Sediment sound attenuation is positive."
|
||||||
|
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
msgBox.setWindowTitle("Alpha computation validation")
|
msgBox.setWindowTitle(title)
|
||||||
msgBox.setIconPixmap(QPixmap(self._path_icon("approved.png")).scaledToHeight(32, Qt.SmoothTransformation))
|
msgBox.setIconPixmap(
|
||||||
msgBox.setText("Sediment sound attenuation is positive.")
|
QPixmap(icon).scaledToHeight(
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
32, Qt.SmoothTransformation
|
||||||
msgBox.exec()
|
)
|
||||||
|
)
|
||||||
|
msgBox.setText(text)
|
||||||
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
|
msgBox.exec()
|
||||||
|
|
||||||
def compute_zeta(self):
|
def compute_zeta(self):
|
||||||
|
|
||||||
# --- Compute zeta ---
|
|
||||||
if stg.M_profile_fine.shape == (0,):
|
if stg.M_profile_fine.shape == (0,):
|
||||||
|
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
msgBox.setWindowTitle("Zeta computation error")
|
msgBox.setWindowTitle("Zeta computation error")
|
||||||
msgBox.setIcon(QMessageBox.Warning)
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
msgBox.setText("Please interpolate fine profile")
|
msgBox.setText("Please interpolate fine profile")
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
|
return
|
||||||
|
|
||||||
|
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||||
|
freq_1 = self.combobox_freq1.currentIndex()
|
||||||
|
freq_2 = self.combobox_freq2.currentIndex()
|
||||||
|
|
||||||
|
if stg.depth_cross_section[data_id].shape != (0,):
|
||||||
|
depth_data = stg.depth_cross_section
|
||||||
else:
|
else:
|
||||||
|
depth_data = stg.depth
|
||||||
|
|
||||||
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
zeta_freq1 = self.inv_hc.zeta(
|
||||||
|
alpha_s = stg.alpha_s[0],
|
||||||
|
r = depth_data[data_id][freq_1, :],
|
||||||
|
M_profile_fine = stg.M_profile_fine
|
||||||
|
)
|
||||||
|
zeta_freq2 = self.inv_hc.zeta(
|
||||||
|
alpha_s = stg.alpha_s[1],
|
||||||
|
r = depth_data[data_id][freq_2, :],
|
||||||
|
M_profile_fine = stg.M_profile_fine
|
||||||
|
)
|
||||||
|
|
||||||
zeta_freq1 = self.inv_hc.zeta(alpha_s=stg.alpha_s[0],
|
stg.zeta = [zeta_freq1, zeta_freq2]
|
||||||
r=stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
|
|
||||||
self.combobox_freq1.currentIndex(), :],
|
|
||||||
M_profile_fine=stg.M_profile_fine)
|
|
||||||
zeta_freq2 = self.inv_hc.zeta(alpha_s=stg.alpha_s[1],
|
|
||||||
r=stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
|
|
||||||
self.combobox_freq2.currentIndex(), :],
|
|
||||||
M_profile_fine=stg.M_profile_fine)
|
|
||||||
|
|
||||||
else:
|
logger.debug(
|
||||||
zeta_freq1 = self.inv_hc.zeta(alpha_s=stg.alpha_s[0],
|
f"\u03B6 for frequency of freq1 : {zeta_freq1:.3f} / m"
|
||||||
r=stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
|
)
|
||||||
self.combobox_freq1.currentIndex(), :],
|
logger.debug(
|
||||||
M_profile_fine=stg.M_profile_fine)
|
f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} / m"
|
||||||
zeta_freq2 = self.inv_hc.zeta(alpha_s=stg.alpha_s[1],
|
)
|
||||||
r=stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
|
|
||||||
self.combobox_freq2.currentIndex(), :],
|
|
||||||
M_profile_fine=stg.M_profile_fine)
|
|
||||||
|
|
||||||
stg.zeta = [zeta_freq1, zeta_freq2]
|
self.lineEdit_zeta_freq1.clear()
|
||||||
|
self.lineEdit_zeta_freq1.setText(f"{zeta_freq1:.5f}")
|
||||||
|
|
||||||
logger.debug(f"\u03B6 for frequency of freq1 : {zeta_freq1:.3f} /m \n")
|
self.lineEdit_zeta_freq2.clear()
|
||||||
logger.debug(f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} /m")
|
self.lineEdit_zeta_freq2.setText(f"{zeta_freq2:.5f}")
|
||||||
|
|
||||||
self.lineEdit_zeta_freq1.clear()
|
|
||||||
self.lineEdit_zeta_freq1.setText(str("%.5f" % zeta_freq1))
|
|
||||||
|
|
||||||
self.lineEdit_zeta_freq2.clear()
|
|
||||||
self.lineEdit_zeta_freq2.setText(str("%.5f" % zeta_freq2))
|
|
||||||
|
|
||||||
def save_calibration(self):
|
def save_calibration(self):
|
||||||
|
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||||
|
|
||||||
|
freq1 = stg.frequencies_for_calibration[0][1]
|
||||||
|
freq2 = stg.frequencies_for_calibration[1][1]
|
||||||
|
|
||||||
if stg.alpha_s:
|
if stg.alpha_s:
|
||||||
|
directory = ""
|
||||||
|
if stg.path_calibration_file != "":
|
||||||
|
directory = stg.path_calibration_file
|
||||||
|
elif self.combobox_acoustic_data_choice.count() > 0:
|
||||||
|
directory = stg.path_BS_raw_data[-1]
|
||||||
|
|
||||||
dir_save_cal = QFileDialog.getExistingDirectory(
|
dir_save_cal = QFileDialog.getExistingDirectory(
|
||||||
caption="Save calibration",
|
caption="Save calibration",
|
||||||
directory=[stg.path_calibration_file if stg.path_calibration_file else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0],
|
directory=directory,
|
||||||
options=QFileDialog.DontUseNativeDialog)
|
options=QFileDialog.DontUseNativeDialog
|
||||||
|
)
|
||||||
|
|
||||||
if dir_save_cal:
|
if dir_save_cal:
|
||||||
|
|
||||||
stg.path_calibration_file = os.path.dirname(dir_save_cal)
|
stg.path_calibration_file = os.path.dirname(dir_save_cal)
|
||||||
|
|
||||||
cal_array = [[' ', stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[0][1]],
|
cal_array = [
|
||||||
stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]]],
|
[
|
||||||
['ks', stg.ks[0], stg.ks[1]],
|
' ', stg.freq_text[data_id][freq1],
|
||||||
['sv', stg.sv[0], stg.sv[1]],
|
stg.freq_text[data_id][freq2]
|
||||||
['X', stg.X_exponent[0], 0],
|
],
|
||||||
['alphas', stg.alpha_s[0], stg.alpha_s[1]],
|
['ks', stg.ks[0], stg.ks[1]],
|
||||||
['zeta', stg.zeta[0], stg.zeta[1]]]
|
['sv', stg.sv[0], stg.sv[1]],
|
||||||
|
['X', stg.X_exponent[0], 0],
|
||||||
eval("np.savetxt('"+ dir_save_cal + "/Sediment_calibration_" +
|
['alphas', stg.alpha_s[0], stg.alpha_s[1]],
|
||||||
str(stg.filename_BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:-4]) + ".csv' ," +
|
['zeta', stg.zeta[0], stg.zeta[1]]
|
||||||
"cal_array, " +
|
]
|
||||||
"delimiter=',' ," +
|
|
||||||
"fmt ='% s'" +
|
|
||||||
")")
|
|
||||||
|
|
||||||
|
np.savetxt(
|
||||||
|
f"{dir_save_cal}/Sediment_calibration_"
|
||||||
|
+ f"{stg.filename_BS_raw_data[data_id][:-4]}.csv",
|
||||||
|
cal_array,
|
||||||
|
delimiter=',', fmt ='% s'
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
msgBox.setWindowTitle("Save Error")
|
msgBox.setWindowTitle("Save Error")
|
||||||
msgBox.setIcon(QMessageBox.Warning)
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
|
@ -2190,68 +2201,49 @@ class SedimentCalibrationTab(QWidget):
|
||||||
# ------------ Computing real cell size ------------ #
|
# ------------ Computing real cell size ------------ #
|
||||||
def range_cells_function(self):
|
def range_cells_function(self):
|
||||||
""" Computing the real cell size, that depends on the temperature """
|
""" Computing the real cell size, that depends on the temperature """
|
||||||
|
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||||
|
|
||||||
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
aquascat_cell_size = []
|
||||||
|
tau = []
|
||||||
aquascat_cell_size = []
|
real_cell_size = []
|
||||||
tau = []
|
|
||||||
real_cell_size = []
|
|
||||||
|
|
||||||
stg.depth_real = np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)
|
|
||||||
|
|
||||||
for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]):
|
|
||||||
# defaut Aquascat cell size
|
|
||||||
aquascat_cell_size.append(
|
|
||||||
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, 1] -
|
|
||||||
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, 0])
|
|
||||||
|
|
||||||
# Pulse duration
|
|
||||||
tau.append(aquascat_cell_size[f] * 2 / 1500) # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat
|
|
||||||
|
|
||||||
# Real cell size
|
|
||||||
real_cell_size.append(stg.water_velocity * tau[f] / 2) # voir fig 2.9
|
|
||||||
|
|
||||||
# Converting to real cell profile
|
|
||||||
stg.depth_real[f, :] = (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :]
|
|
||||||
/ aquascat_cell_size[f] * real_cell_size[f])
|
|
||||||
|
|
||||||
|
if stg.depth_cross_section[data_id].shape != (0,):
|
||||||
|
depth_data = stg.depth_cross_section
|
||||||
else:
|
else:
|
||||||
|
depth_data = stg.depth
|
||||||
|
|
||||||
aquascat_cell_size = []
|
stg.depth_real = np.zeros(depth_data[data_id].shape)
|
||||||
tau = []
|
|
||||||
real_cell_size = []
|
|
||||||
|
|
||||||
stg.depth_real = (np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape))
|
for f in range(stg.freq[data_id].shape[0]):
|
||||||
|
# defaut Aquascat cell size
|
||||||
|
aquascat_cell_size.append(
|
||||||
|
depth_data[data_id][f, 1] - depth_data[data_id][f, 0]
|
||||||
|
)
|
||||||
|
|
||||||
for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]):
|
# Pulse duration: figure 2.9 1500 vitesse du son entrée
|
||||||
|
# pour le paramètrage des mesures aquascat
|
||||||
|
tau.append(aquascat_cell_size[f] * 2 / 1500)
|
||||||
|
|
||||||
# defaut Aquascat cell size
|
# voir fig 2.9
|
||||||
aquascat_cell_size.append(
|
real_cell_size.append(stg.water_velocity * tau[f] / 2)
|
||||||
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, 1] -
|
|
||||||
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, 0])
|
|
||||||
|
|
||||||
# Pulse duration
|
# Converting to real cell profile
|
||||||
tau.append(aquascat_cell_size[f] * 2 / 1500) # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat
|
stg.depth_real[f, :] = (
|
||||||
|
depth_data[data_id][f, :]
|
||||||
|
/ aquascat_cell_size[f]
|
||||||
|
* real_cell_size[f]
|
||||||
|
)
|
||||||
|
|
||||||
# Real cell size
|
|
||||||
real_cell_size.append(stg.water_velocity * tau[f] / 2) # voir fig 2.9
|
|
||||||
|
|
||||||
# Converting to real cell profile
|
|
||||||
|
|
||||||
stg.depth_real[f, :] = (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] /
|
|
||||||
aquascat_cell_size[f] * real_cell_size[f])
|
|
||||||
|
|
||||||
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
|
||||||
|
|
||||||
stg.depth_real = \
|
|
||||||
(np.repeat(stg.depth_real[:, :, np.newaxis],
|
|
||||||
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
|
|
||||||
|
|
||||||
|
if stg.time_cross_section[data_id].shape != (0,):
|
||||||
|
time_data = stg.time_cross_section
|
||||||
else:
|
else:
|
||||||
|
time_data = stg.time
|
||||||
|
|
||||||
stg.depth_real = (
|
stg.depth_real = np.repeat(
|
||||||
np.repeat(stg.depth_real[:, :, np.newaxis],
|
stg.depth_real[:, :, np.newaxis],
|
||||||
stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
|
time_data[data_id].shape[1], axis=2
|
||||||
|
)
|
||||||
|
|
||||||
def compute_FCB(self):
|
def compute_FCB(self):
|
||||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue