From 66f62765a1b66c2e207a14cac4b33f7a8460ec8a Mon Sep 17 00:00:00 2001 From: brahim Date: Wed, 21 Aug 2024 09:26:08 +0200 Subject: [PATCH] Acoustic inversion tab display results of the inversion computation for both, fine and sand sediments. The user can visualize the concentrations fields, plot vertical profiles of the concentrations and choose samples to compare measured SSC vs inverted SSC. --- View/acoustic_data_tab.py | 13 +- View/acoustic_inversion_tab.py | 3473 ++++++++++++++++++------------ View/sediment_calibration_tab.py | 50 +- settings.py | 11 +- 4 files changed, 2104 insertions(+), 1443 deletions(-) diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 742f23e..e738759 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -2157,7 +2157,8 @@ class AcousticDataTab(QWidget): stg.BS_raw_data.append(acoustic_data._BS_raw_data) stg.BS_raw_data_reshape.append(acoustic_data.reshape_BS_raw_data()) stg.depth.append(acoustic_data._r) - stg.depth_2D.append(acoustic_data.compute_r_2D()) + # stg.depth_2D.append(acoustic_data.compute_r_2D()) + stg.depth_2D.append(np.array([])) stg.depth_reshape.append(acoustic_data.reshape_r()) stg.time.append(acoustic_data._time) stg.time_reshape.append(acoustic_data.reshape_t()) @@ -2225,6 +2226,16 @@ class AcousticDataTab(QWidget): stg.BS_stream_bed_pre_process_average.append(np.array([])) stg.BS_stream_bed_pre_process_SNR_average.append(np.array([])) + stg.frequencies_for_calibration.append([]) + stg.frequency_for_inversion.append([]) + + stg.fine_sample_position.append([]) + stg.sand_sample_position.append([]) + + stg.VBI_cross_section.append(np.array([])) + stg.SSC_fine.append(np.array([])) + stg.SSC_sand.append(np.array([])) + # if self.fileListWidget.count() == 0: # # stg.ABS_name = [self.combobox_ABS_system_choice.currentText()] diff --git a/View/acoustic_inversion_tab.py b/View/acoustic_inversion_tab.py index f1bf8ad..a333815 100644 --- a/View/acoustic_inversion_tab.py +++ b/View/acoustic_inversion_tab.py @@ -33,6 +33,16 @@ from Model.acoustic_inversion_method_high_concentration import AcousticInversion _translate = QCoreApplication.translate +def deleteItemsOfLayout(layout): + if layout is not None: + while layout.count(): + item = layout.takeAt(0) + widget = item.widget() + if widget is not None: + widget.setParent(None) + else: + deleteItemsOfLayout(item.layout()) + class AcousticInversionTab(QWidget): @@ -44,7 +54,10 @@ class AcousticInversionTab(QWidget): 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_left_to_begin = QIcon(self.path_icon + "triangle_left_to_begin.png") 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.inv_hc = AcousticInversionMethodHighConcentration() @@ -74,31 +87,42 @@ class AcousticInversionTab(QWidget): ### --- Layout of groupbox in the Top horizontal layout box - # Plot SSC 2D field | Plot SSC graph sample vs inversion / SSC vertical profile ===>>> FINE + # Plot SSC 2D field | SSC vertical profile | Plot SSC graph sample vs inversion ===>>> FINE self.groupbox_plot_SSC_fine = QGroupBox() - self.horizontalLayoutTop.addWidget(self.groupbox_plot_SSC_fine, 7) + self.horizontalLayoutTop.addWidget(self.groupbox_plot_SSC_fine, 6) - 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) + self.groupbox_plot_SSC_fine_vertical_profile = QGroupBox() + # self.horizontalLayoutTop.addWidget(self.groupbox_plot_SSC_fine_vertical_profile, 3) + self.verticalLayout_groupbox_plot_SSC_fine_profile_and_slider = QVBoxLayout() + self.horizontalLayoutTop.addLayout(self.verticalLayout_groupbox_plot_SSC_fine_profile_and_slider, 3) + + self.groupbox_plot_measured_vs_inverted_SSC_fine = QGroupBox() + # self.horizontalLayoutTop.addWidget(self.groupbox_plot_measured_vs_inverted_SSC_fine, 3) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine_and_combobox = QVBoxLayout() + self.horizontalLayoutTop.addLayout(self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine_and_combobox, 3) ### --- Layout of groupbox in the Bottom horizontal layout box - # Plot SSC 2D field | Plot SSC graph sample vs inversion / SSC vertical profile ===>>> SAND + # Plot SSC 2D field | SSC vertical profile | Plot SSC graph sample vs inversion ===>>> SAND self.groupbox_plot_SSC_sand = QGroupBox() - self.horizontalLayoutBottom.addWidget(self.groupbox_plot_SSC_sand, 7) + self.horizontalLayoutBottom.addWidget(self.groupbox_plot_SSC_sand, 6) + + self.groupbox_plot_SSC_sand_vertical_profile = QGroupBox() + self.horizontalLayoutBottom.addWidget(self.groupbox_plot_SSC_sand_vertical_profile, 3) + + self.groupbox_plot_measured_vs_inverted_SSC_sand = QGroupBox() + self.horizontalLayoutBottom.addWidget(self.groupbox_plot_measured_vs_inverted_SSC_sand, 3) - 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 SSC 2D Field FINE | - # ++++++++++++++++++++++++++++++++++++++ + # +++++++++++++++++++++++++++++++++++++++ + # | Group box SSC 2D Field FINE | + # +++++++++++++++++++++++++++++++++++++++ self.verticalLayout_groupbox_plot_SSC_fine = QVBoxLayout(self.groupbox_plot_SSC_fine) @@ -108,23 +132,91 @@ class AcousticInversionTab(QWidget): self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) - # +++++++++++++++++++++++++++++++++++++++++++++++++++++ - # | Group box SSC profile OR Ctot VS SSC FINE | - # +++++++++++++++++++++++++++++++++++++++++++++++++++++ + # +++++++++++++++++++++++++++++++++++++++++++++++ + # | Group box SSC fine vertical profile | + # +++++++++++++++++++++++++++++++++++++++++++++++ - self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine = QVBoxLayout(self.groupbox_plot_SSC_profile_and_Ctot_vs_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine_profile_and_slider.addWidget(self.groupbox_plot_SSC_fine_vertical_profile) - 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.verticalLayout_groupbox_plot_vertical_profile_fine = QVBoxLayout( + self.groupbox_plot_SSC_fine_vertical_profile) self.canvas_profile_fine = FigureCanvas() self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) - 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) + self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine) + self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine) + + self.horizontalLayout_slider_fine = QHBoxLayout() + # self.verticalLayout_groupbox_plot_vertical_profile_fine.addLayout(self.horizontalLayout_slider_fine) + self.verticalLayout_groupbox_plot_SSC_fine_profile_and_slider.addLayout(self.horizontalLayout_slider_fine) + + self.pushbutton_left_to_begin_fine = QPushButton() + self.pushbutton_left_to_begin_fine.setIcon(self.icon_triangle_left_to_begin) + self.horizontalLayout_slider_fine.addWidget(self.pushbutton_left_to_begin_fine) + + self.pushbutton_left_fine = QPushButton() + self.pushbutton_left_fine.setIcon(self.icon_triangle_left) + self.horizontalLayout_slider_fine.addWidget(self.pushbutton_left_fine) + + self.lineEdit_slider_fine = QLineEdit() + self.lineEdit_slider_fine.setText("1") + self.lineEdit_slider_fine.setFixedWidth(50) + self.horizontalLayout_slider_fine.addWidget(self.lineEdit_slider_fine) + + self.pushbutton_right_fine = QPushButton() + self.pushbutton_right_fine.setIcon(self.icon_triangle_right) + self.horizontalLayout_slider_fine.addWidget(self.pushbutton_right_fine) + + self.pushbutton_right_to_end_fine = QPushButton() + self.pushbutton_right_to_end_fine.setIcon(self.icon_triangle_right_to_end) + self.horizontalLayout_slider_fine.addWidget(self.pushbutton_right_to_end_fine) + + self.slider_fine = QSlider() + self.horizontalLayout_slider_fine.addWidget(self.slider_fine) + + self.slider_fine.setOrientation(Qt.Horizontal) + self.slider_fine.setCursor(Qt.OpenHandCursor) + self.slider_fine.setMinimum(1) + self.slider_fine.setMaximum(10) + self.slider_fine.setTickInterval(1) + self.slider_fine.setValue(1) + + # +++++++++++++++++++++++++++++++++++++++++++++++++++ + # | Group box Measured VS Inverted SSC Fine | + # +++++++++++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine_and_combobox.addWidget( + self.groupbox_plot_measured_vs_inverted_SSC_fine) + + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine = QVBoxLayout( + self.groupbox_plot_measured_vs_inverted_SSC_fine) + + self.canvas_inverted_vs_measured_SSC_fine = FigureCanvas() + self.toolbar_inverted_vs_measured_SSC_fine = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_fine, self) + + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.toolbar_inverted_vs_measured_SSC_fine) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.canvas_inverted_vs_measured_SSC_fine) + + self.horizontalLayout_combobox_fine_sample_choice = QHBoxLayout() + # self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addLayout( + # self.horizontalLayout_combobox_fine_sample_choice) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine_and_combobox.addLayout( + self.horizontalLayout_combobox_fine_sample_choice) + + self.label_fine_sample_choice = QLabel() + self.label_fine_sample_choice.setText("Fine sample choice : ") + self.horizontalLayout_combobox_fine_sample_choice.addWidget(self.label_fine_sample_choice) + + self.combobox_fine_sample_choice = CheckableComboBox() + self.horizontalLayout_combobox_fine_sample_choice.addWidget(self.combobox_fine_sample_choice) + + self.pushbutton_plot_fine_sample_choice = QPushButton() + self.pushbutton_plot_fine_sample_choice.setIcon(self.icon_update) + self.pushbutton_plot_fine_sample_choice.setMaximumWidth(50) + self.horizontalLayout_combobox_fine_sample_choice.addWidget(self.pushbutton_plot_fine_sample_choice) + + self.fine_sample_to_plot = [] # ===================================================== # BOTTOM HORIZONTAL BOX LAYOUT @@ -142,25 +234,78 @@ class AcousticInversionTab(QWidget): self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand) self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand) - # +++++++++++++++++++++++++++++++++++++++++++++++++++++ - # | Group box SSC profile OR Ctot VS SSC SAND | - # +++++++++++++++++++++++++++++++++++++++++++++++++++++ + # +++++++++++++++++++++++++++++++++++++++++++++++ + # | Group box SSC sand vertical profile | + # +++++++++++++++++++++++++++++++++++++++++++++++ - self.verticalLayout_groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand = QVBoxLayout( - self.groupbox_plot_SSC_profile_and_Ctot_vs_SSC_sand) - - 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"]) + self.verticalLayout_groupbox_plot_vertical_profile_sand = QVBoxLayout( + self.groupbox_plot_SSC_sand_vertical_profile) 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) + self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.toolbar_profile_sand) + self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.canvas_profile_sand) + + self.horizontalLayout_slider_sand = QHBoxLayout() + self.verticalLayout_groupbox_plot_vertical_profile_sand.addLayout(self.horizontalLayout_slider_sand) + + self.pushbutton_left_to_begin_sand = QPushButton() + self.pushbutton_left_to_begin_sand.setIcon(self.icon_triangle_left_to_begin) + self.horizontalLayout_slider_sand.addWidget(self.pushbutton_left_to_begin_sand) + + self.pushbutton_left_sand = QPushButton() + self.pushbutton_left_sand.setIcon(self.icon_triangle_left) + self.horizontalLayout_slider_sand.addWidget(self.pushbutton_left_sand) + + self.lineEdit_slider_sand = QLineEdit() + self.lineEdit_slider_sand.setText("1") + self.lineEdit_slider_sand.setFixedWidth(50) + self.horizontalLayout_slider_sand.addWidget(self.lineEdit_slider_sand) + + self.pushbutton_right_sand = QPushButton() + self.pushbutton_right_sand.setIcon(self.icon_triangle_right) + self.horizontalLayout_slider_sand.addWidget(self.pushbutton_right_sand) + + self.pushbutton_right_to_end_sand = QPushButton() + self.pushbutton_right_to_end_sand.setIcon(self.icon_triangle_right_to_end) + self.horizontalLayout_slider_sand.addWidget(self.pushbutton_right_to_end_sand) + + self.slider_sand = QSlider() + self.horizontalLayout_slider_sand.addWidget(self.slider_sand) + + self.slider_sand.setOrientation(Qt.Horizontal) + self.slider_sand.setCursor(Qt.OpenHandCursor) + self.slider_sand.setMinimum(1) + self.slider_sand.setMaximum(10) + self.slider_sand.setTickInterval(1) + self.slider_sand.setValue(1) + + # +++++++++++++++++++++++++++++++++++++++++++++++++++ + # | Group box Measured VS Inverted SSC Fine | + # +++++++++++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand = QVBoxLayout( + self.groupbox_plot_measured_vs_inverted_SSC_sand) + + self.canvas_inverted_vs_measured_SSC_sand = FigureCanvas() + self.toolbar_inverted_vs_measured_SSC_sand = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_sand, self) + + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addWidget( + self.toolbar_inverted_vs_measured_SSC_sand) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addWidget( + self.canvas_inverted_vs_measured_SSC_sand) + + self.horizontalLayout_combobox_sand_sample_choice = QHBoxLayout() + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addLayout( + self.horizontalLayout_combobox_sand_sample_choice) + + self.label_sand_sample_choice = QLabel() + self.label_sand_sample_choice.setText("Sand sample choice : ") + self.horizontalLayout_combobox_sand_sample_choice.addWidget(self.label_sand_sample_choice) + + self.combobox_sand_sample_choice = QComboBox() + self.horizontalLayout_combobox_sand_sample_choice.addWidget(self.combobox_sand_sample_choice) # ============================================================================================================== # ---------------------------------------- Connect signal of widget -------------------------------------------- @@ -170,6 +315,24 @@ class AcousticInversionTab(QWidget): self.pushbutton_run_inversion.clicked.connect(self.function_run_inversion) + self.pushbutton_left_to_begin_fine.clicked.connect(self.slider_profile_number_to_begin_fine) + self.pushbutton_left_fine.clicked.connect(self.slider_profile_number_to_left_fine) + self.pushbutton_right_fine.clicked.connect(self.slider_profile_number_to_right_fine) + self.pushbutton_right_to_end_fine.clicked.connect(self.slider_profile_number_to_end_fine) + self.lineEdit_slider_fine.returnPressed.connect(self.profile_number_on_lineEdit_fine) + self.slider_fine.valueChanged.connect(self.update_lineEdit_by_moving_slider_fine) + self.slider_fine.valueChanged.connect(self.update_plot_SSC_fine_vertical_profile) + + self.pushbutton_left_to_begin_sand.clicked.connect(self.slider_profile_number_to_begin_sand) + self.pushbutton_left_sand.clicked.connect(self.slider_profile_number_to_left_sand) + self.pushbutton_right_sand.clicked.connect(self.slider_profile_number_to_right_sand) + self.pushbutton_right_to_end_sand.clicked.connect(self.slider_profile_number_to_end_sand) + self.lineEdit_slider_sand.returnPressed.connect(self.profile_number_on_lineEdit_sand) + self.slider_sand.valueChanged.connect(self.update_lineEdit_by_moving_slider_sand) + + self.pushbutton_plot_fine_sample_choice.clicked.connect(self.plot_measured_vs_inverted_SSC_fine) + self.pushbutton_plot_fine_sample_choice.clicked.connect(self.update_plot_sample_position_on_concentration_field) + # ================================================================================================================== # ------------------------------------ Functions for Acoustic Inversion Tab ---------------------------------------- # ================================================================================================================== @@ -186,62 +349,74 @@ class AcousticInversionTab(QWidget): self.compute_VBI() self.compute_SSC_fine() self.compute_SSC_sand() + self.fill_combobox_fine_sample() self.plot_SSC_fine() self.plot_SSC_sand() + self.plot_SSC_fine_vertical_profile() + self.plot_measured_vs_inverted_SSC_fine() def compute_VBI(self): print("compute VBI") - print(stg.frequencies_for_calibration[0][0], stg.frequencies_for_calibration[1][0]) + print(stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()][0][0], + stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()][1][0]) + print(stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()]) 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.depth_2D[self.combobox_acoustic_data_choice.currentIndex()].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], + stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.VBI_cross_section( + freq1=stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()][0][0], + freq2=stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()][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]], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][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.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape) + # print(stg.VBI_cross_section.shape) + print(stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()][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]])) + print(np.full(shape=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape, + fill_value=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])) - stg.SSC_fine = self.inv_hc.SSC_fine( + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = 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], + r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + VBI=stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()], + freq=stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()][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]]) + alpha_w=np.full(shape=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape, + fill_value=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][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], + stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_sand( + VBI=stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()], + freq=stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()][1][0], X=stg.X_exponent, ks=stg.ks[1]) @@ -258,8 +433,8 @@ class AcousticInversionTab(QWidget): 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) + val_min = np.nanmin(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()]) + val_max = np.nanmax(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()]) print("ABS name ", stg.ABS_name) @@ -271,40 +446,90 @@ class AcousticInversionTab(QWidget): 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]) + # print("time cross section ", stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + # print("depth cross section ", stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + # print(stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][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.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequencies_for_calibration[1][1]], - stg.SSC_fine, + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()], 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.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], color='black', linewidth=1, linestyle="solid") + self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot( + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], + self.slider_fine.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape), + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + linestyle="solid", color='r', linewidth=2) + + print("o+o+o+o+o+o") + print(stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]) + print([i for i, _ in stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]]) + # print([stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], i] + # for i, _ in stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]]) + print("o+o+o+o+o+o") + + # self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot( + # [stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], i] + # for i, _ in stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]], + # [-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], j] + # for _, j in stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]], + # ls=" ", marker="o", ms=5, mec="k", mfc="k") + + self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot(stg.time_fine, stg.depth_fine, + ls=" ", marker="o", ms=5, mec="k", mfc="k") + + print(stg.time_fine) + print(stg.depth_fine) + print([f for _, f in stg.sample_fine]) + for i, j in stg.sample_fine: + self.pcm_SSC_fine_meas_vs_inv_text = self.axis_SSC_fine.text( + stg.time_fine[j], + stg.depth_fine[j], + i) + 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, + stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()], 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.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], color='black', linewidth=1, linestyle="solid") + self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot( + [stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], i] + for i, _ in stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]], + [-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], j] + for _, j in stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]], + ls=" ", marker="o", ms=5, mec="k", mfc="k") + 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) @@ -317,15 +542,422 @@ class AcousticInversionTab(QWidget): 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_fine_vertical_profile(self): + + if stg.filename_BS_noise_data != []: + + if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + self.slider_fine.setMaximum(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) + + self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.toolbar_profile_fine) + self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.canvas_profile_fine) + + self.figure_vertical_profile_SSC_fine, self.axis_vertical_profile_SSC_fine = plt.subplots( + nrows=1, ncols=1, layout="constrained") + + self.canvas_profile_fine = FigureCanvas(self.figure_vertical_profile_SSC_fine) + self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine) + + self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine) + self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine) + + if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot( + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_fine.value() -1], + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + linestyle="solid", linewidth=1, color="k") + + self.pcm_SSC_fine_vertical_line.set_data( + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], + self.slider_fine.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape), + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + self.figure_SSC_fine.canvas.draw_idle() + + self.axis_vertical_profile_SSC_fine.set_ylim( + [-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]), + -np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])]) + + else: + + self.axis_vertical_profile_SSC_fine.plot( + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_fine.value() -1], + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + linestyle="solid", linewidth=1, color="k") + + self.pcm_SSC_fine_vertical_line.set_data( + stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], self.slider_fine.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape), + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + self.figure_SSC_fine.canvas.draw_idle() + + self.axis_vertical_profile_SSC_fine.set_ylim( + [-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]), + -np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])]) + + # self.axis_SSC_fine.plot([], [], ) + + self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)") + self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)") + self.figure_vertical_profile_SSC_fine.canvas.draw_idle() + + def update_plot_SSC_fine_vertical_profile(self): + + if stg.filename_BS_noise_data != []: + + if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + self.plot_fine.set_data( + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, + self.slider_fine.value() - 1], + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + + self.pcm_SSC_fine_vertical_line.set_data( + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], + self.slider_fine.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape), + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + self.figure_SSC_fine.canvas.draw_idle() + + self.axis_vertical_profile_SSC_fine.set_ylim( + [-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]), + -np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])]) + + else: + + self.axis_vertical_profile_SSC_fine.set_data( + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, + self.slider_fine.value() - 1], + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + + self.pcm_SSC_fine_vertical_line.set_data( + stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], self.slider_fine.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape), + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + self.figure_SSC_fine.canvas.draw_idle() + + self.axis_vertical_profile_SSC_fine.set_ylim( + [-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]), + -np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])]) + + self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)") + self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)") + self.figure_vertical_profile_SSC_fine.canvas.draw_idle() + + def slider_profile_number_to_begin_fine(self): + self.slider_fine.setValue(int(self.slider_fine.minimum())) + self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + + def slider_profile_number_to_right_fine(self): + self.slider_fine.setValue(int(self.slider_fine.value()) + 1) + self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + + def slider_profile_number_to_left_fine(self): + self.slider_fine.setValue(int(self.slider_fine.value()) - 1) + self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + + def slider_profile_number_to_end_fine(self): + self.slider_fine.setValue(int(self.slider_fine.maximum())) + self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + + def profile_number_on_lineEdit_fine(self): + self.slider_fine.setValue(int(self.lineEdit_slider_fine.text())) + + def update_lineEdit_by_moving_slider_fine(self): + self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + + # --- Plot fine SSC : measured vs inverted --- + + def fill_combobox_fine_sample(self): + + print("stg.sample_fine ", stg.sample_fine) + self.combobox_fine_sample_choice.addItems([f for f, _ in stg.sample_fine]) + + # --- Get position (index, value) of sample in acoustic measurement space --- + if ((stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and + (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))): + + print(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + print(stg.depth_fine) + + for j in range(len(stg.time_fine)): + + (stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + append( + ( + np.where( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - stg.time_fine[j]) + == + np.nanmin(np.abs(stg.time_cross_section[ + self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - stg.time_fine[j])) + )[0][0], + np.where( + np.abs(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - (-stg.depth_fine[j])) + == + np.nanmin(np.abs(stg.depth_cross_section[ + self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - (-stg.depth_fine[j]))) + )[0][0] + ) + ) + ) + + print("0 stg.fine_sample_position ", stg.fine_sample_position) + + elif ((stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and + (stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))): + + for j in range(len(stg.time_fine)): + + (stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + append( + ( + np.where( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - stg.time_fine[j]) + == + np.nanmin(np.abs(stg.time_cross_section[ + self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - stg.time_fine[j])) + )[0][0], + np.where( + np.abs(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - (-stg.depth_fine[j])) + == + np.nanmin(np.abs(stg.depth[ + self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - (-stg.depth_fine[j]))) + )[0][0] + ) + ) + ) + + print("1 stg.fine_sample_position ", stg.fine_sample_position) + + elif ((stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and + (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))): + + for j in range(len(stg.time_fine)): + + (stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + append( + ( + np.where( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - stg.time_fine[j]) + == + np.nanmin(np.abs(stg.time[ + self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - stg.time_fine[j])) + )[0][0], + np.where( + np.abs(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - (-stg.depth_fine[j])) + == + np.nanmin(np.abs(stg.depth_cross_section[ + self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - (-stg.depth_fine[j]))) + )[0][0] + ) + ) + ) + + print("2 stg.fine_sample_position ", stg.fine_sample_position) + + elif ((stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and + (stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))): + + for j in range(len(stg.time_fine)): + + (stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + append( + ( + np.where( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - stg.time_fine[j]) + == + np.nanmin(np.abs(stg.time[ + self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - stg.time_fine[j])) + )[0][0], + np.where( + np.abs(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - (-stg.depth_fine[j])) + == + np.nanmin(np.abs(stg.depth[ + self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]] - (-stg.depth_fine[j]))) + )[0][0] + ) + ) + ) + + print("3 stg.fine_sample_position ", stg.fine_sample_position) + + def plot_measured_vs_inverted_SSC_fine(self): + + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.removeWidget(self.toolbar_inverted_vs_measured_SSC_fine) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.removeWidget(self.canvas_inverted_vs_measured_SSC_fine) + + self.figure_measured_vs_inverted_fine, self.axis_measured_vs_inverted_fine = ( + plt.subplots(nrows=1, ncols=1, layout="constrained")) + + self.canvas_inverted_vs_measured_SSC_fine = FigureCanvas(self.figure_measured_vs_inverted_fine) + self.toolbar_inverted_vs_measured_SSC_fine = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_fine, self) + + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.toolbar_inverted_vs_measured_SSC_fine) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.canvas_inverted_vs_measured_SSC_fine) + + print("self.combobox_fine_sample_choice.currentData() ", self.combobox_fine_sample_choice.currentData()) + print("self.combobox_fine_sample_choice.currentIndex() ", self.combobox_fine_sample_choice.currentIndex()) + + print("///////////////////////////////////////////////////") + self.fine_sample_to_plot = [int(f[1:]) - 1 for f in self.combobox_fine_sample_choice.currentData()] + print("self.fine_sample_to_plot ", self.fine_sample_to_plot) + + # for k in self.fine_sample_to_plot: + # print("stg.Ctot_fine[k] ", stg.Ctot_fine[k]) + # print(stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][1]) + # print(stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][0]) + # print(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][1], + # stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][0]]) + + if self.fine_sample_to_plot: + + self.axis_measured_vs_inverted_fine.plot( + [stg.Ctot_fine[k] for k in self.fine_sample_to_plot], + [stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][1], + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][0]] for k in self.fine_sample_to_plot], + ls=" ", marker='o', ms=5, mec='black', mfc="black" + ) + + self.axis_measured_vs_inverted_fine.plot( + [0, np.nanmax([np.nanmax([stg.Ctot_fine[c] for c in self.fine_sample_to_plot]), + np.nanmax([stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][1], + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][0]] + for i in self.fine_sample_to_plot]) ]) + 1], + [0, np.nanmax([np.nanmax([stg.Ctot_fine[c] for c in self.fine_sample_to_plot]), + np.nanmax([stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][1], + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][0]] + for i in self.fine_sample_to_plot])]) + 1], + ls="solid", linewidth=1, color="k" + ) + + # --- Display sample label on plot --- + for i in self.fine_sample_to_plot: + self.axis_measured_vs_inverted_fine.text( + stg.Ctot_fine[i], + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][1], + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][0]], + stg.sample_fine[i][0], + fontstyle="normal", fontweight="light", fontsize=10) + + else: + + self.axis_measured_vs_inverted_fine.plot( + [stg.Ctot_fine[k] for k in range(len(stg.sample_fine))], + [stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][1], + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][0]] for k in + range(len(stg.sample_fine))], + ls=" ", marker='o', ms=5, mec='black', mfc="black" + ) + + self.axis_measured_vs_inverted_fine.plot( + [0, np.nanmax([np.nanmax([stg.Ctot_fine[c] for c in range(len(stg.sample_fine))]), + np.nanmax([stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + stg.fine_sample_position[ + self.combobox_acoustic_data_choice.currentIndex()][i][1], + stg.fine_sample_position[ + self.combobox_acoustic_data_choice.currentIndex()][i][0]] + for i in range(len(stg.sample_fine))])]) + 1], + [0, np.nanmax([np.nanmax([stg.Ctot_fine[c] for c in range(len(stg.sample_fine))]), + np.nanmax([stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + stg.fine_sample_position[ + self.combobox_acoustic_data_choice.currentIndex()][i][1], + stg.fine_sample_position[ + self.combobox_acoustic_data_choice.currentIndex()][i][0]] + for i in range(len(stg.sample_fine))])]) + 1], + ls="solid", linewidth=1, color="k" + ) + + for j in range(len(stg.sample_fine)): + self.axis_measured_vs_inverted_fine.text( + stg.Ctot_fine[j], + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][j][1], + stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][j][0]], + stg.sample_fine[j][0], + fontstyle="normal", fontweight="light", fontsize=10) + + self.axis_measured_vs_inverted_fine.set_xlabel("Measured SSC fine (g/L)") + self.axis_measured_vs_inverted_fine.set_ylabel("Inverted SSC fine (g/L)") + + self.figure_measured_vs_inverted_fine.canvas.draw_idle() + + def update_plot_sample_position_on_concentration_field(self): + # --- Plot sample position on concentration field --- + # self.pcm_SSC_fine_meas_vs_inv.set_data( + # [stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], + # stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][0]] + # for i in self.fine_sample_to_plot], + # [-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1], + # stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()][j][1]] + # for j in self.fine_sample_to_plot] + # ) + + self.pcm_SSC_fine_meas_vs_inv.set_data([stg.time_fine[i] for i in self.fine_sample_to_plot], + [stg.depth_fine[j] for j in self.fine_sample_to_plot]) + self.figure_SSC_fine.canvas.draw_idle() + + for i in self.fine_sample_to_plot: + self.pcm_SSC_fine_meas_vs_inv_text.set_text(stg.sample_fine[i][0]) + self.pcm_SSC_fine_meas_vs_inv_text.set_position(stg.time_fine[i], stg.depth_fine[i]) + self.figure_SSC_fine.canvas.draw_idle() + def plot_SSC_sand(self): self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.toolbar_SSC_sand) @@ -346,29 +978,29 @@ class AcousticInversionTab(QWidget): 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.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][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') + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()], + cmap='rainbow', norm=LogNorm(vmin=1e-2, vmax=10), 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.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][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') + stg.time[self.combobox_acoustic_data_choice.currentIndex()][stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()], + cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=10), 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.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], color='black', linewidth=1, linestyle="solid") @@ -419,7 +1051,27 @@ class AcousticInversionTab(QWidget): self.figure_SSC_sand.supylabel("Depth (m)", fontsize=10) self.figure_SSC_sand.canvas.draw_idle() + def slider_profile_number_to_begin_sand(self): + self.slider_sand.setValue(int(self.slider_sand.minimum())) + self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + def slider_profile_number_to_right_sand(self): + self.slider_sand.setValue(int(self.slider_sand.value()) + 1) + self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + + def slider_profile_number_to_left_sand(self): + self.slider_sand.setValue(int(self.slider_sand.value()) - 1) + self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + + def slider_profile_number_to_end_sand(self): + self.slider_sand.setValue(int(self.slider_sand.maximum())) + self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + + def profile_number_on_lineEdit_sand(self): + self.slider_sand.setValue(int(self.lineEdit_slider_sand.text())) + + def update_lineEdit_by_moving_slider_sand(self): + self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) # -------------------------------------------------------------------------------------------------------------- @@ -806,1386 +1458,1373 @@ class AcousticInversionTab(QWidget): # # 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() - - # --- add items in combobox of samples (sand and vertical fine) to calibrate acoustic inversion method --- - - # samples_vertical_line = np.split(stg.samples, np.where(np.diff(stg.sample_time) != 0)[0]+1) - - # self.combobox_calibration_sand_sample.addItem(" ") - # for s in samples_vertical_line: - # self.combobox_calibration_sand_sample.addItem(" - ".join([i for i in s])) - - self.combobox_frequency.addItems(stg.freq_text) - - self.combobox_calibration_sand_sample.addItems(stg.samples) - # self.combobox_calibration_sand_sample.currentData.connect(self.update_plot_transect_with_sample_position) - - self.combobox_calibration_fine_sample.addItems(stg.samples) - # self.combobox_calibration_fine_sample.currentData.connect(self.update_plot_transect_with_sample_position) - - self.combobox_freq1.addItems(stg.freq_text) - self.combobox_freq2.addItems(stg.freq_text) - - - # for i in range(len(samples_vertical_line)): - # self.combobox_calibration_samples.setItemChecked(i, False) - - # --- add items in combobox of frequencies for VBI computation --- - # self.combobox_frequencies_VBI.addItem(" ") - # for k in combinations(stg.freq_text, 2): - # self.combobox_frequencies_VBI.addItem(k[0] + " - " + k[1]) - # print(k) - # for i in range(len(list(combinations(stg.freq_text, 2)))): - # self.combobox_frequencies_VBI.setItemChecked(i, False) - - # print(f"stg.fine_sediment_columns length : {len(stg.fine_sediment_columns)}") - # print(f"stg.fine_sediment_columns : {stg.fine_sediment_columns}") - # print(f"stg.frac_vol_fine.shape : {stg.frac_vol_fine.shape}") - # 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) - self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \ - plt.subplots(nrows=1, ncols=1, layout="constrained") - self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect) - self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.canvas_plot_sample_position_on_transect) - - if stg.BS_stream_bed.size == 0: - - val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) - if val_min == 0: - val_min = 1e-5 - - self.axis_plot_sample_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], - -stg.r[stg.freq_bottom_detection, :], - stg.BS_cross_section[stg.freq_bottom_detection, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - if stg.r_bottom.size != 0: - self.axis_plot_sample_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], - -stg.r_bottom, color='black', linewidth=1, linestyle="solid") - - else: - - val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) - if val_min == 0: - val_min = 1e-5 - - self.axis_plot_sample_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], - -stg.r[stg.freq_bottom_detection, :], - stg.BS_stream_bed[stg.freq_bottom_detection, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - if stg.r_bottom.size != 0: - self.axis_plot_sample_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, - color='black', linewidth=1, linestyle="solid") - - self.axis_plot_sample_position_on_transect.set_xticks([]) - self.axis_plot_sample_position_on_transect.set_yticks([]) - self.figure_plot_sample_position_on_transect.canvas.draw_idle() - - def update_plot_transect_with_sample_position(self): - - # --- List selected sand and fine samples --- - sand_position_list, fine_position_list = self.sample_choice() - - # --- Create canvas of Matplotlib figure --- - if stg.BS_raw_data.size == 0: - - self.verticalLayout_groupbox_plot_sample_position_on_transect.removeWidget( - self.canvas_plot_sample_position_on_transect) - self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \ - plt.subplots(nrows=1, ncols=1, layout="constrained") - self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect) - self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget( - self.canvas_plot_sample_position_on_transect) - - if sand_position_list: - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list], - stg.sample_depth[sand_position_list], - marker="o", s=20) - - if fine_position_list: - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list], - stg.sample_depth[fine_position_list], - marker="o", s=14) - - self.axis_plot_sample_position_on_transect.set_xticks([]) - self.axis_plot_sample_position_on_transect.set_yticks([]) - self.figure_plot_sample_position_on_transect.canvas.draw_idle() - - elif stg.BS_stream_bed.size == 0: - - val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) - if val_min == 0: - val_min = 1e-5 - - self.axis_plot_sample_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], - stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - if stg.r_bottom.size != 0: - self.axis_plot_sample_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, - color='black', linewidth=1, linestyle="solid") - - if sand_position_list: - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list], - stg.sample_depth[sand_position_list], - marker="o", s=20) - # markeredgecolor='k', markerfacecolor='none') - - if fine_position_list: - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list], - stg.sample_depth[fine_position_list], - marker="o", s=14) - # markeredgecolor='k', markerfacecolor='k') - - self.axis_plot_sample_position_on_transect.set_xticks([]) - self.axis_plot_sample_position_on_transect.set_yticks([]) - self.figure_plot_sample_position_on_transect.canvas.draw_idle() - - else: - - val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) - if val_min == 0: - val_min = 1e-5 - - self.axis_plot_sample_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], - stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - if stg.r_bottom.size != 0: - self.axis_plot_sample_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid") - - if sand_position_list: - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list], - stg.sample_depth[sand_position_list], - marker="o", s=20) - - if fine_position_list: - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list], - stg.sample_depth[fine_position_list], - marker="o", s=14) - - self.axis_plot_sample_position_on_transect.set_xticks([]) - self.axis_plot_sample_position_on_transect.set_yticks([]) - self.figure_plot_sample_position_on_transect.canvas.draw_idle() - - def sample_choice(self): - # --- List selected sand samples --- - sand_position_list = [int(s[1:])-1 for s in self.combobox_calibration_sand_sample.currentData()] - print(f"sand_position_list : {sand_position_list}") - # print(f"sand samples checked : {sand_samples_checked}") - - # --- List selected fine samples --- - fine_position_list = [int(s[1:])-1 for s in self.combobox_calibration_fine_sample.currentData()] - print(f"fine_position_list : {fine_position_list}") - # print(f"fine samples checked : {fine_samples_checked}") - return sand_position_list, fine_position_list - - def frequencies_pair_choice_to_compute_VBI(self): - freq_combination = list(combinations(stg.freq, 2)) - frequencies_position = [] - # for i in range(self.combobox_frequencies_VBI.count()): - # if self.combobox_frequencies_VBI.itemChecked(i): - # frequencies_position.append(i) - # elif (i in frequencies_position) and (not self.combobox_frequencies_VBI.itemChecked(i)): - # frequencies_position.remove(i) - frequencies_position.append(self.combobox_frequencies_VBI.currentIndex()) - print(f"frequencies_position : {frequencies_position}") - - if len(frequencies_position) != 0: - # print(frequencies_position) - # print(freq_combination[frequencies_position[0]][0], freq_combination[frequencies_position[0]][1]) - stg.frequencies_to_compute_VBI = ( - np.array([[int(np.where(stg.freq == freq_combination[frequencies_position[0]-1][0])[0][0]), - freq_combination[frequencies_position[0]-1][0]], - [int(np.where(stg.freq == freq_combination[frequencies_position[0]-1][1])[0][0]), - freq_combination[frequencies_position[0]-1][1]]])) - print(f"stg.frequencies_to_compute_VBI : {stg.frequencies_to_compute_VBI}") - - # --- add items in combobox of frequency for SSC computation --- - # for k in range(stg.frequencies_to_compute_VBI.shape[0]+1): - # self.combobox_frequency_SSC.removeItem(k) - self.combobox_frequency_SSC.clear() - for k in range(stg.frequencies_to_compute_VBI.shape[0]+1): - if k == 0: - self.combobox_frequency_SSC.addItem(" ") - else: - self.combobox_frequency_SSC.addItem(str(1e-6*stg.frequencies_to_compute_VBI[k-1, 1]) + " MHz") - # for i in range(stg.frequencies_to_compute_VBI.shape[0]): - # self.combobox_frequency_SSC.setItemChecked(i, False) - - print("frequencies to compute VBI", stg.frequencies_to_compute_VBI) - - def frequency_choice_to_compute_SSC(self): - print(self.combobox_frequency_SSC.currentText()) - print(self.combobox_frequency_SSC.currentIndex()) - # print(self.combobox_frequency_SSC.itemChecked(index)) - - - # if self.combobox_frequency_SSC.itemChecked(index): - # # itemChecked(index)): # currentIndex() == 0) or (self.combobox_frequency_SSC.currentIndex() == 1): - # print(self.combobox_frequency_SSC.currentText()) - # print(stg.freq_text) - # print(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText())) - - # stg.frequency_to_compute_SSC \ - # = np.array([int(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText())[0][0]), - # stg.freq[int(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText())[0][0])]]) - # - # print("stg.frequency_to_compute_SSC ", stg.frequency_to_compute_SSC) - - # def temperature_value(self): - # stg.temperature = self.spinbox_temperature.value() - # print(stg.temperature) - - def compute_sound_velocity(self): - stg.water_velocity = self.inv_hc.water_velocity(stg.temperature) - print("water velocity ", stg.water_velocity) - - # def compute_kt(self, freq_ind): + # def acoustic_inversion_method_choice(self): + # print("acoustic_inversion_method_choice") + # if self.combobox_acoustic_inversion_method_choice.currentIndex() == 1: # - # # stg.kt_corrected = self.inv_hc.kt_corrected(stg.r[int(stg.frequency_to_compute_SSC[0]), :], stg.water_velocity, - # # stg.gain_rx[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]], - # # stg.gain_tx[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]], - # # stg.kt[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]]) + # self.plot_transect_with_sample_position() # - # if stg.ABS_name == "Aquascat 1000R": - # kt_corrected = self.inv_hc.kt_corrected(stg.r[0, :], stg.water_velocity, - # stg.gain_rx[freq_ind], stg.gain_tx[freq_ind], stg.kt[0, freq_ind]) - # kt_corrected_2D = np.repeat(kt_corrected, stg.r.shape[1], axis=0) - # print("kt 2D ", kt_corrected_2D) - # print("kt 2D shape ", kt_corrected_2D.shape) - # kt_corrected_3D = np.zeros((kt_corrected_2D.shape[1], kt_corrected_2D.shape[0], stg.t.shape[1])) - # for k in range(kt_corrected_2D.shape[1]): - # kt_corrected_3D[k, :, :] = np.repeat(kt_corrected_2D, stg.t.shape[1], axis=1)[:, - # k * stg.t.shape[1]:(k + 1) * stg.t.shape[1]] - # print("kt 3D ", kt_corrected_3D) - # print("kt 3D shape ", kt_corrected_3D.shape) - # elif stg.ABS_name == "UB-SediFlow": - # stg.kt_corrected = np.array([[0.003, 0.006]]) - # print("kt ", stg.kt_corrected) - # print("kt shape ", stg.kt_corrected.shape) - # stg.kt_corrected_2D = np.array(np.repeat(stg.kt_corrected, stg.r.shape[1], axis=0)) - # print("kt 2D shape ", stg.kt_corrected_2D.shape) - # stg.kt_corrected_3D = np.zeros((stg.kt_corrected_2D.shape[1], stg.kt_corrected_2D.shape[0], stg.t.shape[1])) - # for k in range(stg.kt_corrected_2D.shape[1]): - # stg.kt_corrected_3D[k, :, :] = np.repeat(stg.kt_corrected_2D, stg.t.shape[1], axis=1)[:, - # k * stg.t.shape[1]:(k + 1) * stg.t.shape[1]] - # print("kt corrected 3D zeros shape ", stg.kt_corrected_3D.shape) + # # --- add items in combobox of samples (sand and vertical fine) to calibrate acoustic inversion method --- # - # print("kt ", stg.kt_corrected) - # # print("kt shape ", stg.kt_corrected.shape) + # # samples_vertical_line = np.split(stg.samples, np.where(np.diff(stg.sample_time) != 0)[0]+1) # - # # stg.kt_corrected_2D = np.repeat(stg.kt_corrected, stg.r.shape[1], axis=0) + # # self.combobox_calibration_sand_sample.addItem(" ") + # # for s in samples_vertical_line: + # # self.combobox_calibration_sand_sample.addItem(" - ".join([i for i in s])) # - # # stg.kt_corrected_3D = np.zeros((stg.kt_corrected_2D.shape[1], stg.kt_corrected_2D.shape[0], stg.t.shape[1])) - # # print("stg.t.shape ", stg.t.shape) - # # print("kt corrected 3D zeros shape ", stg.kt_corrected_3D.shape) - # # for k in range(stg.kt_corrected_2D.shape[1]): - # # stg.kt_corrected_3D[k, :, :] = np.repeat(stg.kt_corrected_2D, stg.t.shape[1], axis=1)[:, k*stg.t.shape[1]:(k+1)*stg.t.shape[1]] + # self.combobox_frequency.addItems(stg.freq_text) # - # # print("kt 2D", np.repeat(stg.kt_corrected[:, :, np.newaxis], stg.t.shape[0], axis=2)) - - def compute_J(self, freq_ind, kt): - if stg.ABS_name == "Aquascat 1000R": - print(f"stg.BS_stream_bed.shape : {stg.BS_stream_bed.shape}") - - if stg.BS_stream_bed.size != 0: - - if stg.BS_stream_bed_pre_process_SNR.size != 0: - print("1/ stg.BS_stream_bed_pre_process_SNR") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_stream_bed_pre_process_SNR[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_SNR.shape[2]], - kt[freq_ind, :, :])) - - elif stg.BS_stream_bed_pre_process_average.size != 0: - print("2/ stg.BS_stream_bed_pre_process_average") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_stream_bed_pre_process_average[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_average.shape[2]], - kt[freq_ind, :, :])) - - else: - print("3/ stg.BS_stream_bed") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_stream_bed[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_stream_bed.shape[2]], - kt[freq_ind, :, :])) - - elif stg.BS_cross_section.size != 0: - - if stg.BS_cross_section_pre_process_SNR.size != 0: - print("1/ stg.BS_cross_section_pre_process_SNR") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_cross_section_pre_process_SNR[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_cross_section_pre_process_SNR.shape[2]], - kt[freq_ind, :, :])) - - elif stg.BS_cross_section_pre_process_average.size != 0: - print("2/ stg.BS_cross_section_pre_process_average") - stg.J_cross_section = ( - self.inv_hc.j_cross_section(stg.BS_cross_section_pre_process_average[freq_ind, :, :], - stg.r_2D[0, :, :stg.BS_cross_section_pre_process_average.shape[2]], - kt[freq_ind, :, :])) - - else: - print("3/ stg.BS_cross_section") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_cross_section[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_cross_section.shape[2]], - kt[freq_ind, :, :])) - - elif stg.ABS_name == "UB-SediFlow": - - if stg.BS_stream_bed.size != 0: - - if stg.BS_stream_bed_pre_process_SNR.size != 0: - print("1/ stg.BS_stream_bed_pre_process_SNR") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_stream_bed_pre_process_SNR[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_SNR.shape[2]], - kt[freq_ind, :, :])) - - elif stg.BS_stream_bed_pre_process_average.size != 0: - print("2/ stg.BS_stream_bed_pre_process_average") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_stream_bed_pre_process_average[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_average.shape[2]], - kt[freq_ind, :, :])) - - - - else: - print("3/ stg.BS_stream_bed") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_stream_bed[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_stream_bed.shape[2]], - kt[freq_ind, :, :])) - - elif stg.BS_cross_section.size != 0: - - if stg.BS_cross_section_pre_process_SNR.size != 0: - print("2/ stg.BS_cross_section_pre_process_SNR") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_cross_section_pre_process_SNR[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_cross_section_pre_process_SNR.shape[2]], - kt[freq_ind, :, :])) - - if stg.BS_cross_section_pre_process_average.size != 0: - print("1/ stg.BS_cross_section_pre_process_average") - stg.J_cross_section = ( - self.inv_hc.j_cross_section(stg.BS_cross_section_pre_process_average[freq_ind, :, :], - stg.r_2D[freq_ind, :, - :stg.BS_cross_section_pre_process_average.shape[2]], - kt[freq_ind, :, :])) - - - - else: - print("3/ stg.BS_cross_section") - stg.J_cross_section = ( - self.inv_hc.j_cross_section( - stg.BS_cross_section[freq_ind, :, :], - stg.r_2D[freq_ind, :, :stg.BS_cross_section.shape[2]], - kt[freq_ind, :, :])) - - - - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_cross_section_pre_process_average[ - # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], - # :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_cross_section_pre_process_average.shape[2]], - # stg.kt_corrected_3D)) - - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_cross_section_pre_process_SNR[ - # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], - # :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, - # :stg.BS_cross_section_pre_process_SNR.shape[2]], - # stg.kt_corrected_3D)) - - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_cross_section[ - # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], - # :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, - # :stg.BS_cross_section.shape[2]], - # stg.kt_corrected_3D)) - - # stg.J_stream_bed = ( - # self.inv_hc.j_cross_section( - # stg.BS_stream_bed_pre_process_average[ - # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], - # :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_stream_bed_pre_process_average.shape[2]], - # stg.kt_corrected_3D)) - - - # stg.J_stream_bed = ( - # self.inv_hc.j_cross_section( - # stg.BS_stream_bed_pre_process_SNR[ - # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], - # :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_stream_bed_pre_process_SNR.shape[2]], - # stg.kt_corrected_3D)) - - # stg.J_stream_bed = ( - # self.inv_hc.j_cross_section( - # stg.BS_stream_bed[ - # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], - # :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, - # :stg.BS_stream_bed.shape[2]], - # stg.kt_corrected_3D)) - - # elif (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0): - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_data_section[[int(stg.frequencies_to_compute_VBI[0, 0]), - # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section.shape[2]], stg.kt_corrected_3D)) - # elif (stg.BS_data_section_averaged.size != 0) and (stg.BS_data_section_SNR_filter.size == 0): - # print("Je suis dans ce J") - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_data_section_averaged[[0, 2], :, :], - # stg.r_2D[[0, 2], :, :stg.BS_data_section_averaged.shape[2]], - # stg.kt_corrected_3D[[0, 1], :, :])) - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_data_section_averaged[[int(stg.frequencies_to_compute_VBI[0, 0]), - # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_averaged.shape[2]], stg.kt_corrected_3D)) - # else: - # print("stg.r_2D.shape ", stg.r_2D.shape) - # print("stg.kt_corrected_3D.shape ", stg.kt_corrected_3D.shape) - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_data_section_SNR_filter[[int(stg.frequencies_to_compute_VBI[0, 0]), - # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_SNR_filter.shape[2]], stg.kt_corrected_3D)) - # - # print("J ", stg.J_cross_section) - # print("J sahpe ", stg.J_cross_section.shape) - - # if stg.BS_data_section.size == 0: - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_data[ - # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], - # :, :], stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data.shape[2]], - # stg.kt_corrected_3D)) - # elif (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0): - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_data_section[[int(stg.frequencies_to_compute_VBI[0, 0]), - # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], - # np.array([stg.r_2D[0, :, :stg.BS_data_section.shape[2]]]), - # stg.kt_corrected_3D)) - # elif (stg.BS_data_section_averaged.size != 0) and (stg.BS_data_section_SNR_filter.size == 0): - # print("Je suis dans ce J") - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_data_section_averaged[[0, 2], :, :], - # stg.r_2D[[0, 2], :, :stg.BS_data_section_averaged.shape[2]], - # stg.kt_corrected_3D[[0, 1], :, :])) - # # stg.J_cross_section = ( - # # self.inv_hc.j_cross_section( - # # stg.BS_data_section_averaged[[int(stg.frequencies_to_compute_VBI[0, 0]), - # # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], - # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_averaged.shape[2]], stg.kt_corrected_3D)) - # else: - # print("stg.r_2D.shape ", stg.r_2D.shape) - # print("stg.kt_corrected_3D.shape ", stg.kt_corrected_3D.shape) - # stg.J_cross_section = ( - # self.inv_hc.j_cross_section( - # stg.BS_data_section_SNR_filter[[int(stg.frequencies_to_compute_VBI[0, 0]), - # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_SNR_filter.shape[2]], - # stg.kt_corrected_3D)) - # - # print("J ", stg.J_cross_section) - # print("J sahpe ", stg.J_cross_section.shape) - - return stg.J_cross_section - - # def compute_alpha_s(self, freq, freq_ind): - # stg.sv = self.compute_sv(freq) - # j_cross_section = self.compute_J(freq_ind) - # stg.alpha_s = np.log(stg.sv / j_cross_section) / (4 * stg.sample_depth[10]) - stg.water_attenuation - # return - - # def compute_zeta(self): - # stg.zeta_freq1 = self.inv_hc.zeta(0, 2) - # stg.zeta_freq2 = self.inv_hc.zeta() - # # stg.zeta = self.inv_hc.zeta(int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])) - # print("zeta ", stg.zeta) - - # def compute_X(self): - # stg.X_exponent = self.inv_hc.X_exponent(2) #self.inv_hc.X_exponent(self.combobox_frequencies_VBI.currentIndex()) - # print("X ", stg.X_exponent) - - # def compute_VBI(self): - # stg.VBI_cross_section = self.inv_hc.VBI_cross_section(3e5, - # 1e6, - # stg.zeta[0], - # # zeta is already limited to the frequencies pairs so that we just need to select indices 0 and 1 - # stg.zeta[1], - # stg.J_cross_section[0, :, :], - # stg.J_cross_section[1, :, :], - # stg.r_2D[0, :, :stg.t.shape[1]], - # stg.water_attenuation[0], - # stg.water_attenuation[1], - # stg.X_exponent) - - # stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.frequencies_to_compute_VBI[0, 1], stg.frequencies_to_compute_VBI[1, 1], - # stg.zeta[0], # zeta is already limited to the frequencies pairs so that we just need to select indices 0 and 1 - # stg.zeta[1], - # stg.J_cross_section[0, :, :], - # stg.J_cross_section[1, :, :], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.t.shape[1]], - # stg.water_attenuation[0], - # stg.water_attenuation[1], - # stg.X_exponent) - # print("VBI shape ", stg.VBI_cross_section.shape) - # print(int(self.combobox_frequency_SSC.currentIndex())) - # print(stg.zeta[int(self.combobox_frequency_SSC.currentIndex())]) - - def range_cells_function(self): - """ Computing the real cell size, that depends on the temperature """ - # defaut Aquascat cell size - aquascat_cell_size = stg.r[0, 1] - stg.r[0, 0] - # Pulse duration - tau = aquascat_cell_size * 2 / 1500 # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat - # Sound speed - cel = self.inv_hc.water_velocity(self.spinbox_temperature.value()) - # Real cell size - real_cell_size = cel * tau / 2 # voir fig 2.9 - - # Converting to real cell profile - real_r = np.zeros((stg.freq.shape[0], stg.r.shape[1])) - for i in range(stg.freq.shape[0]): - real_r[i, :] = stg.r[i, :] / aquascat_cell_size * real_cell_size # (/ 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 - - # R with right shape (numpy array) - R_real = real_r # np.repeat(real_r, len(stg.freq), axis=1) - print(f"R_real = {R_real.shape}") - - return R_real - - def compute_acoustic_inversion_method_high_concentration(self): - - # --- List selected sand and fine samples --- - sand_position_list, fine_position_list = self.sample_choice() - - if stg.ABS_name == "Aquascat 1000R": - - freq1 = int(self.combobox_freq1.currentIndex()) # 0 = 300kHz et 1 = 500kHz - freq2 = int(self.combobox_freq2.currentIndex()) # 2 = 1MHz - print(f"freq1 = {freq1}, freq2 = {freq2}") - - stg.water_velocity = self.inv_hc.water_velocity(stg.temperature) - - alpha_w_freq1, alpha_w_freq2 = (self.inv_hc.water_attenuation(freq=stg.freq[freq1], T=stg.temperature), - self.inv_hc.water_attenuation(freq=stg.freq[freq2], T=stg.temperature)) - print(f"alpha_w_freq1 = {alpha_w_freq1}, alpha_w_freq2 = {alpha_w_freq2}") - - self.compute_sound_velocity() - - # print("ks value : ", self.inv_hc.ks(a_s=stg.sand_sediment_columns[5:], rho_s=2500, freq=stg.freq[0], pdf=stg.frac_vol_sand[2, :])) - - # ks_freq1, ks_freq2 = ( - # self.inv_hc.ks(num_sample=2, freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[2, :]), - # self.inv_hc.ks(num_sample=2, freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[2, :])) - ks_freq1, ks_freq2 = ( - self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :]), - self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :])) - # 6 = V11 , 10 = V12 sur le notebook d'Adrien - # ks_freq1, ks_freq2 = self.inv_hc.ks()[0], self.inv_hc.ks()[2] - print(f"ks_freq1 = {ks_freq1}, ks_freq2 = {ks_freq2}") - - # f = self.inv_hc.form_factor_function_MoateThorne2012(np.log(np.logspace(-10, -2, 3000)), stg.freq[2]) - # fig, ax = plt.subplots(nrows=1, ncols=1) - # ax.plot(list(range(len(np.log(np.logspace(-10, -2, 3000))))), f, color="k", ls="solid") - # plt.show() - - # sv_freq1, sv_freq2 = ( - # self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[2]), - # self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[2])) - sv_freq1, sv_freq2 = ( - self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[sand_position_list[0]]), - self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[sand_position_list[0]])) - print(f"sv_freq1 = {sv_freq1}, sv_freq2 = {sv_freq2}") - - X_exponent = self.inv_hc.X_exponent(freq1=stg.freq[freq1], freq2=stg.freq[freq2], sv_freq1=sv_freq1, sv_freq2=sv_freq2) - # X_exponent = self.inv_hc.X_exponent(ind=2) - print(f"X_exponent = {X_exponent}") - - stg.kt = np.array([[0.04], [0.01838], [0.03267], [0.01376]]) - kt = np.array([]) - for i, v in enumerate(stg.kt): - kt = np.append(kt, self.inv_hc.kt_corrected(r=stg.r[i, :], - water_velocity=stg.water_velocity, - RxGain=stg.gain_rx[i], - TxGain=stg.gain_tx[i], - kt_ref=stg.kt[i])) - kt = np.reshape(kt, (len(kt), 1)) - print(f"kt = {kt}") - kt2D = np.repeat(np.array(kt), stg.r.shape[1], axis=1) - print(f"kt2D.shape = {kt2D.shape}") - # print(f"kt2D = {kt2D}") - kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2) - print(f"kt3D.shape = {kt3D.shape}") - # print(f"kt3D = {kt3D}") - - # kt_freq1, kt_freq2 = ( - # self.inv_hc.kt_corrected(r=stg.r[0, :], water_velocity=stg.water_velocity, RxGain=stg.gain_rx[0], - # TxGain=stg.gain_tx[0], kt_ref=stg.kt[0]), - # self.inv_hc.kt_corrected(r=stg.r[2, :], water_velocity=stg.water_velocity, RxGain=stg.gain_rx[2], - # TxGain=stg.gain_tx[2], kt_ref=stg.kt[2])) - # print(f"kt_freq1 = {kt_freq1}, kt_freq2 = {kt_freq2}") - # kt2D_freq1 = np.full((stg.r.shape[1], stg.t.shape[1]), kt_freq1) - # kt2D_freq2 = np.full((stg.r.shape[1], stg.t.shape[1]), kt_freq2) - # print(f"kt2D_freq1 = {kt2D_freq1.shape}") - # print(f"kt2D_freq2 = {kt2D_freq2.shape}") - # kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2) - # print(f"kt_3D = {kt3D.shape}") - # print(f"kt_3D = {kt3D}") - - # kt_freq1, kt_freq2 = ( - # np.full((stg.r.shape[1], stg.t.shape[1]), stg.kt[0]), - # np.full((stg.r.shape[1], stg.t.shape[1]), stg.kt[2])) - # print(f"kt_freq1 = {kt_freq1.shape}, kt_freq2 = {kt_freq2.shape}") - - J_freq1, J_freq2 = self.compute_J(freq_ind=freq1, kt=kt3D), self.compute_J(freq_ind=freq2, kt=kt3D) - print(f"J_freq1 = {J_freq1.shape}, J_freq2 = {J_freq2.shape}") - - # fig, ax = plt.subplots(nrows=1, ncols=1) - # pcm = ax.pcolormesh(stg.t[0, :], stg.r[0, :], J_freq2, cmap='rainbow', shading='gouraud') - # fig.colorbar(pcm, ax=ax, shrink=1, location='right') - # plt.show() - - # print("***************************") - # print(sv_freq1.shape) - # print(J_freq1.shape) - # print(np.repeat(stg.r[0, :][:, np.newaxis], stg.t.shape[1], axis=1).shape) - # print(np.full((stg.r.shape[1], stg.t.shape[1]), alpha_w_freq1).shape) - # print("***************************") - - r_sample_ind = [] - t_sample_ind = [] - for i in range(len(stg.sample_depth[fine_position_list])): #:3 - # for i in range(len(stg.sample_depth[:3])): #:3 - # print(-stg.sample_depth[i]) - # print(-stg.sample_time[i]) - r_sample_ind.append(np.where(np.abs(stg.r[0, :] - (-stg.sample_depth[i])) == - np.nanmin(np.abs(stg.r[0, :] - (-stg.sample_depth[i]))))) - # print(np.abs(stg.t[0, :] - (-stg.sample_time[i]))) - t_sample_ind.append(np.where(np.abs(stg.t[0, :] - (stg.sample_time[i])) == - np.nanmin(np.abs(stg.t[0, :] - (stg.sample_time[i]))))) - print(f"r_sample_ind = {r_sample_ind}") - print(f"t_sample_ind = {t_sample_ind}") - # print("J_freq1[r_sample_ind[1][0], t_sample_ind[1][0]] ", J_freq1[r_sample_ind[1][0], t_sample_ind[1][0]]) - - # ind_r_min = int(ind_X_min_around_sample[p, k]) - # print(f"ind_r_min = {ind_r_min}") - # ind_r_max = int(ind_X_max_around_sample[p, k]) - # print(f"ind_r_max = {ind_r_max}") - # ind_t_min = int(ind_r_min_around_sample[p, k]) - # print(f"ind_t_min = {ind_t_min}") - # ind_t_max = int(ind_r_max_around_sample[p, k]) - # print(f"ind_t_max = {ind_t_max}") - - # print(f"stg.BS freq1 = {stg.BS_stream_bed_pre_process_average[freq1, r_sample_ind[-1], t_sample_ind[-1]]}") - # print(f"stg.BS freq2 = {stg.BS_stream_bed_pre_process_average[freq2, r_sample_ind[-1], t_sample_ind[-1]]}") - # - # print(f"J_freq1[r_sample_ind[-1], t_sample_ind[-1]] {J_freq1[r_sample_ind[-1], t_sample_ind[-1]]}") - # print(f"J_freq2[r_sample_ind[-1], t_sample_ind[-1]] {J_freq2[r_sample_ind[-1], t_sample_ind[-1]]}") - # - # print(f"stg.r[0, r_sample_ind[-1]] {stg.r[2, r_sample_ind[-1]]}") - - - alpha_s_freq1, alpha_s_freq2 = ( - self.inv_hc.alpha_s(sv=sv_freq1, j_cross_section=J_freq1[r_sample_ind[-1], t_sample_ind[-1]], depth=stg.r[freq1, r_sample_ind[-1]], alpha_w=alpha_w_freq1), - self.inv_hc.alpha_s(sv=sv_freq2, j_cross_section=J_freq2[r_sample_ind[-1], t_sample_ind[-1]], depth=stg.r[freq2, r_sample_ind[-1]], alpha_w=alpha_w_freq2)) - print(f"alpha_s_freq1 = {alpha_s_freq1}, alpha_s_freq2 = {alpha_s_freq2}") - - # range_lin_interp, M_profile_fine = self.inv_hc.M_profile_SCC_fine_interpolated( - # sample_depth=-stg.sample_depth[:3], #:3 - # M_profile=stg.Ctot_fine[:3], #:3 - # range_cells=stg.r[0, :], - # r_bottom=stg.r_bottom[t_sample_ind[0][0]]) - 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]] 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}") - - M_profile_fine = M_profile_fine[:len(range_lin_interp)] - print(f"M_profile_fine : {M_profile_fine}") - - - # print("----------------------") - # print(f"r_sample_ind[-1][0] = {r_sample_ind[-1][0][0]}") - # print(f"M_profile_fine[:r_sample_ind[-1][0]] = ", M_profile_fine[:r_sample_ind[-1][0][0]]) - # print(f"stg.r[0, r_sample_ind[-1][0]] = ", stg.r[0, r_sample_ind[-1][0][0]]) - # print("----------------------") - - zeta_freq1, zeta_freq2 = (self.inv_hc.zeta(alpha_s=alpha_s_freq1, r=stg.r[freq1, :], M_profile_fine=M_profile_fine), - self.inv_hc.zeta(alpha_s=alpha_s_freq2, r=stg.r[freq2, :], M_profile_fine=M_profile_fine)) - # zeta_freq1, zeta_freq2 = ( - # self.inv_hc.zeta(r=stg.r[0, :r_sample_ind[-1][0][0]], M_profile_fine=M_profile_fine[:r_sample_ind[-1][0][0]]), - # self.inv_hc.zeta(r=stg.r[0, :r_sample_ind[-1][0][0]], M_profile_fine=M_profile_fine[:r_sample_ind[-1][0][0]])) - print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}") - # plt.figure() - # plt.plot(stg.r[0, :], Mprofile, 'b.', -stg.sample_depth[:3], stg.Ctot_fine[:3], 'ko') - # plt.show() - - # --- Fill spinboxes with values of parameters --- - self.spinbox_ks_freq1.setValue(ks_freq1) - self.spinbox_ks_freq2.setValue(ks_freq2) - self.spinbox_sv_freq1.setValue(sv_freq1) - self.spinbox_sv_freq2.setValue(sv_freq2) - self.spinbox_X.setValue(X_exponent) - self.spinbox_alphas_freq1.setValue(alpha_s_freq1) - self.spinbox_alphas_freq2.setValue(alpha_s_freq2) - self.spinbox_zeta_freq1.setValue(zeta_freq1) - self.spinbox_zeta_freq2.setValue(zeta_freq2) - - # fig, ax = plt.subplots(nrows=2, ncols=1) - # pcm1 = ax[0].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq1, - # cmap='rainbow', vmin=0, vmax=1e-5, shading='gouraud') - # cbar1 = fig.colorbar(pcm1, ax=ax[0], shrink=1, location='right') - # cbar1.set_label(label='J (/m', rotation=270, labelpad=15) - # pcm2 = ax[1].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq2, - # cmap='rainbow', vmin=0, vmax=1e-4, shading='gouraud') - # cbar2 = fig.colorbar(pcm2, ax=ax[1], shrink=1, location='right') - # cbar2.set_label(label='J (/m', rotation=270, labelpad=15) - # fig.supxlabel("Time (sec)", fontsize=10) - # fig.supylabel("Depth (m)", fontsize=10) - # plt.show() - - stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.freq[freq1], stg.freq[freq2], - zeta_freq1, zeta_freq2, - J_freq1, J_freq2, - stg.r_2D[freq1, :, :stg.t.shape[1]], - alpha_w_freq1, alpha_w_freq2, - X_exponent) - - stg.SSC_fine = self.inv_hc.SSC_fine(zeta_freq2, stg.r_2D[freq2, :, :stg.t.shape[1]], - stg.VBI_cross_section, stg.freq[freq2], X_exponent, J_freq2, - np.full(shape=(stg.r.shape[1], stg.t.shape[1]), fill_value=alpha_w_freq2)) - - stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section, stg.freq[freq2], X_exponent, ks_freq2) - - elif stg.ABS_name == "UB-SediFlow": - - freq1 = int(self.combobox_freq1.currentIndex()) # 0 = 500kHz - freq2 = int(self.combobox_freq2.currentIndex()) # 1 = 1MHz - - stg.water_velocity = self.inv_hc.water_velocity(stg.temperature) - - alpha_w_freq1, alpha_w_freq2 = (self.inv_hc.water_attenuation(freq=stg.freq[freq1], T=stg.temperature), - self.inv_hc.water_attenuation(freq=stg.freq[freq2], T=stg.temperature)) - print(f"alpha_w_freq1 = {alpha_w_freq1}, alpha_w_freq2 = {alpha_w_freq2}") - - self.compute_sound_velocity() - - # ks_freq1, ks_freq2 = 0.11373812635175432, 0.35705575378038723 - # ks_freq1, ks_freq2 = (self.inv_hc.form_factor_function_MoateThorne2012(a=100e-6, freq=stg.freq[freq1])/np.sqrt(2500*100e-6), - # self.inv_hc.form_factor_function_MoateThorne2012(a=100e-6, freq=stg.freq[freq2])/np.sqrt(2500*100e-6)) - - ks_freq1, ks_freq2 = ( - self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :]), - self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :])) - # ks_freq1 = 0.05261498026985425 - # ks_freq2 = 0.19303997854869764 - print(f"ks_freq1 = {ks_freq1}, ks_freq2 = {ks_freq2}") - - # Fine sediments 19/05/2021 15h11 - 15h42 (locale) = 13h10 - 13h42 (UTC) --> 6 samples - # 52 to 428 / fixed at 234 - # 14h10 = position 766 - # Sand sediments 20/05/2021 12h04 - 12h20 (locale) = 10h04 - 10h20 (UTC) --> 2 samples - # 777 to 972 / fixed at 777 - - sv_freq1, sv_freq2 = ( - self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[sand_position_list[0]]), - self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[sand_position_list[0]])) - # sv_freq1 = 0.0004956686799986783 - # sv_freq2 = 0.006672171109602389 - print(f"sv_freq1 = {sv_freq1}, sv_freq2 = {sv_freq2}") - - X_exponent = self.inv_hc.X_exponent(freq1=stg.freq[freq1], freq2=stg.freq[freq2], - sv_freq1=sv_freq1, sv_freq2=sv_freq2) - # X_exponent = 3.750708280862506 - print(f"X_exponent = {X_exponent}") - - # stg.kt = np.array([[1.38e-3], [6.02e-4]]) # Values of kt for 500kHz and 1MHz - stg.kt = np.array([[0.5], [0.5]]) - - kt = stg.kt - # kt = np.array([]) - # for i, v in enumerate(stg.kt): - # kt = np.append(kt, self.inv_hc.kt_corrected(r=stg.r[i, :], - # water_velocity=stg.water_velocity, - # RxGain=0, - # TxGain=0, - # kt_ref=stg.kt[i])) - # kt = np.reshape(kt, (len(kt), 1)) - print(f"kt = {kt}, kt.shape = {kt.shape}") - kt2D = np.repeat(np.array(kt), stg.r.shape[1], axis=1) - print(f"kt2D.shape = {kt2D.shape}") - # print(f"kt2D = {kt2D}") - kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2) - print(f"kt3D.shape = {kt3D.shape}") - - J_freq1, J_freq2 = self.compute_J(freq_ind=freq1, kt=kt3D), self.compute_J(freq_ind=freq2, kt=kt3D) - print(f"J_freq1 = {J_freq1.shape}, J_freq2 = {J_freq2.shape}") - - r_sample_ind = [] - t_sample_ind = [] - for i in range(len(stg.sample_depth[fine_position_list])): - # print(-stg.sample_depth[i]) - # print(-stg.sample_time[i]) - r_sample_ind.append(np.where(np.abs(stg.r[freq1, :] - (-stg.sample_depth[i])) == - np.nanmin(np.abs(stg.r[freq1, :] - (-stg.sample_depth[i]))))) - # print(np.abs(stg.t[0, :] - (-stg.sample_time[i]))) - t_sample_ind.append(np.where(np.abs(stg.t[freq1, :] - (stg.sample_time[i])) == - np.nanmin(np.abs(stg.t[freq1, :] - (stg.sample_time[i]))))) - print(f"r_sample_ind = {r_sample_ind}") - print(f"t_sample_ind = {t_sample_ind}") - - print(f"stg.BS freq1 = {stg.BS_cross_section[freq1, r_sample_ind[-1], t_sample_ind[-1]]}") - print(f"stg.BS freq2 = {stg.BS_cross_section[freq2, r_sample_ind[-1], t_sample_ind[-1]]}") - - print(f"J_freq1[r_sample_ind[-1], t_sample_ind[-1]] : {J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]}") - # print(f"J_freq1[r_sample_ind[-1]+-n, t_sample_ind[-1]+-n] : {J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]:t_sample_ind[-1][0][0]].mean(axis=0)}") - - # delta_t = 0 - alpha_s_freq1, alpha_s_freq2 = ( - self.inv_hc.alpha_s(sv=sv_freq1, - j_cross_section=np.mean(J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]), - depth=stg.r[freq1, r_sample_ind[-1][0][0]], alpha_w=alpha_w_freq1), - self.inv_hc.alpha_s(sv=sv_freq2, - j_cross_section=np.mean(J_freq2[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]), - # j_cross_section=J_freq2[r_sample_ind[-1], t_sample_ind[-1]], - depth=stg.r[freq2, r_sample_ind[-1][0][0]], alpha_w=alpha_w_freq2)) - - # avec J (alpha_w = 0.03578217234512747) - # alpha_s_freq1 = -0.12087339 - # alpha_s_freq2 = -0.01437704 - - # avec log(J) - # alpha_s_freq1 = -1.91967628 - # alpha_s_freq2 = -1.87942544 - - # --- Calculation of alpha_s with FCB slope --- - - # R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[1], axis=2) - # water_attenuation = np.full((2, stg.r.shape[1], stg.t.shape[1]), 1) - # water_attenuation[0, :, :] = alpha_w_freq1*water_attenuation[0, :, :] - # water_attenuation[1, :, :] = alpha_w_freq2*water_attenuation[1, :, :] - # if stg.BS_stream_bed.size == 0: - # stg.FCB = (np.log(stg.BS_cross_section[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) + - # 2 * water_attenuation * R_real[[freq1, freq2], :, :]) - # elif (stg.BS_stream_bed_pre_process_average.size == 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0): - # stg.FCB = (np.log(stg.BS_stream_bed[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) + - # 2 * water_attenuation * R_real[[freq1, freq2], :, :]) - # elif stg.BS_stream_bed_pre_process_SNR.size == 0: - # stg.FCB = (np.log(stg.BS_stream_bed_pre_process_average[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) + - # 2 * water_attenuation * R_real[[freq1, freq2], :, :]) - # else: - # stg.FCB = (np.log(stg.BS_stream_bed_pre_process_SNR[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) + - # 2 * water_attenuation * R_real[[freq1, freq2], :, :]) - # - # print(f"FCB shape : {stg.FCB.shape}") - # - # y1 = stg.FCB[freq1, 5:138, t_sample_ind[-1][0][0]] - # x1 = stg.r[freq1, 5:138] - # lin_reg_compute1 = stats.linregress(x1, y1) - # - # y2 = stg.FCB[freq2, 5:138, t_sample_ind[-1][0][0]] - # x2 = stg.r[freq2, 5:138] - # lin_reg_compute2 = stats.linregress(x2, y2) - # - # print(f"lin_reg_compute1 : {lin_reg_compute1}") - # print(f"lin_reg_compute2 : {lin_reg_compute2}") - # - # fig, ax = plt.subplots(nrows=1, ncols=2) - # ax[0].plot(x1, y1, ls='solid', c='k') - # ax[0].plot(x1, x1*lin_reg_compute1.slope + lin_reg_compute1.intercept, ls='dashed', c='b') - # ax[0].set_xlabel("Distance from transducer (m)") - # ax[0].set_ylabel("FCB") - # ax[0].set_title("Frequency 500kHz") - # ax[1].plot(x2, y2, ls='solid', c='k') - # ax[1].plot(x2, x2*lin_reg_compute2.slope + lin_reg_compute2.intercept, ls='solid', c='r') - # ax[1].set_xlabel("Distance from transducer (m)") - # ax[1].set_ylabel("FCB") - # ax[1].set_title("Frequency 1MHz") - # plt.show() - # - # alpha_s_freq1 , alpha_s_freq2 = -0.5*lin_reg_compute1.slope, -0.5*lin_reg_compute2.slope - # alpha_s_freq1 = 0.35107724188865586 - # alpha_s_freq2 = 0.37059368399238274 - print(f"alpha_s_freq1 = {alpha_s_freq1}, alpha_s_freq2 = {alpha_s_freq2}") - - range_lin_interp, M_profile_fine = self.inv_hc.M_profile_SCC_fine_interpolated( - sample_depth=-stg.sample_depth[:], - M_profile=stg.Ctot_fine[:], - range_cells=stg.r[0, :], - r_bottom=np.array([])) # stg.r_bottom[t_sample_ind[0][0]] is empty - # M_profile_fine = M_profile_fine[:len(range_lin_interp)] - # range_lin_interp, M_profile_fine = 3.2, 6.5 - - print(f"range_lin_interp : {range_lin_interp}") - print(f"M_profile_fine : {M_profile_fine}") - - # zeta_freq1, zeta_freq2 = (alpha_s_freq1 / (M_profile_fine[0]*(3.19127224 - 0.52102404)), - # alpha_s_freq2 / (M_profile_fine[0]*(3.19127224 - 0.52102404))) - zeta_freq1, zeta_freq2 = ( - self.inv_hc.zeta(alpha_s=alpha_s_freq1, r=stg.r[freq1, :], M_profile_fine=M_profile_fine), - self.inv_hc.zeta(alpha_s=alpha_s_freq2, r=stg.r[freq2, :], M_profile_fine=M_profile_fine)) - # zeta_freq1, zeta_freq2 = zeta_freq1*1e-8, zeta_freq2*1e-8 - # zeta_freq1 = 0.06417348381928434 - # zeta_freq2 = 0.06774089842814904 - # zeta_freq1, zeta_freq2 = 0.03018602, 0.05496619 - print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}") - - # zeta_freq1, zeta_freq2 = 1e-10*self.inv_hc.zeta(ind=1), 1e1*self.inv_hc.zeta(ind=2) - # print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}") - - # --- Fill spinboxes with values of parameters --- - self.spinbox_ks_freq1.setValue(ks_freq1) - self.spinbox_ks_freq2.setValue(ks_freq2) - self.spinbox_sv_freq1.setValue(sv_freq1) - self.spinbox_sv_freq2.setValue(sv_freq2) - self.spinbox_X.setValue(X_exponent) - self.spinbox_alphas_freq1.setValue(alpha_s_freq1) - self.spinbox_alphas_freq2.setValue(alpha_s_freq2) - self.spinbox_zeta_freq1.setValue(zeta_freq1) - self.spinbox_zeta_freq2.setValue(zeta_freq2) - - # fig, ax = plt.subplots(nrows=2, ncols=1) - # pcm1 = ax[0].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq1, - # cmap='rainbow', shading='gouraud') - # cbar1 = fig.colorbar(pcm1, ax=ax[0], shrink=1, location='right') - # cbar1.set_label(label='J (/m', rotation=270, labelpad=15) - # pcm2 = ax[1].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq2, - # cmap='rainbow', shading='gouraud') - # cbar2 = fig.colorbar(pcm2, ax=ax[1], shrink=1, location='right') - # cbar2.set_label(label='J (/m', rotation=270, labelpad=15) - # fig.supxlabel("Time (sec)", fontsize=10) - # fig.supylabel("Depth (m)", fontsize=10) - # plt.show() - - stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.freq[freq1], stg.freq[freq2], - zeta_freq1, zeta_freq2, - J_freq1, J_freq2, - stg.r_2D[freq2, :, :stg.t.shape[1]], - alpha_w_freq1, alpha_w_freq2, - X_exponent) - - - - stg.SSC_fine = self.inv_hc.SSC_fine(zeta_freq2, stg.r_2D[freq2, :, :stg.t.shape[1]], - stg.VBI_cross_section, stg.freq[freq2], X_exponent, J_freq2, - np.full(shape=(stg.r.shape[1], stg.t.shape[1]), fill_value=alpha_w_freq2)) - # stg.SSC_fine = self.inv_hc.SSC_fine(stg.zeta[int(self.combobox_frequency_SSC.currentIndex())], - # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.t.shape[1]], - # stg.VBI_cross_section, - # stg.frequency_to_compute_SSC[1], - # stg.X_exponent, - # stg.J_cross_section[self.combobox_frequency_SSC.currentIndex(), :, :]) - # print("SSC fine shape ", stg.SSC_fine.shape) - - stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section, stg.freq[freq2], X_exponent, ks_freq2) - # stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section, - # stg.frequency_to_compute_SSC[1], - # stg.X_exponent, - # stg.ks) - - # print("SSC sand shape ", stg.SSC_sand.shape) - - # def plot_SSC_2D_fields(self): + # self.combobox_calibration_sand_sample.addItems(stg.samples) + # # self.combobox_calibration_sand_sample.currentData.connect(self.update_plot_transect_with_sample_position) # - # if self.canvas_SSC_2D_field == None: + # self.combobox_calibration_fine_sample.addItems(stg.samples) + # # self.combobox_calibration_fine_sample.currentData.connect(self.update_plot_transect_with_sample_position) # - # 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.combobox_freq1.addItems(stg.freq_text) + # self.combobox_freq2.addItems(stg.freq_text) # - # self.plot_SSC_fine() - # self.plot_SSC_sand() + # + # # for i in range(len(samples_vertical_line)): + # # self.combobox_calibration_samples.setItemChecked(i, False) + # + # # --- add items in combobox of frequencies for VBI computation --- + # # self.combobox_frequencies_VBI.addItem(" ") + # # for k in combinations(stg.freq_text, 2): + # # self.combobox_frequencies_VBI.addItem(k[0] + " - " + k[1]) + # # print(k) + # # for i in range(len(list(combinations(stg.freq_text, 2)))): + # # self.combobox_frequencies_VBI.setItemChecked(i, False) + # + # # print(f"stg.fine_sediment_columns length : {len(stg.fine_sediment_columns)}") + # # print(f"stg.fine_sediment_columns : {stg.fine_sediment_columns}") + # # print(f"stg.frac_vol_fine.shape : {stg.frac_vol_fine.shape}") + # # 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) + # self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \ + # plt.subplots(nrows=1, ncols=1, layout="constrained") + # self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect) + # self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.canvas_plot_sample_position_on_transect) + # + # if stg.BS_stream_bed.size == 0: + # + # val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + # val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # self.axis_plot_sample_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], + # -stg.r[stg.freq_bottom_detection, :], + # stg.BS_cross_section[stg.freq_bottom_detection, :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # if stg.r_bottom.size != 0: + # self.axis_plot_sample_position_on_transect.plot( + # stg.t[stg.freq_bottom_detection, :], + # -stg.r_bottom, color='black', linewidth=1, linestyle="solid") + # + # else: + # + # val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + # val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # self.axis_plot_sample_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], + # -stg.r[stg.freq_bottom_detection, :], + # stg.BS_stream_bed[stg.freq_bottom_detection, :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # if stg.r_bottom.size != 0: + # self.axis_plot_sample_position_on_transect.plot( + # stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, + # color='black', linewidth=1, linestyle="solid") + # + # self.axis_plot_sample_position_on_transect.set_xticks([]) + # self.axis_plot_sample_position_on_transect.set_yticks([]) + # self.figure_plot_sample_position_on_transect.canvas.draw_idle() + # + # def update_plot_transect_with_sample_position(self): + # + # # --- List selected sand and fine samples --- + # sand_position_list, fine_position_list = self.sample_choice() + # + # # --- Create canvas of Matplotlib figure --- + # if stg.BS_raw_data.size == 0: + # + # self.verticalLayout_groupbox_plot_sample_position_on_transect.removeWidget( + # self.canvas_plot_sample_position_on_transect) + # self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \ + # plt.subplots(nrows=1, ncols=1, layout="constrained") + # self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect) + # self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget( + # self.canvas_plot_sample_position_on_transect) + # + # if sand_position_list: + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list], + # stg.sample_depth[sand_position_list], + # marker="o", s=20) + # + # if fine_position_list: + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list], + # stg.sample_depth[fine_position_list], + # marker="o", s=14) + # + # self.axis_plot_sample_position_on_transect.set_xticks([]) + # self.axis_plot_sample_position_on_transect.set_yticks([]) + # self.figure_plot_sample_position_on_transect.canvas.draw_idle() + # + # elif stg.BS_stream_bed.size == 0: + # + # val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + # val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # self.axis_plot_sample_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], + # stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # if stg.r_bottom.size != 0: + # self.axis_plot_sample_position_on_transect.plot( + # stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, + # color='black', linewidth=1, linestyle="solid") + # + # if sand_position_list: + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list], + # stg.sample_depth[sand_position_list], + # marker="o", s=20) + # # markeredgecolor='k', markerfacecolor='none') + # + # if fine_position_list: + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list], + # stg.sample_depth[fine_position_list], + # marker="o", s=14) + # # markeredgecolor='k', markerfacecolor='k') + # + # self.axis_plot_sample_position_on_transect.set_xticks([]) + # self.axis_plot_sample_position_on_transect.set_yticks([]) + # self.figure_plot_sample_position_on_transect.canvas.draw_idle() # # else: # - # self.verticalLayout_groupbox_SSC_2D_field.removeWidget(self.canvas_SSC_2D_field) - # self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field) + # val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + # val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + # if val_min == 0: + # val_min = 1e-5 # - # self.plot_SSC_fine() - # self.plot_SSC_sand() - - # def update_plot_SSC_fine_and_sand(self): - # self.verticalLayout_groupbox_SSC_2D_field.removeWidget(self.canvas_SSC_2D_field) + # self.axis_plot_sample_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], + # stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) # - # 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) + # if stg.r_bottom.size != 0: + # self.axis_plot_sample_position_on_transect.plot( + # stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid") # - # self.plot_SSC_fine() - # self.plot_SSC_sand() - - # def plot_SSC_fine(self): + # if sand_position_list: + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list], + # stg.sample_depth[sand_position_list], + # marker="o", s=20) # - # self.slider.setMaximum(stg.t.shape[1]) + # if fine_position_list: + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list], + # stg.sample_depth[fine_position_list], + # marker="o", s=14) # - # self.figure_SSC_fine.clf() - # self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) + # self.axis_plot_sample_position_on_transect.set_xticks([]) + # self.axis_plot_sample_position_on_transect.set_yticks([]) + # self.figure_plot_sample_position_on_transect.canvas.draw_idle() # - # 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) + # def sample_choice(self): + # # --- List selected sand samples --- + # sand_position_list = [int(s[1:])-1 for s in self.combobox_calibration_sand_sample.currentData()] + # print(f"sand_position_list : {sand_position_list}") + # # print(f"sand samples checked : {sand_samples_checked}") # - # # 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) + # # --- List selected fine samples --- + # fine_position_list = [int(s[1:])-1 for s in self.combobox_calibration_fine_sample.currentData()] + # print(f"fine_position_list : {fine_position_list}") + # # print(f"fine samples checked : {fine_samples_checked}") + # return sand_position_list, fine_position_list # - # # 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') + # def frequencies_pair_choice_to_compute_VBI(self): + # freq_combination = list(combinations(stg.freq, 2)) + # frequencies_position = [] + # # for i in range(self.combobox_frequencies_VBI.count()): + # # if self.combobox_frequencies_VBI.itemChecked(i): + # # frequencies_position.append(i) + # # elif (i in frequencies_position) and (not self.combobox_frequencies_VBI.itemChecked(i)): + # # frequencies_position.remove(i) + # frequencies_position.append(self.combobox_frequencies_VBI.currentIndex()) + # print(f"frequencies_position : {frequencies_position}") + # + # if len(frequencies_position) != 0: + # # print(frequencies_position) + # # print(freq_combination[frequencies_position[0]][0], freq_combination[frequencies_position[0]][1]) + # stg.frequencies_to_compute_VBI = ( + # np.array([[int(np.where(stg.freq == freq_combination[frequencies_position[0]-1][0])[0][0]), + # freq_combination[frequencies_position[0]-1][0]], + # [int(np.where(stg.freq == freq_combination[frequencies_position[0]-1][1])[0][0]), + # freq_combination[frequencies_position[0]-1][1]]])) + # print(f"stg.frequencies_to_compute_VBI : {stg.frequencies_to_compute_VBI}") + # + # # --- add items in combobox of frequency for SSC computation --- + # # for k in range(stg.frequencies_to_compute_VBI.shape[0]+1): + # # self.combobox_frequency_SSC.removeItem(k) + # self.combobox_frequency_SSC.clear() + # for k in range(stg.frequencies_to_compute_VBI.shape[0]+1): + # if k == 0: + # self.combobox_frequency_SSC.addItem(" ") + # else: + # self.combobox_frequency_SSC.addItem(str(1e-6*stg.frequencies_to_compute_VBI[k-1, 1]) + " MHz") + # # for i in range(stg.frequencies_to_compute_VBI.shape[0]): + # # self.combobox_frequency_SSC.setItemChecked(i, False) + # + # print("frequencies to compute VBI", stg.frequencies_to_compute_VBI) + # + # def frequency_choice_to_compute_SSC(self): + # print(self.combobox_frequency_SSC.currentText()) + # print(self.combobox_frequency_SSC.currentIndex()) + # # print(self.combobox_frequency_SSC.itemChecked(index)) + # + # + # # if self.combobox_frequency_SSC.itemChecked(index): + # # # itemChecked(index)): # currentIndex() == 0) or (self.combobox_frequency_SSC.currentIndex() == 1): + # # print(self.combobox_frequency_SSC.currentText()) + # # print(stg.freq_text) + # # print(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText())) + # + # # stg.frequency_to_compute_SSC \ + # # = np.array([int(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText())[0][0]), + # # stg.freq[int(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText())[0][0])]]) + # # + # # print("stg.frequency_to_compute_SSC ", stg.frequency_to_compute_SSC) + # + # # def temperature_value(self): + # # stg.temperature = self.spinbox_temperature.value() + # # print(stg.temperature) + # + # def compute_sound_velocity(self): + # stg.water_velocity = self.inv_hc.water_velocity(stg.temperature) + # print("water velocity ", stg.water_velocity) + # + # # def compute_kt(self, freq_ind): + # # + # # # stg.kt_corrected = self.inv_hc.kt_corrected(stg.r[int(stg.frequency_to_compute_SSC[0]), :], stg.water_velocity, + # # # stg.gain_rx[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]], + # # # stg.gain_tx[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]], + # # # stg.kt[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]]) + # # + # # if stg.ABS_name == "Aquascat 1000R": + # # kt_corrected = self.inv_hc.kt_corrected(stg.r[0, :], stg.water_velocity, + # # stg.gain_rx[freq_ind], stg.gain_tx[freq_ind], stg.kt[0, freq_ind]) + # # kt_corrected_2D = np.repeat(kt_corrected, stg.r.shape[1], axis=0) + # # print("kt 2D ", kt_corrected_2D) + # # print("kt 2D shape ", kt_corrected_2D.shape) + # # kt_corrected_3D = np.zeros((kt_corrected_2D.shape[1], kt_corrected_2D.shape[0], stg.t.shape[1])) + # # for k in range(kt_corrected_2D.shape[1]): + # # kt_corrected_3D[k, :, :] = np.repeat(kt_corrected_2D, stg.t.shape[1], axis=1)[:, + # # k * stg.t.shape[1]:(k + 1) * stg.t.shape[1]] + # # print("kt 3D ", kt_corrected_3D) + # # print("kt 3D shape ", kt_corrected_3D.shape) + # # elif stg.ABS_name == "UB-SediFlow": + # # stg.kt_corrected = np.array([[0.003, 0.006]]) + # # print("kt ", stg.kt_corrected) + # # print("kt shape ", stg.kt_corrected.shape) + # # stg.kt_corrected_2D = np.array(np.repeat(stg.kt_corrected, stg.r.shape[1], axis=0)) + # # print("kt 2D shape ", stg.kt_corrected_2D.shape) + # # stg.kt_corrected_3D = np.zeros((stg.kt_corrected_2D.shape[1], stg.kt_corrected_2D.shape[0], stg.t.shape[1])) + # # for k in range(stg.kt_corrected_2D.shape[1]): + # # stg.kt_corrected_3D[k, :, :] = np.repeat(stg.kt_corrected_2D, stg.t.shape[1], axis=1)[:, + # # k * stg.t.shape[1]:(k + 1) * stg.t.shape[1]] + # # print("kt corrected 3D zeros shape ", stg.kt_corrected_3D.shape) + # # + # # print("kt ", stg.kt_corrected) + # # # print("kt shape ", stg.kt_corrected.shape) + # # + # # # stg.kt_corrected_2D = np.repeat(stg.kt_corrected, stg.r.shape[1], axis=0) + # # + # # # stg.kt_corrected_3D = np.zeros((stg.kt_corrected_2D.shape[1], stg.kt_corrected_2D.shape[0], stg.t.shape[1])) + # # # print("stg.t.shape ", stg.t.shape) + # # # print("kt corrected 3D zeros shape ", stg.kt_corrected_3D.shape) + # # # for k in range(stg.kt_corrected_2D.shape[1]): + # # # stg.kt_corrected_3D[k, :, :] = np.repeat(stg.kt_corrected_2D, stg.t.shape[1], axis=1)[:, k*stg.t.shape[1]:(k+1)*stg.t.shape[1]] + # # + # # # print("kt 2D", np.repeat(stg.kt_corrected[:, :, np.newaxis], stg.t.shape[0], axis=2)) + # + # def compute_J(self, freq_ind, kt): # if stg.ABS_name == "Aquascat 1000R": + # print(f"stg.BS_stream_bed.shape : {stg.BS_stream_bed.shape}") # - # 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') + # if stg.BS_stream_bed.size != 0: # - # 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) + # if stg.BS_stream_bed_pre_process_SNR.size != 0: + # print("1/ stg.BS_stream_bed_pre_process_SNR") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_stream_bed_pre_process_SNR[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_SNR.shape[2]], + # kt[freq_ind, :, :])) + # + # elif stg.BS_stream_bed_pre_process_average.size != 0: + # print("2/ stg.BS_stream_bed_pre_process_average") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_stream_bed_pre_process_average[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_average.shape[2]], + # kt[freq_ind, :, :])) + # + # else: + # print("3/ stg.BS_stream_bed") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_stream_bed[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_stream_bed.shape[2]], + # kt[freq_ind, :, :])) + # + # elif stg.BS_cross_section.size != 0: + # + # if stg.BS_cross_section_pre_process_SNR.size != 0: + # print("1/ stg.BS_cross_section_pre_process_SNR") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_cross_section_pre_process_SNR[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_cross_section_pre_process_SNR.shape[2]], + # kt[freq_ind, :, :])) + # + # elif stg.BS_cross_section_pre_process_average.size != 0: + # print("2/ stg.BS_cross_section_pre_process_average") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section(stg.BS_cross_section_pre_process_average[freq_ind, :, :], + # stg.r_2D[0, :, :stg.BS_cross_section_pre_process_average.shape[2]], + # kt[freq_ind, :, :])) + # + # else: + # print("3/ stg.BS_cross_section") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_cross_section[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_cross_section.shape[2]], + # kt[freq_ind, :, :])) # # 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.BS_stream_bed.size != 0: + # + # if stg.BS_stream_bed_pre_process_SNR.size != 0: + # print("1/ stg.BS_stream_bed_pre_process_SNR") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_stream_bed_pre_process_SNR[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_SNR.shape[2]], + # kt[freq_ind, :, :])) + # + # elif stg.BS_stream_bed_pre_process_average.size != 0: + # print("2/ stg.BS_stream_bed_pre_process_average") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_stream_bed_pre_process_average[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_average.shape[2]], + # kt[freq_ind, :, :])) # # - # 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) + # else: + # print("3/ stg.BS_stream_bed") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_stream_bed[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_stream_bed.shape[2]], + # kt[freq_ind, :, :])) # - # 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() + # elif stg.BS_cross_section.size != 0: # - # def plot_SSC_sand(self): + # if stg.BS_cross_section_pre_process_SNR.size != 0: + # print("2/ stg.BS_cross_section_pre_process_SNR") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_cross_section_pre_process_SNR[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_cross_section_pre_process_SNR.shape[2]], + # kt[freq_ind, :, :])) # - # self.slider.setMaximum(stg.t.shape[1]) + # if stg.BS_cross_section_pre_process_average.size != 0: + # print("1/ stg.BS_cross_section_pre_process_average") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section(stg.BS_cross_section_pre_process_average[freq_ind, :, :], + # stg.r_2D[freq_ind, :, + # :stg.BS_cross_section_pre_process_average.shape[2]], + # kt[freq_ind, :, :])) # - # 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) + # else: + # print("3/ stg.BS_cross_section") + # stg.J_cross_section = ( + # self.inv_hc.j_cross_section( + # stg.BS_cross_section[freq_ind, :, :], + # stg.r_2D[freq_ind, :, :stg.BS_cross_section.shape[2]], + # kt[freq_ind, :, :])) # - # # print(stg.SSC_sand) + # + # + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_cross_section_pre_process_average[ + # # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], + # # :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_cross_section_pre_process_average.shape[2]], + # # stg.kt_corrected_3D)) + # + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_cross_section_pre_process_SNR[ + # # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], + # # :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, + # # :stg.BS_cross_section_pre_process_SNR.shape[2]], + # # stg.kt_corrected_3D)) + # + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_cross_section[ + # # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], + # # :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, + # # :stg.BS_cross_section.shape[2]], + # # stg.kt_corrected_3D)) + # + # # stg.J_stream_bed = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_stream_bed_pre_process_average[ + # # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], + # # :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_stream_bed_pre_process_average.shape[2]], + # # stg.kt_corrected_3D)) + # + # + # # stg.J_stream_bed = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_stream_bed_pre_process_SNR[ + # # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], + # # :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_stream_bed_pre_process_SNR.shape[2]], + # # stg.kt_corrected_3D)) + # + # # stg.J_stream_bed = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_stream_bed[ + # # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], + # # :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, + # # :stg.BS_stream_bed.shape[2]], + # # stg.kt_corrected_3D)) + # + # # elif (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0): + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_data_section[[int(stg.frequencies_to_compute_VBI[0, 0]), + # # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section.shape[2]], stg.kt_corrected_3D)) + # # elif (stg.BS_data_section_averaged.size != 0) and (stg.BS_data_section_SNR_filter.size == 0): + # # print("Je suis dans ce J") + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_data_section_averaged[[0, 2], :, :], + # # stg.r_2D[[0, 2], :, :stg.BS_data_section_averaged.shape[2]], + # # stg.kt_corrected_3D[[0, 1], :, :])) + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_data_section_averaged[[int(stg.frequencies_to_compute_VBI[0, 0]), + # # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_averaged.shape[2]], stg.kt_corrected_3D)) + # # else: + # # print("stg.r_2D.shape ", stg.r_2D.shape) + # # print("stg.kt_corrected_3D.shape ", stg.kt_corrected_3D.shape) + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_data_section_SNR_filter[[int(stg.frequencies_to_compute_VBI[0, 0]), + # # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_SNR_filter.shape[2]], stg.kt_corrected_3D)) + # # + # # print("J ", stg.J_cross_section) + # # print("J sahpe ", stg.J_cross_section.shape) + # + # # if stg.BS_data_section.size == 0: + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_data[ + # # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])], + # # :, :], stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data.shape[2]], + # # stg.kt_corrected_3D)) + # # elif (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0): + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_data_section[[int(stg.frequencies_to_compute_VBI[0, 0]), + # # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], + # # np.array([stg.r_2D[0, :, :stg.BS_data_section.shape[2]]]), + # # stg.kt_corrected_3D)) + # # elif (stg.BS_data_section_averaged.size != 0) and (stg.BS_data_section_SNR_filter.size == 0): + # # print("Je suis dans ce J") + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_data_section_averaged[[0, 2], :, :], + # # stg.r_2D[[0, 2], :, :stg.BS_data_section_averaged.shape[2]], + # # stg.kt_corrected_3D[[0, 1], :, :])) + # # # stg.J_cross_section = ( + # # # self.inv_hc.j_cross_section( + # # # stg.BS_data_section_averaged[[int(stg.frequencies_to_compute_VBI[0, 0]), + # # # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], + # # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_averaged.shape[2]], stg.kt_corrected_3D)) + # # else: + # # print("stg.r_2D.shape ", stg.r_2D.shape) + # # print("stg.kt_corrected_3D.shape ", stg.kt_corrected_3D.shape) + # # stg.J_cross_section = ( + # # self.inv_hc.j_cross_section( + # # stg.BS_data_section_SNR_filter[[int(stg.frequencies_to_compute_VBI[0, 0]), + # # int(stg.frequencies_to_compute_VBI[1, 0])], :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_SNR_filter.shape[2]], + # # stg.kt_corrected_3D)) + # # + # # print("J ", stg.J_cross_section) + # # print("J sahpe ", stg.J_cross_section.shape) + # + # return stg.J_cross_section + # + # # def compute_alpha_s(self, freq, freq_ind): + # # stg.sv = self.compute_sv(freq) + # # j_cross_section = self.compute_J(freq_ind) + # # stg.alpha_s = np.log(stg.sv / j_cross_section) / (4 * stg.sample_depth[10]) - stg.water_attenuation + # # return + # + # # def compute_zeta(self): + # # stg.zeta_freq1 = self.inv_hc.zeta(0, 2) + # # stg.zeta_freq2 = self.inv_hc.zeta() + # # # stg.zeta = self.inv_hc.zeta(int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])) + # # print("zeta ", stg.zeta) + # + # # def compute_X(self): + # # stg.X_exponent = self.inv_hc.X_exponent(2) #self.inv_hc.X_exponent(self.combobox_frequencies_VBI.currentIndex()) + # # print("X ", stg.X_exponent) + # + # # def compute_VBI(self): + # # stg.VBI_cross_section = self.inv_hc.VBI_cross_section(3e5, + # # 1e6, + # # stg.zeta[0], + # # # zeta is already limited to the frequencies pairs so that we just need to select indices 0 and 1 + # # stg.zeta[1], + # # stg.J_cross_section[0, :, :], + # # stg.J_cross_section[1, :, :], + # # stg.r_2D[0, :, :stg.t.shape[1]], + # # stg.water_attenuation[0], + # # stg.water_attenuation[1], + # # stg.X_exponent) + # + # # stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.frequencies_to_compute_VBI[0, 1], stg.frequencies_to_compute_VBI[1, 1], + # # stg.zeta[0], # zeta is already limited to the frequencies pairs so that we just need to select indices 0 and 1 + # # stg.zeta[1], + # # stg.J_cross_section[0, :, :], + # # stg.J_cross_section[1, :, :], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.t.shape[1]], + # # stg.water_attenuation[0], + # # stg.water_attenuation[1], + # # stg.X_exponent) + # # print("VBI shape ", stg.VBI_cross_section.shape) + # # print(int(self.combobox_frequency_SSC.currentIndex())) + # # print(stg.zeta[int(self.combobox_frequency_SSC.currentIndex())]) + # + # def range_cells_function(self): + # """ Computing the real cell size, that depends on the temperature """ + # # defaut Aquascat cell size + # aquascat_cell_size = stg.r[0, 1] - stg.r[0, 0] + # # Pulse duration + # tau = aquascat_cell_size * 2 / 1500 # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat + # # Sound speed + # cel = self.inv_hc.water_velocity(self.spinbox_temperature.value()) + # # Real cell size + # real_cell_size = cel * tau / 2 # voir fig 2.9 + # + # # Converting to real cell profile + # real_r = np.zeros((stg.freq.shape[0], stg.r.shape[1])) + # for i in range(stg.freq.shape[0]): + # real_r[i, :] = stg.r[i, :] / aquascat_cell_size * real_cell_size # (/ 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 + # + # # R with right shape (numpy array) + # R_real = real_r # np.repeat(real_r, len(stg.freq), axis=1) + # print(f"R_real = {R_real.shape}") + # + # return R_real + # + # def compute_acoustic_inversion_method_high_concentration(self): + # + # # --- List selected sand and fine samples --- + # sand_position_list, fine_position_list = self.sample_choice() # # 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') + # freq1 = int(self.combobox_freq1.currentIndex()) # 0 = 300kHz et 1 = 500kHz + # freq2 = int(self.combobox_freq2.currentIndex()) # 2 = 1MHz + # print(f"freq1 = {freq1}, freq2 = {freq2}") # - # 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) + # stg.water_velocity = self.inv_hc.water_velocity(stg.temperature) + # + # alpha_w_freq1, alpha_w_freq2 = (self.inv_hc.water_attenuation(freq=stg.freq[freq1], T=stg.temperature), + # self.inv_hc.water_attenuation(freq=stg.freq[freq2], T=stg.temperature)) + # print(f"alpha_w_freq1 = {alpha_w_freq1}, alpha_w_freq2 = {alpha_w_freq2}") + # + # self.compute_sound_velocity() + # + # # print("ks value : ", self.inv_hc.ks(a_s=stg.sand_sediment_columns[5:], rho_s=2500, freq=stg.freq[0], pdf=stg.frac_vol_sand[2, :])) + # + # # ks_freq1, ks_freq2 = ( + # # self.inv_hc.ks(num_sample=2, freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[2, :]), + # # self.inv_hc.ks(num_sample=2, freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[2, :])) + # ks_freq1, ks_freq2 = ( + # self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :]), + # self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :])) + # # 6 = V11 , 10 = V12 sur le notebook d'Adrien + # # ks_freq1, ks_freq2 = self.inv_hc.ks()[0], self.inv_hc.ks()[2] + # print(f"ks_freq1 = {ks_freq1}, ks_freq2 = {ks_freq2}") + # + # # f = self.inv_hc.form_factor_function_MoateThorne2012(np.log(np.logspace(-10, -2, 3000)), stg.freq[2]) + # # fig, ax = plt.subplots(nrows=1, ncols=1) + # # ax.plot(list(range(len(np.log(np.logspace(-10, -2, 3000))))), f, color="k", ls="solid") + # # plt.show() + # + # # sv_freq1, sv_freq2 = ( + # # self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[2]), + # # self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[2])) + # sv_freq1, sv_freq2 = ( + # self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[sand_position_list[0]]), + # self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[sand_position_list[0]])) + # print(f"sv_freq1 = {sv_freq1}, sv_freq2 = {sv_freq2}") + # + # X_exponent = self.inv_hc.X_exponent(freq1=stg.freq[freq1], freq2=stg.freq[freq2], sv_freq1=sv_freq1, sv_freq2=sv_freq2) + # # X_exponent = self.inv_hc.X_exponent(ind=2) + # print(f"X_exponent = {X_exponent}") + # + # stg.kt = np.array([[0.04], [0.01838], [0.03267], [0.01376]]) + # kt = np.array([]) + # for i, v in enumerate(stg.kt): + # kt = np.append(kt, self.inv_hc.kt_corrected(r=stg.r[i, :], + # water_velocity=stg.water_velocity, + # RxGain=stg.gain_rx[i], + # TxGain=stg.gain_tx[i], + # kt_ref=stg.kt[i])) + # kt = np.reshape(kt, (len(kt), 1)) + # print(f"kt = {kt}") + # kt2D = np.repeat(np.array(kt), stg.r.shape[1], axis=1) + # print(f"kt2D.shape = {kt2D.shape}") + # # print(f"kt2D = {kt2D}") + # kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2) + # print(f"kt3D.shape = {kt3D.shape}") + # # print(f"kt3D = {kt3D}") + # + # # kt_freq1, kt_freq2 = ( + # # self.inv_hc.kt_corrected(r=stg.r[0, :], water_velocity=stg.water_velocity, RxGain=stg.gain_rx[0], + # # TxGain=stg.gain_tx[0], kt_ref=stg.kt[0]), + # # self.inv_hc.kt_corrected(r=stg.r[2, :], water_velocity=stg.water_velocity, RxGain=stg.gain_rx[2], + # # TxGain=stg.gain_tx[2], kt_ref=stg.kt[2])) + # # print(f"kt_freq1 = {kt_freq1}, kt_freq2 = {kt_freq2}") + # # kt2D_freq1 = np.full((stg.r.shape[1], stg.t.shape[1]), kt_freq1) + # # kt2D_freq2 = np.full((stg.r.shape[1], stg.t.shape[1]), kt_freq2) + # # print(f"kt2D_freq1 = {kt2D_freq1.shape}") + # # print(f"kt2D_freq2 = {kt2D_freq2.shape}") + # # kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2) + # # print(f"kt_3D = {kt3D.shape}") + # # print(f"kt_3D = {kt3D}") + # + # # kt_freq1, kt_freq2 = ( + # # np.full((stg.r.shape[1], stg.t.shape[1]), stg.kt[0]), + # # np.full((stg.r.shape[1], stg.t.shape[1]), stg.kt[2])) + # # print(f"kt_freq1 = {kt_freq1.shape}, kt_freq2 = {kt_freq2.shape}") + # + # J_freq1, J_freq2 = self.compute_J(freq_ind=freq1, kt=kt3D), self.compute_J(freq_ind=freq2, kt=kt3D) + # print(f"J_freq1 = {J_freq1.shape}, J_freq2 = {J_freq2.shape}") + # + # # fig, ax = plt.subplots(nrows=1, ncols=1) + # # pcm = ax.pcolormesh(stg.t[0, :], stg.r[0, :], J_freq2, cmap='rainbow', shading='gouraud') + # # fig.colorbar(pcm, ax=ax, shrink=1, location='right') + # # plt.show() + # + # # print("***************************") + # # print(sv_freq1.shape) + # # print(J_freq1.shape) + # # print(np.repeat(stg.r[0, :][:, np.newaxis], stg.t.shape[1], axis=1).shape) + # # print(np.full((stg.r.shape[1], stg.t.shape[1]), alpha_w_freq1).shape) + # # print("***************************") + # + # r_sample_ind = [] + # t_sample_ind = [] + # for i in range(len(stg.sample_depth[fine_position_list])): #:3 + # # for i in range(len(stg.sample_depth[:3])): #:3 + # # print(-stg.sample_depth[i]) + # # print(-stg.sample_time[i]) + # r_sample_ind.append(np.where(np.abs(stg.r[0, :] - (-stg.sample_depth[i])) == + # np.nanmin(np.abs(stg.r[0, :] - (-stg.sample_depth[i]))))) + # # print(np.abs(stg.t[0, :] - (-stg.sample_time[i]))) + # t_sample_ind.append(np.where(np.abs(stg.t[0, :] - (stg.sample_time[i])) == + # np.nanmin(np.abs(stg.t[0, :] - (stg.sample_time[i]))))) + # print(f"r_sample_ind = {r_sample_ind}") + # print(f"t_sample_ind = {t_sample_ind}") + # # print("J_freq1[r_sample_ind[1][0], t_sample_ind[1][0]] ", J_freq1[r_sample_ind[1][0], t_sample_ind[1][0]]) + # + # # ind_r_min = int(ind_X_min_around_sample[p, k]) + # # print(f"ind_r_min = {ind_r_min}") + # # ind_r_max = int(ind_X_max_around_sample[p, k]) + # # print(f"ind_r_max = {ind_r_max}") + # # ind_t_min = int(ind_r_min_around_sample[p, k]) + # # print(f"ind_t_min = {ind_t_min}") + # # ind_t_max = int(ind_r_max_around_sample[p, k]) + # # print(f"ind_t_max = {ind_t_max}") + # + # # print(f"stg.BS freq1 = {stg.BS_stream_bed_pre_process_average[freq1, r_sample_ind[-1], t_sample_ind[-1]]}") + # # print(f"stg.BS freq2 = {stg.BS_stream_bed_pre_process_average[freq2, r_sample_ind[-1], t_sample_ind[-1]]}") + # # + # # print(f"J_freq1[r_sample_ind[-1], t_sample_ind[-1]] {J_freq1[r_sample_ind[-1], t_sample_ind[-1]]}") + # # print(f"J_freq2[r_sample_ind[-1], t_sample_ind[-1]] {J_freq2[r_sample_ind[-1], t_sample_ind[-1]]}") + # # + # # print(f"stg.r[0, r_sample_ind[-1]] {stg.r[2, r_sample_ind[-1]]}") + # + # + # alpha_s_freq1, alpha_s_freq2 = ( + # self.inv_hc.alpha_s(sv=sv_freq1, j_cross_section=J_freq1[r_sample_ind[-1], t_sample_ind[-1]], depth=stg.r[freq1, r_sample_ind[-1]], alpha_w=alpha_w_freq1), + # self.inv_hc.alpha_s(sv=sv_freq2, j_cross_section=J_freq2[r_sample_ind[-1], t_sample_ind[-1]], depth=stg.r[freq2, r_sample_ind[-1]], alpha_w=alpha_w_freq2)) + # print(f"alpha_s_freq1 = {alpha_s_freq1}, alpha_s_freq2 = {alpha_s_freq2}") + # + # # range_lin_interp, M_profile_fine = self.inv_hc.M_profile_SCC_fine_interpolated( + # # sample_depth=-stg.sample_depth[:3], #:3 + # # M_profile=stg.Ctot_fine[:3], #:3 + # # range_cells=stg.r[0, :], + # # r_bottom=stg.r_bottom[t_sample_ind[0][0]]) + # 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]] 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}") + # + # M_profile_fine = M_profile_fine[:len(range_lin_interp)] + # print(f"M_profile_fine : {M_profile_fine}") + # + # + # # print("----------------------") + # # print(f"r_sample_ind[-1][0] = {r_sample_ind[-1][0][0]}") + # # print(f"M_profile_fine[:r_sample_ind[-1][0]] = ", M_profile_fine[:r_sample_ind[-1][0][0]]) + # # print(f"stg.r[0, r_sample_ind[-1][0]] = ", stg.r[0, r_sample_ind[-1][0][0]]) + # # print("----------------------") + # + # zeta_freq1, zeta_freq2 = (self.inv_hc.zeta(alpha_s=alpha_s_freq1, r=stg.r[freq1, :], M_profile_fine=M_profile_fine), + # self.inv_hc.zeta(alpha_s=alpha_s_freq2, r=stg.r[freq2, :], M_profile_fine=M_profile_fine)) + # # zeta_freq1, zeta_freq2 = ( + # # self.inv_hc.zeta(r=stg.r[0, :r_sample_ind[-1][0][0]], M_profile_fine=M_profile_fine[:r_sample_ind[-1][0][0]]), + # # self.inv_hc.zeta(r=stg.r[0, :r_sample_ind[-1][0][0]], M_profile_fine=M_profile_fine[:r_sample_ind[-1][0][0]])) + # print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}") + # # plt.figure() + # # plt.plot(stg.r[0, :], Mprofile, 'b.', -stg.sample_depth[:3], stg.Ctot_fine[:3], 'ko') + # # plt.show() + # + # # --- Fill spinboxes with values of parameters --- + # self.spinbox_ks_freq1.setValue(ks_freq1) + # self.spinbox_ks_freq2.setValue(ks_freq2) + # self.spinbox_sv_freq1.setValue(sv_freq1) + # self.spinbox_sv_freq2.setValue(sv_freq2) + # self.spinbox_X.setValue(X_exponent) + # self.spinbox_alphas_freq1.setValue(alpha_s_freq1) + # self.spinbox_alphas_freq2.setValue(alpha_s_freq2) + # self.spinbox_zeta_freq1.setValue(zeta_freq1) + # self.spinbox_zeta_freq2.setValue(zeta_freq2) + # + # # fig, ax = plt.subplots(nrows=2, ncols=1) + # # pcm1 = ax[0].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq1, + # # cmap='rainbow', vmin=0, vmax=1e-5, shading='gouraud') + # # cbar1 = fig.colorbar(pcm1, ax=ax[0], shrink=1, location='right') + # # cbar1.set_label(label='J (/m', rotation=270, labelpad=15) + # # pcm2 = ax[1].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq2, + # # cmap='rainbow', vmin=0, vmax=1e-4, shading='gouraud') + # # cbar2 = fig.colorbar(pcm2, ax=ax[1], shrink=1, location='right') + # # cbar2.set_label(label='J (/m', rotation=270, labelpad=15) + # # fig.supxlabel("Time (sec)", fontsize=10) + # # fig.supylabel("Depth (m)", fontsize=10) + # # plt.show() + # + # stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.freq[freq1], stg.freq[freq2], + # zeta_freq1, zeta_freq2, + # J_freq1, J_freq2, + # stg.r_2D[freq1, :, :stg.t.shape[1]], + # alpha_w_freq1, alpha_w_freq2, + # X_exponent) + # + # stg.SSC_fine = self.inv_hc.SSC_fine(zeta_freq2, stg.r_2D[freq2, :, :stg.t.shape[1]], + # stg.VBI_cross_section, stg.freq[freq2], X_exponent, J_freq2, + # np.full(shape=(stg.r.shape[1], stg.t.shape[1]), fill_value=alpha_w_freq2)) + # + # stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section, stg.freq[freq2], X_exponent, ks_freq2) # # 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') + # freq1 = int(self.combobox_freq1.currentIndex()) # 0 = 500kHz + # freq2 = int(self.combobox_freq2.currentIndex()) # 1 = 1MHz # - # 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") + # stg.water_velocity = self.inv_hc.water_velocity(stg.temperature) + # + # alpha_w_freq1, alpha_w_freq2 = (self.inv_hc.water_attenuation(freq=stg.freq[freq1], T=stg.temperature), + # self.inv_hc.water_attenuation(freq=stg.freq[freq2], T=stg.temperature)) + # print(f"alpha_w_freq1 = {alpha_w_freq1}, alpha_w_freq2 = {alpha_w_freq2}") + # + # self.compute_sound_velocity() + # + # # ks_freq1, ks_freq2 = 0.11373812635175432, 0.35705575378038723 + # # ks_freq1, ks_freq2 = (self.inv_hc.form_factor_function_MoateThorne2012(a=100e-6, freq=stg.freq[freq1])/np.sqrt(2500*100e-6), + # # self.inv_hc.form_factor_function_MoateThorne2012(a=100e-6, freq=stg.freq[freq2])/np.sqrt(2500*100e-6)) + # + # ks_freq1, ks_freq2 = ( + # self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :]), + # self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :])) + # # ks_freq1 = 0.05261498026985425 + # # ks_freq2 = 0.19303997854869764 + # print(f"ks_freq1 = {ks_freq1}, ks_freq2 = {ks_freq2}") + # + # # Fine sediments 19/05/2021 15h11 - 15h42 (locale) = 13h10 - 13h42 (UTC) --> 6 samples + # # 52 to 428 / fixed at 234 + # # 14h10 = position 766 + # # Sand sediments 20/05/2021 12h04 - 12h20 (locale) = 10h04 - 10h20 (UTC) --> 2 samples + # # 777 to 972 / fixed at 777 + # + # sv_freq1, sv_freq2 = ( + # self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[sand_position_list[0]]), + # self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[sand_position_list[0]])) + # # sv_freq1 = 0.0004956686799986783 + # # sv_freq2 = 0.006672171109602389 + # print(f"sv_freq1 = {sv_freq1}, sv_freq2 = {sv_freq2}") + # + # X_exponent = self.inv_hc.X_exponent(freq1=stg.freq[freq1], freq2=stg.freq[freq2], + # sv_freq1=sv_freq1, sv_freq2=sv_freq2) + # # X_exponent = 3.750708280862506 + # print(f"X_exponent = {X_exponent}") + # + # # stg.kt = np.array([[1.38e-3], [6.02e-4]]) # Values of kt for 500kHz and 1MHz + # stg.kt = np.array([[0.5], [0.5]]) + # + # kt = stg.kt + # # kt = np.array([]) + # # for i, v in enumerate(stg.kt): + # # kt = np.append(kt, self.inv_hc.kt_corrected(r=stg.r[i, :], + # # water_velocity=stg.water_velocity, + # # RxGain=0, + # # TxGain=0, + # # kt_ref=stg.kt[i])) + # # kt = np.reshape(kt, (len(kt), 1)) + # print(f"kt = {kt}, kt.shape = {kt.shape}") + # kt2D = np.repeat(np.array(kt), stg.r.shape[1], axis=1) + # print(f"kt2D.shape = {kt2D.shape}") + # # print(f"kt2D = {kt2D}") + # kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2) + # print(f"kt3D.shape = {kt3D.shape}") + # + # J_freq1, J_freq2 = self.compute_J(freq_ind=freq1, kt=kt3D), self.compute_J(freq_ind=freq2, kt=kt3D) + # print(f"J_freq1 = {J_freq1.shape}, J_freq2 = {J_freq2.shape}") + # + # r_sample_ind = [] + # t_sample_ind = [] + # for i in range(len(stg.sample_depth[fine_position_list])): + # # print(-stg.sample_depth[i]) + # # print(-stg.sample_time[i]) + # r_sample_ind.append(np.where(np.abs(stg.r[freq1, :] - (-stg.sample_depth[i])) == + # np.nanmin(np.abs(stg.r[freq1, :] - (-stg.sample_depth[i]))))) + # # print(np.abs(stg.t[0, :] - (-stg.sample_time[i]))) + # t_sample_ind.append(np.where(np.abs(stg.t[freq1, :] - (stg.sample_time[i])) == + # np.nanmin(np.abs(stg.t[freq1, :] - (stg.sample_time[i]))))) + # print(f"r_sample_ind = {r_sample_ind}") + # print(f"t_sample_ind = {t_sample_ind}") + # + # print(f"stg.BS freq1 = {stg.BS_cross_section[freq1, r_sample_ind[-1], t_sample_ind[-1]]}") + # print(f"stg.BS freq2 = {stg.BS_cross_section[freq2, r_sample_ind[-1], t_sample_ind[-1]]}") + # + # print(f"J_freq1[r_sample_ind[-1], t_sample_ind[-1]] : {J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]}") + # # print(f"J_freq1[r_sample_ind[-1]+-n, t_sample_ind[-1]+-n] : {J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]:t_sample_ind[-1][0][0]].mean(axis=0)}") + # + # # delta_t = 0 + # alpha_s_freq1, alpha_s_freq2 = ( + # self.inv_hc.alpha_s(sv=sv_freq1, + # j_cross_section=np.mean(J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]), + # depth=stg.r[freq1, r_sample_ind[-1][0][0]], alpha_w=alpha_w_freq1), + # self.inv_hc.alpha_s(sv=sv_freq2, + # j_cross_section=np.mean(J_freq2[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]), + # # j_cross_section=J_freq2[r_sample_ind[-1], t_sample_ind[-1]], + # depth=stg.r[freq2, r_sample_ind[-1][0][0]], alpha_w=alpha_w_freq2)) + # + # # avec J (alpha_w = 0.03578217234512747) + # # alpha_s_freq1 = -0.12087339 + # # alpha_s_freq2 = -0.01437704 + # + # # avec log(J) + # # alpha_s_freq1 = -1.91967628 + # # alpha_s_freq2 = -1.87942544 + # + # # --- Calculation of alpha_s with FCB slope --- + # + # # R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[1], axis=2) + # # water_attenuation = np.full((2, stg.r.shape[1], stg.t.shape[1]), 1) + # # water_attenuation[0, :, :] = alpha_w_freq1*water_attenuation[0, :, :] + # # water_attenuation[1, :, :] = alpha_w_freq2*water_attenuation[1, :, :] + # # if stg.BS_stream_bed.size == 0: + # # stg.FCB = (np.log(stg.BS_cross_section[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) + + # # 2 * water_attenuation * R_real[[freq1, freq2], :, :]) + # # elif (stg.BS_stream_bed_pre_process_average.size == 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0): + # # stg.FCB = (np.log(stg.BS_stream_bed[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) + + # # 2 * water_attenuation * R_real[[freq1, freq2], :, :]) + # # elif stg.BS_stream_bed_pre_process_SNR.size == 0: + # # stg.FCB = (np.log(stg.BS_stream_bed_pre_process_average[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) + + # # 2 * water_attenuation * R_real[[freq1, freq2], :, :]) + # # else: + # # stg.FCB = (np.log(stg.BS_stream_bed_pre_process_SNR[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) + + # # 2 * water_attenuation * R_real[[freq1, freq2], :, :]) + # # + # # print(f"FCB shape : {stg.FCB.shape}") + # # + # # y1 = stg.FCB[freq1, 5:138, t_sample_ind[-1][0][0]] + # # x1 = stg.r[freq1, 5:138] + # # lin_reg_compute1 = stats.linregress(x1, y1) + # # + # # y2 = stg.FCB[freq2, 5:138, t_sample_ind[-1][0][0]] + # # x2 = stg.r[freq2, 5:138] + # # lin_reg_compute2 = stats.linregress(x2, y2) + # # + # # print(f"lin_reg_compute1 : {lin_reg_compute1}") + # # print(f"lin_reg_compute2 : {lin_reg_compute2}") + # # + # # fig, ax = plt.subplots(nrows=1, ncols=2) + # # ax[0].plot(x1, y1, ls='solid', c='k') + # # ax[0].plot(x1, x1*lin_reg_compute1.slope + lin_reg_compute1.intercept, ls='dashed', c='b') + # # ax[0].set_xlabel("Distance from transducer (m)") + # # ax[0].set_ylabel("FCB") + # # ax[0].set_title("Frequency 500kHz") + # # ax[1].plot(x2, y2, ls='solid', c='k') + # # ax[1].plot(x2, x2*lin_reg_compute2.slope + lin_reg_compute2.intercept, ls='solid', c='r') + # # ax[1].set_xlabel("Distance from transducer (m)") + # # ax[1].set_ylabel("FCB") + # # ax[1].set_title("Frequency 1MHz") + # # plt.show() + # # + # # alpha_s_freq1 , alpha_s_freq2 = -0.5*lin_reg_compute1.slope, -0.5*lin_reg_compute2.slope + # # alpha_s_freq1 = 0.35107724188865586 + # # alpha_s_freq2 = 0.37059368399238274 + # print(f"alpha_s_freq1 = {alpha_s_freq1}, alpha_s_freq2 = {alpha_s_freq2}") + # + # range_lin_interp, M_profile_fine = self.inv_hc.M_profile_SCC_fine_interpolated( + # sample_depth=-stg.sample_depth[:], + # M_profile=stg.Ctot_fine[:], + # range_cells=stg.r[0, :], + # r_bottom=np.array([])) # stg.r_bottom[t_sample_ind[0][0]] is empty + # # M_profile_fine = M_profile_fine[:len(range_lin_interp)] + # # range_lin_interp, M_profile_fine = 3.2, 6.5 + # + # print(f"range_lin_interp : {range_lin_interp}") + # print(f"M_profile_fine : {M_profile_fine}") + # + # # zeta_freq1, zeta_freq2 = (alpha_s_freq1 / (M_profile_fine[0]*(3.19127224 - 0.52102404)), + # # alpha_s_freq2 / (M_profile_fine[0]*(3.19127224 - 0.52102404))) + # zeta_freq1, zeta_freq2 = ( + # self.inv_hc.zeta(alpha_s=alpha_s_freq1, r=stg.r[freq1, :], M_profile_fine=M_profile_fine), + # self.inv_hc.zeta(alpha_s=alpha_s_freq2, r=stg.r[freq2, :], M_profile_fine=M_profile_fine)) + # # zeta_freq1, zeta_freq2 = zeta_freq1*1e-8, zeta_freq2*1e-8 + # # zeta_freq1 = 0.06417348381928434 + # # zeta_freq2 = 0.06774089842814904 + # # zeta_freq1, zeta_freq2 = 0.03018602, 0.05496619 + # print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}") + # + # # zeta_freq1, zeta_freq2 = 1e-10*self.inv_hc.zeta(ind=1), 1e1*self.inv_hc.zeta(ind=2) + # # print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}") + # + # # --- Fill spinboxes with values of parameters --- + # self.spinbox_ks_freq1.setValue(ks_freq1) + # self.spinbox_ks_freq2.setValue(ks_freq2) + # self.spinbox_sv_freq1.setValue(sv_freq1) + # self.spinbox_sv_freq2.setValue(sv_freq2) + # self.spinbox_X.setValue(X_exponent) + # self.spinbox_alphas_freq1.setValue(alpha_s_freq1) + # self.spinbox_alphas_freq2.setValue(alpha_s_freq2) + # self.spinbox_zeta_freq1.setValue(zeta_freq1) + # self.spinbox_zeta_freq2.setValue(zeta_freq2) + # + # # fig, ax = plt.subplots(nrows=2, ncols=1) + # # pcm1 = ax[0].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq1, + # # cmap='rainbow', shading='gouraud') + # # cbar1 = fig.colorbar(pcm1, ax=ax[0], shrink=1, location='right') + # # cbar1.set_label(label='J (/m', rotation=270, labelpad=15) + # # pcm2 = ax[1].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq2, + # # cmap='rainbow', shading='gouraud') + # # cbar2 = fig.colorbar(pcm2, ax=ax[1], shrink=1, location='right') + # # cbar2.set_label(label='J (/m', rotation=270, labelpad=15) + # # fig.supxlabel("Time (sec)", fontsize=10) + # # fig.supylabel("Depth (m)", fontsize=10) + # # plt.show() + # + # stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.freq[freq1], stg.freq[freq2], + # zeta_freq1, zeta_freq2, + # J_freq1, J_freq2, + # stg.r_2D[freq2, :, :stg.t.shape[1]], + # alpha_w_freq1, alpha_w_freq2, + # X_exponent) + # + # + # + # stg.SSC_fine = self.inv_hc.SSC_fine(zeta_freq2, stg.r_2D[freq2, :, :stg.t.shape[1]], + # stg.VBI_cross_section, stg.freq[freq2], X_exponent, J_freq2, + # np.full(shape=(stg.r.shape[1], stg.t.shape[1]), fill_value=alpha_w_freq2)) + # # stg.SSC_fine = self.inv_hc.SSC_fine(stg.zeta[int(self.combobox_frequency_SSC.currentIndex())], + # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.t.shape[1]], + # # stg.VBI_cross_section, + # # stg.frequency_to_compute_SSC[1], + # # stg.X_exponent, + # # stg.J_cross_section[self.combobox_frequency_SSC.currentIndex(), :, :]) + # # print("SSC fine shape ", stg.SSC_fine.shape) + # + # stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section, stg.freq[freq2], X_exponent, ks_freq2) + # # stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section, + # # stg.frequency_to_compute_SSC[1], + # # stg.X_exponent, + # # stg.ks) + # + # # print("SSC sand shape ", stg.SSC_sand.shape) + # + # # def plot_SSC_2D_fields(self): + # # + # # if self.canvas_SSC_2D_field == None: + # # + # # 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() + # # + # # else: + # # + # # self.verticalLayout_groupbox_SSC_2D_field.removeWidget(self.canvas_SSC_2D_field) + # # self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field) + # # + # # self.plot_SSC_fine() + # # self.plot_SSC_sand() + # + # # 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() + # + # # 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.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): + # self.axis_SSC_sand_vertical_profile.cla() # - # if ((self.combobox_fig_choice.currentText() == "Inverted SSC fine vertical profile") or - # (self.combobox_fig_choice.currentText() == "Inverted SSC sand vertical profile")): + # # --- 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) - # - # # --- 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())) - - + # 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() + # + # + # diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index 06fb409..4e972a6 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -277,12 +277,18 @@ 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())) + stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()].clear() + (stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()]. + append((stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex()], + self.combobox_freq1.currentIndex()))) + (stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()]. + append((stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()], + self.combobox_freq2.currentIndex()))) + + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()].clear() + stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()].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) @@ -705,12 +711,14 @@ class SedimentCalibrationTab(QWidget): # --- Compute J --- if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - depth_2D = np.zeros(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape) + stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( + np.zeros(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape)) for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - depth_2D[f, :, :] = np.repeat(np.transpose(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()] + stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][f, :, :] = ( + np.repeat(np.transpose(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()] [self.combobox_freq1.currentIndex()])[:, np.newaxis], stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], - axis=1) + axis=1)) print("kt cor ", stg.kt_corrected) print("kt read", stg.kt_read) @@ -736,20 +744,20 @@ class SedimentCalibrationTab(QWidget): J_cross_section_freq1 = self.inv_hc.j_cross_section( BS=stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex(), :, :], - r2D=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_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_freq2.currentIndex(), :, :], - r2D=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_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - depth_2D = np.zeros(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape) + stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = np.zeros(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape) for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - depth_2D[f, :, :] = np.repeat( + stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][f, :, :] = np.repeat( np.transpose(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()] [self.combobox_freq1.currentIndex()])[:, np.newaxis], stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], @@ -771,20 +779,20 @@ 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=depth_2D[self.combobox_freq1.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_freq1.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=depth_2D[self.combobox_freq2.currentIndex(), :, :], + r2D=stg.depth_2D[self.combobox_freq2.currentIndex(), :, :][self.combobox_freq2.currentIndex(), :, :], kt=kt3D[self.combobox_freq2.currentIndex(), :, :]) else: - depth_2D = np.zeros(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape) + stg.depth_2D = np.zeros(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape) for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - depth_2D[f, :, :] = np.repeat( + stg.depth_2D[f, :, :] = np.repeat( np.transpose(stg.depth[self.combobox_acoustic_data_choice.currentIndex()] [self.combobox_freq1.currentIndex()])[:, np.newaxis], stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], @@ -806,17 +814,15 @@ 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=depth_2D[self.combobox_freq1.currentIndex(), :, :], + r2D=stg.depth_2D[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=depth_2D[self.combobox_freq2.currentIndex(), :, :], + r2D=stg.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) @@ -909,3 +915,5 @@ class SedimentCalibrationTab(QWidget): self.spinbox_zeta_freq2.clear() self.spinbox_zeta_freq2.setValue(zeta_freq2) + + diff --git a/settings.py b/settings.py index 00bd434..2812a51 100644 --- a/settings.py +++ b/settings.py @@ -153,6 +153,9 @@ sand_sample_target_indice = [] Ctot_fine_per_cent = [] Ctot_sand_per_cent = [] +fine_sample_position = [] +sand_sample_position = [] + # --- Acoustic inversion method --- temperature = [] @@ -164,8 +167,8 @@ water_velocity = [] # kt_corrected_3D = np.array([]) frequencies_to_compute_VBI = np.array([]) -VBI_cross_section = np.array([]) -VBI_stream_bed = np.array([[[]]]) +VBI_cross_section = [] +# VBI_stream_bed = np.array([[[]]]) # --- Sediment Calibration frequencies_for_calibration = [] @@ -183,8 +186,8 @@ J_cross_section = [] frequency_for_inversion = [] -SSC_fine = np.array([[]]) -SSC_sand = np.array([[]]) +SSC_fine = [] +SSC_sand = [] # --- Save study ---