diff --git a/View/acoustic_inversion_tab.py b/View/acoustic_inversion_tab.py index 03973bb..f1bf8ad 100644 --- a/View/acoustic_inversion_tab.py +++ b/View/acoustic_inversion_tab.py @@ -1,9 +1,11 @@ import sys -from PyQt5.QtWidgets import QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox, \ - QGridLayout, QLabel, QPushButton, QSpinBox, QDoubleSpinBox, QAbstractSpinBox -from PyQt5.QtCore import QCoreApplication, Qt -from PyQt5.QtGui import QStandardItemModel +from PyQt5.QtWidgets import (QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox, + QGridLayout, QLabel, QPushButton, QSpinBox, QDoubleSpinBox, QAbstractSpinBox, QSpacerItem, + QSizePolicy, QSlider, QLineEdit) + +from PyQt5.QtCore import QCoreApplication, Qt, pyqtSignal +from PyQt5.QtGui import QStandardItemModel, QIcon import numpy as np @@ -25,6 +27,8 @@ from View.checkable_combobox import CheckableComboBox import settings as stg +from View.show_popup_combobox import ComboBoxShowPopUpWindow + from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration _translate = QCoreApplication.translate @@ -37,309 +41,773 @@ class AcousticInversionTab(QWidget): def __init__(self, widget_tab): super().__init__() + self.path_icon = "./icons/" + self.icon_folder = QIcon(self.path_icon + "folder.png") + self.icon_triangle_left = QIcon(self.path_icon + "triangle_left.png") + self.icon_triangle_right = QIcon(self.path_icon + "triangle_right.png") + self.inv_hc = AcousticInversionMethodHighConcentration() ### --- General layout of widgets --- self.verticalLayoutMain = QVBoxLayout(widget_tab) + self.horizontalLayout_Run_Inversion = QHBoxLayout() + self.verticalLayoutMain.addLayout(self.horizontalLayout_Run_Inversion) + self.horizontalLayoutTop = QHBoxLayout() - self.verticalLayoutMain.addLayout(self.horizontalLayoutTop, 4) # 1O units is 100% , 1 units is 10% + self.verticalLayoutMain.addLayout(self.horizontalLayoutTop, 5) # 1O units is 100% , 1 units is 10% self.horizontalLayoutBottom = QHBoxLayout() - self.verticalLayoutMain.addLayout(self.horizontalLayoutBottom, 6) + self.verticalLayoutMain.addLayout(self.horizontalLayoutBottom, 5) + + ### --- Combobox acoustic data choice + pushbutton Run Inversion --- + + self.combobox_acoustic_data_choice = ComboBoxShowPopUpWindow() + self.combobox_acoustic_data_choice.setMaximumWidth(300) + self.horizontalLayout_Run_Inversion.addWidget(self.combobox_acoustic_data_choice) + + self.pushbutton_run_inversion = QPushButton() + self.pushbutton_run_inversion.setText("RUN INVERSION") + self.pushbutton_run_inversion.setMaximumWidth(100) + self.horizontalLayout_Run_Inversion.addWidget(self.pushbutton_run_inversion) ### --- Layout of groupbox in the Top horizontal layout box - # Acoustic inversion Options | Acoustic inversion method Settings parameter + # Plot SSC 2D field | Plot SSC graph sample vs inversion / SSC vertical profile ===>>> FINE - self.groupbox_acoustic_inversion_options = QGroupBox() - self.horizontalLayoutTop.addWidget(self.groupbox_acoustic_inversion_options, 3) + self.groupbox_plot_SSC_fine = QGroupBox() + self.horizontalLayoutTop.addWidget(self.groupbox_plot_SSC_fine, 7) - self.groupbox_acoustic_inversion_settings_parameter = QGroupBox() - self.horizontalLayoutTop.addWidget(self.groupbox_acoustic_inversion_settings_parameter, 7) + self.groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine = QGroupBox() + self.horizontalLayoutTop.addWidget(self.groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine, 3) ### --- Layout of groupbox in the Bottom horizontal layout box - # Plot SSC 2D field | Plot SSC graph sample vs inversion + # Plot SSC 2D field | Plot SSC graph sample vs inversion / SSC vertical profile ===>>> SAND - self.groupbox_SSC_2D_field = QGroupBox() - self.horizontalLayoutBottom.addWidget(self.groupbox_SSC_2D_field, 6) + self.groupbox_plot_SSC_sand = QGroupBox() + self.horizontalLayoutBottom.addWidget(self.groupbox_plot_SSC_sand, 7) - self.groupbox_SSC_sample_vs_inversion = QGroupBox() - self.horizontalLayoutBottom.addWidget(self.groupbox_SSC_sample_vs_inversion, 4) + self.groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand = QGroupBox() + self.horizontalLayoutBottom.addWidget(self.groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand, 3) # ===================================================== # TOP HORIZONTAL BOX LAYOUT # ===================================================== - # +++++++++++++++++++++++++++++++++++++++++++++++ - # | Group box Acoustic inversion options | - # +++++++++++++++++++++++++++++++++++++++++++++++ + # ++++++++++++++++++++++++++++++++++++++ + # | Group box SSC 2D Field FINE | + # ++++++++++++++++++++++++++++++++++++++ - self.gridLayout_groupbox_acoustic_inversion_options = QGridLayout(self.groupbox_acoustic_inversion_options) + self.verticalLayout_groupbox_plot_SSC_fine = QVBoxLayout(self.groupbox_plot_SSC_fine) - self.groupbox_acoustic_inversion_options.setTitle("Acoustic inversion option") + self.canvas_SSC_fine = FigureCanvas() + self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self) - self.label_acoustic_inversion_method_choice = QLabel() - self.gridLayout_groupbox_acoustic_inversion_options.addWidget( - self.label_acoustic_inversion_method_choice, 0, 0, 1, 1) - self.label_acoustic_inversion_method_choice.setText("Acoustic inversion method : ") + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) - self.combobox_acoustic_inversion_method_choice = QComboBox() - self.gridLayout_groupbox_acoustic_inversion_options.addWidget( - self.combobox_acoustic_inversion_method_choice, 0, 1, 1, 1) - self.combobox_acoustic_inversion_method_choice.addItems([" ", "Acoustic inversion method 1"]) - self.combobox_acoustic_inversion_method_choice.currentIndexChanged.connect( - self.acoustic_inversion_method_choice) - # self.combobox_acoustic_inversion_method_choice.currentIndexChanged.connect( - # self.plot_transect_with_sample_position) + # +++++++++++++++++++++++++++++++++++++++++++++++++++++ + # | Group box SSC profile OR Ctot VS SSC FINE | + # +++++++++++++++++++++++++++++++++++++++++++++++++++++ - self.groupbox_calibration_samples = QGroupBox() - self.groupbox_calibration_samples.setTitle("Sample choice for calibration") - self.gridLayout_groupbox_acoustic_inversion_options.addWidget(self.groupbox_calibration_samples, 1, 0, 1, 2) + self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine = QVBoxLayout(self.groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine) - self.gridLayout_groupbox_calibration_samples = QGridLayout(self.groupbox_calibration_samples) + self.combobox_vertical_profile_or_Ctot_vs_SSC_fine = QComboBox() + self.combobox_vertical_profile_or_Ctot_vs_SSC_fine.setMaximumWidth(300) + self.combobox_vertical_profile_or_Ctot_vs_SSC_fine.addItems(["Inverted SSC vertical profile", + "Measured SSC vs Inverted SSC"]) + self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine.addWidget(self.combobox_vertical_profile_or_Ctot_vs_SSC_fine) - self.label_frequency = QLabel() - self.label_frequency.setText("Frequency :") - self.gridLayout_groupbox_calibration_samples.addWidget(self.label_frequency, 0, 0, 1, 1) + self.canvas_profile_fine = FigureCanvas() + self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) - self.combobox_frequency = QComboBox() - self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_frequency, 0, 1, 1, 1) - self.combobox_frequency.currentIndexChanged.connect(self.update_plot_transect_with_sample_position) - - self.label_sand_sample_choice = QLabel() - self.label_sand_sample_choice.setText("Sand sediments :") - self.gridLayout_groupbox_calibration_samples.addWidget(self.label_sand_sample_choice, 0, 2, 1, 1) - - self.combobox_calibration_sand_sample = CheckableComboBox() - self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_calibration_sand_sample, 0, 3, 1, 1) - # self.combobox_calibration_sand_sample.currentData.connect(self.update_plot_transect_with_sample_position) - self.combobox_calibration_sand_sample.currentIndexChanged.connect( - self.update_plot_transect_with_sample_position) - # self.combobox_calibration_sand_sample.currentIndexChanged.connect(self.sample_choice) - - self.label_fine_sample_choice = QLabel() - self.label_fine_sample_choice.setText("Fine sediments :") - self.gridLayout_groupbox_calibration_samples.addWidget(self.label_fine_sample_choice, 0, 4, 1, 1) - - self.combobox_calibration_fine_sample = CheckableComboBox() - self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_calibration_fine_sample, 0, 5, 1, 1) - # self.combobox_calibration_fine_sample.currentData.connect(self.update_plot_transect_with_sample_position) - self.combobox_calibration_fine_sample.currentIndexChanged.connect( - self.update_plot_transect_with_sample_position) - - # self.combobox_calibration_fine_sample.currentIndexChanged.connect(self.sample_choice) - - self.groupbox_plot_sample_position_on_transect = QGroupBox() - self.gridLayout_groupbox_calibration_samples.addWidget(self.groupbox_plot_sample_position_on_transect, 1, 0, 1, 6) - self.verticalLayout_groupbox_plot_sample_position_on_transect = QVBoxLayout(self.groupbox_plot_sample_position_on_transect) - - self.canvas_plot_sample_position_on_transect = None - # self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.canvas_plot_sample_position_on_transect) - - - # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - # | Group box Acoustic inversion method settings parameter | - # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - self.gridLayout_groupbox_acoustic_inversion_settings_parameter \ - = QGridLayout(self.groupbox_acoustic_inversion_settings_parameter) - - self.groupbox_acoustic_inversion_settings_parameter.setTitle("Acoustic inversion method settings parameter") - - self.groupbox_parameter = QGroupBox() - self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.groupbox_parameter, 0, 0, 1, 2) - - self.gridLayout_groupbox_parameter = QGridLayout(self.groupbox_parameter) - - # self.label_temperature = QLabel() - # self.label_temperature.setText("Temperature : ") - # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.label_temperature, 0, 0, 1, 1) - # self.gridLayout_groupbox_parameter.addWidget(self.label_temperature, 0, 0, 1, 1) - # self.spinbox_temperature = QDoubleSpinBox() - # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.spinbox_temperature, 0, 1, 1, 1) - # self.gridLayout_groupbox_parameter.addWidget(self.spinbox_temperature, 0, 1, 1, 1) - # self.spinbox_temperature.valueChanged.connect(self.temperature_value) - - self.label_frequencies_pairs_to_compute_VBI = QLabel() - self.label_frequencies_pairs_to_compute_VBI.setText("Frequencies for VBI") - self.gridLayout_groupbox_parameter.addWidget( - self.label_frequencies_pairs_to_compute_VBI, 0, 1, 1, 1) - - # self.combobox_frequencies_VBI = QComboBox() - # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget( - # self.combobox_frequencies_VBI, 1, 1, 1, 1) - # self.combobox_frequencies_VBI.currentIndexChanged.connect(self.frequencies_pair_choice_to_compute_VBI) - - self.label_ks = QLabel() - self.label_ks.setText("ks") - self.gridLayout_groupbox_parameter.addWidget(self.label_ks, 0, 2, 1, 1) - - self.label_sv = QLabel() - self.label_sv.setText("sv") - self.gridLayout_groupbox_parameter.addWidget(self.label_sv, 0, 3, 1, 1) - - self.label_X = QLabel() - self.label_X.setText("X") - self.gridLayout_groupbox_parameter.addWidget(self.label_X, 0, 4, 1, 1) - - self.label_alphas = QLabel() - self.label_alphas.setText("\u03B1s") - self.gridLayout_groupbox_parameter.addWidget(self.label_alphas, 0, 5, 1, 1) - - self.label_zeta = QLabel() - self.label_zeta.setText("\u03B6") - self.gridLayout_groupbox_parameter.addWidget(self.label_zeta, 0, 6, 1, 1) - - self.label_freq1 = QLabel() - self.label_freq1.setText("Frequency 1 : ") - self.gridLayout_groupbox_parameter.addWidget(self.label_freq1, 1, 0, 1, 1) - - self.label_freq2 = QLabel() - self.label_freq2.setText("Frequency 2 : ") - self.gridLayout_groupbox_parameter.addWidget(self.label_freq2, 2, 0, 1, 1) - - self.combobox_freq1 = QComboBox() - self.gridLayout_groupbox_parameter.addWidget(self.combobox_freq1, 1, 1, 1, 1) - - self.combobox_freq2 = QComboBox() - self.gridLayout_groupbox_parameter.addWidget(self.combobox_freq2, 2, 1, 1, 1) - - self.spinbox_ks_freq1 = QDoubleSpinBox() - self.spinbox_ks_freq1.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_ks_freq1, 1, 2, 1, 1) - - self.spinbox_ks_freq2 = QDoubleSpinBox() - self.spinbox_ks_freq2.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_ks_freq2, 2, 2, 1, 1) - - self.spinbox_sv_freq1 = QDoubleSpinBox() - self.spinbox_sv_freq1.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_sv_freq1, 1, 3, 1, 1) - - self.spinbox_sv_freq2 = QDoubleSpinBox() - self.spinbox_sv_freq2.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_sv_freq2, 2, 3, 1, 1) - - self.spinbox_X = QDoubleSpinBox() - self.spinbox_X.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_X, 1, 4, 1, 1) - - self.spinbox_alphas_freq1 = QDoubleSpinBox() - self.spinbox_alphas_freq1.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_alphas_freq1, 1, 5, 1, 1) - - self.spinbox_alphas_freq2 = QDoubleSpinBox() - self.spinbox_alphas_freq2.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_alphas_freq2, 2, 5, 1, 1) - - self.spinbox_zeta_freq1 = QDoubleSpinBox() - self.spinbox_zeta_freq1.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_zeta_freq1, 1, 6, 1, 1) - - self.spinbox_zeta_freq2 = QDoubleSpinBox() - self.spinbox_zeta_freq2.setDecimals(5) - self.gridLayout_groupbox_parameter.addWidget(self.spinbox_zeta_freq2, 2, 6, 1, 1) - - # self.label_frequency_to_compute_SSC = QLabel() - # self.label_frequency_to_compute_SSC.setText("frequencies for SSC : ") - # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget( - # # self.label_frequency_to_compute_SSC, 2, 0, 1, 1) - # self.gridLayout_groupbox_parameter.addWidget(self.label_frequency_to_compute_SSC, 3, 0, 1, 1) - - # self.combobox_frequency_SSC = QComboBox() - # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget( - # # self.combobox_frequency_SSC, 2, 1, 1, 1) - # self.gridLayout_groupbox_parameter.addWidget(self.combobox_frequency_SSC, 3, 1, 1, 1) - # self.combobox_frequency_SSC.currentIndexChanged.connect(self.frequency_choice_to_compute_SSC) - - self.pushbutton_run = QPushButton() - self.pushbutton_run.setText("RUN") - self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.pushbutton_run, 1, 0, 1, 1) - self.pushbutton_run.clicked.connect(self.compute_acoustic_inversion_method_high_concentration) - - self.pushbutton_plot = QPushButton() - self.pushbutton_plot.setText("PLOT") - self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.pushbutton_plot, 1, 1, 1, 1) - self.pushbutton_plot.clicked.connect(self.plot_SSC_fine) - self.pushbutton_plot.clicked.connect(self.plot_SSC_sand) - self.pushbutton_plot.clicked.connect(self.plot_SSC_inverse_VS_measured) + self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine.addWidget(self.toolbar_profile_fine) + self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine.addWidget(self.canvas_profile_fine) # ===================================================== # BOTTOM HORIZONTAL BOX LAYOUT # ===================================================== - # +++++++++++++++++++++++++++++++++++++++++++++++ - # | Group box SSC 2D field | - # +++++++++++++++++++++++++++++++++++++++++++++++ + # ++++++++++++++++++++++++++++++++++++++ + # | Group box SSC 2D Field SAND | + # ++++++++++++++++++++++++++++++++++++++ - self.verticalLayout_groupbox_SSC_2D_field = QVBoxLayout(self.groupbox_SSC_2D_field) - self.groupbox_SSC_2D_field.setTitle("Suspended Sediment Concentration 2D plot") + self.verticalLayout_groupbox_plot_SSC_sand = QVBoxLayout(self.groupbox_plot_SSC_sand) - self.figure_SSC_2D_field, self.axis_SSC_2D_field = plt.subplots(nrows=2, ncols=1, layout="constrained") - self.canvas_SSC_2D_field = FigureCanvas(self.figure_SSC_2D_field) - self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field) + self.canvas_SSC_sand = FigureCanvas() + self.toolbar_SSC_sand = NavigationToolBar(self.canvas_SSC_sand, self) - # +++++++++++++++++++++++++++++++++++++++++++++++ - # | Group box plot samples vs inversion | - # +++++++++++++++++++++++++++++++++++++++++++++++ + self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand) + self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand) - self.verticalLayout_groupbox_SSC_sample_vs_inversion = QVBoxLayout(self.groupbox_SSC_sample_vs_inversion) - self.groupbox_SSC_sample_vs_inversion.setTitle("Suspended Sediment Concentration : sample vs inversion") + # +++++++++++++++++++++++++++++++++++++++++++++++++++++ + # | Group box SSC profile OR Ctot VS SSC SAND | + # +++++++++++++++++++++++++++++++++++++++++++++++++++++ - self.figure_SSC_sample_vs_inversion, self.axis_SSC_sample_vs_inversion = plt.subplots(nrows=1, ncols=1, - layout="constrained") - self.canvas_SSC_sample_vs_inversion = FigureCanvas(self.figure_SSC_sample_vs_inversion) - self.verticalLayout_groupbox_SSC_sample_vs_inversion.addWidget(self.canvas_SSC_sample_vs_inversion) -# -# self.verticalLayout_groupbox_sediment_concentration_2Dplot = QVBoxLayout(self.groupbox_sediment_concentration_2Dplot) -# -# self.figure_SSC_2Dplot, self.axis_SSC_2Dplot = plt.subplots(nrows=2, ncols=1) -# self.canvas_sediments2DPlot = FigureCanvas(self.figure_SSC_2Dplot) -# self.toolbar_concentration_2Dplot = NavigationToolBar(self.canvas_sediments2DPlot, self) -# self.plot_SSC_fine() -# self.plot_SSC_sand() -# # self.verticalLayout_groupbox_sediment_concentration_2Dplot.addWidget(self.toolbar_concentration_2Dplot) -# self.verticalLayout_groupbox_sediment_concentration_2Dplot.addWidget(self.canvas_sediments2DPlot) -# -# # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.canvas_sediments2DPlot) -# self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.groupbox_sediment_concentration_2Dplot, 7) -# -# -# # self.groupbox_sediment_concentration_sample_vs_measurement.setTitle( -# # "Suspended sediment concentration plot : acoustic inversion theory VS measurements") -# -# self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement = QVBoxLayout( -# self.groupbox_sediment_concentration_sample_vs_measurement) -# -# self.figure_inverseSSC_vs_measuredSSC, self.axis_inverseSSC_vs_measuredSSC = plt.subplots(nrows=1, ncols=1) -# self.canvas_InverseSSC_vs_MeasuredSSC = FigureCanvas(self.figure_inverseSSC_vs_measuredSSC) -# self.toolbar_InverseSSC_vs_MeasuredSSC = NavigationToolBar(self.canvas_InverseSSC_vs_MeasuredSSC, self) -# # self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement.addWidget( -# # self.toolbar_InverseSSC_vs_MeasuredSSC) -# self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement.addWidget( -# self.canvas_InverseSSC_vs_MeasuredSSC, 3) -# # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.canvas_InverseSSC_vs_MeasuredSSC) -# -# self.horizontalLayout_Bottom_acousticInversionTab.addWidget( -# self.groupbox_sediment_concentration_sample_vs_measurement) -# -# self.verticalLayout_acoustic_inversion_tab.addLayout(self.horizontalLayout_Bottom_acousticInversionTab, 6) -# -# self.retranslate_acoustic_inversion_tab() + self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand = QVBoxLayout( + self.groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand) - # ---------------------------------------------------------------------------------------------------------------- - # -------------------- Functions -------------------- + self.combobox_vertical_profile_or_Ctot_vs_SSC_sand = QComboBox() + self.combobox_vertical_profile_or_Ctot_vs_SSC_sand.setMaximumWidth(300) + self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand.addWidget( + self.combobox_vertical_profile_or_Ctot_vs_SSC_sand) + self.combobox_vertical_profile_or_Ctot_vs_SSC_sand.addItems(["Inverted SSC vertical profile", + "Measured SSC vs Inverted SSC"]) -# def retranslate_acoustic_inversion_tab(self): + self.canvas_profile_sand = FigureCanvas() + self.toolbar_profile_sand = NavigationToolBar(self.canvas_profile_sand, self) + + self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand.addWidget(self.toolbar_profile_sand) + self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand.addWidget(self.canvas_profile_sand) + + # ============================================================================================================== + # ---------------------------------------- Connect signal of widget -------------------------------------------- + # ============================================================================================================== + + self.combobox_acoustic_data_choice.ShowPopUpWindowSignal.connect(self.event_combobobx_acoustic_data_choice) + + self.pushbutton_run_inversion.clicked.connect(self.function_run_inversion) + + # ================================================================================================================== + # ------------------------------------ Functions for Acoustic Inversion Tab ---------------------------------------- + # ================================================================================================================== + + def event_combobobx_acoustic_data_choice(self): + print("(stg.filename_BS_noise_data ", (stg.filename_BS_noise_data)) + + self.combobox_acoustic_data_choice.clear() + # self.combobox_fileListWidget.addItem("") + for i in range(len(stg.filename_BS_raw_data)): + self.combobox_acoustic_data_choice.addItem(stg.filename_BS_raw_data[i]) + + def function_run_inversion(self): + self.compute_VBI() + self.compute_SSC_fine() + self.compute_SSC_sand() + self.plot_SSC_fine() + self.plot_SSC_sand() + + def compute_VBI(self): + + print("compute VBI") + print(stg.frequencies_for_calibration[0][0], stg.frequencies_for_calibration[1][0]) + print(stg.zeta[0], stg.zeta[1]) + print(stg.J_cross_section[0].shape, stg.J_cross_section[0].shape) + print(stg.depth_2D.shape) + print(stg.alpha_s[0], stg.alpha_s[1]) + print(stg.X_exponent[0]) + + stg.VBI_cross_section = self.inv_hc.VBI_cross_section( + freq1=stg.frequencies_for_calibration[0][0], freq2=stg.frequencies_for_calibration[1][0], + zeta_freq1=stg.zeta[0], zeta_freq2=stg.zeta[1], + j_cross_section_freq1=stg.J_cross_section[0], j_cross_section_freq2=stg.J_cross_section[1], + r2D=stg.depth_2D[stg.frequencies_for_calibration[1][1]], + water_attenuation_freq1=stg.alpha_s[0], water_attenuation_freq2=stg.alpha_s[1], + X=stg.X_exponent[0] + ) + + print("stg.VBI_cross_section.shape ", stg.VBI_cross_section.shape) + print("compute VBI end") + + def compute_SSC_fine(self): + + print("Compute SSC fine - start") + print(stg.zeta[1]) + print(stg.depth_2D[stg.frequencies_for_calibration[1][1]].shape) + print(stg.VBI_cross_section.shape) + print(stg.frequencies_for_calibration[1][0]) + print(stg.X_exponent[0]) + print(stg.J_cross_section[1].shape) + print(stg.water_attenuation) + print(np.full(shape=stg.depth_2D[stg.frequencies_for_calibration[1][1]].shape, + fill_value=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]])) + + stg.SSC_fine = self.inv_hc.SSC_fine( + zeta=stg.zeta[1], + r2D=stg.depth_2D[stg.frequencies_for_calibration[1][1]], + VBI=stg.VBI_cross_section, + freq=stg.frequencies_for_calibration[1][0], + X=stg.X_exponent[0], + j_cross_section=stg.J_cross_section[1], + alpha_w=np.full(shape=stg.depth_2D[stg.frequencies_for_calibration[1][1]].shape, + fill_value=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]]) + ) + + print("stg.SSC_fine ", stg.SSC_fine) + + def compute_SSC_sand(self): + + stg.SSC_sand = self.inv_hc.SSC_sand( + VBI=stg.VBI_cross_section, + freq=stg.frequencies_for_calibration[1][0], + X=stg.X_exponent, + ks=stg.ks[1]) + + print("stg.SSC_sand ", stg.SSC_sand) + + def plot_SSC_fine(self): + + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) + + self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(nrows=1, ncols=1, layout="constrained") + self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine) + + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) + + val_min = np.nanmin(stg.SSC_fine) + val_max = np.nanmax(stg.SSC_fine) + + print("ABS name ", stg.ABS_name) + + if stg.ABS_name[0] == "Aquascat 1000R": + + print("hey !") + + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + print("hey hey !") + + print("time cross section ", stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]]) + print("depth cross section ", stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]]) + print(stg.frequencies_for_calibration[1][1]) + + pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]], + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]], + stg.SSC_fine, + cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud') + + if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.axis_SSC_fine.plot(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]], + -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], + color='black', linewidth=1, linestyle="solid") + + else: + + pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( + stg.time[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]], + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]], + stg.SSC_fine, + cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud') + + if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.axis_SSC_fine.plot(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]], + -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], + color='black', linewidth=1, linestyle="solid") + + cbar_SSC_fine = self.figure_SSC_fine.colorbar(pcm_SSC_fine, ax=self.axis_SSC_fine, shrink=1, + location='right') + cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15) + + elif stg.ABS_name[0] == "UB-SediFlow": + pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(stg.t[0, :], + -stg.r[0, :], + stg.SSC_fine, + cmap='rainbow', + norm=LogNorm(vmin=1e-2, vmax=10), + shading='gouraud') + + # if self.combobox_fig_choice.currentText() == "Inverted SSC fine vertical profile": + # self.axis_SSC_fine.plot(stg.t[0, self.slider.value() - 1] * np.ones(stg.r.shape[1]), + # -stg.r[0, :], + # color='black', linestyle="solid", linewidth=2) + + self.figure_SSC_fine.supxlabel("Time (sec)", fontsize=10) + self.figure_SSC_fine.supylabel("Depth (m)", fontsize=10) + self.figure_SSC_fine.canvas.draw_idle() + + def plot_SSC_sand(self): + + self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.toolbar_SSC_sand) + self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.canvas_SSC_sand) + + self.figure_SSC_sand, self.axis_SSC_sand = plt.subplots(nrows=1, ncols=1, layout="constrained") + self.canvas_SSC_sand = FigureCanvas(self.figure_SSC_sand) + + self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand) + self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand) + + val_min = np.nanmin(stg.SSC_sand) + val_max = np.nanmax(stg.SSC_sand) + + if stg.ABS_name[0] == "Aquascat 1000R": + + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + pcm_SSC_sand = self.axis_SSC_sand.pcolormesh( + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]], + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]], + stg.SSC_sand, + cmap='rainbow', norm=LogNorm(vmin=1e-2, vmax=2), shading='gouraud') + + if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.axis_SSC_sand.plot(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]], + -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], + color='black', linewidth=1, linestyle="solid") + + else: + + pcm_SSC_sand = self.axis_SSC_sand.pcolormesh( + stg.time[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]], + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]], + stg.SSC_sand, + cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud') + + if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.axis_SSC_sand.plot(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequencies_for_calibration[1][1]], + -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], + color='black', linewidth=1, linestyle="solid") + + cbar_SSC_sand = self.figure_SSC_sand.colorbar(pcm_SSC_sand, ax=self.axis_SSC_sand, shrink=1, + location='right') + cbar_SSC_sand.set_label(label='Sand SSC (g/L', rotation=270, labelpad=15) + + elif stg.ABS_name[0] == "UB-SediFlow": + pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :], + -stg.r[0, 5:155], + (stg.SSC_sand[5:155, :]), + cmap="plasma", + # cmap='rainbow', + vmin=0, vmax=10, + # vmin=1e-2, vmax=10) + # vmin=val_min, vmax=val_max, + # norm=LogNorm(vmin=1e-2, vmax=1), + shading='gouraud') + # self.axis_SSC_2D_field[1].plot(stg.t[1, 52] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], + # c='b', ls='solid', lw=2) + # self.axis_SSC_2D_field[1].plot(stg.t[1, ] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], + # c='red', ls='solid', lw=2) + # self.axis_SSC_2D_field[1].plot(stg.t[1, 777] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], + # c='red', ls='solid', lw=2) + + # pcm_SSC_sand = self.axis_SSC_2D_field[1].pcolormesh(stg.t[int(stg.frequency_to_compute_SSC[0]), :], + # -stg.r[int(stg.frequency_to_compute_SSC[0]), :], + # stg.SSC_sand, + # cmap='rainbow', + # # vmin=val_min, vmax=val_max, + # norm=LogNorm(vmin=1e-2, vmax=2), + # shading='gouraud') + + # if stg.r_bottom.size: + # self.axis_SSC_sand.plot(stg.t[0, :], + # -stg.r_bottom, + # color='black', linewidth=1, linestyle="solid") + # # self.axis_SSC_2D_field[1].plot(stg.t[int(stg.frequency_to_compute_SSC[0]), :], + # # -stg.r_bottom, + # # color='black', linewidth=1, linestyle="solid") + # + # if self.combobox_fig_choice.currentText() == "Inverted SSC sand vertical profile": + # self.axis_SSC_sand.plot(stg.t[0, self.slider.value() - 1] * np.ones(stg.r.shape[1]), + # -stg.r[0, :], + # color='black', linestyle="solid", linewidth=2) + + self.figure_SSC_sand.supxlabel("Time (sec)", fontsize=10) + self.figure_SSC_sand.supylabel("Depth (m)", fontsize=10) + self.figure_SSC_sand.canvas.draw_idle() + + + + + # -------------------------------------------------------------------------------------------------------------- + + # ______ _______ + # | | | | \ + # | | | | \ + # | | | | | + # | | | | / + # |______| |________ |________/ + + # COMMENT OLD CODE LINE FROM HERE .... + +# ### --- Layout of groupbox in the Top horizontal layout box # -# self.groupbox_AcousticInversionOption.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_INVERSION_OPTIONS)) -# self.groupbox_sediment_concentration_2Dplot.setTitle(_translate("CONSTANT_STRING", cs.FINE_AND_SAND_SEDIMENTS_CONCENTRATION_2D_FIELD)) -# self.groupbox_sediment_concentration_sample_vs_measurement.setTitle(_translate("CONSTANT_STRING", cs.SUSPENDED_SEDIMENT_CONCENTRATION_PLOT)) +# # Acoustic inversion Options | Acoustic inversion method Settings parameter +# +# self.groupbox_acoustic_inversion_options = QGroupBox() +# self.horizontalLayoutTop.addWidget(self.groupbox_acoustic_inversion_options, 3) +# +# self.groupbox_acoustic_inversion_settings_parameter = QGroupBox() +# self.horizontalLayoutTop.addWidget(self.groupbox_acoustic_inversion_settings_parameter, 7) +# +# ### --- Layout of groupbox in the Bottom horizontal layout box +# +# # Plot SSC 2D field | Plot SSC graph sample vs inversion +# +# self.groupbox_SSC_2D_field = QGroupBox() +# self.horizontalLayoutBottom.addWidget(self.groupbox_SSC_2D_field, 6) +# +# self.groupbox_SSC_profiles_or_measured_vs_inverted = QGroupBox() +# self.horizontalLayoutBottom.addWidget(self.groupbox_SSC_profiles_or_measured_vs_inverted, 4) +# +# # ===================================================== +# # TOP HORIZONTAL BOX LAYOUT +# # ===================================================== +# +# # +++++++++++++++++++++++++++++++++++++++++++++++ +# # | Group box Acoustic inversion options | +# # +++++++++++++++++++++++++++++++++++++++++++++++ +# +# self.gridLayout_groupbox_acoustic_inversion_options = QGridLayout(self.groupbox_acoustic_inversion_options) +# +# self.groupbox_acoustic_inversion_options.setTitle("Acoustic inversion option") +# +# self.label_acoustic_inversion_method_choice = QLabel() +# self.gridLayout_groupbox_acoustic_inversion_options.addWidget( +# self.label_acoustic_inversion_method_choice, 0, 0, 1, 1) +# self.label_acoustic_inversion_method_choice.setText("Acoustic inversion method : ") +# +# self.combobox_acoustic_inversion_method_choice = QComboBox() +# self.gridLayout_groupbox_acoustic_inversion_options.addWidget( +# self.combobox_acoustic_inversion_method_choice, 0, 1, 1, 1) +# self.combobox_acoustic_inversion_method_choice.addItems([" ", "Acoustic inversion method 1"]) +# self.combobox_acoustic_inversion_method_choice.currentIndexChanged.connect( +# self.acoustic_inversion_method_choice) +# # self.combobox_acoustic_inversion_method_choice.currentIndexChanged.connect(self.test) +# +# self.groupbox_calibration_samples = QGroupBox() +# self.groupbox_calibration_samples.setTitle("Sample choice for calibration") +# self.gridLayout_groupbox_acoustic_inversion_options.addWidget(self.groupbox_calibration_samples, 1, 0, 1, 2) +# +# self.gridLayout_groupbox_calibration_samples = QGridLayout(self.groupbox_calibration_samples) +# +# self.label_frequency = QLabel() +# self.label_frequency.setText("Frequency :") +# self.gridLayout_groupbox_calibration_samples.addWidget(self.label_frequency, 0, 0, 1, 1) +# +# self.combobox_frequency = QComboBox() +# self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_frequency, 0, 1, 1, 1) +# self.combobox_frequency.currentIndexChanged.connect(self.update_plot_transect_with_sample_position) +# +# self.label_sand_sample_choice = QLabel() +# self.label_sand_sample_choice.setText("Sand sediments :") +# self.gridLayout_groupbox_calibration_samples.addWidget(self.label_sand_sample_choice, 0, 2, 1, 1) +# +# self.combobox_calibration_sand_sample = CheckableComboBox() +# self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_calibration_sand_sample, 0, 3, 1, 1) +# # self.combobox_calibration_sand_sample.currentData.connect(self.update_plot_transect_with_sample_position) +# self.combobox_calibration_sand_sample.currentIndexChanged.connect( +# self.update_plot_transect_with_sample_position) +# # self.combobox_calibration_sand_sample.currentIndexChanged.connect(self.sample_choice) +# +# self.label_fine_sample_choice = QLabel() +# self.label_fine_sample_choice.setText("Fine sediments :") +# self.gridLayout_groupbox_calibration_samples.addWidget(self.label_fine_sample_choice, 0, 4, 1, 1) +# +# self.combobox_calibration_fine_sample = CheckableComboBox() +# self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_calibration_fine_sample, 0, 5, 1, 1) +# # self.combobox_calibration_fine_sample.currentData.connect(self.update_plot_transect_with_sample_position) +# self.combobox_calibration_fine_sample.currentIndexChanged.connect( +# self.update_plot_transect_with_sample_position) +# +# # self.combobox_calibration_fine_sample.currentIndexChanged.connect(self.sample_choice) +# +# self.groupbox_plot_sample_position_on_transect = QGroupBox() +# self.gridLayout_groupbox_calibration_samples.addWidget(self.groupbox_plot_sample_position_on_transect, 1, 0, 1, 6) +# self.verticalLayout_groupbox_plot_sample_position_on_transect = QVBoxLayout(self.groupbox_plot_sample_position_on_transect) +# +# self.canvas_plot_sample_position_on_transect = None +# # self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.canvas_plot_sample_position_on_transect) +# +# +# # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# # | Group box Acoustic inversion method settings parameter | +# # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# +# self.gridLayout_groupbox_acoustic_inversion_settings_parameter \ +# = QGridLayout(self.groupbox_acoustic_inversion_settings_parameter) +# +# self.groupbox_acoustic_inversion_settings_parameter.setTitle("Acoustic inversion method settings parameter") +# +# self.groupbox_parameter = QGroupBox() +# self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.groupbox_parameter, 0, 0, 1, 2) +# +# self.gridLayout_groupbox_parameter = QGridLayout(self.groupbox_parameter) +# +# # self.label_temperature = QLabel() +# # self.label_temperature.setText("Temperature : ") +# # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.label_temperature, 0, 0, 1, 1) +# # self.gridLayout_groupbox_parameter.addWidget(self.label_temperature, 0, 0, 1, 1) +# # self.spinbox_temperature = QDoubleSpinBox() +# # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.spinbox_temperature, 0, 1, 1, 1) +# # self.gridLayout_groupbox_parameter.addWidget(self.spinbox_temperature, 0, 1, 1, 1) +# # self.spinbox_temperature.valueChanged.connect(self.temperature_value) +# +# self.label_frequencies_pairs_to_compute_VBI = QLabel() +# self.label_frequencies_pairs_to_compute_VBI.setText("Frequencies for VBI") +# self.gridLayout_groupbox_parameter.addWidget( +# self.label_frequencies_pairs_to_compute_VBI, 0, 1, 1, 1) +# +# # self.combobox_frequencies_VBI = QComboBox() +# # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget( +# # self.combobox_frequencies_VBI, 1, 1, 1, 1) +# # self.combobox_frequencies_VBI.currentIndexChanged.connect(self.frequencies_pair_choice_to_compute_VBI) +# +# self.label_ks = QLabel() +# self.label_ks.setText("ks") +# self.gridLayout_groupbox_parameter.addWidget(self.label_ks, 0, 2, 1, 1) +# +# self.label_sv = QLabel() +# self.label_sv.setText("sv") +# self.gridLayout_groupbox_parameter.addWidget(self.label_sv, 0, 3, 1, 1) +# +# self.label_X = QLabel() +# self.label_X.setText("X") +# self.gridLayout_groupbox_parameter.addWidget(self.label_X, 0, 4, 1, 1) +# +# self.label_alphas = QLabel() +# self.label_alphas.setText("\u03B1s") +# self.gridLayout_groupbox_parameter.addWidget(self.label_alphas, 0, 5, 1, 1) +# +# self.label_zeta = QLabel() +# self.label_zeta.setText("\u03B6") +# self.gridLayout_groupbox_parameter.addWidget(self.label_zeta, 0, 6, 1, 1) +# +# self.label_freq1 = QLabel() +# self.label_freq1.setText("Frequency 1 : ") +# self.gridLayout_groupbox_parameter.addWidget(self.label_freq1, 1, 0, 1, 1) +# +# self.label_freq2 = QLabel() +# self.label_freq2.setText("Frequency 2 : ") +# self.gridLayout_groupbox_parameter.addWidget(self.label_freq2, 2, 0, 1, 1) +# +# self.combobox_freq1 = QComboBox() +# self.gridLayout_groupbox_parameter.addWidget(self.combobox_freq1, 1, 1, 1, 1) +# +# self.combobox_freq2 = QComboBox() +# self.gridLayout_groupbox_parameter.addWidget(self.combobox_freq2, 2, 1, 1, 1) +# +# self.spinbox_ks_freq1 = QDoubleSpinBox() +# self.spinbox_ks_freq1.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_ks_freq1, 1, 2, 1, 1) +# +# self.spinbox_ks_freq2 = QDoubleSpinBox() +# self.spinbox_ks_freq2.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_ks_freq2, 2, 2, 1, 1) +# +# self.spinbox_sv_freq1 = QDoubleSpinBox() +# self.spinbox_sv_freq1.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_sv_freq1, 1, 3, 1, 1) +# +# self.spinbox_sv_freq2 = QDoubleSpinBox() +# self.spinbox_sv_freq2.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_sv_freq2, 2, 3, 1, 1) +# +# self.spinbox_X = QDoubleSpinBox() +# self.spinbox_X.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_X, 1, 4, 1, 1) +# +# self.spinbox_alphas_freq1 = QDoubleSpinBox() +# self.spinbox_alphas_freq1.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_alphas_freq1, 1, 5, 1, 1) +# +# self.spinbox_alphas_freq2 = QDoubleSpinBox() +# self.spinbox_alphas_freq2.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_alphas_freq2, 2, 5, 1, 1) +# +# self.spinbox_zeta_freq1 = QDoubleSpinBox() +# self.spinbox_zeta_freq1.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_zeta_freq1, 1, 6, 1, 1) +# +# self.spinbox_zeta_freq2 = QDoubleSpinBox() +# self.spinbox_zeta_freq2.setDecimals(5) +# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_zeta_freq2, 2, 6, 1, 1) +# +# # self.label_frequency_to_compute_SSC = QLabel() +# # self.label_frequency_to_compute_SSC.setText("frequencies for SSC : ") +# # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget( +# # # self.label_frequency_to_compute_SSC, 2, 0, 1, 1) +# # self.gridLayout_groupbox_parameter.addWidget(self.label_frequency_to_compute_SSC, 3, 0, 1, 1) +# +# # self.combobox_frequency_SSC = QComboBox() +# # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget( +# # # self.combobox_frequency_SSC, 2, 1, 1, 1) +# # self.gridLayout_groupbox_parameter.addWidget(self.combobox_frequency_SSC, 3, 1, 1, 1) +# # self.combobox_frequency_SSC.currentIndexChanged.connect(self.frequency_choice_to_compute_SSC) +# +# self.pushbutton_run = QPushButton() +# self.pushbutton_run.setText("RUN") +# self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.pushbutton_run, 1, 0, 1, 1) +# self.pushbutton_run.clicked.connect(self.compute_acoustic_inversion_method_high_concentration) +# +# self.pushbutton_plot = QPushButton() +# self.pushbutton_plot.setText("PLOT") +# self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.pushbutton_plot, 1, 1, 1, 1) +# self.pushbutton_plot.clicked.connect(self.plot_SSC_fine) +# self.pushbutton_plot.clicked.connect(self.plot_SSC_sand) +# # self.pushbutton_plot.clicked.connect(self.insert_slider_for_vertical_profile_figure_area) +# self.pushbutton_plot.clicked.connect(self.plot_inverted_SSC_sand_vertical_profile) +# # self.pushbutton_plot.clicked.connect(self.plot_inverted_SSC_vs_measured_SSC) +# # self.pushbutton_plot.clicked.connect(self.plot_inverted_SSC_vs_measured_SSC_OR_inverted_SSC_vertical_profile) +# +# # ===================================================== +# # BOTTOM HORIZONTAL BOX LAYOUT +# # ===================================================== +# +# # +++++++++++++++++++++++++++++++++++++++++++++++ +# # | Group box SSC 2D field | +# # +++++++++++++++++++++++++++++++++++++++++++++++ +# +# self.verticalLayout_groupbox_SSC_2D_field = QVBoxLayout(self.groupbox_SSC_2D_field) +# self.groupbox_SSC_2D_field.setTitle("Suspended Sediment Concentration 2D plot") +# +# self.groupbox_plot_SSC_sand = QGroupBox() +# self.verticalLayout_groupbox_plot_SSC_sand = QVBoxLayout(self.groupbox_plot_SSC_sand) +# self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.groupbox_plot_SSC_sand) +# +# self.figure_SSC_sand, self.axis_SSC_sand = plt.subplots(nrows=1, ncols=1, layout="constrained") +# self.canvas_SSC_sand = FigureCanvas(self.figure_SSC_sand) +# self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand) +# +# self.groupbox_plot_SSC_fine = QGroupBox() +# self.verticalLayout_groupbox_plot_SSC_fine = QVBoxLayout(self.groupbox_plot_SSC_fine) +# self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.groupbox_plot_SSC_fine) +# +# self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(nrows=1, ncols=1, layout="constrained") +# self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine) +# self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) +# +# # +++++++++++++++++++++++++++++++++++++++++++++++ +# # | Group box plot samples vs inversion | +# # +++++++++++++++++++++++++++++++++++++++++++++++ +# +# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted = QVBoxLayout(self.groupbox_SSC_profiles_or_measured_vs_inverted) +# # self.groupbox_SSC_profiles_or_measured_vs_inverted.setTitle("Suspended Sediment Concentration : sample vs inversion") +# +# self.horizontalLayout_fig_choice = QHBoxLayout() +# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addLayout(self.horizontalLayout_fig_choice) +# self.spacerItem_fig_choice = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) +# self.horizontalLayout_fig_choice.addSpacerItem(self.spacerItem_fig_choice) +# self.combobox_fig_choice = QComboBox() +# self.combobox_fig_choice.addItems([ +# "Inverted SSC sand vertical profile", +# "Inverted SSC fine vertical profile", +# "Inverted SSC vs Measured SSC"]) +# self.horizontalLayout_fig_choice.addWidget(self.combobox_fig_choice) +# +# # self.combobox_fig_choice.currentIndexChanged.connect(self.plot_inverted_SSC_fine_vertical_profile) +# # self.combobox_fig_choice.currentIndexChanged.connect(self.plot_inverted_SSC_sand_vertical_profile) +# # self.combobox_fig_choice.currentIndexChanged.connect(self.plot_inverted_SSC_vs_measured_SSC) +# +# # self.combobox_fig_choice.currentIndexChanged.connect(self.plot_inverted_SSC_vs_measured_SSC_OR_inverted_SSC_vertical_profile) +# +# # --- Figure, axis, canvas for Inverted SSC vs Measured SSC +# self.figure_SSC_measured_vs_inverted, self.axis_SSC_measured_vs_inverted = plt.subplots(nrows=1, ncols=1, +# layout="constrained") +# self.canvas_SSC_measured_vs_inverted = FigureCanvas(self.figure_SSC_measured_vs_inverted) +# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(self.canvas_SSC_measured_vs_inverted) +# +# # --- Figure, axis, canvas for SSC sand vertical profile +# self.figure_SSC_sand_vertical_profile, self.axis_SSC_sand_vertical_profile = ( +# plt.subplots(nrows=1, ncols=1, layout="constrained")) +# self.canvas_SSC_sand_vertical_profile = FigureCanvas(self.figure_SSC_sand_vertical_profile) +# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget( +# self.canvas_SSC_sand_vertical_profile) +# +# # --- Figure, axis, canvas for SSC fine vertical profile +# # self.figure_SSC_fine_vertical_profile, self.axis_SSC_fine_vertical_profile = ( +# # plt.subplots(nrows=1, ncols=1, layout="constrained")) +# # self.canvas_SSC_fine_vertical_profile = FigureCanvas(self.figure_SSC_fine_vertical_profile) +# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget( +# # self.canvas_SSC_fine_vertical_profile) +# +# # --- Slider for moving the profile --- +# self.horizontalLayout_slider = QHBoxLayout() +# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addLayout(self.horizontalLayout_slider) +# +# self.pushbutton_slider_left = QPushButton() +# self.pushbutton_slider_left.setIcon(self.icon_triangle_left) +# self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left) +# +# self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left) +# +# self.pushbutton_slider_right = QPushButton() +# self.pushbutton_slider_right.setIcon(self.icon_triangle_right) +# self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) +# +# self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right) +# +# self.lineEdit_slider = QLineEdit() +# self.lineEdit_slider.setText("1") +# self.lineEdit_slider.setFixedWidth(50) +# self.horizontalLayout_slider.addWidget(self.lineEdit_slider) +# +# self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit) +# +# self.slider = QSlider() +# self.horizontalLayout_slider.addWidget(self.slider, 9) +# +# self.slider.setOrientation(Qt.Horizontal) +# self.slider.setCursor(Qt.OpenHandCursor) +# self.slider.setMinimum(1) +# self.slider.setMaximum(10) +# self.slider.setTickInterval(1) +# self.slider.setValue(1) +# +# self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) +# self.slider.valueChanged.connect(self.plot_inverted_SSC_sand_vertical_profile) +# self.slider.valueChanged.connect(self.plot_SSC_sand) +# +# # self.verticalLayout_groupbox_sediment_concentration_2Dplot = QVBoxLayout(self.groupbox_sediment_concentration_2Dplot) +# # +# # self.figure_SSC_2Dplot, self.axis_SSC_2Dplot = plt.subplots(nrows=2, ncols=1) +# # self.canvas_sediments2DPlot = FigureCanvas(self.figure_SSC_2Dplot) +# # self.toolbar_concentration_2Dplot = NavigationToolBar(self.canvas_sediments2DPlot, self) +# # self.plot_SSC_fine() +# # self.plot_SSC_sand() +# # # self.verticalLayout_groupbox_sediment_concentration_2Dplot.addWidget(self.toolbar_concentration_2Dplot) +# # self.verticalLayout_groupbox_sediment_concentration_2Dplot.addWidget(self.canvas_sediments2DPlot) +# # +# # # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.canvas_sediments2DPlot) +# # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.groupbox_sediment_concentration_2Dplot, 7) +# # +# # +# # # self.groupbox_sediment_concentration_sample_vs_measurement.setTitle( +# # # "Suspended sediment concentration plot : acoustic inversion theory VS measurements") +# # +# # self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement = QVBoxLayout( +# # self.groupbox_sediment_concentration_sample_vs_measurement) +# # +# # self.figure_inverseSSC_vs_measuredSSC, self.axis_inverseSSC_vs_measuredSSC = plt.subplots(nrows=1, ncols=1) +# # self.canvas_InverseSSC_vs_MeasuredSSC = FigureCanvas(self.figure_inverseSSC_vs_measuredSSC) +# # self.toolbar_InverseSSC_vs_MeasuredSSC = NavigationToolBar(self.canvas_InverseSSC_vs_MeasuredSSC, self) +# # # self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement.addWidget( +# # # self.toolbar_InverseSSC_vs_MeasuredSSC) +# # self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement.addWidget( +# # self.canvas_InverseSSC_vs_MeasuredSSC, 3) +# # # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.canvas_InverseSSC_vs_MeasuredSSC) +# # +# # self.horizontalLayout_Bottom_acousticInversionTab.addWidget( +# # self.groupbox_sediment_concentration_sample_vs_measurement) +# # +# # self.verticalLayout_acoustic_inversion_tab.addLayout(self.horizontalLayout_Bottom_acousticInversionTab, 6) +# # +# # self.retranslate_acoustic_inversion_tab() +# +# # ---------------------------------------------------------------------------------------------------------------- +# # -------------------- Functions -------------------- +# +# # def retranslate_acoustic_inversion_tab(self): +# # +# # self.groupbox_AcousticInversionOption.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_INVERSION_OPTIONS)) +# # self.groupbox_sediment_concentration_2Dplot.setTitle(_translate("CONSTANT_STRING", cs.FINE_AND_SAND_SEDIMENTS_CONCENTRATION_2D_FIELD)) +# # self.groupbox_sediment_concentration_sample_vs_measurement.setTitle(_translate("CONSTANT_STRING", cs.SUSPENDED_SEDIMENT_CONCENTRATION_PLOT)) def acoustic_inversion_method_choice(self): + print("acoustic_inversion_method_choice") if self.combobox_acoustic_inversion_method_choice.currentIndex() == 1: self.plot_transect_with_sample_position() @@ -381,6 +849,7 @@ class AcousticInversionTab(QWidget): # print(f"stg.frac_vol_fine : {stg.frac_vol_fine}") def plot_transect_with_sample_position(self): + print("plot_transect_with_sample_position") if self.canvas_plot_sample_position_on_transect == None: self.verticalLayout_groupbox_plot_sample_position_on_transect.removeWidget(self.canvas_plot_sample_position_on_transect) @@ -1087,7 +1556,7 @@ class AcousticInversionTab(QWidget): range_lin_interp, M_profile_fine = self.inv_hc.M_profile_SCC_fine_interpolated(sample_depth=-stg.sample_depth[fine_position_list], #:3 M_profile=stg.Ctot_fine[fine_position_list], #:3 range_cells=stg.r[0, :], - r_bottom=stg.r_bottom[t_sample_ind[0][0]]) + r_bottom=[stg.r_bottom[t_sample_ind[0][0]] if stg.r_bottom.size != 0 else stg.r_bottom]) print(f"range_lin_interp : {range_lin_interp}") print(f"M_profile_fine : {M_profile_fine}") @@ -1395,206 +1864,328 @@ class AcousticInversionTab(QWidget): # self.plot_SSC_fine() # self.plot_SSC_sand() - def plot_SSC_fine(self): + # def update_plot_SSC_fine_and_sand(self): + # self.verticalLayout_groupbox_SSC_2D_field.removeWidget(self.canvas_SSC_2D_field) + # + # self.figure_SSC_2D_field, self.axis_SSC_2D_field = plt.subplots(nrows=2, ncols=1, layout="constrained") + # self.canvas_SSC_2D_field = FigureCanvas(self.figure_SSC_2D_field) + # self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field) + # + # self.plot_SSC_fine() + # self.plot_SSC_sand() - # val_min = 1e-2 - # val_max = 15 - val_min = np.nanmin(stg.SSC_fine) - val_max = np.nanmax(stg.SSC_fine) - print('val_min fine = ', val_min) - print('val_max fine =', val_max) - # print('val_min fine = ', np.nanmin(stg.VBI_cross_section)) - # print('val_max fine =', np.nanmax(stg.VBI_cross_section)) - # if val_min == 0: - # val_min = 0.5 - # print('val_min update =', val_min) - - # pcm_SSC_fine = self.axis_SSC_2D_field[0].pcolormesh(stg.t[0, :], - # -stg.r[0, :], - # stg.SSC_fine, - # # np.log(stg.VBI_cross_section/1.1932980954310682e-27), - # # cmap='jet', - # # vmin=val_min, vmax=val_max) - # cmap = 'rainbow', - # norm=LogNorm(vmin=1e-1, vmax=15)) - # # shading='gouraud') - if stg.ABS_name == "Aquascat 1000R": - - self.verticalLayout_groupbox_SSC_2D_field.removeWidget(self.canvas_SSC_2D_field) - self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field) - - pcm_SSC_fine = self.axis_SSC_2D_field[0].pcolormesh(stg.t[0, :], - -stg.r[0, :], - stg.SSC_fine, - cmap='rainbow', - norm=LogNorm(vmin=1e0, vmax=15), - shading='gouraud') - - cbar_SSC_fine = self.figure_SSC_2D_field.colorbar(pcm_SSC_fine, ax=self.axis_SSC_2D_field[0], shrink=1, - location='right') - cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15) - # pcm_SSC_fine = self.axis_SSC_2D_field[0].pcolormesh(stg.t[int(stg.frequency_to_compute_SSC[0]), :], - # -stg.r[int(stg.frequency_to_compute_SSC[0]), :], - # stg.SSC_fine, - # cmap='rainbow', - # norm=LogNorm(vmin=1e-2, vmax=15), - # shading='gouraud') - elif stg.ABS_name == "UB-SediFlow": - pcm_SSC_fine = self.axis_SSC_2D_field[0].pcolormesh(stg.t[0, :], - -stg.r[0, :], - stg.SSC_fine, - cmap='rainbow', - norm=LogNorm(vmin=1e-2, vmax=10), - shading='gouraud') - - - if stg.r_bottom.size != 0: - self.axis_SSC_2D_field[0].plot(stg.t[0, :], - -stg.r_bottom, - color='black', linewidth=1, linestyle="solid") - # self.axis_SSC_2D_field[0].plot(stg.t[int(stg.frequency_to_compute_SSC[0]), :], - # -stg.r_bottom, - # color='black', linewidth=1, linestyle="solid") - - def plot_SSC_sand(self): - - val_min = 1e-2 - val_max = 2 - val_min = np.nanmin(stg.SSC_sand) - val_max = np.nanmax(stg.SSC_sand) - # val_min = np.nanmin(np.log(stg.VBI_cross_section)) - # val_max = np.nanmax(np.log(stg.VBI_cross_section)) - print('val_min sand = ', val_min) - print('val_max sand =', val_max) - # print('val_min sand = ', np.nanmin(stg.VBI_cross_section)) - # print('val_max sand = ', np.nanmax(stg.VBI_cross_section)) - # if val_min == 0: - # val_min = 0.5 - # print('val_min update =', val_min) - - # print(stg.SSC_sand) - - if stg.ABS_name == "Aquascat 1000R": - - self.verticalLayout_groupbox_SSC_2D_field.removeWidget(self.canvas_SSC_2D_field) - self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field) - - pcm_SSC_sand = self.axis_SSC_2D_field[1].pcolormesh(stg.t[0, :], - -stg.r[0, :], - (stg.SSC_sand), - cmap='rainbow', - # vmin=-60, vmax=-45) - # vmin=1e-2, vmax=10) - # vmin=val_min, vmax=val_max, - norm=LogNorm(vmin=1e-2, vmax=2), - shading='gouraud') - - cbar_SSC_sand = self.figure_SSC_2D_field.colorbar(pcm_SSC_sand, ax=self.axis_SSC_2D_field[1], shrink=1, - location='right') - cbar_SSC_sand.set_label(label='Sand SSC (g/L', rotation=270, labelpad=15) - - elif stg.ABS_name == "UB-SediFlow": - pcm_SSC_sand = self.axis_SSC_2D_field[1].pcolormesh(stg.t[0, :], - -stg.r[0, 5:155], - (stg.SSC_sand[5:155, :]), - cmap="plasma", - # cmap='rainbow', - vmin=0, vmax=10, - # vmin=1e-2, vmax=10) - # vmin=val_min, vmax=val_max, - # norm=LogNorm(vmin=1e-2, vmax=1), - shading='gouraud') - # self.axis_SSC_2D_field[1].plot(stg.t[1, 52] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], - # c='b', ls='solid', lw=2) - # self.axis_SSC_2D_field[1].plot(stg.t[1, ] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], - # c='red', ls='solid', lw=2) - self.axis_SSC_2D_field[1].plot(stg.t[1, 777] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], - c='red', ls='solid', lw=2) - - # pcm_SSC_sand = self.axis_SSC_2D_field[1].pcolormesh(stg.t[int(stg.frequency_to_compute_SSC[0]), :], - # -stg.r[int(stg.frequency_to_compute_SSC[0]), :], - # stg.SSC_sand, - # cmap='rainbow', - # # vmin=val_min, vmax=val_max, - # norm=LogNorm(vmin=1e-2, vmax=2), - # shading='gouraud') - - if stg.r_bottom.size: - self.axis_SSC_2D_field[1].plot(stg.t[0, :], - -stg.r_bottom, - color='black', linewidth=1, linestyle="solid") - # self.axis_SSC_2D_field[1].plot(stg.t[int(stg.frequency_to_compute_SSC[0]), :], - # -stg.r_bottom, - # color='black', linewidth=1, linestyle="solid") - - self.figure_SSC_2D_field.supxlabel("Time (sec)", fontsize=10) - self.figure_SSC_2D_field.supylabel("Depth (m)", fontsize=10) - self.figure_SSC_2D_field.canvas.draw_idle() - - def plot_SSC_inverse_VS_measured(self): - - sample_depth_position = [] - for i in range(stg.sample_depth.shape[0]): - sample_depth_position.append( - np.where(np.abs(stg.r[0, :] + stg.sample_depth[i]) == - np.min(np.abs(stg.r[0, :] + stg.sample_depth[i])))[0][0]) - - sample_time_position = [] - for j in range(stg.sample_time.shape[0]): - sample_time_position.append( - np.where(np.abs(stg.t[0, :] - stg.sample_time[j]) == - np.min(np.abs(stg.t[0, :] - stg.sample_time[j])))[0][0]) - - self.verticalLayout_groupbox_SSC_sample_vs_inversion.removeWidget(self.canvas_SSC_sample_vs_inversion) - self.verticalLayout_groupbox_SSC_sample_vs_inversion.addWidget(self.canvas_SSC_sample_vs_inversion) - - print("Ctot fine : ", stg.Ctot_fine) - print("SCC fine : ", stg.SSC_fine[sample_depth_position, sample_time_position]) - print("Ctot sand : ", stg.Ctot_sand) - print("SCC sand : ", stg.SSC_sand[sample_depth_position, sample_time_position]) - - if stg.ABS_name == "Aquascat 1000R": - self.axis_SSC_sample_vs_inversion.plot(stg.Ctot_fine, stg.SSC_fine[sample_depth_position, sample_time_position], ls=" ", marker='v', color='black', label='Fine SSC') - self.axis_SSC_sample_vs_inversion.plot(stg.Ctot_sand, - stg.SSC_sand[sample_depth_position, sample_time_position], - ls=" ", marker='x', color='black', label='Sand SSC') - - self.axis_SSC_sample_vs_inversion.set_xscale('log') - self.axis_SSC_sample_vs_inversion.set_yscale('log') - self.axis_SSC_sample_vs_inversion.plot([0, 10], [0, 10], color='black', lw=1) - self.axis_SSC_sample_vs_inversion.set_xlabel('Measured SSC (g/l)', weight='bold') - self.axis_SSC_sample_vs_inversion.set_ylabel('Inverse SSC (g/l)', weight='bold') - self.axis_SSC_sample_vs_inversion.legend() - - elif stg.ABS_name == "UB-SediFlow": - # self.axis_SSC_sample_vs_inversion.plot(stg.Ctot_sand, - # stg.SSC_sand[sample_depth_position, sample_time_position], - # ls=" ", marker='x', color='black', label='Sand SSC') - - # fig, ax = plt.subplots(nrows=2, ncols=10) - # for j in range(2): - # for i in range(10): - # ax[j, i].plot(stg.r[1, :145], stg.SSC_sand[:145, 750+j*10+i]) - # plt.show() - # fig, ax = plt.subplots(nrows=1, ncols=1) - # for i in range(20): - # ax.plot(stg.r[1, :145], stg.SSC_sand[:145, 750+i]) - # plt.show() - - # self.axis_SSC_sample_vs_inversion.plot(stg.r[1, :145], stg.SSC_sand[:145, 40], color='blue', ls='solid') - # self.axis_SSC_sample_vs_inversion.plot(stg.r[1, 5:152], stg.SSC_sand[5:152, 52], - # color='blue', ls='solid') #, marker='o', mec='k', mfc='k', ms=3) - # self.axis_SSC_sample_vs_inversion.plot(stg.r[1, 5:152], stg.SSC_sand[5:152, 766], - # color='red', ls='solid') - self.axis_SSC_sample_vs_inversion.plot(stg.r[1, 5:138], stg.SSC_sand[5:138, 777], color='red', ls='solid') - - self.axis_SSC_sample_vs_inversion.set_xlabel('Depth (m)', weight='bold') - self.axis_SSC_sample_vs_inversion.set_ylabel('Sand concentration (g/l)', weight='bold') - - self.figure_SSC_sample_vs_inversion.canvas.draw_idle() + # def plot_SSC_fine(self): + # + # self.slider.setMaximum(stg.t.shape[1]) + # + # self.figure_SSC_fine.clf() + # self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) + # + # self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(nrows=1, ncols=1, layout="constrained") + # self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine) + # self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) + # + # # val_min = 1e-2 + # # val_max = 15 + # val_min = np.nanmin(stg.SSC_fine) + # val_max = np.nanmax(stg.SSC_fine) + # # print('val_min fine = ', val_min) + # # print('val_max fine =', val_max) + # # print('val_min fine = ', np.nanmin(stg.VBI_cross_section)) + # # print('val_max fine =', np.nanmax(stg.VBI_cross_section)) + # # if val_min == 0: + # # val_min = 0.5 + # # print('val_min update =', val_min) + # + # # pcm_SSC_fine = self.axis_SSC_2D_field[0].pcolormesh(stg.t[0, :], + # # -stg.r[0, :], + # # stg.SSC_fine, + # # # np.log(stg.VBI_cross_section/1.1932980954310682e-27), + # # # cmap='jet', + # # # vmin=val_min, vmax=val_max) + # # cmap = 'rainbow', + # # norm=LogNorm(vmin=1e-1, vmax=15)) + # # # shading='gouraud') + # if stg.ABS_name == "Aquascat 1000R": + # + # pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(stg.t[0, :], + # -stg.r[0, :], + # stg.SSC_fine, + # cmap='rainbow', + # norm=LogNorm(vmin=1e0, vmax=15), + # shading='gouraud') + # + # cbar_SSC_fine = self.figure_SSC_fine.colorbar(pcm_SSC_fine, ax=self.axis_SSC_fine, shrink=1, + # location='right') + # cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15) + # + # elif stg.ABS_name == "UB-SediFlow": + # pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(stg.t[0, :], + # -stg.r[0, :], + # stg.SSC_fine, + # cmap='rainbow', + # norm=LogNorm(vmin=1e-2, vmax=10), + # shading='gouraud') + # + # + # if stg.r_bottom.size != 0: + # self.axis_SSC_fine.plot(stg.t[0, :], + # -stg.r_bottom, + # color='black', linewidth=1, linestyle="solid") + # # self.axis_SSC_2D_field[0].plot(stg.t[int(stg.frequency_to_compute_SSC[0]), :], + # # -stg.r_bottom, + # # color='black', linewidth=1, linestyle="solid") + # + # if self.combobox_fig_choice.currentText() == "Inverted SSC fine vertical profile": + # self.axis_SSC_fine.plot(stg.t[0, self.slider.value() - 1] * np.ones(stg.r.shape[1]), + # -stg.r[0, :], + # color='black', linestyle="solid", linewidth=2) + # + # self.figure_SSC_fine.supxlabel("Time (sec)", fontsize=10) + # self.figure_SSC_fine.supylabel("Depth (m)", fontsize=10) + # self.figure_SSC_fine.canvas.draw_idle() + # + # def plot_SSC_sand(self): + # + # self.slider.setMaximum(stg.t.shape[1]) + # + # self.figure_SSC_sand.clf() + # self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.canvas_SSC_sand) + # + # self.figure_SSC_sand, self.axis_SSC_sand = plt.subplots(nrows=1, ncols=1, layout="constrained") + # self.canvas_SSC_sand = FigureCanvas(self.figure_SSC_sand) + # self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand) + # + # val_min = 1e-2 + # val_max = 2 + # val_min = np.nanmin(stg.SSC_sand) + # val_max = np.nanmax(stg.SSC_sand) + # # val_min = np.nanmin(np.log(stg.VBI_cross_section)) + # # val_max = np.nanmax(np.log(stg.VBI_cross_section)) + # # print('val_min sand = ', val_min) + # # print('val_max sand =', val_max) + # # print('val_min sand = ', np.nanmin(stg.VBI_cross_section)) + # # print('val_max sand = ', np.nanmax(stg.VBI_cross_section)) + # if val_min == 0: + # val_min = 0.5 + # # print('val_min update =', val_min) + # + # # print(stg.SSC_sand) + # + # if stg.ABS_name == "Aquascat 1000R": + # + # pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :], + # -stg.r[0, :], + # (stg.SSC_sand), + # cmap='rainbow', + # # vmin=-60, vmax=-45) + # # vmin=1e-2, vmax=10) + # # vmin=val_min, vmax=val_max, + # norm=LogNorm(vmin=1e-2, vmax=2), + # shading='gouraud') + # + # cbar_SSC_sand = self.figure_SSC_sand.colorbar(pcm_SSC_sand, ax=self.axis_SSC_sand, shrink=1, + # location='right') + # cbar_SSC_sand.set_label(label='Sand SSC (g/L', rotation=270, labelpad=15) + # + # elif stg.ABS_name == "UB-SediFlow": + # pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :], + # -stg.r[0, 5:155], + # (stg.SSC_sand[5:155, :]), + # cmap="plasma", + # # cmap='rainbow', + # vmin=0, vmax=10, + # # vmin=1e-2, vmax=10) + # # vmin=val_min, vmax=val_max, + # # norm=LogNorm(vmin=1e-2, vmax=1), + # shading='gouraud') + # # self.axis_SSC_2D_field[1].plot(stg.t[1, 52] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], + # # c='b', ls='solid', lw=2) + # # self.axis_SSC_2D_field[1].plot(stg.t[1, ] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], + # # c='red', ls='solid', lw=2) + # # self.axis_SSC_2D_field[1].plot(stg.t[1, 777] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152], + # # c='red', ls='solid', lw=2) + # + # # pcm_SSC_sand = self.axis_SSC_2D_field[1].pcolormesh(stg.t[int(stg.frequency_to_compute_SSC[0]), :], + # # -stg.r[int(stg.frequency_to_compute_SSC[0]), :], + # # stg.SSC_sand, + # # cmap='rainbow', + # # # vmin=val_min, vmax=val_max, + # # norm=LogNorm(vmin=1e-2, vmax=2), + # # shading='gouraud') + # + # if stg.r_bottom.size: + # self.axis_SSC_sand.plot(stg.t[0, :], + # -stg.r_bottom, + # color='black', linewidth=1, linestyle="solid") + # # self.axis_SSC_2D_field[1].plot(stg.t[int(stg.frequency_to_compute_SSC[0]), :], + # # -stg.r_bottom, + # # color='black', linewidth=1, linestyle="solid") + # + # if self.combobox_fig_choice.currentText() == "Inverted SSC sand vertical profile": + # self.axis_SSC_sand.plot(stg.t[0, self.slider.value() - 1] * np.ones(stg.r.shape[1]), + # -stg.r[0, :], + # color='black', linestyle="solid", linewidth=2) + # + # self.figure_SSC_sand.supxlabel("Time (sec)", fontsize=10) + # self.figure_SSC_sand.supylabel("Depth (m)", fontsize=10) + # self.figure_SSC_sand.canvas.draw_idle() + def plot_inverted_SSC_sand_vertical_profile(self): + # self.combobox_fig_choice.setCurrentIndex(1) + if self.combobox_fig_choice.currentText() == "Inverted SSC sand vertical profile": + self.axis_SSC_sand_vertical_profile.cla() + + # --- Plot inverted SSC vertical profile --- + self.axis_SSC_sand_vertical_profile.plot(stg.SSC_sand[:, self.slider.value()-1], + -stg.r[self.combobox_freq2.currentIndex(), :], + color='black', ls='solid') + + self.axis_SSC_sand_vertical_profile.set_xlabel('Sand concentration (g/l)', weight='bold') + self.axis_SSC_sand_vertical_profile.set_ylabel('Depth (m)', weight='bold') + + self.axis_SSC_sand_vertical_profile.set_xlim(0, 10) + + self.figure_SSC_sand_vertical_profile.canvas.draw_idle() + + def plot_inverted_SSC_fine_vertical_profile(self): + + if self.combobox_fig_choice.currentText() == "Inverted SSC vs Measured SSC": + + self.axis_SSC_fine_vertical_profile.cla() + + # --- Plot inverted SSC vertical profile --- + self.axis_SSC_fine_vertical_profile.plot(stg.r[self.combobox_freq2.currentIndex(), :], + stg.SSC_sand[:, self.slider.value()-1], + color='black', ls='solid') + + self.axis_SSC_fine_vertical_profile.set_xlabel('Sand concentration (g/l)', weight='bold') + self.axis_SSC_fine_vertical_profile.set_ylabel('Depth (m)', weight='bold') + + self.figure_SSC_fine_vertical_profile.canvas.draw_idle() + + def plot_inverted_SSC_vs_measured_SSC(self): + + if self.combobox_fig_choice.currentText() == "Inverted SSC vs Measured SSC": + + self.figure_SSC_measured_vs_inverted.clf() + self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.canvas_SSC_measured_vs_inverted) + + self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(self.canvas_SSC_measured_vs_inverted) + + sample_depth_position = [] + for i in range(stg.sample_depth.shape[0]): + sample_depth_position.append( + np.where(np.abs(stg.r[0, :] + stg.sample_depth[i]) == + np.min(np.abs(stg.r[0, :] + stg.sample_depth[i])))[0][0]) + + sample_time_position = [] + for j in range(stg.sample_time.shape[0]): + sample_time_position.append( + np.where(np.abs(stg.t[0, :] - stg.sample_time[j]) == + np.min(np.abs(stg.t[0, :] - stg.sample_time[j])))[0][0]) + + # print("Ctot fine : ", stg.Ctot_fine) + # print("SCC fine : ", stg.SSC_fine[sample_depth_position, sample_time_position]) + # print("Ctot sand : ", stg.Ctot_sand) + # print("SCC sand : ", stg.SSC_sand[sample_depth_position, sample_time_position]) + + self.axis_SSC_measured_vs_inverted.cla() + + self.axis_SSC_measured_vs_inverted.plot(stg.Ctot_fine, stg.SSC_fine[sample_depth_position, sample_time_position], ls=" ", marker='v', color='black', label='Fine SSC') + self.axis_SSC_measured_vs_inverted.plot(stg.Ctot_sand, + stg.SSC_sand[sample_depth_position, sample_time_position], + ls=" ", marker='x', color='black', label='Sand SSC') + + self.axis_SSC_measured_vs_inverted.set_xscale('log') + self.axis_SSC_measured_vs_inverted.set_yscale('log') + self.axis_SSC_measured_vs_inverted.plot([0, 10], [0, 10], color='black', lw=1) + self.axis_SSC_measured_vs_inverted.set_xlabel('Measured SSC (g/l)', weight='bold') + self.axis_SSC_measured_vs_inverted.set_ylabel('Inverse SSC (g/l)', weight='bold') + self.axis_SSC_measured_vs_inverted.legend() + + # def insert_slider_for_vertical_profile_figure_area(self): + # + # if ((self.combobox_fig_choice.currentText() == "Inverted SSC fine vertical profile") or + # (self.combobox_fig_choice.currentText() == "Inverted SSC sand vertical profile")): + # + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.canvas_SSC_measured_vs_inverted) + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(self.canvas_SSC_measured_vs_inverted) + # + # # --- Slider for moving the profile --- + # self.horizontalLayout_slider = QHBoxLayout() + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addLayout(self.horizontalLayout_slider) + # + # self.pushbutton_slider_left = QPushButton() + # self.pushbutton_slider_left.setIcon(self.icon_triangle_left) + # self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left) + # + # self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left) + # + # self.pushbutton_slider_right = QPushButton() + # self.pushbutton_slider_right.setIcon(self.icon_triangle_right) + # self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) + # + # self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right) + # + # self.lineEdit_slider = QLineEdit() + # self.lineEdit_slider.setText("1") + # self.lineEdit_slider.setFixedWidth(50) + # self.horizontalLayout_slider.addWidget(self.lineEdit_slider) + # + # self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit) + # + # self.slider = QSlider() + # self.horizontalLayout_slider.addWidget(self.slider, 9) + # + # self.slider.setOrientation(Qt.Horizontal) + # self.slider.setCursor(Qt.OpenHandCursor) + # self.slider.setMinimum(1) + # self.slider.setMaximum(stg.t.shape[1]) + # self.slider.setTickInterval(1) + # self.slider.setValue(1) + # + # self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) + # + # self.slider.valueChanged.connect(self.plot_inverted_SSC_fine_vertical_profile) + # + # self.slider.valueChanged.connect(self.plot_SSC_sand) + # + # self.plot_inverted_SSC_fine_vertical_profile() + # self.update_plot_SSC_fine_and_sand() + # + # elif self.combobox_fig_choice.currentText() == "Inverted SSC vs Measured SSC": + # + # self.figure_SSC_sand.clf() + # self.figure_SSC_fine.clf() + # + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.canvas_SSC_sand) + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.canvas_SSC_fine) + # + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.pushbutton_slider_right) + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.pushbutton_slider_left) + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.lineEdit_slider) + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.slider) + # + # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(self.canvas_SSC_measured_vs_inverted) + # + # self.figure_SSC_measured_vs_inverted.canvas.draw_idle() + + def slide_profile_number_to_right(self): + self.slider.setValue(int(self.slider.value()) + 1) + self.lineEdit_slider.setText(str(self.slider.value())) + + def slide_profile_number_to_left(self): + self.slider.setValue(int(self.slider.value()) - 1) + self.lineEdit_slider.setText(str(self.slider.value())) + + def profile_number_on_lineEdit(self): + self.slider.setValue(int(self.lineEdit_slider.text())) + + def update_lineEdit_by_moving_slider(self): + self.lineEdit_slider.setText(str(self.slider.value())) diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index 01b9d2d..06fb409 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -276,6 +276,15 @@ class SedimentCalibrationTab(QWidget): def plot_acoustic_recording(self): + # --- Record frequencies for calibration --- + stg.frequencies_for_calibration.append((stg.freq[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_freq1.currentIndex()], + self.combobox_freq1.currentIndex())) + stg.frequencies_for_calibration.append((stg.freq[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_freq2.currentIndex()], + self.combobox_freq2.currentIndex())) + + # --- Plot acoustic data recording --- self.verticalLayout_groupbox_acoustic_data.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) @@ -654,6 +663,8 @@ class SedimentCalibrationTab(QWidget): self.combobox_freq2.currentIndex()], C=stg.water_velocity[self.combobox_acoustic_data_choice.currentIndex()]) + 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") @@ -668,6 +679,8 @@ class SedimentCalibrationTab(QWidget): sv_freq1 = self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[stg.sand_sample_target[0][1]]) sv_freq2 = self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[stg.sand_sample_target[0][1]]) + stg.sv = [sv_freq1, sv_freq2] + print(f"sv for frequency of {stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex()]} : {sv_freq1:.8f} /m \n") print(f"sv for frequency of {stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()]} : {sv_freq2:.8f} /m") @@ -682,6 +695,8 @@ class SedimentCalibrationTab(QWidget): freq2=stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()], sv_freq1=sv_freq1, sv_freq2=sv_freq2) + stg.X_exponent.append(X_exponent) + print(f"Exponent X = {X_exponent:.2f}\n") self.spinbox_X.clear() @@ -800,6 +815,11 @@ class SedimentCalibrationTab(QWidget): r2D=depth_2D[self.combobox_freq2.currentIndex(), :, :], kt=kt3D[self.combobox_freq2.currentIndex(), :, :]) + stg.depth_2D = depth_2D + + stg.J_cross_section.append(J_cross_section_freq1) + stg.J_cross_section.append(J_cross_section_freq2) + print("J_cross_section_freq1.shape ", J_cross_section_freq1.shape) print("J_cross_section_freq2.shape ", J_cross_section_freq2.shape) @@ -844,6 +864,8 @@ class SedimentCalibrationTab(QWidget): alpha_w=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq2.currentIndex()]) + stg.alpha_s = [alpha_s_freq1, alpha_s_freq2] + 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") @@ -876,6 +898,8 @@ class SedimentCalibrationTab(QWidget): 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") diff --git a/settings.py b/settings.py index 3d6f03e..00bd434 100644 --- a/settings.py +++ b/settings.py @@ -153,36 +153,38 @@ sand_sample_target_indice = [] Ctot_fine_per_cent = [] Ctot_sand_per_cent = [] -range_lin_interp = [] -M_profile_fine = [] - # --- Acoustic inversion method --- temperature = [] water_attenuation = [] water_velocity = [] -X_exponent = np.array([]) - -zeta = np.array([]) - # kt_corrected = np.array([]) # kt_corrected_2D = np.array([]) # kt_corrected_3D = np.array([]) -J_cross_section = np.array([]) -J_stream_bed = np.array([[[]]]) frequencies_to_compute_VBI = np.array([]) VBI_cross_section = np.array([]) VBI_stream_bed = np.array([[[]]]) -frequency_to_compute_SSC = 0 -ks = 0 -sv = 0 -alpha_s = 0 +# --- Sediment Calibration +frequencies_for_calibration = [] -SSC_fine = np.array(()) -SSC_sand = np.array([]) +range_lin_interp = [] +M_profile_fine = [] + +ks = [] +sv = [] +X_exponent = [] +alpha_s = [] +zeta = [] + +J_cross_section = [] + +frequency_for_inversion = [] + +SSC_fine = np.array([[]]) +SSC_sand = np.array([[]]) # --- Save study ---