Sediment calibration: Some refactoring.
parent
fbda28eb86
commit
0b10926978
|
|
@ -67,7 +67,9 @@ class SedimentCalibrationTab(QWidget):
|
|||
self._setup_widgets()
|
||||
|
||||
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):
|
||||
self.icon_folder = QIcon(self._path_icon("folder.png"))
|
||||
|
|
@ -2065,88 +2067,86 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
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(f"\u03B1s for frequency of freq2 : {alpha_s_freq2:.2f} /m")
|
||||
logger.debug(
|
||||
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.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.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):
|
||||
|
||||
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()
|
||||
|
||||
text = "Sediment sound attenuation is negative !"
|
||||
elif isinf(alpha_s_freq1) or isinf(alpha_s_freq2):
|
||||
|
||||
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()
|
||||
|
||||
text = "Sediment sound attenuation is infinite !"
|
||||
else:
|
||||
title = "Alpha computation validation"
|
||||
icon = self._path_icon("approved.png")
|
||||
text = "Sediment sound attenuation is positive."
|
||||
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Alpha computation validation")
|
||||
msgBox.setIconPixmap(QPixmap(self._path_icon("approved.png")).scaledToHeight(32, Qt.SmoothTransformation))
|
||||
msgBox.setText("Sediment sound attenuation is positive.")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle(title)
|
||||
msgBox.setIconPixmap(
|
||||
QPixmap(icon).scaledToHeight(
|
||||
32, Qt.SmoothTransformation
|
||||
)
|
||||
)
|
||||
msgBox.setText(text)
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
|
||||
def compute_zeta(self):
|
||||
|
||||
# --- Compute zeta ---
|
||||
if stg.M_profile_fine.shape == (0,):
|
||||
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Zeta computation error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
msgBox.setText("Please interpolate fine profile")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
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:
|
||||
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],
|
||||
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)
|
||||
stg.zeta = [zeta_freq1, zeta_freq2]
|
||||
|
||||
else:
|
||||
zeta_freq1 = self.inv_hc.zeta(alpha_s=stg.alpha_s[0],
|
||||
r=stg.depth[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[self.combobox_acoustic_data_choice.currentIndex()][
|
||||
self.combobox_freq2.currentIndex(), :],
|
||||
M_profile_fine=stg.M_profile_fine)
|
||||
logger.debug(
|
||||
f"\u03B6 for frequency of freq1 : {zeta_freq1:.3f} / m"
|
||||
)
|
||||
logger.debug(
|
||||
f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} / m"
|
||||
)
|
||||
|
||||
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")
|
||||
logger.debug(f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} /m")
|
||||
|
||||
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))
|
||||
self.lineEdit_zeta_freq2.clear()
|
||||
self.lineEdit_zeta_freq2.setText(f"{zeta_freq2:.5f}")
|
||||
|
||||
def save_calibration(self):
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
|
|
|||
Loading…
Reference in New Issue