diff --git a/Model/acoustic_inversion_method_high_concentration.py b/Model/acoustic_inversion_method_high_concentration.py index e7d7164..b7c943c 100644 --- a/Model/acoustic_inversion_method_high_concentration.py +++ b/Model/acoustic_inversion_method_high_concentration.py @@ -207,70 +207,134 @@ class AcousticInversionMethodHighConcentration(): # ------------- Computing interpolation of fine SSC data obtained from water sampling ------------- # ------------- collected at various depth in the vertical sample ------------- + # def M_profile_SCC_fine_interpolated(self, sample_depth, M_profile, range_cells, r_bottom): + # res = np.zeros((len(range_cells),)) * np.nan + # for i in range(len(M_profile) - 1): + # # print(f"i = {i}") + # r_ini = sample_depth[i] + # # print(f"r_ini = {r_ini}") + # c_ini = M_profile[i] + # # print(f"c_ini = {c_ini}") + # r_end = sample_depth[i + 1] + # # print(f"r_end = {r_end}") + # c_end = M_profile[i + 1] + # # print(f"c_end = {c_end}") + # + # # Computing the linear equation + # a = (c_end - c_ini) / (r_end - r_ini) + # # print(f"a = {a}") + # b = c_ini - a * r_ini + # # print(f"b = {b}") + # + # # Finding the indices of r_ini and r_end in the interpolated array + # # print(f"range_cells = {range_cells}") + # loc = (range_cells >= r_ini) * (range_cells < r_end) + # # print(f"loc = {loc}") + # # print(f"loc shape = {len(loc)}") + # + # # Filling the array with interpolation values + # res[loc] = range_cells[loc] * a + b + # # print(res.shape) + # # print(f"res = {res}") + # # print(f"1. res.shape = {res.shape}") + # + # # Filling first and last values + # i = 0 + # while np.isnan(res[i]): + # res[i] = M_profile[0] + # i += 1 + # + # # Filling the last values + # i = -1 + # while np.isnan(res[i]): + # res[i] = M_profile[-1] + # i += -1 + # # print(f"res.shape = {res.shape}") + # # print(f"res = {res}") + # # print(f"r_bottom.shape = {r_bottom.shape}") + # # print(f" = {res}") + # + # if r_bottom.shape != (0,): + # res[np.where(range_cells > r_bottom)] = np.nan + # + # loc_point_lin_interp0 = range_cells[np.where((range_cells > sample_depth[0]) & (range_cells < sample_depth[-1]))] + # # print(f"range_cells : {range_cells}") + # # print(f"loc_point_lin_interp0 shape : {len(loc_point_lin_interp0)}") + # # print(f"loc_point_lin_interp0 : {loc_point_lin_interp0}") + # res0 = res[np.where((range_cells > sample_depth[0]) & (range_cells < sample_depth[-1]))] + # + # loc_point_lin_interp = loc_point_lin_interp0[np.where(loc_point_lin_interp0 > range_cells[0])] + # # print(f"loc_point_lin_interp shape : {len(loc_point_lin_interp)}") + # # print(f"loc_point_lin_interp : {loc_point_lin_interp}") + # res = res0[np.where(loc_point_lin_interp0 > range_cells[0])] + # + # # fig, ax = plt.subplots(nrows=1, ncols=1) + # # ax.plot(loc_point_lin_interp, res[:len(loc_point_lin_interp)], marker="*", mfc="blue") + # # ax.plot(sample_depth, M_profile, marker="o", mfc="k", mec="k") + # # plt.show() + # + # return (loc_point_lin_interp, res) + def M_profile_SCC_fine_interpolated(self, sample_depth, M_profile, range_cells, r_bottom): res = np.zeros((len(range_cells),)) * np.nan - for i in range(len(M_profile) - 1): - # print(f"i = {i}") - r_ini = sample_depth[i] - # print(f"r_ini = {r_ini}") - c_ini = M_profile[i] - # print(f"c_ini = {c_ini}") - r_end = sample_depth[i + 1] - # print(f"r_end = {r_end}") - c_end = M_profile[i + 1] - # print(f"c_end = {c_end}") - + l0 = sample_depth + print("l0 = ", l0) + l1 = [l0.index(x) for x in sorted(l0)] + print("l1 = ", l1) + l2 = [l0[k] for k in l1] + print("l2 = ", l2) + c1 = [list(M_profile)[j] for j in l1] + print("c1 = ", c1) + for i in range(len(c1) - 1): + # print("i = ", i) + r_ini = l2[i] + c_ini = c1[i] + r_end = l2[i + 1] + c_end = c1[i + 1] + print("r_ini ", r_ini, "c_ini ", c_ini, "r_end ", r_end, "c_end ", c_end) # Computing the linear equation a = (c_end - c_ini) / (r_end - r_ini) - # print(f"a = {a}") b = c_ini - a * r_ini - # print(f"b = {b}") + print("range_cells ", (range_cells)) # Finding the indices of r_ini and r_end in the interpolated array - # print(f"range_cells = {range_cells}") loc = (range_cells >= r_ini) * (range_cells < r_end) - # print(f"loc = {loc}") - # print(f"loc shape = {len(loc)}") - + print("range_cells >= r_ini ", range_cells >= r_ini) + print("range_cells < r_end ", range_cells < r_end) + print("loc ", loc) # Filling the array with interpolation values res[loc] = range_cells[loc] * a + b - # print(res.shape) - # print(f"res = {res}") - # print(f"1. res.shape = {res.shape}") + + print("a = ", a, "b = ", b) + + print("res ", res) # Filling first and last values i = 0 while np.isnan(res[i]): - res[i] = M_profile[0] + res[i] = c1[0] i += 1 # Filling the last values i = -1 while np.isnan(res[i]): - res[i] = M_profile[-1] + res[i] = c1[-1] i += -1 - # print(f"res.shape = {res.shape}") - # print(f"res = {res}") - # print(f"r_bottom.shape = {r_bottom.shape}") - # print(f" = {res}") - if r_bottom.shape != (0,): + if r_bottom.size != 0: res[np.where(range_cells > r_bottom)] = np.nan - loc_point_lin_interp0 = range_cells[np.where((range_cells > sample_depth[0]) & (range_cells < sample_depth[-1]))] - # print(f"range_cells : {range_cells}") - # print(f"loc_point_lin_interp0 shape : {len(loc_point_lin_interp0)}") - # print(f"loc_point_lin_interp0 : {loc_point_lin_interp0}") - res0 = res[np.where((range_cells > sample_depth[0]) & (range_cells < sample_depth[-1]))] + loc_point_lin_interp0 = range_cells[np.where((range_cells > l2[0]) & (range_cells < l2[-1]))] + res0 = res[np.where((range_cells > l2[0]) & (range_cells < l2[-1]))] - loc_point_lin_interp = loc_point_lin_interp0[np.where(loc_point_lin_interp0 > range_cells[0])] - # print(f"loc_point_lin_interp shape : {len(loc_point_lin_interp)}") - # print(f"loc_point_lin_interp : {loc_point_lin_interp}") - res = res0[np.where(loc_point_lin_interp0 > range_cells[0])] + loc_point_lin_interp = loc_point_lin_interp0[np.where(loc_point_lin_interp0 > l2[0])] + res = res0[np.where(loc_point_lin_interp0 > l2[0])] # fig, ax = plt.subplots(nrows=1, ncols=1) - # ax.plot(loc_point_lin_interp, res[:len(loc_point_lin_interp)], marker="*", mfc="blue") - # ax.plot(sample_depth, M_profile, marker="o", mfc="k", mec="k") + # ax.plot(res[:len(loc_point_lin_interp)], -loc_point_lin_interp, marker="*", mfc="blue") + # ax.plot(c1, [-x for x in l2], marker="o", mfc="k", mec="k", ls="None") + # ax.set_xlabel("Concentration (g/L)") + # ax.set_ylabel("Depth (m)") # plt.show() return (loc_point_lin_interp, res) diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index f0d3bf7..c6c1561 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -1856,9 +1856,9 @@ class AcousticDataTab(QWidget): self.label_date_acoustic_file.setText("Date: ") self.label_hour_acoustic_file.clear() self.label_hour_acoustic_file.setText("Hour: ") - self.spinbox_temperature.clear() - self.spinbox_speed_of_sound.clear() - self.spinbox_sound_attenuation.clear() + self.spinbox_temperature.setValue(0) + self.spinbox_speed_of_sound.setValue(0) + self.spinbox_sound_attenuation.setValue(0) self.combobox_frequency_information.clear() self.label_profiles_value.clear() self.label_profiles_per_sec_value.clear() @@ -1867,9 +1867,9 @@ class AcousticDataTab(QWidget): self.label_pulse_length_value.clear() self.label_pings_per_sec_value.clear() self.label_pings_per_profile_value.clear() - self.spinbox_kt.clear() - self.spinbox_rx.clear() - self.spinbox_tx.clear() + self.spinbox_kt.setValue(0) + self.spinbox_rx.setValue(0) + self.spinbox_tx.setValue(0) # --- Clear display options --- @@ -1893,18 +1893,43 @@ class AcousticDataTab(QWidget): self.tableModel = TableModel(data) self.tableView.setModel(self.tableModel) - # --- Clear figures --- - self.canvas_BS.figure.clear() - self.fig_BS.clf() - print("axis BS : ", self.axis_BS) - self.axis_BS.tolist().clear() - print("clear axis BS : ", self.axis_BS) - self.canvas_plot_profile.figure.clear() - self.fig_profile.clear() - self.axis_profile.clear() + # --- Clear figure : 2D plot of the acoustic recording --- + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.toolbar_BS) + + self.canvas_BS = FigureCanvas() + self.toolbar_BS = NavigationToolBar(self.canvas_BS, self) + self.scroll_BS.setWidget(self.canvas_BS) + + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.toolbar_BS) + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) + + # --- Clear figure : profile --- + self.combobox_frequency_profile.clear() + + self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) + self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile) + + self.canvas_plot_profile = FigureCanvas() + self.toolbar_profile = NavigationToolBar(self.canvas_plot_profile, self) + + self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) + self.slider.setValue(0) self.slider.setMaximum(10) + # if self.line + # self.fig_BS.clf() + # print("axis BS : ", self.axis_BS) + # self.axis_BS.tolist().clear() + # print("clear axis BS : ", self.axis_BS) + # self.canvas_plot_profile.figure.clear() + # self.fig_profile.clear() + # self.axis_profile.clear() + # self.slider.setValue(0) + # self.slider.setMaximum(10) + def clear_files_from_ListWidget(self): # if self.fileListWidget.count() > 0: @@ -1928,9 +1953,9 @@ class AcousticDataTab(QWidget): self.label_date_acoustic_file.setText("Date: ") self.label_hour_acoustic_file.clear() self.label_hour_acoustic_file.setText("Hour: ") - self.spinbox_temperature.clear() - self.spinbox_speed_of_sound.clear() - self.spinbox_sound_attenuation.clear() + self.spinbox_temperature.setValue(0) + self.spinbox_speed_of_sound.setValue(0) + self.spinbox_sound_attenuation.setValue(0) self.combobox_frequency_information.clear() self.label_profiles_value.clear() self.label_profiles_per_sec_value.clear() @@ -1939,9 +1964,9 @@ class AcousticDataTab(QWidget): self.label_pulse_length_value.clear() self.label_pings_per_sec_value.clear() self.label_pings_per_profile_value.clear() - self.spinbox_kt.clear() - self.spinbox_rx.clear() - self.spinbox_tx.clear() + self.spinbox_kt.setValue(0) + self.spinbox_rx.setValue(0) + self.spinbox_tx.setValue(0) # --- Clear display options --- @@ -1980,7 +2005,32 @@ class AcousticDataTab(QWidget): # print("1 fig profile : ", self.fig_profile) # # self.axis_profile.clear() + # --- Clear figure : 2D plot of the acoustic recording --- + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.toolbar_BS) + + self.canvas_BS = FigureCanvas() + self.toolbar_BS = NavigationToolBar(self.canvas_BS, self) + self.scroll_BS.setWidget(self.canvas_BS) + + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.toolbar_BS) + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) + + # --- Clear figure : profile --- self.combobox_frequency_profile.clear() + + self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) + self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile) + + self.canvas_plot_profile = FigureCanvas() + self.toolbar_profile = NavigationToolBar(self.canvas_plot_profile, self) + + self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) + + self.slider.setValue(0) + self.slider.setMaximum(10) + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) # self.canvas_BS = FigureCanvas() # self.scroll_BS.setWidget(self.canvas_BS) @@ -1996,22 +2046,21 @@ class AcousticDataTab(QWidget): # self.canvas_plot_profile = FigureCanvas() # self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) - self.canvas_BS.figure.clear() - self.fig_BS.clf() - print("axis BS : ", self.axis_BS) - self.axis_BS.tolist().clear() - print("clear axis BS : ", self.axis_BS) - self.canvas_BS = FigureCanvas() - self.scroll_BS.setWidget(self.canvas_BS) + # self.canvas_BS.figure.clear() + # self.fig_BS.clf() + # print("axis BS : ", self.axis_BS) + # self.axis_BS.tolist().clear() + # print("clear axis BS : ", self.axis_BS) + # self.canvas_BS = FigureCanvas() + # self.scroll_BS.setWidget(self.canvas_BS) + # + # self.canvas_plot_profile.figure.clear() + # self.fig_profile.clear() + # self.axis_profile.clear() + # self.canvas_plot_profile = FigureCanvas() + # self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) - self.canvas_plot_profile.figure.clear() - self.fig_profile.clear() - self.axis_profile.clear() - self.canvas_plot_profile = FigureCanvas() - self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) - self.slider.setValue(0) - self.slider.setMaximum(10) def load_BS_acoustic_raw_data(self): @@ -2069,7 +2118,7 @@ class AcousticDataTab(QWidget): stg.nb_pings_per_sec.append(acoustic_data._nb_pings_per_sec) stg.nb_pings_averaged_per_profile.append(acoustic_data._nb_pings_averaged_per_profile) stg.kt_read.append(acoustic_data._kt) - # stg.kt_corrected.append(acoustic_data._kt) + stg.kt_corrected.append([0]*len(stg.kt_read[-1])) stg.gain_rx.append(acoustic_data._gain_rx) stg.gain_tx.append(acoustic_data._gain_tx) stg.temperature.append(0) @@ -2121,15 +2170,15 @@ 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.FCB.append([]) - stg.depth_real.append([]) - stg.lin_reg.append(tuple()) - - stg.frequencies_for_calibration.append([]) - stg.frequency_for_inversion.append([]) - - stg.fine_sample_position.append([]) - stg.sand_sample_position.append([]) + # stg.FCB.append([]) + # stg.depth_real.append([]) + # stg.lin_reg.append(tuple()) + # + # 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([])) @@ -2186,6 +2235,8 @@ class AcousticDataTab(QWidget): self.combobox_frequency_information.addItems(stg.freq_text[self.fileListWidget.currentRow()]) self.combobox_frequency_information.currentIndexChanged.connect(self.combobox_frequency_information_update) + self.spinbox_temperature.setValue(0) + self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 7, 1, 1, 1) @@ -2214,7 +2265,7 @@ class AcousticDataTab(QWidget): [self.combobox_frequency_information.currentIndex()])) self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 13, 1, 1, 1) - stg.kt_corrected = deepcopy(stg.kt_read) + stg.kt_corrected[self.fileListWidget.currentRow()] = stg.kt_read[self.fileListWidget.currentRow()] # if self.checkbox_kt.isChecked(): # self.spinbox_kt.setValue( # stg.kt_corrected[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) @@ -2336,43 +2387,44 @@ class AcousticDataTab(QWidget): self.gridLayout_goupbox_info.removeWidget(self.label_profiles_value) self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) - self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 6, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 7, 1, 1, 1) self.label_profiles_per_sec_value.clear() self.label_profiles_per_sec_value.setText( str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) + " Hz") - self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 7, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 8, 1, 1, 1) self.label_cells_value.clear() self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) - self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 8, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 9, 1, 1, 1) self.label_cell_size_value.clear() self.gridLayout_goupbox_info.removeWidget(self.label_cell_size_value) self.label_cell_size_value.setText( str(100 * round(stg.cell_size[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()], 3)) + " cm") - self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 9, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 10, 1, 1, 1) self.label_pulse_length_value.clear() self.label_pulse_length_value.setText( str(round(stg.pulse_length[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()], 6)) + " sec") - self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 10, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 11, 1, 1, 1) self.label_pings_per_sec_value.clear() self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) + " Hz") - self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 11, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 12, 1, 1, 1) self.label_pings_per_profile_value.clear() self.label_pings_per_profile_value.setText( str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) - self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 12, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 13, 1, 1, 1) + print("stg.kt_corrected ", stg.kt_corrected) self.spinbox_kt.clear() if self.checkbox_kt.isChecked(): # print("combobox information update : checkbox checked") @@ -2422,20 +2474,23 @@ class AcousticDataTab(QWidget): def kt_value(self): # print(f"0 stg.kt_read : {stg.kt_read}") # print(f"0 stg.kt_corrected {stg.kt_corrected}") - if self.checkbox_kt.isChecked(): - stg.kt_corrected[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] = ( - self.spinbox_kt.value()) + if self.fileListWidget.count() > 0: + if self.checkbox_kt.isChecked(): + stg.kt_corrected[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] \ + = self.spinbox_kt.value() # print(f"1 stg.kt_read : {stg.kt_read}") # print(f"1 stg.kt_corrected {stg.kt_corrected}") def gain_rx_value(self): - stg.gain_rx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] =\ - self.spinbox_rx.value() + if self.fileListWidget.count() > 0: + stg.gain_rx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] = ( + self.spinbox_rx.value()) # print(f"stg.rx : {stg.gain_rx}") def gain_tx_value(self): - stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] =\ - self.spinbox_tx.value() + if self.fileListWidget.count() > 0: + stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] = ( + self.spinbox_tx.value()) # print(f"stg.tx : {stg.gain_tx}") def fill_table(self): diff --git a/View/acoustic_inversion_tab.py b/View/acoustic_inversion_tab.py index c509d52..7849302 100644 --- a/View/acoustic_inversion_tab.py +++ b/View/acoustic_inversion_tab.py @@ -2,10 +2,10 @@ import sys from PyQt5.QtWidgets import (QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox, QGridLayout, QLabel, QPushButton, QSpinBox, QDoubleSpinBox, QAbstractSpinBox, QSpacerItem, - QSizePolicy, QSlider, QLineEdit) + QSizePolicy, QSlider, QLineEdit, QMessageBox) from PyQt5.QtCore import QCoreApplication, Qt, pyqtSignal -from PyQt5.QtGui import QStandardItemModel, QIcon +from PyQt5.QtGui import QStandardItemModel, QIcon, QPixmap import numpy as np @@ -366,11 +366,9 @@ class AcousticInversionTab(QWidget): for i in range(len(stg.filename_BS_raw_data)): self.combobox_acoustic_data_choice.addItem(stg.filename_BS_raw_data[i]) - def function_run_inversion(self): - self.compute_VBI() - self.compute_SSC_fine() - self.compute_SSC_sand() + self.combobox_acoustic_data_choice.currentIndexChanged.connect(self.combobox_acoustic_data_choice_currentIndexChanged) + def combobox_acoustic_data_choice_currentIndexChanged(self): self.fill_combobox_fine_sample() self.plot_SSC_fine() self.plot_SSC_fine_vertical_profile() @@ -381,13 +379,40 @@ class AcousticInversionTab(QWidget): self.plot_SSC_sand_vertical_profile() self.plot_measured_vs_inverted_SSC_sand() + def function_run_inversion(self): + if (stg.alpha_s[0] < 0) or (stg.alpha_s[1] < 0): + + msgBox = QMessageBox() + msgBox.setWindowTitle("Alpha computation error") + msgBox.setIconPixmap( + QPixmap(self.path_icon + "no_approved.png").scaledToHeight(32, Qt.SmoothTransformation)) + msgBox.setText("Sediment sound attenuation is negative !") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + + else: + + self.compute_VBI() + self.compute_SSC_fine() + self.compute_SSC_sand() + + self.fill_combobox_fine_sample() + self.plot_SSC_fine() + self.plot_SSC_fine_vertical_profile() + self.plot_measured_vs_inverted_SSC_fine() + + self.fill_combobox_sand_sample() + self.plot_SSC_sand() + self.plot_SSC_sand_vertical_profile() + self.plot_measured_vs_inverted_SSC_sand() def compute_VBI(self): + stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) print("compute VBI") - 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.frequencies_for_calibration[0][0], + stg.frequencies_for_calibration[1][0]) + print(stg.frequency_for_inversion) print(stg.zeta[0], stg.zeta[1]) print(stg.J_cross_section[0].shape, stg.J_cross_section[0].shape) print(stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()].shape) @@ -395,12 +420,12 @@ class AcousticInversionTab(QWidget): print(stg.X_exponent[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], + freq1=stg.frequencies_for_calibration[0][0], + freq2=stg.frequencies_for_calibration[1][0], zeta_freq1=stg.zeta[0], zeta_freq2=stg.zeta[1], j_cross_section_freq1=stg.J_cross_section[0], j_cross_section_freq2=stg.J_cross_section[1], r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.frequency_for_inversion[1]], water_attenuation_freq1=stg.alpha_s[0], water_attenuation_freq2=stg.alpha_s[1], X=stg.X_exponent[0] ) @@ -409,41 +434,49 @@ class AcousticInversionTab(QWidget): def compute_SSC_fine(self): + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) print("Compute SSC fine - start") print(stg.zeta[1]) print(stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape) + stg.frequency_for_inversion[1]].shape) # print(stg.VBI_cross_section.shape) - print(stg.frequencies_for_calibration[self.combobox_acoustic_data_choice.currentIndex()][1][0]) + print(stg.frequencies_for_calibration[1][0]) print(stg.X_exponent[0]) print(stg.J_cross_section[1].shape) print(stg.water_attenuation) print(np.full(shape=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape, + stg.frequency_for_inversion[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.frequency_for_inversion[1]])) stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_fine( zeta=stg.zeta[1], r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.frequency_for_inversion[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], + freq=stg.frequencies_for_calibration[1][0], X=stg.X_exponent[0], j_cross_section=stg.J_cross_section[1], alpha_w=np.full(shape=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]].shape, + stg.frequency_for_inversion[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.frequency_for_inversion[1]]) ) print("stg.SSC_fine ", stg.SSC_fine) def compute_SSC_sand(self): + stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) + print("+++++++++++++++++++++") + print(stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape) + print(stg.frequencies_for_calibration[1][0]) + print(stg.X_exponent) + print(stg.ks[1]) + print("+++++++++++++++++++++") 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], + freq=stg.frequencies_for_calibration[1][0], X=stg.X_exponent, ks=stg.ks[1]) @@ -451,131 +484,181 @@ class AcousticInversionTab(QWidget): def plot_SSC_fine(self): - self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) - self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) + if self.combobox_acoustic_data_choice.count() > 0: - 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) + if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): - self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) - self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_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()]) + self.canvas_SSC_fine = FigureCanvas() + self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self) - print("ABS name ", stg.ABS_name) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) - if stg.ABS_name[0] == "Aquascat 1000R": + elif stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - print("hey !") + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + 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.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self) - print("hey hey !") + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) - # 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]) + 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()]) - pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], - -stg.depth_cross_section[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') + print("ABS name ", stg.ABS_name) - 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.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") + if stg.ABS_name[0] == "Aquascat 1000R": - 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("hey !") - 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") + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # 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") + print("hey hey !") - 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("time cross section ", stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1]]) + # print("depth cross section ", stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1]]) + # print(stg.frequency_for_inversion[1]) - 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) + pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()], + cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud') - else: + 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.frequency_for_inversion[1]], + -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], + color='black', linewidth=1, linestyle="solid") - pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( - 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') + 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[1], + self.slider_fine.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]].shape), + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + linestyle="solid", color='r', linewidth=2) - 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.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") + print("o+o+o+o+o+o") + print(stg.frequency_for_inversion[1]) + print([i for i, _ in stg.fine_sample_position]) + # print([stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1], i] + # for i, _ in stg.fine_sample_position]) + print("o+o+o+o+o+o") - 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") + # 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[1], i] + # for i, _ in stg.fine_sample_position], + # [-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1], j] + # for _, j in stg.fine_sample_position], + # 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) + 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") - elif stg.ABS_name[0] == "UB-SediFlow": - pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(stg.t[0, :], - -stg.r[0, :], - stg.SSC_fine, - cmap='rainbow', - norm=LogNorm(vmin=1e-2, vmax=10), - shading='gouraud') + 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) - 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() + else: + + pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( + stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()], + cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud') + + self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot( + stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1], + self.slider_fine.value() - 1] * + np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[ + 1]].shape), + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + linestyle="solid", color='r', linewidth=2) + + 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.frequency_for_inversion[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_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) + + # self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot( + # [stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1], i] + # for i, _ in stg.fine_sample_position], + # [-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1], j] + # for _, j in stg.fine_sample_position], + # 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) + + elif stg.ABS_name[0] == "UB-SediFlow": + pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(stg.t[0, :], + -stg.r[0, :], + stg.SSC_fine, + cmap='rainbow', + norm=LogNorm(vmin=1e-2, vmax=10), + shading='gouraud') + + 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 self.combobox_acoustic_data_choice.count() > 0: + + if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): + + 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.canvas_profile_fine = FigureCanvas() + self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) + + 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.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -588,7 +671,7 @@ class AcousticInversionTab(QWidget): 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.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine) self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine) @@ -598,47 +681,47 @@ class AcousticInversionTab(QWidget): 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]], + stg.frequency_for_inversion[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], + stg.frequency_for_inversion[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.frequency_for_inversion[1]].shape), -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[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]]), + stg.frequency_for_inversion[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]])]) + stg.frequency_for_inversion[1]])]) else: - self.axis_vertical_profile_SSC_fine.plot( + 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[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.frequency_for_inversion[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.frequency_for_inversion[1], self.slider_fine.value() - 1] * + np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]].shape), -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[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]]), + stg.frequency_for_inversion[1]]), -np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])]) + stg.frequency_for_inversion[1]])]) # self.axis_SSC_fine.plot([], [], ) @@ -658,46 +741,46 @@ class AcousticInversionTab(QWidget): 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]]) + stg.frequency_for_inversion[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], + stg.frequency_for_inversion[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.frequency_for_inversion[1]].shape), -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[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]]), + stg.frequency_for_inversion[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]])]) + stg.frequency_for_inversion[1]])]) else: - self.axis_vertical_profile_SSC_fine.set_data( + self.plot_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]]) + stg.frequency_for_inversion[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.frequency_for_inversion[1], self.slider_fine.value() - 1] * + np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]].shape), -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[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]]), + stg.frequency_for_inversion[1]]), -np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])]) + stg.frequency_for_inversion[1]])]) self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)") self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)") @@ -737,29 +820,29 @@ class AcousticInversionTab(QWidget): (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]]) + stg.frequency_for_inversion[1]]) print(stg.depth_fine) for j in range(len(stg.time_fine)): - (stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + (stg.fine_sample_position. 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]) + stg.frequency_for_inversion[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])) + stg.frequency_for_inversion[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])) + stg.frequency_for_inversion[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]))) + stg.frequency_for_inversion[1]] - (-stg.depth_fine[j]))) )[0][0] ) ) @@ -772,24 +855,24 @@ class AcousticInversionTab(QWidget): for j in range(len(stg.time_fine)): - (stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + (stg.fine_sample_position. 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]) + stg.frequency_for_inversion[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])) + stg.frequency_for_inversion[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])) + stg.frequency_for_inversion[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]))) + stg.frequency_for_inversion[1]] - (-stg.depth_fine[j]))) )[0][0] ) ) @@ -802,24 +885,24 @@ class AcousticInversionTab(QWidget): for j in range(len(stg.time_fine)): - (stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + (stg.fine_sample_position. 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]) + stg.frequency_for_inversion[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])) + stg.frequency_for_inversion[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])) + stg.frequency_for_inversion[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]))) + stg.frequency_for_inversion[1]] - (-stg.depth_fine[j]))) )[0][0] ) ) @@ -832,24 +915,24 @@ class AcousticInversionTab(QWidget): for j in range(len(stg.time_fine)): - (stg.fine_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + (stg.fine_sample_position. 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]) + stg.frequency_for_inversion[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])) + stg.frequency_for_inversion[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])) + stg.frequency_for_inversion[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]))) + stg.frequency_for_inversion[1]] - (-stg.depth_fine[j]))) )[0][0] ) ) @@ -859,120 +942,131 @@ class AcousticInversionTab(QWidget): 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) + if self.combobox_acoustic_data_choice.count() > 0: - self.figure_measured_vs_inverted_fine, self.axis_measured_vs_inverted_fine = ( - plt.subplots(nrows=1, ncols=1, layout="constrained")) + if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): - 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.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.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.canvas_inverted_vs_measured_SSC_fine = FigureCanvas() + self.toolbar_inverted_vs_measured_SSC_fine = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_fine, self) - 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()) + 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.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) + else: - # 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]]) + 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) - if self.fine_sample_to_plot: + self.figure_measured_vs_inverted_fine, self.axis_measured_vs_inverted_fine = ( + plt.subplots(nrows=1, ncols=1, layout="constrained")) - 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.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.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" - ) + 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) - # --- 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) + 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()) - else: + 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) - 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" - ) + # for k in self.fine_sample_to_plot: + # print("stg.Ctot_fine[k] ", stg.Ctot_fine[k]) + # print(stg.fine_sample_position[k][1]) + # print(stg.fine_sample_position[k][0]) + # print(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.fine_sample_position[k][1], + # stg.fine_sample_position[k][0]]) - 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" - ) + if self.fine_sample_to_plot: - 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.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[k][1], + stg.fine_sample_position[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.set_xlabel("Measured SSC fine (g/L)") - self.axis_measured_vs_inverted_fine.set_ylabel("Inverted SSC fine (g/L)") + 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[i][1], + stg.fine_sample_position[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[i][1], + stg.fine_sample_position[i][0]] + for i in self.fine_sample_to_plot])]) + 1], + ls="solid", linewidth=1, color="k" + ) - self.figure_measured_vs_inverted_fine.canvas.draw_idle() + # --- 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[i][1], + stg.fine_sample_position[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[k][1], + stg.fine_sample_position[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[i][1], + stg.fine_sample_position[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[i][1], + stg.fine_sample_position[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[j][1], + stg.fine_sample_position[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]] + # stg.frequency_for_inversion[1], + # stg.fine_sample_position[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]] + # stg.frequency_for_inversion[1], + # stg.fine_sample_position[j][1]] # for j in self.fine_sample_to_plot] # ) @@ -987,134 +1081,182 @@ class AcousticInversionTab(QWidget): def plot_SSC_sand(self): - self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.toolbar_SSC_sand) - self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.canvas_SSC_sand) + if self.combobox_acoustic_data_choice.count() > 0: - 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) + if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): - self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand) - self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand) + self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.toolbar_SSC_sand) + self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.canvas_SSC_sand) - val_min = np.nanmin(stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()]) - val_max = np.nanmax(stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()]) + self.canvas_SSC_sand = FigureCanvas() + self.toolbar_SSC_sand = NavigationToolBar(self.canvas_SSC_sand, self) - print("ABS name ", stg.ABS_name) - - if stg.ABS_name[0] == "Aquascat 1000R": - - print("hey !") - - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - - print("hey hey !") - - # print("time cross section ", stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # stg.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_sand = self.axis_SSC_sand.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], - -stg.depth_cross_section[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_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - 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_sand_vertical_line, = self.axis_SSC_sand.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_sand.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.sand_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_sand_meas_vs_inv, = self.axis_SSC_sand.plot(stg.time_sand, stg.depth_sand, - ls=" ", marker="o", ms=5, mec="k", mfc="k") - - print(stg.time_sand) - print(stg.depth_sand) - print([f for _, f in stg.sample_sand]) - for i, j in stg.sample_sand: - self.pcm_SSC_sand_meas_vs_inv_text = self.axis_SSC_sand.text( - stg.time_sand[j], - stg.depth_sand[j], - i) + self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand) + self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand) else: - pcm_SSC_sand = self.axis_SSC_sand.pcolormesh( - 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') + self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.toolbar_SSC_sand) + self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.canvas_SSC_sand) - 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.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.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.toolbar_SSC_sand = NavigationToolBar(self.canvas_SSC_sand, self) - self.pcm_SSC_sand_meas_vs_inv, = self.axis_SSC_sand.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.sand_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.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()]], - ls=" ", marker="o", ms=5, mec="k", mfc="k") + self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand) + self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand) - 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='Fine SSC (g/L', rotation=270, labelpad=15) + val_min = np.nanmin(stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()]) + val_max = np.nanmax(stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()]) - elif stg.ABS_name[0] == "UB-SediFlow": - pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :], - -stg.r[0, :], - stg.SSC_sand, - cmap='rainbow', - norm=LogNorm(vmin=1e-2, vmax=10), - shading='gouraud') + print("ABS name ", stg.ABS_name) - 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() + if stg.ABS_name[0] == "Aquascat 1000R": + + print("hey !") + + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + print("hey hey !") + + # print("time cross section ", stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1]]) + # print("depth cross section ", stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1]]) + # print(stg.frequency_for_inversion[1]) + + pcm_SSC_sand = self.axis_SSC_sand.pcolormesh( + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[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_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], + color='black', linewidth=1, linestyle="solid") + + self.pcm_SSC_sand_vertical_line, = self.axis_SSC_sand.plot( + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1], + self.slider_sand.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[ + 1]].shape), + -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + linestyle="solid", color='r', linewidth=2) + + print("o+o+o+o+o+o") + print(stg.frequency_for_inversion[1]) + print([i for i, _ in stg.sand_sample_position]) + # print([stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1], i] + # for i, _ in stg.fine_sample_position]) + 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[1], i] + # for i, _ in stg.fine_sample_position], + # [-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1], j] + # for _, j in stg.fine_sample_position], + # ls=" ", marker="o", ms=5, mec="k", mfc="k") + + self.pcm_SSC_sand_meas_vs_inv, = self.axis_SSC_sand.plot(stg.time_sand, stg.depth_sand, + ls=" ", marker="o", ms=5, mec="k", mfc="k") + + print(stg.time_sand) + print(stg.depth_sand) + print([f for _, f in stg.sample_sand]) + for i, j in stg.sample_sand: + self.pcm_SSC_sand_meas_vs_inv_text = self.axis_SSC_sand.text( + stg.time_sand[j], + stg.depth_sand[j], + i) + + else: + + pcm_SSC_sand = self.axis_SSC_sand.pcolormesh( + stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[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.frequency_for_inversion[1]], + -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], + color='black', linewidth=1, linestyle="solid") + + self.pcm_SSC_sand_vertical_line, = self.axis_SSC_sand.plot( + stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1], + self.slider_sand.value() - 1] * + np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[ + 1]].shape), + -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]], + linestyle="solid", color='r', linewidth=2) + + # self.pcm_SSC_sand_meas_vs_inv, = self.axis_SSC_sand.plot( + # [stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1], i] + # for i, _ in stg.sand_sample_position], + # [-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.frequency_for_inversion[1], j] + # for _, j in stg.sand_sample_position], + # ls=" ", marker="o", ms=5, mec="k", mfc="k") + + self.pcm_SSC_sand_meas_vs_inv, = self.axis_SSC_sand.plot(stg.time_sand, stg.depth_sand, + ls=" ", marker="o", ms=5, mec="k", mfc="k") + + print(stg.time_sand) + print(stg.depth_sand) + print([f for _, f in stg.sample_sand]) + for i, j in stg.sample_sand: + self.pcm_SSC_sand_meas_vs_inv_text = self.axis_SSC_sand.text( + stg.time_sand[j], + stg.depth_sand[j], + i) + + 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='Fine SSC (g/L', rotation=270, labelpad=15) + + elif stg.ABS_name[0] == "UB-SediFlow": + pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :], + -stg.r[0, :], + stg.SSC_sand, + cmap='rainbow', + norm=LogNorm(vmin=1e-2, vmax=10), + shading='gouraud') + + 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_SSC_sand_vertical_profile(self): - if stg.filename_BS_noise_data != []: + if self.combobox_acoustic_data_choice.count() > 0: + + if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): + + self.verticalLayout_groupbox_plot_vertical_profile_sand.removeWidget(self.toolbar_profile_sand) + self.verticalLayout_groupbox_plot_vertical_profile_sand.removeWidget(self.canvas_profile_sand) + + self.canvas_profile_sand = FigureCanvas() + self.toolbar_profile_sand = NavigationToolBar(self.canvas_profile_sand, self) + + self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.toolbar_profile_sand) + self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.canvas_profile_sand) if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1127,7 +1269,7 @@ class AcousticInversionTab(QWidget): nrows=1, ncols=1, layout="constrained") self.canvas_profile_sand = FigureCanvas(self.figure_vertical_profile_SSC_sand) - self.toolbar_profile_sand = NavigationToolBar(self.canvas_profile_sand) + self.toolbar_profile_sand = NavigationToolBar(self.canvas_profile_sand, self) self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.toolbar_profile_sand) self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.canvas_profile_sand) @@ -1137,47 +1279,47 @@ class AcousticInversionTab(QWidget): self.plot_sand , = self.axis_vertical_profile_SSC_sand.plot( stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_sand.value() -1], -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.frequency_for_inversion[1]], linestyle="solid", linewidth=1, color="k") self.pcm_SSC_sand_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], + stg.frequency_for_inversion[1], self.slider_sand.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.frequency_for_inversion[1]].shape), -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[1]]) self.figure_SSC_sand.canvas.draw_idle() self.axis_vertical_profile_SSC_sand.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]]), + stg.frequency_for_inversion[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]])]) + stg.frequency_for_inversion[1]])]) else: - self.axis_vertical_profile_SSC_sand.plot( + self.plot_sand , = self.axis_vertical_profile_SSC_sand.plot( stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_sand.value() -1], -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]], + stg.frequency_for_inversion[1]], linestyle="solid", linewidth=1, color="k") self.pcm_SSC_sand_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_sand.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.frequency_for_inversion[1], self.slider_sand.value() - 1] * + np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]].shape), -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[1]]) self.figure_SSC_sand.canvas.draw_idle() self.axis_vertical_profile_SSC_sand.set_ylim( [-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]), + stg.frequency_for_inversion[1]]), -np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])]) + stg.frequency_for_inversion[1]])]) # self.axis_SSC_fine.plot([], [], ) @@ -1197,46 +1339,46 @@ class AcousticInversionTab(QWidget): stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_sand.value() - 1], -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[1]]) self.pcm_SSC_sand_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], + stg.frequency_for_inversion[1], self.slider_sand.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.frequency_for_inversion[1]].shape), -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[1]]) self.figure_SSC_sand.canvas.draw_idle() self.axis_vertical_profile_SSC_sand.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]]), + stg.frequency_for_inversion[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]])]) + stg.frequency_for_inversion[1]])]) else: - self.axis_vertical_profile_SSC_sand.set_data( + self.plot_sand.set_data( stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_sand.value() - 1], -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[1]]) self.pcm_SSC_sand_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_sand.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.frequency_for_inversion[1], self.slider_sand.value() - 1] * + np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]].shape), -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]) + stg.frequency_for_inversion[1]]) self.figure_SSC_sand.canvas.draw_idle() self.axis_vertical_profile_SSC_sand.set_ylim( [-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]]), + stg.frequency_for_inversion[1]]), -np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[self.combobox_acoustic_data_choice.currentIndex()][0][1]])]) + stg.frequency_for_inversion[1]])]) self.axis_vertical_profile_SSC_sand.set_xlabel("Inverted Sand SSC (g/L)") self.axis_vertical_profile_SSC_sand.set_ylabel("Depth (m)") @@ -1276,29 +1418,29 @@ class AcousticInversionTab(QWidget): (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]]) + stg.frequency_for_inversion[1]]) print(stg.depth_fine) for j in range(len(stg.time_sand)): - (stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + (stg.sand_sample_position. 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_sand[j]) + stg.frequency_for_inversion[1]] - stg.time_sand[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_sand[j])) + stg.frequency_for_inversion[1]] - stg.time_sand[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_sand[j])) + stg.frequency_for_inversion[1]] - (-stg.depth_sand[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_sand[j]))) + stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))) )[0][0] ) ) @@ -1311,24 +1453,24 @@ class AcousticInversionTab(QWidget): for j in range(len(stg.time_sand)): - (stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + (stg.sand_sample_position. 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_sand[j]) + stg.frequency_for_inversion[1]] - stg.time_sand[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_sand[j])) + stg.frequency_for_inversion[1]] - stg.time_sand[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_sand[j])) + stg.frequency_for_inversion[1]] - (-stg.depth_sand[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_sand[j]))) + stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))) )[0][0] ) ) @@ -1341,24 +1483,24 @@ class AcousticInversionTab(QWidget): for j in range(len(stg.time_sand)): - (stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + (stg.sand_sample_position. 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_sand[j]) + stg.frequency_for_inversion[1]] - stg.time_sand[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_sand[j])) + stg.frequency_for_inversion[1]] - stg.time_sand[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_sand[j])) + stg.frequency_for_inversion[1]] - (-stg.depth_sand[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_sand[j]))) + stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))) )[0][0] ) ) @@ -1371,24 +1513,24 @@ class AcousticInversionTab(QWidget): for j in range(len(stg.time_sand)): - (stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()]. + (stg.sand_sample_position. 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_sand[j]) + stg.frequency_for_inversion[1]] - stg.time_sand[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_sand[j])) + stg.frequency_for_inversion[1]] - stg.time_sand[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_sand[j])) + stg.frequency_for_inversion[1]] - (-stg.depth_sand[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_sand[j]))) + stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))) )[0][0] ) ) @@ -1398,118 +1540,130 @@ class AcousticInversionTab(QWidget): def plot_measured_vs_inverted_SSC_sand(self): - self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget( - self.toolbar_inverted_vs_measured_SSC_sand) - self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget( - self.canvas_inverted_vs_measured_SSC_sand) + if self.combobox_acoustic_data_choice.count() > 0: - self.figure_measured_vs_inverted_sand, self.axis_measured_vs_inverted_sand = ( - plt.subplots(nrows=1, ncols=1, layout="constrained")) + if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): - self.canvas_inverted_vs_measured_SSC_sand = FigureCanvas(self.figure_measured_vs_inverted_sand) - 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.removeWidget( + self.toolbar_inverted_vs_measured_SSC_sand) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget( + self.canvas_inverted_vs_measured_SSC_sand) - 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.canvas_inverted_vs_measured_SSC_sand = FigureCanvas() + self.toolbar_inverted_vs_measured_SSC_sand = NavigationToolBar( + self.canvas_inverted_vs_measured_SSC_sand, self) - print("self.combobox_sand_sample_choice.currentData() ", self.combobox_sand_sample_choice.currentData()) - print("self.combobox_sand_sample_choice.currentIndex() ", self.combobox_sand_sample_choice.currentIndex()) + 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) - print("///////////////////////////////////////////////////") - self.sand_sample_to_plot = [int(f[1:]) - 1 for f in self.combobox_sand_sample_choice.currentData()] - print("self.sand_sample_to_plot ", self.sand_sample_to_plot) + else: - # 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]]) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget( + self.toolbar_inverted_vs_measured_SSC_sand) + self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget( + self.canvas_inverted_vs_measured_SSC_sand) - if self.sand_sample_to_plot: + self.figure_measured_vs_inverted_sand, self.axis_measured_vs_inverted_sand = ( + plt.subplots(nrows=1, ncols=1, layout="constrained")) - self.axis_measured_vs_inverted_sand.plot( - [stg.Ctot_sand[k] for k in self.sand_sample_to_plot], - [stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ - stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][1], - stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][0]] for k in - self.sand_sample_to_plot], - ls=" ", marker='o', ms=5, mec='black', mfc="black" - ) + self.canvas_inverted_vs_measured_SSC_sand = FigureCanvas(self.figure_measured_vs_inverted_sand) + self.toolbar_inverted_vs_measured_SSC_sand = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_sand, self) - self.axis_measured_vs_inverted_sand.plot( - [0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in self.sand_sample_to_plot]), - np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ - stg.sand_sample_position[ - self.combobox_acoustic_data_choice.currentIndex()][i][1], - stg.sand_sample_position[ - self.combobox_acoustic_data_choice.currentIndex()][i][0]] - for i in self.sand_sample_to_plot])]) + 1], - [0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in self.sand_sample_to_plot]), - np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ - stg.sand_sample_position[ - self.combobox_acoustic_data_choice.currentIndex()][i][1], - stg.sand_sample_position[ - self.combobox_acoustic_data_choice.currentIndex()][i][0]] - for i in self.sand_sample_to_plot])]) + 1], - ls="solid", linewidth=1, color="k" - ) + 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) - # --- Display sample label on plot --- - for i in self.sand_sample_to_plot: - self.axis_measured_vs_inverted_sand.text( - stg.Ctot_sand[i], - stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ - stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][1], - stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()][i][0]], - stg.sample_sand[i][0], - fontstyle="normal", fontweight="light", fontsize=10) + print("self.combobox_sand_sample_choice.currentData() ", self.combobox_sand_sample_choice.currentData()) + print("self.combobox_sand_sample_choice.currentIndex() ", self.combobox_sand_sample_choice.currentIndex()) - else: + print("///////////////////////////////////////////////////") + self.sand_sample_to_plot = [int(f[1:]) - 1 for f in self.combobox_sand_sample_choice.currentData()] + print("self.sand_sample_to_plot ", self.sand_sample_to_plot) - self.axis_measured_vs_inverted_sand.plot( - [stg.Ctot_sand[k] for k in range(len(stg.sample_sand))], - [stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ - stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][1], - stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()][k][0]] for k in - range(len(stg.sample_sand))], - ls=" ", marker='o', ms=5, mec='black', mfc="black" - ) + # for k in self.fine_sample_to_plot: + # print("stg.Ctot_fine[k] ", stg.Ctot_fine[k]) + # print(stg.fine_sample_position[k][1]) + # print(stg.fine_sample_position[k][0]) + # print(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][ + # stg.fine_sample_position[k][1], + # stg.fine_sample_position[k][0]]) - self.axis_measured_vs_inverted_sand.plot( - [0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in range(len(stg.sample_sand))]), - np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ - stg.sand_sample_position[ - self.combobox_acoustic_data_choice.currentIndex()][i][1], - stg.sand_sample_position[ - self.combobox_acoustic_data_choice.currentIndex()][i][0]] - for i in range(len(stg.sample_sand))])]) + 1], - [0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in range(len(stg.sample_sand))]), - np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ - stg.sand_sample_position[ - self.combobox_acoustic_data_choice.currentIndex()][i][1], - stg.sand_sample_position[ - self.combobox_acoustic_data_choice.currentIndex()][i][0]] - for i in range(len(stg.sample_sand))])]) + 1], - ls="solid", linewidth=1, color="k" - ) + if self.sand_sample_to_plot: - for j in range(len(stg.sample_sand)): - self.axis_measured_vs_inverted_sand.text( - stg.Ctot_sand[j], - stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ - stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()][j][1], - stg.sand_sample_position[self.combobox_acoustic_data_choice.currentIndex()][j][0]], - stg.sample_sand[j][0], - fontstyle="normal", fontweight="light", fontsize=10) + self.axis_measured_vs_inverted_sand.plot( + [stg.Ctot_sand[k] for k in self.sand_sample_to_plot], + [stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ + stg.sand_sample_position[k][1], + stg.sand_sample_position[k][0]] for k in + self.sand_sample_to_plot], + ls=" ", marker='o', ms=5, mec='black', mfc="black" + ) - self.axis_measured_vs_inverted_sand.set_xlabel("Measured SSC sand (g/L)") - self.axis_measured_vs_inverted_sand.set_ylabel("Inverted SSC sand (g/L)") + self.axis_measured_vs_inverted_sand.plot( + [0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in self.sand_sample_to_plot]), + np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ + stg.sand_sample_position[i][1], + stg.sand_sample_position[i][0]] + for i in self.sand_sample_to_plot])]) + 1], + [0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in self.sand_sample_to_plot]), + np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ + stg.sand_sample_position[i][1], + stg.sand_sample_position[i][0]] + for i in self.sand_sample_to_plot])]) + 1], + ls="solid", linewidth=1, color="k" + ) - self.figure_measured_vs_inverted_sand.canvas.draw_idle() + # --- Display sample label on plot --- + for i in self.sand_sample_to_plot: + self.axis_measured_vs_inverted_sand.text( + stg.Ctot_sand[i], + stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ + stg.sand_sample_position[i][1], + stg.sand_sample_position[i][0]], + stg.sample_sand[i][0], + fontstyle="normal", fontweight="light", fontsize=10) + + else: + + self.axis_measured_vs_inverted_sand.plot( + [stg.Ctot_sand[k] for k in range(len(stg.sample_sand))], + [stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ + stg.sand_sample_position[k][1], + stg.sand_sample_position[k][0]] for k in + range(len(stg.sample_sand))], + ls=" ", marker='o', ms=5, mec='black', mfc="black" + ) + + self.axis_measured_vs_inverted_sand.plot( + [0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in range(len(stg.sample_sand))]), + np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ + stg.sand_sample_position[i][1], + stg.sand_sample_position[i][0]] + for i in range(len(stg.sample_sand))])]) + 1], + [0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in range(len(stg.sample_sand))]), + np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ + stg.sand_sample_position[i][1], + stg.sand_sample_position[i][0]] + for i in range(len(stg.sample_sand))])]) + 1], + ls="solid", linewidth=1, color="k" + ) + + for j in range(len(stg.sample_sand)): + self.axis_measured_vs_inverted_sand.text( + stg.Ctot_sand[j], + stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][ + stg.sand_sample_position[j][1], + stg.sand_sample_position[j][0]], + stg.sample_sand[j][0], + fontstyle="normal", fontweight="light", fontsize=10) + + self.axis_measured_vs_inverted_sand.set_xlabel("Measured SSC sand (g/L)") + self.axis_measured_vs_inverted_sand.set_ylabel("Inverted SSC sand (g/L)") + + self.figure_measured_vs_inverted_sand.canvas.draw_idle() # -------------------------------------------------------------------------------------------------------------- diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index 007ff4b..b84df39 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -474,6 +474,7 @@ class SedimentCalibrationTab(QWidget): def function_pushbutton_update_acoustic_file(self): self.update_acoustic_data() + self.compute_depth_2D() def function_pushbutton_plot_sample(self): self.sample_choice_for_calibration() @@ -507,18 +508,18 @@ class SedimentCalibrationTab(QWidget): def plot_acoustic_recording(self): # --- Record frequencies for calibration --- - 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.frequencies_for_calibration.clear() + 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.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())) + stg.frequency_for_inversion = tuple() + stg.frequency_for_inversion = (stg.freq[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_freq2.currentIndex()], + self.combobox_freq2.currentIndex()) # --- Plot acoustic data recording --- self.verticalLayout_groupbox_data_plot.removeWidget(self.toolbar_BS) @@ -1154,6 +1155,78 @@ class SedimentCalibrationTab(QWidget): self.spinbox_zeta_freq2.clear() self.spinbox_zeta_freq2.setValue(float(data.iloc[4][1])) + def compute_depth_2D(self): + print("self.combobox_acoustic_data_choice.count() ", self.combobox_acoustic_data_choice.count()) + if self.combobox_acoustic_data_choice.count() > 0: + + for k in range(self.combobox_acoustic_data_choice.count()): + + if stg.depth_cross_section[k].shape != (0,): + + if stg.time_cross_section[k].shape != (0,): + + stg.depth_2D[k] = ( + np.zeros((stg.freq[k].shape[0], + stg.depth_cross_section[k].shape[1], + stg.time_cross_section[k].shape[1]))) + + for f, _ in enumerate(stg.freq[k]): + stg.depth_2D[k][f, :, :] = ( + np.repeat(np.transpose(stg.depth_cross_section[k] + [self.combobox_freq1.currentIndex()])[:, np.newaxis], + stg.time_cross_section[k].shape[1], + axis=1)) + + elif stg.time[k].shape != (0,): + + stg.depth_2D[k] = ( + np.zeros((stg.freq[k].shape[0], + stg.depth_cross_section[k].shape[1], + stg.time[k].shape[1]))) + + for f, _ in enumerate(stg.freq[k]): + stg.depth_2D[k][f, :, :] = ( + np.repeat( + np.transpose(stg.depth_cross_section[k] + [self.combobox_freq1.currentIndex()])[:, np.newaxis], + stg.time[k].shape[1], + axis=1)) + + elif stg.depth[k].shape != (0,): + + if stg.time_cross_section[k].shape != (0,): + + stg.depth_2D[k] = ( + np.zeros((stg.freq[k].shape[0], + stg.depth[k].shape[1], + stg.time_cross_section[k].shape[1]))) + + for f, _ in enumerate(stg.freq[k]): + stg.depth_2D[k][f, :, :] = ( + np.repeat( + np.transpose(stg.depth[k] + [self.combobox_freq1.currentIndex()])[:, np.newaxis], + stg.time_cross_section[k].shape[1], + axis=1)) + + elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + stg.depth_2D[k] = ( + np.zeros((stg.freq[k].shape[0], + stg.depth[k].shape[1], + stg.time[k].shape[1]))) + + for f, _ in enumerate(stg.freq[k]): + stg.depth_2D[k][f, :, :] = ( + np.repeat( + np.transpose(stg.depth[k] + [self.combobox_freq1.currentIndex()])[:, np.newaxis], + stg.time[k].shape[1], + axis=1)) + + print("stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()].shape ", + stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()].shape) + def function_pushbutton_compute_calibration(self): # --- Compute frequency --- @@ -1211,6 +1284,7 @@ class SedimentCalibrationTab(QWidget): freq2=stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()], sv_freq1=sv_freq1, sv_freq2=sv_freq2) + stg.X_exponent.clear() stg.X_exponent.append(X_exponent) print(f"Exponent X = {X_exponent:.2f}\n") @@ -1224,20 +1298,20 @@ class SedimentCalibrationTab(QWidget): if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.zeros((stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], - stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]))) - - for f, _ in enumerate(stg.freq[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)) - - print("kt cor ", stg.kt_corrected) - print("kt read", stg.kt_read) + # stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( + # np.zeros((stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], + # stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], + # stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]))) + # + # for f, _ in enumerate(stg.freq[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)) + # + # print("kt cor ", stg.kt_corrected) + # print("kt read", stg.kt_read) if (stg.kt_corrected[self.combobox_acoustic_data_choice.currentIndex()] != stg.kt_read[self.combobox_acoustic_data_choice.currentIndex()]): @@ -1270,18 +1344,18 @@ class SedimentCalibrationTab(QWidget): elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.zeros((stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], - stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], - stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1]))) - - for f, _ in enumerate(stg.freq[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[self.combobox_acoustic_data_choice.currentIndex()].shape[1], - axis=1)) + # stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( + # np.zeros((stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], + # stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], + # stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1]))) + # + # for f, _ in enumerate(stg.freq[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[self.combobox_acoustic_data_choice.currentIndex()].shape[1], + # axis=1)) print("kt cor ", stg.kt_corrected) print("kt read", stg.kt_read) @@ -1319,18 +1393,18 @@ class SedimentCalibrationTab(QWidget): if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.zeros((stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], - stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1], - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]))) - - for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][f, :, :] = ( - np.repeat( - np.transpose(stg.depth[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)) + # stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( + # np.zeros((stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], + # stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1], + # stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]))) + # + # for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): + # stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][f, :, :] = ( + # np.repeat( + # np.transpose(stg.depth[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)) print("kt cor ", stg.kt_corrected) print("kt read", stg.kt_read) @@ -1366,18 +1440,18 @@ class SedimentCalibrationTab(QWidget): elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.zeros((stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], - stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1], - stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1]))) - - for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][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], - axis=1)) + # stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()] = ( + # np.zeros((stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], + # stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1], + # stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1]))) + # + # for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): + # stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][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], + # axis=1)) print("kt cor ", stg.kt_corrected) print("kt read", stg.kt_read) @@ -1750,8 +1824,9 @@ class SedimentCalibrationTab(QWidget): aquascat_cell_size = [] tau = [] real_cell_size = [] - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)) + # stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( + # np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)) + stg.depth_real = np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape) for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]): print("f = ", f) @@ -1769,9 +1844,11 @@ class SedimentCalibrationTab(QWidget): real_cell_size.append(stg.water_velocity[self.combobox_acoustic_data_choice.currentIndex()] * tau[f] / 2) # voir fig 2.9 # Converting to real cell profile - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][f, :] = \ - (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :] / - aquascat_cell_size[f] * real_cell_size[f]) # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1 + # stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][f, :] = \ + # (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :] / + # aquascat_cell_size[f] * real_cell_size[f]) # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1 + stg.depth_real[f, :] = (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :] + / aquascat_cell_size[f] * real_cell_size[f]) print("stg.depth_real ", stg.depth_real) # (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules @@ -1780,8 +1857,9 @@ class SedimentCalibrationTab(QWidget): aquascat_cell_size = [] tau = [] real_cell_size = [] - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape)) + # stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( + # np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape)) + stg.depth_real = (np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape)) for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]): @@ -1797,28 +1875,36 @@ class SedimentCalibrationTab(QWidget): real_cell_size.append(stg.water_velocity[self.combobox_acoustic_data_choice.currentIndex()] * tau[f] / 2) # voir fig 2.9 # Converting to real cell profile - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][f, :] = \ - (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] / - aquascat_cell_size[f] * real_cell_size[f]) # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1 - # (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules + # stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][f, :] = \ + # (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] / + # aquascat_cell_size[f] * real_cell_size[f]) # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1 + # # (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules + stg.depth_real[f, :] = (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] / + aquascat_cell_size[f] * real_cell_size[f]) - print("R_real 2D ", stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print("R_real 2D ", stg.depth_real.shape) if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.repeat(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][:, :, np.newaxis], - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2)) + # stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( + # np.repeat(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][:, :, np.newaxis], + # stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2)) + stg.depth_real = \ + (np.repeat(stg.depth_real[:, :, np.newaxis], + stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2)) - print("R_real 3D ", stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print("R_real 3D ", stg.depth_real.shape) else: - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( - np.repeat(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][:, :, np.newaxis], + # stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = ( + # np.repeat(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][:, :, np.newaxis], + # stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2)) + stg.depth_real = ( + np.repeat(stg.depth_real[:, :, np.newaxis], stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2)) - print("R_real 3D ", stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print("R_real 3D ", stg.depth_real.shape) def compute_FCB(self): # if stg.BS_stream_bed.size == 0: @@ -1848,106 +1934,106 @@ class SedimentCalibrationTab(QWidget): if stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) elif stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): print("zzzzzzzzzzzzzzzzzzzzz") print(np.log(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()]).shape) - print(np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]).shape) - print(stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()]) - print(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print(np.log(stg.depth_real).shape) + print(stg.water_attenuation) + print(stg.depth_real.shape) print("zzzzzzzzzzzzzzzzzzzzz") - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) elif stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): print("ttttttttttttttttttttttttt") print(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape) - print(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print(stg.depth_real.shape) print(stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()]) - print(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()].shape) + print(stg.depth_real.shape) print("ttttttttttttttttttttttttt") - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) elif BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()] = \ + stg.FCB = \ (np.log(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) + - np.log(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + + np.log(stg.depth_real) + 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()] * - stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()]) + stg.depth_real) - print("FCB ", stg.FCB[self.combobox_acoustic_data_choice.currentIndex()].shape) + print("FCB ", stg.FCB.shape) self.plot_FCB() def plot_FCB(self): - if stg.FCB[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.FCB.shape != (0,): if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -1976,16 +2062,14 @@ class SedimentCalibrationTab(QWidget): self.axis_FCB.plot( stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()], - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()][ - self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1], + stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1], linestyle="solid", linewidth=1, color="k") else: self.axis_FCB.plot( stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()], - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()][ - self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1], + stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1], linestyle="solid", linewidth=1, color="k") self.axis_FCB.text(.95, .05, @@ -2009,7 +2093,7 @@ class SedimentCalibrationTab(QWidget): def update_plot_FCB(self): - if stg.FCB[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.FCB.shape != (0,): self.axis_FCB.cla() if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -2017,8 +2101,7 @@ class SedimentCalibrationTab(QWidget): self.axis_FCB.plot( stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()], - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()][ - self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1], + stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1], linestyle="solid", linewidth=1, color="k") else: @@ -2026,8 +2109,7 @@ class SedimentCalibrationTab(QWidget): self.axis_FCB.plot( stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex()], - stg.FCB[self.combobox_acoustic_data_choice.currentIndex()][ - self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1], + stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1], linestyle="solid", linewidth=1, color="k") self.axis_FCB.text(.95, .05, @@ -2093,11 +2175,10 @@ class SedimentCalibrationTab(QWidget): self.update_plot_FCB() - if stg.FCB[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.FCB.shape != (0,): # --- Identify FCB profile where value are not NaN --- - y0 = stg.FCB[self.combobox_acoustic_data_choice.currentIndex()][ - self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1] + y0 = stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1] y = y0[np.where(np.isnan(y0) == False)] if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): @@ -2118,17 +2199,17 @@ class SedimentCalibrationTab(QWidget): lin_reg_compute = linregress(x[value1:value2], y[value1:value2]) print("lin_reg_compute ", lin_reg_compute) - stg.lin_reg[self.combobox_acoustic_data_choice.currentIndex()] = (lin_reg_compute.slope, lin_reg_compute.intercept) + stg.lin_reg = (lin_reg_compute.slope, lin_reg_compute.intercept) print("stg.lin_reg ", stg.lin_reg) # --- Plot result of linear regression --- self.axis_FCB.plot( stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex(), value1:value2], - stg.lin_reg[self.combobox_acoustic_data_choice.currentIndex()][0] * + stg.lin_reg[0] * stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex(), value1:value2] + - stg.lin_reg[self.combobox_acoustic_data_choice.currentIndex()][1], + stg.lin_reg[1], linestyle="dashed", linewidth=1, color="b") else: @@ -2149,24 +2230,24 @@ class SedimentCalibrationTab(QWidget): lin_reg_compute = linregress(x[value1:value2], y[value1:value2]) print("lin_reg_compute ", lin_reg_compute) - stg.lin_reg[self.combobox_acoustic_data_choice.currentIndex()] = ( + stg.lin_reg = ( lin_reg_compute.slope, lin_reg_compute.intercept) # --- Plot result of linear regression --- self.axis_FCB.plot( stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex(), value1:value2], - stg.lin_reg[self.combobox_acoustic_data_choice.currentIndex()][0] * + stg.lin_reg[0] * stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_frequency_FCB.currentIndex(), value1:value2] + - stg.lin_reg[self.combobox_acoustic_data_choice.currentIndex()][1], + stg.lin_reg[1], linestyle="dashed", linewidth=1, color="b") self.fig_FCB.canvas.draw_idle() # --- Display the value of alphaS compute with FCB --- self.label_alphaS_FCB.clear() - self.label_alphaS_FCB.setText(f"\u03B1s = {-0.5*stg.lin_reg[self.combobox_acoustic_data_choice.currentIndex()][0]:.4f} dB/m") + self.label_alphaS_FCB.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m") # if stg.FCB.size == 0: # msgBox = QMessageBox() diff --git a/settings.py b/settings.py index 52982e9..9c19dfc 100644 --- a/settings.py +++ b/settings.py @@ -188,7 +188,7 @@ zeta = [] J_cross_section = [] -frequency_for_inversion = [] +frequency_for_inversion = tuple() SSC_fine = [] SSC_sand = []