From fa8e06ecdda60a3ded4120b72c3e99ccde2a15d3 Mon Sep 17 00:00:00 2001 From: brahim Date: Fri, 13 Sep 2024 10:14:50 +0200 Subject: [PATCH] Step 1 and Step 2 of sediment calibration tab are re-organised. --- View/sediment_calibration_tab.py | 324 ++++++++++++++++++++++--------- 1 file changed, 232 insertions(+), 92 deletions(-) diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index 92b243e..007ff4b 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -4,7 +4,7 @@ import matplotlib.pyplot as plt import pandas as pd from PyQt5.QtWidgets import (QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox, QGridLayout, QLabel, QPushButton, QSpinBox, QDoubleSpinBox, QAbstractSpinBox, QSpacerItem, - QSizePolicy, QSlider, QLineEdit, QDial, QFileDialog) + QSizePolicy, QSlider, QLineEdit, QDial, QFileDialog, QMessageBox) from PyQt5.QtCore import QCoreApplication, Qt, QPropertyAnimation, QSize from PyQt5.QtGui import QStandardItemModel, QIcon, QPixmap, QFont @@ -41,6 +41,8 @@ class SedimentCalibrationTab(QWidget): self.icon_triangle_right = QIcon(self.path_icon + "triangle_right.png") self.icon_triangle_right_to_end = QIcon(self.path_icon + "triangle_right_to_end.png") self.icon_update = QIcon(self.path_icon + "update.png") + self.icon_approved = QIcon(self.path_icon + "approved.png") + self.icon_no_approved = QIcon(self.path_icon + "no_approved.png") self.inv_hc = AcousticInversionMethodHighConcentration() @@ -67,57 +69,88 @@ class SedimentCalibrationTab(QWidget): self.groupbox_acoustic_data.setTitle("Step 1 : acoustic and sample data choice") - self.verticalLayout_groupbox_acoustic_data = QVBoxLayout(self.groupbox_acoustic_data) + self.horizontalLayout_groupbox_acoustic_data = QHBoxLayout(self.groupbox_acoustic_data) - # self.horizontalLayout_acoustic_data_choice = QHBoxLayout() - # self.verticalLayout_groupbox_acoustic_data.addLayout(self.horizontalLayout_acoustic_data_choice) + self.groupbox_data_choice = QGroupBox() + self.horizontalLayout_groupbox_acoustic_data.addWidget(self.groupbox_data_choice, 3) - self.gridLayout_data_choice = QGridLayout() - self.verticalLayout_groupbox_acoustic_data.addLayout(self.gridLayout_data_choice) + self.groupbox_data_plot = QGroupBox() + self.horizontalLayout_groupbox_acoustic_data.addWidget(self.groupbox_data_plot, 7) + + # --- Groupbox data choice --- + self.verticalLayout_groupbox_data_choice = QVBoxLayout(self.groupbox_data_choice) + + # -------------------------------------------- + self.groupbox_acoustic_recording = QGroupBox() + self.groupbox_acoustic_recording.setTitle("➊") + self.verticalLayout_groupbox_data_choice.addWidget(self.groupbox_acoustic_recording) + + self.gridLayout_groupbox_acoustic_recording = QGridLayout(self.groupbox_acoustic_recording) self.pushbutton_update_acoustic_file = QPushButton() self.pushbutton_update_acoustic_file.setIcon(self.icon_update) - # self.horizontalLayout_acoustic_data_choice.addWidget(self.pushbutton_update_acoustic_file) - self.gridLayout_data_choice.addWidget(self.pushbutton_update_acoustic_file, 0, 0, 2, 1) + self.gridLayout_groupbox_acoustic_recording.addWidget(self.pushbutton_update_acoustic_file, 0, 0, 1, 2) + + self.label_acoustic_data_choice = QLabel() + self.label_acoustic_data_choice.setText("Acoustic data") + self.gridLayout_groupbox_acoustic_recording.addWidget(self.label_acoustic_data_choice, 1, 0, 1, 1) self.combobox_acoustic_data_choice = QComboBox() - # self.horizontalLayout_acoustic_data_choice.addWidget(self.combobox_acoustic_data_choice) - self.gridLayout_data_choice.addWidget(self.combobox_acoustic_data_choice, 0, 1, 1, 1) + self.gridLayout_groupbox_acoustic_recording.addWidget(self.combobox_acoustic_data_choice, 1, 1, 1, 1) + + # -------------------------------------------- + self.groupbox_frequency = QGroupBox() + self.groupbox_frequency.setTitle("➋") + self.verticalLayout_groupbox_data_choice.addWidget(self.groupbox_frequency) + + self.gridLayout_groupbox_frequency = QGridLayout(self.groupbox_frequency) + + self.label_freq1_choice = QLabel() + self.label_freq1_choice.setText("Frequency 1") + self.gridLayout_groupbox_frequency.addWidget(self.label_freq1_choice, 0, 0, 1, 1) self.combobox_freq1 = QComboBox() - # self.horizontalLayout_acoustic_data_choice.addWidget(self.combobox_freq1) - self.gridLayout_data_choice.addWidget(self.combobox_freq1, 0, 2, 1, 1) + self.gridLayout_groupbox_frequency.addWidget(self.combobox_freq1, 0, 1, 1, 1) + + self.label_freq2_choice = QLabel() + self.label_freq2_choice.setText("Frequency 2") + self.gridLayout_groupbox_frequency.addWidget(self.label_freq2_choice, 1, 0, 1, 1) self.combobox_freq2 = QComboBox() - # self.horizontalLayout_acoustic_data_choice.addWidget(self.combobox_freq2) - self.gridLayout_data_choice.addWidget(self.combobox_freq2, 0, 3, 1, 1) + self.gridLayout_groupbox_frequency.addWidget(self.combobox_freq2, 1, 1, 1, 1) - # self.horizontalLayout_sample_data_choice = QHBoxLayout() - # self.verticalLayout_groupbox_acoustic_data.addLayout(self.horizontalLayout_sample_data_choice) + # -------------------------------------------- + self.groupbox_sample = QGroupBox() + self.groupbox_sample.setTitle("➌") + self.verticalLayout_groupbox_data_choice.addWidget(self.groupbox_sample) - # self.label_fine_sample_choice = QLabel() - # self.label_fine_sample_choice.setText("Fine sediments :") - # self.horizontalLayout_sample_data_choice.addWidget(self.label_fine_sample_choice) + self.gridLayout_groupbox_sample = QGridLayout(self.groupbox_sample) + self.label_fine_profile = QLabel() + self.label_fine_profile.setText("Fine profile") + self.gridLayout_groupbox_sample.addWidget(self.label_fine_profile, 0, 0, 1, 1) self.combobox_fine_sample_choice = CheckableComboBox() - # self.horizontalLayout_sample_data_choice.addWidget(self.combobox_fine_sample_choice) - self.gridLayout_data_choice.addWidget(self.combobox_fine_sample_choice, 1, 1, 1, 1) - - # self.label_sand_sample_choice = QLabel() - # self.label_sand_sample_choice.setText("Sand sediments :") - # self.horizontalLayout_sample_data_choice.addWidget(self.label_sand_sample_choice) + self.gridLayout_groupbox_sample.addWidget(self.combobox_fine_sample_choice, 0, 1, 1, 1) + self.label_sand_target = QLabel() + self.label_sand_target.setText("Sand target") + self.gridLayout_groupbox_sample.addWidget(self.label_sand_target, 1, 0, 1, 1) self.combobox_sand_sample_choice = CheckableComboBox() - # self.horizontalLayout_sample_data_choice.addWidget(self.combobox_sand_sample_choice) - self.gridLayout_data_choice.addWidget(self.combobox_sand_sample_choice, 1, 2, 1, 1) + self.gridLayout_groupbox_sample.addWidget(self.combobox_sand_sample_choice, 1, 1, 1, 1) self.pushbutton_plot_sample = QPushButton() self.pushbutton_plot_sample.setText("Plot sample") - # self.horizontalLayout_sample_data_choice.addWidget(self.pushbutton_plot_sample) - self.gridLayout_data_choice.addWidget(self.pushbutton_plot_sample, 1, 3, 1, 1) + self.gridLayout_groupbox_sample.addWidget(self.pushbutton_plot_sample, 2, 0, 1, 2) + + # --- Groupbox data plot --- + self.verticalLayout_groupbox_data_plot = QVBoxLayout(self.groupbox_data_plot) self.canvas_BS = FigureCanvas() - self.verticalLayout_groupbox_acoustic_data.addWidget(self.canvas_BS) + self.toolbar_BS = NavigationToolBar(self.canvas_BS, self) + + # self.verticalLayout_groupbox_acoustic_data.addWidget(self.canvas_BS) + self.verticalLayout_groupbox_data_plot.addWidget(self.toolbar_BS) + self.verticalLayout_groupbox_data_plot.addWidget(self.canvas_BS) # -------------------------------------------------------------------------------------------------------------- @@ -125,18 +158,61 @@ class SedimentCalibrationTab(QWidget): # +++ Groupbox Fine concentration profile +++ self.groupbox_Mfine_profile.setTitle("Step 2 : profile of the fine sediment concentration") + self.horizontalLayout_groupbox_Mfine_profile = QHBoxLayout(self.groupbox_Mfine_profile) - self.verticalLayout_groupbox_Mfine_profile = QVBoxLayout(self.groupbox_Mfine_profile) + self.groupbox_interpolate_info = QGroupBox() + self.horizontalLayout_groupbox_Mfine_profile.addWidget(self.groupbox_interpolate_info, 4) + + self.groupbox_interpolate_plot = QGroupBox() + self.horizontalLayout_groupbox_Mfine_profile.addWidget(self.groupbox_interpolate_plot, 6) + + # --- Groupbox interpolate info --- + self.gridLayout_groupbox_interpolate_info = QGridLayout(self.groupbox_interpolate_info) self.pushbutton_interpolate_Mfine_profile = QPushButton() self.pushbutton_interpolate_Mfine_profile.setText("Interpolate") - self.verticalLayout_groupbox_Mfine_profile.addWidget(self.pushbutton_interpolate_Mfine_profile) + self.gridLayout_groupbox_interpolate_info.addWidget(self.pushbutton_interpolate_Mfine_profile, 0, 0, 1, 4) + + self.label_sample_fine = QLabel() + self.label_sample_fine.setText("Sample") + self.gridLayout_groupbox_interpolate_info.addWidget(self.label_sample_fine, 1, 0, 1, 1) + + self.label_depth_fine = QLabel() + self.label_depth_fine.setText("Depth (m)") + self.gridLayout_groupbox_interpolate_info.addWidget(self.label_depth_fine, 1, 1, 1, 1) + + self.label_time_fine = QLabel() + self.label_time_fine.setText("time") + self.gridLayout_groupbox_interpolate_info.addWidget(self.label_time_fine, 1, 2, 1, 1) + + self.label_concentration_fine = QLabel() + self.label_concentration_fine.setText("Cfine (g/L)") + self.gridLayout_groupbox_interpolate_info.addWidget(self.label_concentration_fine, 1, 3, 1, 1) + + self.label_sample_sand = QLabel() + self.label_sample_sand.setText("Sample") + self.gridLayout_groupbox_interpolate_info.addWidget(self.label_sample_sand, 5, 0, 1, 1) + + self.label_depth_sand = QLabel() + self.label_depth_sand.setText("Depth (m)") + self.gridLayout_groupbox_interpolate_info.addWidget(self.label_depth_sand, 5, 1, 1, 1) + + self.label_time_sand = QLabel() + self.label_time_sand.setText("time") + self.gridLayout_groupbox_interpolate_info.addWidget(self.label_time_sand, 5, 2, 1, 1) + + self.label_concentration_sand = QLabel() + self.label_concentration_sand.setText("Cfine (g/L)") + self.gridLayout_groupbox_interpolate_info.addWidget(self.label_concentration_sand, 5, 3, 1, 1) + + # --- Groupbox interpolate plot --- + self.verticalLayout_groupbox_interpolate_plot = QVBoxLayout(self.groupbox_interpolate_plot) self.canvas_Mfine = FigureCanvas() self.toolbar_Mfine = NavigationToolBar(self.canvas_Mfine, self) - self.verticalLayout_groupbox_Mfine_profile.addWidget(self.toolbar_Mfine) - self.verticalLayout_groupbox_Mfine_profile.addWidget(self.canvas_Mfine) + self.verticalLayout_groupbox_interpolate_plot.addWidget(self.toolbar_Mfine) + self.verticalLayout_groupbox_interpolate_plot.addWidget(self.canvas_Mfine) # -------------------------------------------------------------------------------------------------------------- self.groupbox_sediment_calibration = QGroupBox() @@ -413,9 +489,11 @@ class SedimentCalibrationTab(QWidget): self.combobox_freq1.clear() self.combobox_freq1.addItems(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]) + self.combobox_freq1.currentIndexChanged.connect(self.update_label_freq1_for_calibration) self.combobox_freq2.clear() self.combobox_freq2.addItems(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]) + self.combobox_freq2.currentIndexChanged.connect(self.update_label_freq2_for_calibration) self.combobox_freq2.currentIndexChanged.connect(self.plot_acoustic_recording) self.combobox_fine_sample_choice.clear() @@ -443,10 +521,13 @@ class SedimentCalibrationTab(QWidget): self.combobox_freq2.currentIndex())) # --- Plot acoustic data recording --- - self.verticalLayout_groupbox_acoustic_data.removeWidget(self.canvas_BS) + self.verticalLayout_groupbox_data_plot.removeWidget(self.toolbar_BS) + self.verticalLayout_groupbox_data_plot.removeWidget(self.canvas_BS) self.fig_BS, self.axis_BS = plt.subplots(nrows=1, ncols=1, sharex=True, sharey=False, layout='constrained') self.canvas_BS = FigureCanvas(self.fig_BS) - self.verticalLayout_groupbox_acoustic_data.addWidget(self.canvas_BS) + self.toolbar_BS = NavigationToolBar(self.canvas_BS, self) + self.verticalLayout_groupbox_data_plot.addWidget(self.toolbar_BS) + self.verticalLayout_groupbox_data_plot.addWidget(self.canvas_BS) if stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -787,13 +868,13 @@ class SedimentCalibrationTab(QWidget): def plot_profile_of_concentration_fine(self): # --- Plot profile of the concentration of the fine sediments --- - self.verticalLayout_groupbox_Mfine_profile.removeWidget(self.canvas_Mfine) - self.verticalLayout_groupbox_Mfine_profile.removeWidget(self.toolbar_Mfine) + self.verticalLayout_groupbox_interpolate_plot.removeWidget(self.canvas_Mfine) + self.verticalLayout_groupbox_interpolate_plot.removeWidget(self.toolbar_Mfine) self.fig_Mfine, self.ax_Mfine = plt.subplots(1, 1, layout="constrained") self.canvas_Mfine = FigureCanvas(self.fig_Mfine) self.toolbar_Mfine = NavigationToolBar(self.canvas_Mfine, self) - self.verticalLayout_groupbox_Mfine_profile.addWidget(self.toolbar_Mfine) - self.verticalLayout_groupbox_Mfine_profile.addWidget(self.canvas_Mfine) + self.verticalLayout_groupbox_interpolate_plot.addWidget(self.toolbar_Mfine) + self.verticalLayout_groupbox_interpolate_plot.addWidget(self.canvas_Mfine) for t, c in stg.fine_sample_profile: @@ -1030,6 +1111,14 @@ class SedimentCalibrationTab(QWidget): self.read_calibration_file_and_fill_parameter() + def update_label_freq1_for_calibration(self): + self.label_freq1.clear() + self.label_freq1.setText(str(self.combobox_freq1.currentText())) + + def update_label_freq2_for_calibration(self): + self.label_freq2.clear() + self.label_freq2.setText(self.combobox_freq2.currentText()) + def read_calibration_file_and_fill_parameter(self): # --- Read calibration file --- data = pd.read_excel(stg.calibration_file[0] + "/" + stg.calibration_file[1], header=0, index_col=0) @@ -1068,11 +1157,11 @@ class SedimentCalibrationTab(QWidget): def function_pushbutton_compute_calibration(self): # --- Compute frequency --- - self.label_freq1.clear() - self.label_freq1.setText(str(self.combobox_freq1.currentText())) - - self.label_freq2.clear() - self.label_freq2.setText(str(self.combobox_freq2.currentText())) + # self.label_freq1.clear() + # self.label_freq1.setText(str(self.combobox_freq1.currentText())) + # + # self.label_freq2.clear() + # self.label_freq2.setText(str(self.combobox_freq2.currentText())) # --- Compute ks --- psd_number_of_particles = ( @@ -1457,13 +1546,13 @@ class SedimentCalibrationTab(QWidget): J_cross_section_freq1 = self.inv_hc.j_cross_section( BS=stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq1.currentIndex(), :, :], - r2D=stg.depth_2D[self.combobox_freq1.currentIndex(), :, :][self.combobox_freq1.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex(), :, :][self.combobox_freq1.currentIndex(), :, :], kt=kt3D[self.combobox_freq1.currentIndex(), :, :]) J_cross_section_freq2 = self.inv_hc.j_cross_section( BS=stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq2.currentIndex(), :, :], - r2D=stg.depth_2D[self.combobox_freq2.currentIndex(), :, :][self.combobox_freq2.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex(), :, :][self.combobox_freq2.currentIndex(), :, :], kt=kt3D[self.combobox_freq2.currentIndex(), :, :]) elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1471,13 +1560,13 @@ class SedimentCalibrationTab(QWidget): J_cross_section_freq1 = self.inv_hc.j_cross_section( BS=stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq1.currentIndex(), :, :], - r2D=stg.depth_2D[self.combobox_freq1.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex(), :, :], kt=kt3D[self.combobox_freq1.currentIndex(), :, :]) J_cross_section_freq2 = self.inv_hc.j_cross_section( BS=stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq2.currentIndex(), :, :], - r2D=stg.depth_2D[self.combobox_freq2.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :, :], kt=kt3D[self.combobox_freq2.currentIndex(), :, :]) elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1485,13 +1574,13 @@ class SedimentCalibrationTab(QWidget): J_cross_section_freq1 = self.inv_hc.j_cross_section( BS=stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq1.currentIndex(), :, :], - r2D=stg.depth_2D[self.combobox_freq1.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex(), :, :], kt=kt3D[self.combobox_freq1.currentIndex(), :, :]) J_cross_section_freq2 = self.inv_hc.j_cross_section( BS=stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq2.currentIndex(), :, :], - r2D=stg.depth_2D[self.combobox_freq2.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :, :], kt=kt3D[self.combobox_freq2.currentIndex(), :, :]) elif stg.BS_raw_data: @@ -1520,13 +1609,13 @@ class SedimentCalibrationTab(QWidget): J_cross_section_freq1 = self.inv_hc.j_cross_section( BS=stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq1.currentIndex(), :, :], - r2D=stg.depth_2D[self.combobox_freq1.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex(), :, :], kt=kt3D[self.combobox_freq1.currentIndex(), :, :]) J_cross_section_freq2 = self.inv_hc.j_cross_section( BS=stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq2.currentIndex(), :, :], - r2D=stg.depth_2D[self.combobox_freq2.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :, :], kt=kt3D[self.combobox_freq2.currentIndex(), :, :]) stg.J_cross_section.append(J_cross_section_freq1) @@ -1581,45 +1670,74 @@ class SedimentCalibrationTab(QWidget): print(f"\u03B1s for frequency of freq1 : {alpha_s_freq1:.2f} /m \n") print(f"\u03B1s for frequency of freq2 : {alpha_s_freq2:.2f} /m") - self.spinbox_alphas_freq1_compute.clear() - self.spinbox_alphas_freq1_compute.setValue(alpha_s_freq1) + self.spinbox_alphas_freq1.clear() + self.spinbox_alphas_freq1.setValue(alpha_s_freq1) self.spinbox_alphas_freq2.clear() self.spinbox_alphas_freq2.setValue(alpha_s_freq2) - # --- Compute zeta --- + if (alpha_s_freq1 < 0) or (alpha_s_freq2 < 0): - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - - zeta_freq1 = self.inv_hc.zeta(alpha_s=alpha_s_freq1, - 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=alpha_s_freq2, - r=stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - self.combobox_freq2.currentIndex(), :], - M_profile_fine=stg.M_profile_fine) + 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() else: - zeta_freq1 = self.inv_hc.zeta(alpha_s=alpha_s_freq1, - 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=alpha_s_freq2, - 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] + 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() - print(f"\u03B6 for frequency of freq1 : {zeta_freq1:.3f} /m \n") - print(f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} /m") - self.spinbox_zeta_freq1.clear() - self.spinbox_zeta_freq1.setValue(zeta_freq1) + # --- Compute zeta --- + if len(stg.M_profile_fine) == 0: - self.spinbox_zeta_freq2.clear() - self.spinbox_zeta_freq2.setValue(zeta_freq2) + msgBox = QMessageBox() + msgBox.setWindowTitle("Zeta computation error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Please interpolate fine profile") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + + else: + + if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + zeta_freq1 = self.inv_hc.zeta(alpha_s=alpha_s_freq1, + 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=alpha_s_freq2, + r=stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_freq2.currentIndex(), :], + M_profile_fine=stg.M_profile_fine) + + else: + zeta_freq1 = self.inv_hc.zeta(alpha_s=alpha_s_freq1, + 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=alpha_s_freq2, + 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] + + print(f"\u03B6 for frequency of freq1 : {zeta_freq1:.3f} /m \n") + print(f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} /m") + + self.spinbox_zeta_freq1.clear() + self.spinbox_zeta_freq1.setValue(zeta_freq1) + + self.spinbox_zeta_freq2.clear() + self.spinbox_zeta_freq2.setValue(zeta_freq2) # --- Compute FCB --- @@ -1663,7 +1781,7 @@ class SedimentCalibrationTab(QWidget): tau = [] real_cell_size = [] stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)) + np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape)) for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]): @@ -1680,11 +1798,11 @@ class SedimentCalibrationTab(QWidget): # Converting to real cell profile stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][f, :] = \ - (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :] / + (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] / aquascat_cell_size[f] * real_cell_size[f]) # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1 # (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules - print("R_real 2D ", stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print("R_real 2D ", stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1692,7 +1810,15 @@ class SedimentCalibrationTab(QWidget): np.repeat(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][:, :, np.newaxis], stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2)) - print("R_real 3D ", stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print("R_real 3D ", stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + + else: + + stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( + np.repeat(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][:, :, np.newaxis], + stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2)) + + print("R_real 3D ", stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) def compute_FCB(self): # if stg.BS_stream_bed.size == 0: @@ -1750,7 +1876,8 @@ class SedimentCalibrationTab(QWidget): stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ (np.log(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()]) + np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + - 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_FCB.currentIndex()] * + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] * stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) elif stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1758,7 +1885,8 @@ class SedimentCalibrationTab(QWidget): stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ (np.log(stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]) + np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + - 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()] * + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] * stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1766,15 +1894,24 @@ class SedimentCalibrationTab(QWidget): stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ (np.log(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]) + np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + - 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()] * + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] * stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + print("ttttttttttttttttttttttttt") + print(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape) + print(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print(stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()]) + print(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print("ttttttttttttttttttttttttt") + stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ (np.log(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()]) + np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + - 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()] * + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] * stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1782,7 +1919,8 @@ class SedimentCalibrationTab(QWidget): stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ (np.log(stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]) + np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + - 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()] * + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] * stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1790,7 +1928,8 @@ class SedimentCalibrationTab(QWidget): stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ (np.log(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]) + np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + - 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()] * + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] * stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) elif BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1798,7 +1937,8 @@ class SedimentCalibrationTab(QWidget): stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ (np.log(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) + np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + - 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()] * + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] * stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) print("FCB ", stg.FCB[self.combobox_acoustic_data_choice.currentIndex()].shape)