From 250fed45fc78025e215963db1ec3a23a139962d0 Mon Sep 17 00:00:00 2001 From: brahim Date: Fri, 12 Jul 2024 11:46:54 +0200 Subject: [PATCH] First, the user needs to choise the acoustic file and one frequency. The he can download the fine sediment file and the sand sediment file. For the moment, the two files must have the same number of sample. Concentration and PSD plots are updated with checking sample checkboxes. However, the z/h plot need to be modified. --- Model/granulo_loader.py | 20 +- View/acoustic_data_tab.py | 5 +- View/sample_data_tab.py | 2152 ++++++++++++++++++++++++------------- settings.py | 51 +- 4 files changed, 1445 insertions(+), 783 deletions(-) diff --git a/Model/granulo_loader.py b/Model/granulo_loader.py index 442c494..08a628e 100644 --- a/Model/granulo_loader.py +++ b/Model/granulo_loader.py @@ -12,18 +12,21 @@ class GranuloLoader: self._path = path self._data = pd.read_excel(self._path, engine="odf", header=0) - self._time = np.array(self._data.iloc[:, 0]) - self._y = np.array(self._data.iloc[:, 1]) # distance from left bank (m) - self._z = np.array(self._data.iloc[:, 2]) # depth (m) + self._time = self._data.iloc[:, 0].tolist() + self._y = self._data.iloc[:, 1].tolist() # distance from left bank (m) + self._z = self._data.iloc[:, 2].tolist() # depth (m) - self._r_grain = 1e-6*np.array(self._data.columns.values)[5:].astype(float) / 2 # grain radius (m) + self._r_grain = 1e-6 * self._data.columns.values[5:] / 2 + # self._r_grain = 1e-6 * np.array(self._data.columns.values)[5:].astype(float) / 2 # grain radius (m) - self._Ctot = np.array(self._data.iloc[:, 3]) # Total concentration (g/L) - self._D50 = np.array(self._data.iloc[:, 4]) # median diameter (um) - self._frac_vol = np.array(self._data.iloc[:, 5:])/100 # Volume fraction (%) + self._Ctot = self._data.iloc[:, 3].tolist() # Total concentration (g/L) + self._D50 = self._data.iloc[:, 4].tolist() # median diameter (um) + self._frac_vol = np.array(self._data.iloc[:, 5:]) / 100 # Volume fraction (%) self._frac_vol_cumul = np.cumsum(self._frac_vol, axis=1) # Cumulated volume fraction (%) + # print(type(self._frac_vol_cumul), self._frac_vol_cumul.shape, self._frac_vol_cumul) + # # --- Load sand sediments data file --- # self.path_sand = path_sand # self._data_sand = pd.read_excel(self.path_sand, engine="odf", header=0) @@ -122,8 +125,7 @@ class GranuloLoader: # if __name__ == "__main__": - # GranuloLoader("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data/" - # "fine_sample_file.ods") +# GranuloLoader("/home/bmoudjed/Documents/2 Data/Confluence_Rhône_Isere_2018/Granulo_data/fine_sample_file.ods") # GranuloLoader("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data/" # "sand_sample_file.ods") # GranuloLoader("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/" diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 8be3aca..5bf0834 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -1894,7 +1894,7 @@ class AcousticDataTab(QWidget): stg.rmax.append("") stg.BS_stream_bed.append(np.array([])) - stg.depth_bottom.append([]) + stg.depth_bottom.append(np.array([])) stg.val_bottom.append([]) stg.ind_bottom.append([]) stg.freq_bottom_detection.append([]) @@ -3971,10 +3971,13 @@ class AcousticDataTab(QWidget): # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]] stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom + print("stg.depth_bottom", stg.depth_bottom) stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom + print("stg.val_bottom", stg.val_bottom) stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind + print("stg.ind_bottom", stg.ind_bottom) # if ((self.fileListWidget.count() == 1) and (len(stg.depth_bottom) == 0)): # stg.depth_bottom = [r_bottom]#[int(stg.tmin[self.combobox_freq_choice.currentIndex()]): diff --git a/View/sample_data_tab.py b/View/sample_data_tab.py index 44f1bd0..6add6bb 100644 --- a/View/sample_data_tab.py +++ b/View/sample_data_tab.py @@ -18,6 +18,8 @@ from copy import deepcopy from os import path import csv +from View.show_popup_combobox import ComboBoxShowPopUpWindow + from Model.granulo_loader import GranuloLoader from View.checkable_combobox import CheckableComboBox @@ -32,6 +34,7 @@ _translate = QCoreApplication.translate class SampleDataTab(QWidget): clickedState = pyqtSignal(bool) + ShowPopUpWindowSignal = pyqtSignal() def __init__(self, widget_tab): super().__init__() @@ -52,8 +55,17 @@ class SampleDataTab(QWidget): # -------------------------------------------------------------------------------------------------------------- ### --- Layout of groupbox in the Top horizontal layout box - # Table of values fines | Sample position - # Table of values sand | Display options + # Sample position | Table of values fines + # Display options | Table of values sand + + self.verticalLayout_groupboxes_plot_sample_position_display_option = QVBoxLayout() + self.horizontalLayoutTop_sampleDataTab.addLayout(self.verticalLayout_groupboxes_plot_sample_position_display_option, 4) + + self.groupbox_plot_sample_position_on_transect = QGroupBox() + self.verticalLayout_groupboxes_plot_sample_position_display_option.addWidget(self.groupbox_plot_sample_position_on_transect, 7) + + self.groupbox_display_option = QGroupBox() + self.verticalLayout_groupboxes_plot_sample_position_display_option.addWidget(self.groupbox_display_option, 3) self.verticalLayout_groupboxes_fine_sand = QVBoxLayout() self.horizontalLayoutTop_sampleDataTab.addLayout(self.verticalLayout_groupboxes_fine_sand, 6) @@ -64,14 +76,7 @@ class SampleDataTab(QWidget): self.groupbox_sand = QGroupBox() self.verticalLayout_groupboxes_fine_sand.addWidget(self.groupbox_sand, 5) - self.verticalLayout_groupboxes_plot_sample_position_display_option = QVBoxLayout() - self.horizontalLayoutTop_sampleDataTab.addLayout(self.verticalLayout_groupboxes_plot_sample_position_display_option, 4) - self.groupbox_plot_sample_position_on_transect = QGroupBox() - self.verticalLayout_groupboxes_plot_sample_position_display_option.addWidget(self.groupbox_plot_sample_position_on_transect, 6) - - self.groupbox_display_option = QGroupBox() - self.verticalLayout_groupboxes_plot_sample_position_display_option.addWidget(self.groupbox_display_option, 4) # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -123,11 +128,30 @@ class SampleDataTab(QWidget): # +++ --- GroupBox plot sample position --- +++ # +++++++++++++++++++++++++++++++++++++++++++++ - self.verticalLayout_groupbox_plot_sample_position_on_transect = QVBoxLayout(self.groupbox_plot_sample_position_on_transect) + self.verticalLayout_groupbox_plot_sample_position_on_transect = QVBoxLayout( + self.groupbox_plot_sample_position_on_transect) self.groupbox_plot_sample_position_on_transect.setTitle("Plot samples positions") + self.horizontalLayout_pushbutton_comboboxes_sample_position_on_transect = QHBoxLayout() + self.verticalLayout_groupbox_plot_sample_position_on_transect.addLayout(self.horizontalLayout_pushbutton_comboboxes_sample_position_on_transect) + + self.pushbutton_plot_transect = QPushButton() + self.pushbutton_plot_transect.setText("Plot Acoustic data") + self.horizontalLayout_pushbutton_comboboxes_sample_position_on_transect.addWidget(self.pushbutton_plot_transect) + + self.combobox_acoustic_data = QComboBox() + self.horizontalLayout_pushbutton_comboboxes_sample_position_on_transect.addWidget(self.combobox_acoustic_data) + + self.combobox_frequencies = QComboBox() + self.horizontalLayout_pushbutton_comboboxes_sample_position_on_transect.addWidget(self.combobox_frequencies) + + self.groupbox_plot_transect = QGroupBox() + self.verticalLayout_groupbox_plot_transect = QVBoxLayout(self.groupbox_plot_transect) + self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.groupbox_plot_transect) + self.canvas_plot_sample_position_on_transect = FigureCanvas() - self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.canvas_plot_sample_position_on_transect) + # self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.canvas_plot_sample_position_on_transect) + self.verticalLayout_groupbox_plot_transect.addWidget(self.canvas_plot_sample_position_on_transect) self.verticalLayout_groupbox_display_option = QVBoxLayout(self.groupbox_display_option) self.groupbox_display_option.setTitle("Display options") @@ -139,17 +163,6 @@ class SampleDataTab(QWidget): self.horizontalLayout_pushbutton_combobox_transect = QHBoxLayout() self.verticalLayout_groupbox_display_option.addLayout(self.horizontalLayout_pushbutton_combobox_transect) - self.pushbutton_plot_transect = QPushButton() - self.pushbutton_plot_transect.setText("Plot transect to visualise sample position") - self.horizontalLayout_pushbutton_combobox_transect.addWidget(self.pushbutton_plot_transect) - - self.pushbutton_plot_transect.clicked.connect(self.plot_sample_position_on_transect) - - self.combobox_frequencies = QComboBox() - self.horizontalLayout_pushbutton_combobox_transect.addWidget(self.combobox_frequencies) - - # self.combobox_frequencies.currentTextChanged.connect(self.update_plot_sample_position_on_transect) - self.horizontalLayout_Ctot_PSD_plot = QHBoxLayout() self.verticalLayout_groupbox_display_option.addLayout(self.horizontalLayout_Ctot_PSD_plot) @@ -167,8 +180,6 @@ class SampleDataTab(QWidget): self.combobox_x_axis.addItems(['Concentration (g/L)', 'Concentration (%)']) self.gridLayout_groupbox_option_total_concentration_plot.addWidget(self.combobox_x_axis, 0, 1) - self.combobox_x_axis.currentTextChanged.connect(self.update_plot_total_concentration) - self.label_y_axis = QLabel() self.label_y_axis.setText("y axis") self.gridLayout_groupbox_option_total_concentration_plot.addWidget(self.label_y_axis, 1, 0) @@ -178,7 +189,6 @@ class SampleDataTab(QWidget): self.gridLayout_groupbox_option_total_concentration_plot.addWidget(self.combobox_y_axis, 1, 1) # self.combobox_y_axis.currentTextChanged.connect(self.empty_field_for_total_concentration_plot) - self.combobox_y_axis.currentTextChanged.connect(self.update_plot_total_concentration) # --- Group box PSD plot --- self.groupbox_option_PSD_plot = QGroupBox() @@ -190,9 +200,6 @@ class SampleDataTab(QWidget): self.combobox_PSD_plot.addItems(["Class PSD", "Cumulative PSD"]) self.verticalLayout__groupbox_option_PSD_plot.addWidget(self.combobox_PSD_plot) - self.combobox_PSD_plot.currentTextChanged.connect(self.update_plot_PSD_fine_and_sand_sediments) - - # -------------------------------------------------------------------------------------------------------------- ### --- Layout of groupbox in the Bottom horizontal layout box @@ -222,6 +229,26 @@ class SampleDataTab(QWidget): self.verticalLayout_groupbox_plot_PSD.addWidget(self.toolbar_plot_PSD) self.verticalLayout_groupbox_plot_PSD.addWidget(self.canvas_plot_PSD) + # -------------------------------------------------------------------------------------------------------------- + # --- Connect signal of widget --- + + self.pushbutton_fine_sediment.clicked.connect(self.open_dialog_box_fine_sediment) + self.pushbutton_sand_sediment.clicked.connect(self.open_dialog_box_sand_sediment) + + self.pushbutton_plot_transect.clicked.connect(self.fill_comboboxes_and_plot_transect) + + # self.combobox_acoustic_data.ShowPopUpWindowSignal.connect(self.event_combobobx_acoustic_data) + + # self.combobox_frequencies.currentTextChanged.connect(self.update_plot_sample_position_on_transect) + + # self.pushbutton_plot_transect.clicked.connect(self.plot_sample_position_on_transect) + + # self.combobox_x_axis.currentTextChanged.connect(self.plot_total_concentration) + # + # self.combobox_y_axis.currentTextChanged.connect(self.plot_total_concentration) + + self.combobox_PSD_plot.currentTextChanged.connect(self.plot_PSD_fine_and_sand_sediments) + # ______ _______ # | | | | \ @@ -566,8 +593,9 @@ class SampleDataTab(QWidget): "Fine sediment file (*.xls, *.ods)") try: - stg.fine_sediment_path = path.dirname(filename_fine_sediment[0]) - stg.fine_sediment_filename = path.basename(filename_fine_sediment[0]) + stg.path_fine = path.dirname(filename_fine_sediment[0]) + stg.filename_fine = path.basename(filename_fine_sediment[0]) + print(stg.path_fine, stg.filename_fine) self.load_fine_sediment_data() except IsADirectoryError: msgBox = QMessageBox() @@ -577,8 +605,9 @@ class SampleDataTab(QWidget): msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() else: - self.lineEdit_fine_sediment.setText(stg.fine_sediment_filename) - self.lineEdit_fine_sediment.setToolTip(stg.fine_sediment_path) + self.lineEdit_fine_sediment.setText(stg.filename_fine) + self.lineEdit_fine_sediment.setToolTip(stg.path_fine) + self.fill_table_fine() # --- Function to select directory and file name of sand sediments sample data --- def open_dialog_box_sand_sediment(self): @@ -587,8 +616,8 @@ class SampleDataTab(QWidget): "Sand sediment file (*.xls, *.ods)") try: - stg.sand_sediment_path = path.dirname(filename_sand_sediment[0]) - stg.sand_sediment_filename = path.basename(filename_sand_sediment[0]) + stg.path_sand = path.dirname(filename_sand_sediment[0]) + stg.filename_sand = path.basename(filename_sand_sediment[0]) self.load_sand_sediment_data() except IsADirectoryError: msgBox = QMessageBox() @@ -598,247 +627,252 @@ class SampleDataTab(QWidget): msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() else: - self.lineEdit_sand.setText(stg.sand_sediment_filename) - self.lineEdit_sand.setToolTip(stg.sand_sediment_path) + self.lineEdit_sand_sediment.setText(stg.filename_sand) + self.lineEdit_sand_sediment.setToolTip(stg.path_sand) + self.fill_table_sand() def load_fine_sediment_data(self): - fine_granulo_data = GranuloLoader(stg.fine_sediment_path + "/" + stg.fine_sediment_filename) - stg.fine_sediment_columns = fine_granulo_data._data.columns - stg.sample_time = fine_granulo_data._time - stg.sample_distance_from_bank = fine_granulo_data._y - stg.sample_depth = fine_granulo_data._z - stg.radius_grain = fine_granulo_data._r_grain + fine_granulo_data = GranuloLoader(stg.path_fine + "/" + stg.filename_fine) + stg.columns_fine = fine_granulo_data._data.columns + stg.time_fine = fine_granulo_data._time + stg.distance_from_bank_fine = fine_granulo_data._y + stg.depth_fine = fine_granulo_data._z + stg.radius_grain_fine = fine_granulo_data._r_grain stg.Ctot_fine = fine_granulo_data._Ctot stg.D50_fine = fine_granulo_data._D50 stg.frac_vol_fine = fine_granulo_data._frac_vol stg.frac_vol_fine_cumul = fine_granulo_data._frac_vol_cumul def load_sand_sediment_data(self): - sand_granulo_data = GranuloLoader(stg.sand_sediment_path + "/" + stg.sand_sediment_filename) - stg.sand_sediment_columns = sand_granulo_data._data.columns - stg.sample_time = sand_granulo_data._time - stg.sample_distance_from_bank = sand_granulo_data._y - stg.sample_depth = sand_granulo_data._z - stg.radius_grain = sand_granulo_data._r_grain + sand_granulo_data = GranuloLoader(stg.path_sand + "/" + stg.filename_sand) + stg.columns_sand = sand_granulo_data._data.columns + stg.time_sand = sand_granulo_data._time + stg.distance_from_bank_sand = sand_granulo_data._y + stg.depth_sand = sand_granulo_data._z + stg.radius_grain_sand = sand_granulo_data._r_grain stg.Ctot_sand = sand_granulo_data._Ctot stg.D50_sand = sand_granulo_data._D50 stg.frac_vol_sand = sand_granulo_data._frac_vol stg.frac_vol_sand_cumul = sand_granulo_data._frac_vol_cumul def compute_Ctot_per_cent(self): - if (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand.text()): - stg.Ctot_fine_per_cent = 100 * stg.Ctot_fine / (stg.Ctot_fine) - elif not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): - stg.Ctot_sand_per_cent = 100 * stg.Ctot_sand / (stg.Ctot_sand) - elif (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): - stg.Ctot_fine_per_cent = 100 * stg.Ctot_fine / (stg.Ctot_fine + stg.Ctot_sand) - stg.Ctot_sand_per_cent = 100 * stg.Ctot_sand / (stg.Ctot_fine + stg.Ctot_sand) + if (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand_sediment.text()): + stg.Ctot_fine_per_cent = [100 * f / f for f in stg.Ctot_fine] + elif not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand_sediment.text()): + stg.Ctot_sand_per_cent = [100 * s / s for s in stg.Ctot_sand] + elif (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand_sediment.text()): + stg.Ctot_fine_per_cent = [100 * f / (f + s) for f, s in zip(stg.Ctot_fine, stg.Ctot_sand)] + stg.Ctot_sand_per_cent = [100 * s / (f + s) for f, s in zip(stg.Ctot_fine, stg.Ctot_sand)] # ------------------------------------------------------------------------------------------------------------------ # --- Function to fill table of values --- - def fill_table(self): - if (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand.text()): + def fill_table_fine(self): + # if (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand.text()): + if self.lineEdit_fine_sediment.text(): - self.row = self.tableWidget_sample.setRowCount(stg.sample_depth.shape[0]) - self.col = self.tableWidget_sample.setColumnCount(6 + stg.radius_grain.shape[0]) + self.row_fine = self.tableWidget_fine.setRowCount(len(stg.depth_fine)) + self.column_fine = self.tableWidget_fine.setColumnCount(6 + stg.radius_grain_fine.shape[0]) # --- Set horizontal header --- # horizontal_header = list(map(str, ["Color", "Sample"] + stg.fine_sediment_columns + # stg.sand_sediment_columns[2:])) horizontal_header = list(itertools.chain(["Color", "Sample"], - list(map(str, stg.fine_sediment_columns[[0, 2]])), - list(map(str, stg.fine_sediment_columns[3:])))) + list(map(str, stg.columns_fine[[0, 2]])), + list(map(str, stg.columns_fine[3:])))) for horizontal_header_text in horizontal_header: # print(horizontal_header_text) - self.horizontal_header_item = QTableWidgetItem() + self.horizontal_header_item_fine = QTableWidgetItem() # print(np.where(horizontal_header == horizontal_header_text)[0][0]) - self.tableWidget_sample.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text), - self.horizontal_header_item) - self.horizontal_header_item.setText(horizontal_header_text) + self.tableWidget_fine.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text), + self.horizontal_header_item_fine) + self.horizontal_header_item_fine.setText(horizontal_header_text) # --- Set vertical header (color) --- - self.tableWidget_sample.verticalHeader().setVisible(False) + self.tableWidget_fine.verticalHeader().setVisible(False) color_list = CSS4_COLORS - for i in range(self.tableWidget_sample.rowCount()): - exec("self.comboBox_sample_table" + str(i) + "= QComboBox()") - exec("self.comboBox_sample_table" + str(i) + ".addItems(color_list)") - eval(f"self.tableWidget_sample.setCellWidget(i, 0, self.comboBox_sample_table{i})") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.extract_position_list_and_color_list_from_table_checkboxes)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_total_concentration)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_PSD_fine_and_sand_sediments)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." + for i in range(self.tableWidget_fine.rowCount()): + exec("self.comboBox_sample_table_fine" + str(i) + "= QComboBox()") + exec("self.comboBox_sample_table_fine" + str(i) + ".addItems(color_list)") + eval(f"self.tableWidget_fine.setCellWidget(i, 0, self.comboBox_sample_table_fine{i})") + eval(f"self.comboBox_sample_table_fine{i}.currentTextChanged." + f"connect(self.extract_position_list_and_color_list_from_table_checkboxes_fine)") + eval(f"self.comboBox_sample_table_fine{i}.currentTextChanged." + f"connect(self.plot_total_concentration)") + eval(f"self.comboBox_sample_table_fine{i}.currentTextChanged." + f"connect(self.plot_PSD_fine_and_sand_sediments)") + eval(f"self.comboBox_sample_table_fine{i}.currentTextChanged." f"connect(self.update_plot_sample_position_on_transect)") # --- Fill Sample column with checkbox --- - for i in range(self.tableWidget_sample.rowCount()): - self.item_checkbox = QTableWidgetItem() - self.item_checkbox.setCheckState(Qt.Unchecked) - self.tableWidget_sample.setItem(i, 1, self.item_checkbox) - self.item_checkbox.setText("S" + str(i + 1)) - stg.samples.append("S" + str(i + 1)) + for i in range(self.tableWidget_fine.rowCount()): + self.item_checkbox_fine = QTableWidgetItem() + self.item_checkbox_fine.setCheckState(Qt.Unchecked) + self.tableWidget_fine.setItem(i, 1, self.item_checkbox_fine) + self.item_checkbox_fine.setText("F" + str(i + 1)) + stg.sample_fine.append("F" + str(i + 1)) # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) # --- Fill table with data --- for i in range(stg.frac_vol_fine.shape[0]): for j in range(stg.frac_vol_fine.shape[1]): # self.tableWidget_sample.setItem(i, j + 2, QTableWidgetItem(str(granulo_data._data_fine.iloc[i, j]))) - self.tableWidget_sample.setItem(i, 2, QTableWidgetItem(str(stg.sample_time[i]))) - self.tableWidget_sample.setItem(i, 3, QTableWidgetItem(str(stg.sample_depth[i]))) + self.tableWidget_fine.setItem(i, 2, QTableWidgetItem(str(stg.time_fine[i]))) + self.tableWidget_fine.setItem(i, 3, QTableWidgetItem(str(stg.depth_fine[i]))) - self.tableWidget_sample.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_fine[i]))) - self.tableWidget_sample.setItem(i, 5, QTableWidgetItem(str(stg.D50_fine[i]))) - self.tableWidget_sample.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_fine[i, j]))) + self.tableWidget_fine.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_fine[i]))) + self.tableWidget_fine.setItem(i, 5, QTableWidgetItem(str(stg.D50_fine[i]))) + self.tableWidget_fine.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_fine[i, j]))) # --- Connect checkbox to all checkboxes of tableWidget --- - self.allChkBox.stateChanged.connect(self.check_allChkBox) + # self.allChkBox.stateChanged.connect(self.check_allChkBox) # --- Connect checkbox items of tableWidget to update plots --- - self.tableWidget_sample.itemChanged.connect( - self.extract_position_list_and_color_list_from_table_checkboxes) - self.tableWidget_sample.itemChanged.connect(self.update_plot_total_concentration) - self.tableWidget_sample.itemChanged.connect(self.update_plot_PSD_fine_and_sand_sediments) - self.tableWidget_sample.itemChanged.connect(self.update_plot_sample_position_on_transect) + self.tableWidget_fine.itemChanged.connect( + self.extract_position_list_and_color_list_from_table_checkboxes_fine) + self.tableWidget_fine.itemChanged.connect(self.update_plot_sample_position_on_transect) + self.tableWidget_fine.itemChanged.connect(self.plot_total_concentration) + self.tableWidget_fine.itemChanged.connect(self.plot_PSD_fine_and_sand_sediments) - elif not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): + self.combobox_x_axis.currentIndexChanged.connect(self.plot_total_concentration) + self.combobox_y_axis.currentIndexChanged.connect(self.plot_total_concentration) - self.row = self.tableWidget_sample.setRowCount(stg.sample_depth.shape[0]) - self.col = self.tableWidget_sample.setColumnCount(6 + stg.radius_grain.shape[0]) - - # --- Set horizontal header --- - # horizontal_header = list(map(str, ["Color", "Sample"] + stg.fine_sediment_columns + - # stg.sand_sediment_columns[2:])) - horizontal_header = list(itertools.chain(["Color", "Sample"], - list(map(str, stg.sand_sediment_columns[[0, 2]])), - - list(map(str, stg.sand_sediment_columns[3:])))) - - for horizontal_header_text in horizontal_header: - # print(horizontal_header_text) - self.horizontal_header_item = QTableWidgetItem() - # print(np.where(horizontal_header == horizontal_header_text)[0][0]) - self.tableWidget_sample.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text), - self.horizontal_header_item) - self.horizontal_header_item.setText(horizontal_header_text) - - # --- Set vertical header (color) --- - self.tableWidget_sample.verticalHeader().setVisible(False) - color_list = CSS4_COLORS - for i in range(self.tableWidget_sample.rowCount()): - exec("self.comboBox_sample_table" + str(i) + "= QComboBox()") - exec("self.comboBox_sample_table" + str(i) + ".addItems(color_list)") - eval(f"self.tableWidget_sample.setCellWidget(i, 0, self.comboBox_sample_table{i})") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.extract_position_list_and_color_list_from_table_checkboxes)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_total_concentration)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_PSD_fine_and_sand_sediments)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_sample_position_on_transect)") - - # --- Fill Sample column with checkbox --- - for i in range(self.tableWidget_sample.rowCount()): - self.item_checkbox = QTableWidgetItem() - self.item_checkbox.setCheckState(Qt.Unchecked) - self.tableWidget_sample.setItem(i, 1, self.item_checkbox) - self.item_checkbox.setText("S" + str(i + 1)) - stg.samples.append("S" + str(i + 1)) - # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) - - # --- Fill table with data --- - for i in range(stg.frac_vol_sand.shape[0]): - for j in range(stg.frac_vol_sand.shape[1]): - # self.tableWidget_sample.setItem(i, j + 2, QTableWidgetItem(str(granulo_data._data_fine.iloc[i, j]))) - self.tableWidget_sample.setItem(i, 2, QTableWidgetItem(str(stg.sample_time[i]))) - self.tableWidget_sample.setItem(i, 3, QTableWidgetItem(str(stg.sample_depth[i]))) - - self.tableWidget_sample.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_sand[i]))) - self.tableWidget_sample.setItem(i, 5, QTableWidgetItem(str(stg.D50_sand[i]))) - self.tableWidget_sample.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_sand[i, j]))) - - # --- Connect checkbox to all checkboxes of tableWidget --- - self.allChkBox.stateChanged.connect(self.check_allChkBox) - - # --- Connect checkbox items of tableWidget to update plots --- - self.tableWidget_sample.itemChanged.connect(self.extract_position_list_and_color_list_from_table_checkboxes) - self.tableWidget_sample.itemChanged.connect(self.update_plot_total_concentration) - self.tableWidget_sample.itemChanged.connect(self.update_plot_PSD_fine_and_sand_sediments) - self.tableWidget_sample.itemChanged.connect(self.update_plot_sample_position_on_transect) - - elif (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): - print(f"stg.sample_depth.shape[0] {stg.sample_depth.shape[0]}") - self.row = self.tableWidget_sample.setRowCount(stg.sample_depth.shape[0]) - self.col = self.tableWidget_sample.setColumnCount(8+2*stg.radius_grain.shape[0]) - - # --- Set horizontal header --- - # horizontal_header = list(map(str, ["Color", "Sample"] + stg.fine_sediment_columns + - # stg.sand_sediment_columns[2:])) - horizontal_header = list(itertools.chain(["Color", "Sample"], - list(map(str, stg.fine_sediment_columns[[0, 2]])), - list(map(str, stg.fine_sediment_columns[3:])), - list(map(str, stg.sand_sediment_columns[3:])))) - - for horizontal_header_text in horizontal_header: - # print(horizontal_header_text) - self.horizontal_header_item = QTableWidgetItem() - # print(np.where(horizontal_header == horizontal_header_text)[0][0]) - self.tableWidget_sample.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text), - self.horizontal_header_item) - self.horizontal_header_item.setText(horizontal_header_text) - - # --- Set vertical header (color) --- - self.tableWidget_sample.verticalHeader().setVisible(False) - color_list = CSS4_COLORS - for i in range(self.tableWidget_sample.rowCount()): - exec("self.comboBox_sample_table" + str(i) + "= QComboBox()") - exec("self.comboBox_sample_table" + str(i) + ".addItems(color_list)") - eval(f"self.tableWidget_sample.setCellWidget(i, 0, self.comboBox_sample_table{i})") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.extract_position_list_and_color_list_from_table_checkboxes)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_total_concentration)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_PSD_fine_and_sand_sediments)") - eval(f"self.comboBox_sample_table{i}.currentTextChanged." - f"connect(self.update_plot_sample_position_on_transect)") - - # --- Fill Sample column with checkbox --- - for i in range(self.tableWidget_sample.rowCount()): - self.item_checkbox = QTableWidgetItem() - self.item_checkbox.setCheckState(Qt.Unchecked) - self.tableWidget_sample.setItem(i, 1, self.item_checkbox) - self.item_checkbox.setText("S" + str(i + 1)) - stg.samples.append("S" + str(i + 1)) - # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) - - # --- Fill table with data --- - for i in range(stg.frac_vol_fine.shape[0]): - for j in range(stg.frac_vol_fine.shape[1]): - # self.tableWidget_sample.setItem(i, j + 2, QTableWidgetItem(str(granulo_data._data_fine.iloc[i, j]))) - self.tableWidget_sample.setItem(i, 2, QTableWidgetItem(str(stg.sample_time[i]))) - self.tableWidget_sample.setItem(i, 3, QTableWidgetItem(str(stg.sample_depth[i]))) - - self.tableWidget_sample.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_fine[i]))) - self.tableWidget_sample.setItem(i, 5, QTableWidgetItem(str(stg.D50_fine[i]))) - self.tableWidget_sample.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_fine[i, j]))) - - self.tableWidget_sample.setItem(i, stg.frac_vol_fine.shape[1] + 6, QTableWidgetItem(str(stg.Ctot_sand[i]))) - self.tableWidget_sample.setItem(i, stg.frac_vol_fine.shape[1] + 7, QTableWidgetItem(str(stg.D50_sand[i]))) - self.tableWidget_sample.setItem(i, stg.frac_vol_fine.shape[1] + 8 + j, QTableWidgetItem(str(stg.frac_vol_sand[i, j]))) - - # --- Connect checkbox to all checkboxes of tableWidget --- - self.allChkBox.stateChanged.connect(self.check_allChkBox) - - # --- Connect checkbox items of tableWidget to update plots --- - self.tableWidget_sample.itemChanged.connect( - self.extract_position_list_and_color_list_from_table_checkboxes) - self.tableWidget_sample.itemChanged.connect(self.update_plot_total_concentration) - self.tableWidget_sample.itemChanged.connect(self.update_plot_PSD_fine_and_sand_sediments) - self.tableWidget_sample.itemChanged.connect(self.update_plot_sample_position_on_transect) + # elif not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): + # + # self.row = self.tableWidget_sample.setRowCount(stg.sample_depth.shape[0]) + # self.col = self.tableWidget_sample.setColumnCount(6 + stg.radius_grain.shape[0]) + # + # # --- Set horizontal header --- + # # horizontal_header = list(map(str, ["Color", "Sample"] + stg.fine_sediment_columns + + # # stg.sand_sediment_columns[2:])) + # horizontal_header = list(itertools.chain(["Color", "Sample"], + # list(map(str, stg.sand_sediment_columns[[0, 2]])), + # + # list(map(str, stg.sand_sediment_columns[3:])))) + # + # for horizontal_header_text in horizontal_header: + # # print(horizontal_header_text) + # self.horizontal_header_item = QTableWidgetItem() + # # print(np.where(horizontal_header == horizontal_header_text)[0][0]) + # self.tableWidget_sample.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text), + # self.horizontal_header_item) + # self.horizontal_header_item.setText(horizontal_header_text) + # + # # --- Set vertical header (color) --- + # self.tableWidget_sample.verticalHeader().setVisible(False) + # color_list = CSS4_COLORS + # for i in range(self.tableWidget_sample.rowCount()): + # exec("self.comboBox_sample_table" + str(i) + "= QComboBox()") + # exec("self.comboBox_sample_table" + str(i) + ".addItems(color_list)") + # eval(f"self.tableWidget_sample.setCellWidget(i, 0, self.comboBox_sample_table{i})") + # eval(f"self.comboBox_sample_table{i}.currentTextChanged." + # f"connect(self.extract_position_list_and_color_list_from_table_checkboxes)") + # eval(f"self.comboBox_sample_table{i}.currentTextChanged." + # f"connect(self.update_plot_total_concentration)") + # eval(f"self.comboBox_sample_table{i}.currentTextChanged." + # f"connect(self.update_plot_PSD_fine_and_sand_sediments)") + # eval(f"self.comboBox_sample_table{i}.currentTextChanged." + # f"connect(self.update_plot_sample_position_on_transect)") + # + # # --- Fill Sample column with checkbox --- + # for i in range(self.tableWidget_sample.rowCount()): + # self.item_checkbox = QTableWidgetItem() + # self.item_checkbox.setCheckState(Qt.Unchecked) + # self.tableWidget_sample.setItem(i, 1, self.item_checkbox) + # self.item_checkbox.setText("S" + str(i + 1)) + # stg.samples.append("S" + str(i + 1)) + # # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) + # + # # --- Fill table with data --- + # for i in range(stg.frac_vol_sand.shape[0]): + # for j in range(stg.frac_vol_sand.shape[1]): + # # self.tableWidget_sample.setItem(i, j + 2, QTableWidgetItem(str(granulo_data._data_fine.iloc[i, j]))) + # self.tableWidget_sample.setItem(i, 2, QTableWidgetItem(str(stg.sample_time[i]))) + # self.tableWidget_sample.setItem(i, 3, QTableWidgetItem(str(stg.sample_depth[i]))) + # + # self.tableWidget_sample.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_sand[i]))) + # self.tableWidget_sample.setItem(i, 5, QTableWidgetItem(str(stg.D50_sand[i]))) + # self.tableWidget_sample.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_sand[i, j]))) + # + # # --- Connect checkbox to all checkboxes of tableWidget --- + # self.allChkBox.stateChanged.connect(self.check_allChkBox) + # + # # --- Connect checkbox items of tableWidget to update plots --- + # self.tableWidget_sample.itemChanged.connect(self.extract_position_list_and_color_list_from_table_checkboxes) + # self.tableWidget_sample.itemChanged.connect(self.update_plot_total_concentration) + # self.tableWidget_sample.itemChanged.connect(self.update_plot_PSD_fine_and_sand_sediments) + # self.tableWidget_sample.itemChanged.connect(self.update_plot_sample_position_on_transect) + # + # elif (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): + # print(f"stg.sample_depth.shape[0] {stg.sample_depth.shape[0]}") + # self.row = self.tableWidget_sample.setRowCount(stg.sample_depth.shape[0]) + # self.col = self.tableWidget_sample.setColumnCount(8+2*stg.radius_grain.shape[0]) + # + # # --- Set horizontal header --- + # # horizontal_header = list(map(str, ["Color", "Sample"] + stg.fine_sediment_columns + + # # stg.sand_sediment_columns[2:])) + # horizontal_header = list(itertools.chain(["Color", "Sample"], + # list(map(str, stg.fine_sediment_columns[[0, 2]])), + # list(map(str, stg.fine_sediment_columns[3:])), + # list(map(str, stg.sand_sediment_columns[3:])))) + # + # for horizontal_header_text in horizontal_header: + # # print(horizontal_header_text) + # self.horizontal_header_item = QTableWidgetItem() + # # print(np.where(horizontal_header == horizontal_header_text)[0][0]) + # self.tableWidget_sample.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text), + # self.horizontal_header_item) + # self.horizontal_header_item.setText(horizontal_header_text) + # + # # --- Set vertical header (color) --- + # self.tableWidget_sample.verticalHeader().setVisible(False) + # color_list = CSS4_COLORS + # for i in range(self.tableWidget_sample.rowCount()): + # exec("self.comboBox_sample_table" + str(i) + "= QComboBox()") + # exec("self.comboBox_sample_table" + str(i) + ".addItems(color_list)") + # eval(f"self.tableWidget_sample.setCellWidget(i, 0, self.comboBox_sample_table{i})") + # eval(f"self.comboBox_sample_table{i}.currentTextChanged." + # f"connect(self.extract_position_list_and_color_list_from_table_checkboxes)") + # eval(f"self.comboBox_sample_table{i}.currentTextChanged." + # f"connect(self.update_plot_total_concentration)") + # eval(f"self.comboBox_sample_table{i}.currentTextChanged." + # f"connect(self.update_plot_PSD_fine_and_sand_sediments)") + # eval(f"self.comboBox_sample_table{i}.currentTextChanged." + # f"connect(self.update_plot_sample_position_on_transect)") + # + # # --- Fill Sample column with checkbox --- + # for i in range(self.tableWidget_sample.rowCount()): + # self.item_checkbox = QTableWidgetItem() + # self.item_checkbox.setCheckState(Qt.Unchecked) + # self.tableWidget_sample.setItem(i, 1, self.item_checkbox) + # self.item_checkbox.setText("S" + str(i + 1)) + # stg.samples.append("S" + str(i + 1)) + # # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) + # + # # --- Fill table with data --- + # for i in range(stg.frac_vol_fine.shape[0]): + # for j in range(stg.frac_vol_fine.shape[1]): + # # self.tableWidget_sample.setItem(i, j + 2, QTableWidgetItem(str(granulo_data._data_fine.iloc[i, j]))) + # self.tableWidget_sample.setItem(i, 2, QTableWidgetItem(str(stg.sample_time[i]))) + # self.tableWidget_sample.setItem(i, 3, QTableWidgetItem(str(stg.sample_depth[i]))) + # + # self.tableWidget_sample.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_fine[i]))) + # self.tableWidget_sample.setItem(i, 5, QTableWidgetItem(str(stg.D50_fine[i]))) + # self.tableWidget_sample.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_fine[i, j]))) + # + # self.tableWidget_sample.setItem(i, stg.frac_vol_fine.shape[1] + 6, QTableWidgetItem(str(stg.Ctot_sand[i]))) + # self.tableWidget_sample.setItem(i, stg.frac_vol_fine.shape[1] + 7, QTableWidgetItem(str(stg.D50_sand[i]))) + # self.tableWidget_sample.setItem(i, stg.frac_vol_fine.shape[1] + 8 + j, QTableWidgetItem(str(stg.frac_vol_sand[i, j]))) + # + # # --- Connect checkbox to all checkboxes of tableWidget --- + # self.allChkBox.stateChanged.connect(self.check_allChkBox) + # + # # --- Connect checkbox items of tableWidget to update plots --- + # self.tableWidget_sample.itemChanged.connect( + # self.extract_position_list_and_color_list_from_table_checkboxes) + # self.tableWidget_sample.itemChanged.connect(self.update_plot_total_concentration) + # self.tableWidget_sample.itemChanged.connect(self.update_plot_PSD_fine_and_sand_sediments) + # self.tableWidget_sample.itemChanged.connect(self.update_plot_sample_position_on_transect) else: # print("PLease download first file") @@ -849,20 +883,102 @@ class SampleDataTab(QWidget): msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() + def fill_table_sand(self): + # if (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand.text()): + if self.lineEdit_sand_sediment.text(): + + self.row_sand = self.tableWidget_sand.setRowCount(len(stg.depth_sand)) + self.column_sand = self.tableWidget_sand.setColumnCount(6 + stg.radius_grain_sand.shape[0]) + + # --- Set horizontal header --- + # horizontal_header = list(map(str, ["Color", "Sample"] + stg.fine_sediment_columns + + # stg.sand_sediment_columns[2:])) + horizontal_header = list(itertools.chain(["Color", "Sample"], + list(map(str, stg.columns_sand[[0, 2]])), + list(map(str, stg.columns_sand[3:])))) + + for horizontal_header_text in horizontal_header: + # print(horizontal_header_text) + self.horizontal_header_item_sand = QTableWidgetItem() + # print(np.where(horizontal_header == horizontal_header_text)[0][0]) + self.tableWidget_sand.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text), + self.horizontal_header_item_sand) + self.horizontal_header_item_sand.setText(horizontal_header_text) + + # --- Set vertical header (color) --- + self.tableWidget_sand.verticalHeader().setVisible(False) + color_list = CSS4_COLORS + for i in range(self.tableWidget_sand.rowCount()): + exec("self.comboBox_sample_table_sand" + str(i) + "= QComboBox()") + exec("self.comboBox_sample_table_sand" + str(i) + ".addItems(color_list)") + eval(f"self.tableWidget_sand.setCellWidget(i, 0, self.comboBox_sample_table_sand{i})") + eval(f"self.comboBox_sample_table_sand{i}.currentTextChanged." + f"connect(self.extract_position_list_and_color_list_from_table_checkboxes_sand)") + eval(f"self.comboBox_sample_table_sand{i}.currentTextChanged." + f"connect(self.plot_total_concentration)") + eval(f"self.comboBox_sample_table_sand{i}.currentTextChanged." + f"connect(self.plot_PSD_fine_and_sand_sediments)") + eval(f"self.comboBox_sample_table_sand{i}.currentTextChanged." + f"connect(self.update_plot_sample_position_on_transect)") + + # --- Fill Sample column with checkbox --- + for i in range(self.tableWidget_sand.rowCount()): + self.item_checkbox_sand = QTableWidgetItem() + self.item_checkbox_sand.setCheckState(Qt.Unchecked) + self.tableWidget_sand.setItem(i, 1, self.item_checkbox_sand) + self.item_checkbox_sand.setText("S" + str(i + 1)) + stg.sample_sand.append("S" + str(i + 1)) + # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) + + # --- Fill table with data --- + for i in range(stg.frac_vol_sand.shape[0]): + for j in range(stg.frac_vol_sand.shape[1]): + # self.tableWidget_sample.setItem(i, j + 2, QTableWidgetItem(str(granulo_data._data_fine.iloc[i, j]))) + self.tableWidget_sand.setItem(i, 2, QTableWidgetItem(str(stg.time_sand[i]))) + self.tableWidget_sand.setItem(i, 3, QTableWidgetItem(str(stg.depth_sand[i]))) + + self.tableWidget_sand.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_sand[i]))) + self.tableWidget_sand.setItem(i, 5, QTableWidgetItem(str(stg.D50_sand[i]))) + self.tableWidget_sand.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_sand[i, j]))) + + # --- Connect checkbox items of tableWidget to update plots --- + self.tableWidget_sand.itemChanged.connect( + self.extract_position_list_and_color_list_from_table_checkboxes_sand) + self.tableWidget_sand.itemChanged.connect(self.update_plot_sample_position_on_transect) + self.tableWidget_sand.itemChanged.connect(self.plot_total_concentration) + self.tableWidget_sand.itemChanged.connect(self.plot_PSD_fine_and_sand_sediments) + # --- Function to extract position of sample from table checkboxes to update plots --- - def extract_position_list_and_color_list_from_table_checkboxes(self): + def extract_position_list_and_color_list_from_table_checkboxes_fine(self): + # if self.tableWidget_fine.columnCount() > 10: position = [] color_list = [] - sample_checkbox = np.zeros((1, len(range(self.tableWidget_sample.rowCount())))) - for i in range(self.tableWidget_sample.rowCount()): - if self.tableWidget_sample.item(i, 1).checkState() == 2: - if self.tableWidget_sample.item(i, 1).checkState() == Qt.Checked: + sample_checkbox = np.zeros((1, len(range(self.tableWidget_fine.rowCount())))) + for i in range(self.tableWidget_fine.rowCount()): + if self.tableWidget_fine.item(i, 1).checkState() == 2: + if self.tableWidget_fine.item(i, 1).checkState() == Qt.Checked: position.append(i) - eval(f"color_list.append(self.comboBox_sample_table{i}.currentText())") + eval(f"color_list.append(self.comboBox_sample_table_fine{i}.currentText())") sample_checkbox[0, i] = 2 - + print("FINE : position ", position, " color_list ", color_list) return position, color_list + def extract_position_list_and_color_list_from_table_checkboxes_sand(self): + if self.tableWidget_sand.columnCount() > 10: + position = [] + color_list = [] + sample_checkbox = np.zeros((1, len(range(self.tableWidget_sand.rowCount())))) + for i in range(self.tableWidget_sand.rowCount()): + if self.tableWidget_sand.item(i, 1).checkState() == 2: + if self.tableWidget_sand.item(i, 1).checkState() == Qt.Checked: + position.append(i) + eval(f"color_list.append(self.comboBox_sample_table_sand{i}.currentText())") + sample_checkbox[0, i] = 2 + print("SAND : position ", position, " color_list ", color_list) + # self.update_plot_sample_position_on_transect() + return position, color_list + + def check_allChkBox(self, state): for i in range(self.tableWidget_sample.rowCount()): self.tableWidget_sample.item(i, 1).setCheckState(state) @@ -977,9 +1093,27 @@ class SampleDataTab(QWidget): # self.axis_sampleposition.set_yticks([]) # self.figure_sampleposition.canvas.draw_idle() + def event_combobobx_acoustic_data(self): + self.ShowPopUpWindowSignal.emit() + + print(stg.filename_BS_raw_data) + self.combobox_acoustic_data.clear() + for i in range(len(stg.filename_BS_raw_data)): + self.combobox_acoustic_data.addItem(stg.filename_BS_raw_data[i]) + + self.combobox_acoustic_data.showPopup() + + def fill_comboboxes_and_plot_transect(self): + + self.combobox_acoustic_data.clear() + self.combobox_acoustic_data.addItems(stg.filename_BS_raw_data) + self.plot_sample_position_on_transect() + self.combobox_acoustic_data.currentIndexChanged.connect(self.update_plot_sample_position_on_transect) + self.combobox_frequencies.currentIndexChanged.connect(self.update_plot_sample_position_on_transect) + def plot_sample_position_on_transect(self): - if stg.BS_cross_section.size == 0: + if len(stg.BS_raw_data) == 0: msgBox = QMessageBox() msgBox.setWindowTitle("Plot transect Error") msgBox.setIcon(QMessageBox.Warning) @@ -989,50 +1123,60 @@ class SampleDataTab(QWidget): else: - self.combobox_frequencies.addItems(stg.freq_text) - self.combobox_frequencies.currentTextChanged.connect(self.update_plot_sample_position_on_transect) + self.combobox_frequencies.clear() + self.combobox_frequencies.addItems(stg.freq_text[self.combobox_acoustic_data.currentIndex()]) + # self.combobox_frequencies.currentTextChanged.connect(self.update_plot_sample_position_on_transect) - self.verticalLayout_groupbox_plot_sample_position.removeWidget(self.canvas_plot_sample_position_on_transect) + self.verticalLayout_groupbox_plot_transect.removeWidget(self.canvas_plot_sample_position_on_transect) self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \ plt.subplots(nrows=1, ncols=1, layout="constrained") self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect) - self.verticalLayout_groupbox_plot_sample_position.addWidget(self.canvas_plot_sample_position_on_transect) + self.verticalLayout_groupbox_plot_transect.addWidget(self.canvas_plot_sample_position_on_transect) - if stg.BS_stream_bed.size == 0: + if stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()].shape != (0,): - val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + val_min = np.nanmin(stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :]) + val_max = np.nanmax(stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 self.axis_plot_sample_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], - -stg.r[stg.freq_bottom_detection, :], - stg.BS_cross_section[stg.freq_bottom_detection, :, :], + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + -stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - if stg.r_bottom.size != 0: - self.axis_plot_sample_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], - -stg.r_bottom, color='black', linewidth=1, linestyle="solid") + self.axis_plot_sample_position_on_transect.plot( + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + -stg.depth_bottom[self.combobox_acoustic_data.currentIndex()], color='black', linewidth=1, linestyle="solid") - else: + elif stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): - val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + val_min = np.nanmin( + stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :]) + val_max = np.nanmax( + stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 self.axis_plot_sample_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], - -stg.r[stg.freq_bottom_detection, :], - stg.BS_stream_bed[stg.freq_bottom_detection, :, :], + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + -stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - if stg.r_bottom.size != 0: - self.axis_plot_sample_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, - color='black', linewidth=1, linestyle="solid") + elif stg.BS_raw_data[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + val_min = np.nanmin(stg.BS_raw_data[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :]) + val_max = np.nanmax(stg.BS_raw_data[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + + self.axis_plot_sample_position_on_transect.pcolormesh( + stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + -stg.depth[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + stg.BS_raw_data[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) self.axis_plot_sample_position_on_transect.set_xticks([]) self.axis_plot_sample_position_on_transect.set_yticks([]) @@ -1040,75 +1184,166 @@ class SampleDataTab(QWidget): def update_plot_sample_position_on_transect(self): - # --- Read selected samples (checkboxes) --- - position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() + self.axis_plot_sample_position_on_transect.cla() # --- Create canvas of Matplotlib figure --- - if stg.BS_raw_data.size == 0: + if stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()].shape != (0,): - self.verticalLayout_groupbox_plot_sample_position.removeWidget(self.canvas_plot_sample_position_on_transect) - self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \ - plt.subplots(nrows=1, ncols=1, layout="constrained") - self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect) - self.verticalLayout_groupbox_plot_sample_position.addWidget(self.canvas_plot_sample_position_on_transect) - - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[position_list], - stg.sample_depth[position_list], - linestyle='None', marker="o", s=14, c=color_list) - - self.axis_plot_sample_position_on_transect.set_xticks([]) - self.axis_plot_sample_position_on_transect.set_yticks([]) - self.figure_plot_sample_position_on_transect.canvas.draw_idle() - - elif stg.BS_stream_bed.size == 0: - - val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + val_min = np.nanmin(stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :]) + val_max = np.nanmax(stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 self.axis_plot_sample_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], - stg.BS_cross_section[self.combobox_frequencies.currentIndex(), :, :], + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + -stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - if stg.r_bottom.size != 0: - self.axis_plot_sample_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, - color='black', linewidth=1, linestyle="solid") + self.axis_plot_sample_position_on_transect.plot( + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), :], + -stg.depth_bottom[self.combobox_acoustic_data.currentIndex()], + color='black', linewidth=1, linestyle="solid") - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[position_list], - stg.sample_depth[position_list], - linestyle='None', marker="o", s=14, c=color_list) + elif stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): - - self.axis_plot_sample_position_on_transect.set_xticks([]) - self.axis_plot_sample_position_on_transect.set_yticks([]) - self.figure_plot_sample_position_on_transect.canvas.draw_idle() - - else: - - val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + val_min = np.nanmin( + stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), + :, :]) + val_max = np.nanmax( + stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), + :, :]) if val_min == 0: val_min = 1e-5 self.axis_plot_sample_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], - stg.BS_stream_bed[self.combobox_frequencies.currentIndex(), :, :], + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), :], + -stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), :], + stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), + :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - if stg.r_bottom.size != 0: - self.axis_plot_sample_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid") + elif stg.BS_raw_data[self.combobox_acoustic_data.currentIndex()].shape != (0,): - self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[position_list], - stg.sample_depth[position_list], - linestyle='None', marker="o", s=14, c=color_list) + val_min = np.nanmin( + stg.BS_raw_data[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), + :, :]) + val_max = np.nanmax( + stg.BS_raw_data[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), + :, :]) + if val_min == 0: + val_min = 1e-5 - self.axis_plot_sample_position_on_transect.set_xticks([]) - self.axis_plot_sample_position_on_transect.set_yticks([]) - self.figure_plot_sample_position_on_transect.canvas.draw_idle() + self.axis_plot_sample_position_on_transect.pcolormesh( + stg.time[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), :], + -stg.depth[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), :], + stg.BS_raw_data[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), + :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + # --- Read selected samples (checkboxes) --- + if self.tableWidget_fine.columnCount() > 10: + + position_list_fine, color_list_fine = self.extract_position_list_and_color_list_from_table_checkboxes_fine() + + if len(position_list_fine) != 0: + time_fine_to_plot = [] + depth_fine_to_plot = [] + for k in position_list_fine: + time_fine_to_plot.append(stg.time_fine[k]) + depth_fine_to_plot.append(stg.depth_fine[k]) + self.axis_plot_sample_position_on_transect.scatter(time_fine_to_plot, depth_fine_to_plot, + linestyle='None', marker="o", s=12, c=color_list_fine) + + if self.tableWidget_sand.columnCount() > 10: + position_list_sand, color_list_sand = self.extract_position_list_and_color_list_from_table_checkboxes_sand() + + if len(position_list_sand) != 0: + time_sand_to_plot = [] + depth_sand_to_plot = [] + for k in position_list_sand: + time_sand_to_plot.append(stg.time_sand[k]) + depth_sand_to_plot.append(stg.depth_sand[k]) + + self.axis_plot_sample_position_on_transect.scatter(time_sand_to_plot, depth_sand_to_plot, + linestyle='None', marker="o", s=24, edgecolor=color_list_sand) + + self.axis_plot_sample_position_on_transect.set_xticks([]) + self.axis_plot_sample_position_on_transect.set_yticks([]) + self.figure_plot_sample_position_on_transect.canvas.draw_idle() + + # if stg.BS_raw_data.size == 0: + # + # self.verticalLayout_groupbox_plot_sample_position.removeWidget(self.canvas_plot_sample_position_on_transect) + # self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \ + # plt.subplots(nrows=1, ncols=1, layout="constrained") + # self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect) + # self.verticalLayout_groupbox_plot_sample_position.addWidget(self.canvas_plot_sample_position_on_transect) + # + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[position_list], + # stg.sample_depth[position_list], + # linestyle='None', marker="o", s=14, c=color_list) + # + # self.axis_plot_sample_position_on_transect.set_xticks([]) + # self.axis_plot_sample_position_on_transect.set_yticks([]) + # self.figure_plot_sample_position_on_transect.canvas.draw_idle() + # + # elif stg.BS_stream_bed.size == 0: + # + # val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + # val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # self.axis_plot_sample_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], + # stg.BS_cross_section[self.combobox_frequencies.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # if stg.r_bottom.size != 0: + # self.axis_plot_sample_position_on_transect.plot( + # stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, + # color='black', linewidth=1, linestyle="solid") + # + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[position_list], + # stg.sample_depth[position_list], + # linestyle='None', marker="o", s=14, c=color_list) + # + # + # self.axis_plot_sample_position_on_transect.set_xticks([]) + # self.axis_plot_sample_position_on_transect.set_yticks([]) + # self.figure_plot_sample_position_on_transect.canvas.draw_idle() + # + # else: + # + # val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + # val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # self.axis_plot_sample_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], + # stg.BS_stream_bed[self.combobox_frequencies.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # if stg.r_bottom.size != 0: + # self.axis_plot_sample_position_on_transect.plot( + # stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid") + # + # self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[position_list], + # stg.sample_depth[position_list], + # linestyle='None', marker="o", s=14, c=color_list) + # + # self.axis_plot_sample_position_on_transect.set_xticks([]) + # self.axis_plot_sample_position_on_transect.set_yticks([]) + # self.figure_plot_sample_position_on_transect.canvas.draw_idle() @@ -1120,302 +1355,12 @@ class SampleDataTab(QWidget): # self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) # self.canvas_total_concentration.draw() - def update_plot_total_concentration(self): - if self.tableWidget_sample.columnCount() > 15: + def plot_total_concentration(self): - # --- Read selected samples (checkboxes) --- - position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() + """ Update total concentration plot according to choices of x-axis and y-axis combo-boxes """ - self.compute_Ctot_per_cent() + if (self.tableWidget_fine.columnCount() == 10) and (self.tableWidget_sand.columnCount() == 10): - if position_list == []: - - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Select sample(s) before changing axis") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - - elif (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand.text()): - - # --- Create canvas of Matplotlib figure --- - if self.canvas_total_concentration == None: - self.figure_total_concentration, self.axis_total_concentration \ - = plt.subplots(nrows=1, ncols=1, layout="constrained") - self.canvas_total_concentration = FigureCanvas(self.figure_total_concentration) - self.verticalLayout_plot_total_concentration.addWidget(self.canvas_total_concentration) - else: - self.axis_total_concentration.cla() - - # --- Update total concentration plot according to choices of x-axis and y-axis combo-boxes --- - - if (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 0): - self.axis_total_concentration.scatter(stg.Ctot_fine[position_list], - stg.sample_depth[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 1): - if stg.r_bottom.size == 0: - self.combobox_y_axis.setCurrentIndex(0) - self.axis_total_concentration.scatter(stg.Ctot_fine[position_list], - stg.sample_depth[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("To use z/h axis, please compute before the bottom detection algorithm " - "\n in acoustic data tab") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - indices = [] - for i in position_list: - # indices.append(np.where(stg.t == stg.sample_time[i])[0][0]) - indices.append(np.where(np.abs(stg.t - stg.sample_time[i]) == np.nanmin(np.abs(stg.t - stg.sample_time[i])))[0][0]) - self.axis_total_concentration.scatter(stg.Ctot_fine[position_list], - -stg.sample_depth[position_list] / stg.r_bottom[indices], - # np.max(stg.sample_depth[position_list]), - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.set_ylim(0, 1) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 0): - self.axis_total_concentration.scatter(stg.Ctot_fine_per_cent[position_list], - stg.sample_depth[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 1): - if stg.r_bottom.size == 0: - self.combobox_y_axis.setCurrentIndex(0) - self.axis_total_concentration.scatter(stg.Ctot_fine_per_cent[position_list], - stg.sample_depth[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("To use z/h axis, please compute before the bottom detection algorithm " - "\n in acoustic data tab") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - indices = [] - for i in position_list: - # indices.append(np.where(stg.t == stg.sample_time[i])[0][0]) - indices.append(np.where( - np.abs(stg.t - stg.sample_time[i]) == np.nanmin(np.abs(stg.t - stg.sample_time[i])))[0][ - 0]) - self.axis_total_concentration.scatter(stg.Ctot_fine_per_cent[position_list], - -stg.sample_depth[position_list] / stg.r_bottom[indices], - # np.max(stg.sample_depth[position_list]), - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_ylim(0, 1) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - self.canvas_total_concentration.draw() - - elif not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): - - # --- Create canvas of Matplotlib figure --- - if self.canvas_total_concentration == None: - self.figure_total_concentration, self.axis_total_concentration \ - = plt.subplots(nrows=1, ncols=1, layout="constrained") - self.canvas_total_concentration = FigureCanvas(self.figure_total_concentration) - self.verticalLayout_plot_total_concentration.addWidget(self.canvas_total_concentration) - else: - self.axis_total_concentration.cla() - - # --- Update total concentration plot according to choices of x-axis and y-axis combo-boxes --- - - if (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 0): - self.axis_total_concentration.scatter(stg.Ctot_sand[position_list], - stg.sample_depth[position_list], - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 1): - if stg.r_bottom.size == 0: - self.combobox_y_axis.setCurrentIndex(0) - self.axis_total_concentration.scatter(stg.Ctot_sand[position_list], - stg.sample_depth[position_list], - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("To use z/h axis, please compute before the bottom detection algorithm " - "\n in acoustic data tab") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - indices = [] - for i in position_list: - # indices.append(np.where(stg.t == stg.sample_time[i])[0][0]) - indices.append(np.where( - np.abs(stg.t - stg.sample_time[i]) == np.nanmin(np.abs(stg.t - stg.sample_time[i])))[0][ - 0]) - self.axis_total_concentration.scatter(stg.Ctot_sand[position_list], - -stg.sample_depth[position_list] / stg.r_bottom[indices], - # np.max(stg.sample_depth[position_list]), - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_ylim(0, 1) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 0): - self.axis_total_concentration.scatter(stg.Ctot_sand_per_cent[position_list], - stg.sample_depth[position_list], - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 1): - if stg.r_bottom.size == 0: - self.combobox_y_axis.setCurrentIndex(0) - self.axis_total_concentration.scatter(stg.Ctot_sand_per_cent[position_list], - stg.sample_depth[position_list], - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("To use z/h axis, please compute before the bottom detection algorithm " - "\n in acoustic data tab") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - indices = [] - for i in position_list: - # indices.append(np.where(stg.t == stg.sample_time[i])[0][0]) - indices.append(np.where( - np.abs(stg.t - stg.sample_time[i]) == np.nanmin(np.abs(stg.t - stg.sample_time[i])))[0][ - 0]) - self.axis_total_concentration.scatter(stg.Ctot_sand_per_cent[position_list], - -stg.sample_depth[position_list] / stg.r_bottom[indices], - # np.max(stg.sample_depth[position_list]), - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_ylim(0, 1) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - self.canvas_total_concentration.draw() - - elif (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): - - # --- Create canvas of Matplotlib figure --- - if self.canvas_total_concentration == None: - self.figure_total_concentration, self.axis_total_concentration \ - = plt.subplots(nrows=1, ncols=1, layout="constrained") - self.canvas_total_concentration = FigureCanvas(self.figure_total_concentration) - self.verticalLayout_plot_total_concentration.addWidget(self.canvas_total_concentration) - else: - self.axis_total_concentration.cla() - - # --- Update total concentration plot according to choices of x-axis and y-axis combo-boxes --- - - if (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 0): - self.axis_total_concentration.scatter(stg.Ctot_fine[position_list], - stg.sample_depth[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.scatter(stg.Ctot_sand[position_list], - stg.sample_depth[position_list], - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 0) and (self. combobox_y_axis.currentIndex() == 1): - if stg.r_bottom.size == 0: - self.combobox_y_axis.setCurrentIndex(0) - self.axis_total_concentration.scatter(stg.Ctot_fine[position_list], - stg.sample_depth[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.scatter(stg.Ctot_sand[position_list], - stg.sample_depth[position_list], - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("To use z/h axis, please compute before the bottom detection algorithm " - "\n in acoustic data tab") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - indices = [] - for i in position_list: - # indices.append(np.where(stg.t == stg.sample_time[i])[0][0]) - indices.append(np.where( - np.abs(stg.t - stg.sample_time[i]) == np.nanmin(np.abs(stg.t - stg.sample_time[i])))[0][ - 0]) - self.axis_total_concentration.scatter(stg.Ctot_fine[position_list], - -stg.sample_depth[position_list] / stg.r_bottom[indices], #np.max(stg.sample_depth[position_list]), - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.scatter(stg.Ctot_sand[position_list], - -stg.sample_depth[position_list] / stg.r_bottom[indices], #np.max(stg.sample_depth[position_list]), - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_ylim(0, 1) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 1) and (self. combobox_y_axis.currentIndex() == 0): - self.axis_total_concentration.scatter(stg.Ctot_fine_per_cent[position_list], - stg.sample_depth[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.scatter(stg.Ctot_sand_per_cent[position_list], - stg.sample_depth[position_list], - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - elif (self.combobox_x_axis.currentIndex() == 1) and (self. combobox_y_axis.currentIndex() == 1): - if stg.r_bottom.size == 0: - self.combobox_y_axis.setCurrentIndex(0) - self.axis_total_concentration.scatter(stg.Ctot_fine_per_cent[position_list], - stg.sample_depth[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.scatter(stg.Ctot_sand_per_cent[position_list], - stg.sample_depth[position_list], - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("To use z/h axis, please compute before the bottom detection algorithm " - "\n in acoustic data tab") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - indices = [] - for i in position_list: - # indices.append(np.where(stg.t == stg.sample_time[i])[0][0]) - indices.append(np.where( - np.abs(stg.t - stg.sample_time[i]) == np.nanmin(np.abs(stg.t - stg.sample_time[i])))[0][ - 0]) - self.axis_total_concentration.scatter(stg.Ctot_fine_per_cent[position_list], - -stg.sample_depth[position_list] / stg.r_bottom[indices], #np.max(stg.sample_depth[position_list]), - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.scatter(stg.Ctot_sand_per_cent[position_list], - -stg.sample_depth[position_list] / stg.r_bottom[indices], #np.max(stg.sample_depth[position_list]), - s=300, facecolors="None", edgecolors=color_list) - self.axis_total_concentration.set_xlim(0, 100) - self.axis_total_concentration.set_ylim(0, 1) - self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) - self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) - self.canvas_total_concentration.draw() - - else: msgBox = QMessageBox() msgBox.setWindowTitle("Axis choice Error") msgBox.setIcon(QMessageBox.Warning) @@ -1423,6 +1368,558 @@ class SampleDataTab(QWidget): msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() + # if (position_list_fine == []) and (position_list_sand == []): + # + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Axis choice Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Select sample(s) before changing axis") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + + else: + + self.verticalLayout_groupbox_plot_total_concentration.removeWidget(self.canvas_plot_total_concentration) + self.figure_total_concentration, self.axis_total_concentration \ + = plt.subplots(nrows=1, ncols=1, layout="constrained") + self.canvas_plot_total_concentration = FigureCanvas(self.figure_total_concentration) + self.verticalLayout_groupbox_plot_total_concentration.addWidget(self.canvas_plot_total_concentration) + + # --- FINE file uploaded / SAND file NOT uploaded --- + if (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand_sediment.text()): + + self.compute_Ctot_per_cent() + + # --- Read selected samples (checkboxes) --- + position_list_fine, color_list_fine = self.extract_position_list_and_color_list_from_table_checkboxes_fine() + Ctot_fine_to_plot = [] + Ctot_fine_percent_to_plot = [] + sample_depth_to_plot_fine = [] + indices_bottom_fine = [] + depth_bottom_to_plot_fine = [] + print("time fine ", stg.time_fine) + for k in range(len(position_list_fine)): + print("k = ", k, "type(k) = ", type(k)) + Ctot_fine_to_plot.append(stg.Ctot_fine[position_list_fine[k]]) + Ctot_fine_percent_to_plot.append(stg.Ctot_fine_per_cent[position_list_fine[k]]) + sample_depth_to_plot_fine.append(stg.depth_fine[position_list_fine[k]]) + if stg.depth_bottom[self.combobox_acoustic_data.currentIndex()].shape != (0,): + print("stg.time_fine ", stg.time_fine[position_list_fine[k]]) + + indice_test = np.argmax(np.abs([stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] + - stg.time_fine[position_list_fine[k]]])) + print("indice test ", indice_test) + print(np.where(np.abs([stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_fine[position_list_fine[k]]]) == + np.nanmin(np.abs(stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_fine[position_list_fine[k]])))) + indices_bottom_fine.append(np.where(np.abs([stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_fine[position_list_fine[k]]]) == + np.nanmin(np.abs(stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_fine[position_list_fine[k]])))[1][0]) + depth_bottom_to_plot_fine.append( + stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_fine[-1]]) + + print("depth_bottom_to_plot_fine ", depth_bottom_to_plot_fine) + print("indices_bottom_fine ", indices_bottom_fine) + + elif stg.time_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + indices_bottom_fine.append(np.where( + np.abs(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_fine[position_list_fine[k]]) == + np.nanmin( + np.abs(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_fine[position_list_fine[k]])))[ + 1][0]) + depth_bottom_to_plot_fine.append( + stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), -1]) + + else: + indices_bottom_fine.append(np.where( + np.abs(stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_fine[position_list_fine[k]]) == + np.nanmin( + np.abs(stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_fine[position_list_fine[k]])))[ + 1][0]) + depth_bottom_to_plot_fine.append( + stg.depth[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), -1]) + + self.axis_total_concentration.cla() + + # --- Concentration (g/L) VS z (m) --- + if (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 0): + self.axis_total_concentration.scatter(Ctot_fine_to_plot, + sample_depth_to_plot_fine, + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (%) VS z (m) --- + elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 0): + self.axis_total_concentration.scatter(Ctot_fine_percent_to_plot, sample_depth_to_plot_fine, + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + self.axis_total_concentration.set_xlim(0, 100) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (g/L) VS z / h --- + elif (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 1): + + if stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_fine_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + elif stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_fine_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + # stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + # self.combobox_frequencies.currentIndex(), -1], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + else: + + self.axis_total_concentration.scatter( + Ctot_fine_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + # stg.depth[self.combobox_acoustic_data.currentIndex()][ + # self.combobox_frequencies.currentIndex(), -1], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + self.axis_total_concentration.set_ylim(-1, 0) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (%) VS z / h --- + elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 1): + + if stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_fine_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + elif stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_fine_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + # stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + # self.combobox_frequencies.currentIndex(), -1], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + else: + + self.axis_total_concentration.scatter( + Ctot_fine_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + # stg.depth[self.combobox_acoustic_data.currentIndex()][ + # self.combobox_frequencies.currentIndex(), -1], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + self.axis_total_concentration.set_xlim(0, 100) + self.axis_total_concentration.set_ylim(-1, 0) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + self.figure_total_concentration.canvas.draw_idle() + + # --- FINE file NOT uploaded / SAND file uploaded --- + elif not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand_sediment.text()): + + self.compute_Ctot_per_cent() + + # --- Read selected sand samples (checkboxes) --- + position_list_sand, color_list_sand = self.extract_position_list_and_color_list_from_table_checkboxes_sand() + Ctot_sand_to_plot = [] + Ctot_sand_percent_to_plot = [] + sample_depth_to_plot_sand = [] + indices_bottom_sand = [] + depth_bottom_to_plot_sand = [] + for k in range(len(position_list_sand)): + Ctot_sand_to_plot.append(stg.Ctot_sand[position_list_sand[k]]) + Ctot_sand_percent_to_plot.append(stg.Ctot_sand_per_cent[position_list_sand[k]]) + sample_depth_to_plot_sand.append(stg.depth_sand[position_list_sand[k]]) + if stg.depth_bottom[self.combobox_acoustic_data.currentIndex()].shape != (0,): + indices_bottom_sand.append(np.where(np.abs( + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_sand[ + position_list_sand[k]]) == + np.nanmin(np.abs(stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_sand[k])))[1][0]) + depth_bottom_to_plot_sand.append( + stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_sand[-1]]) + + elif stg.time_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + indices_bottom_sand.append(np.where( + np.abs(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_sand[position_list_sand[k]]) == + np.nanmin( + np.abs(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_sand[position_list_sand[k]])))[ + 1][0]) + depth_bottom_to_plot_sand.append( + stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), -1]) + + else: + indices_bottom_sand.append(np.where( + np.abs(stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_sand[position_list_sand[k]]) == + np.nanmin( + np.abs(stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_sand[position_list_sand[k]])))[ + 1][0]) + depth_bottom_to_plot_sand.append( + stg.depth[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), -1]) + + + self.axis_total_concentration.cla() + + # --- Concentration (g/L) VS z (m) --- + if (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 0): + self.axis_total_concentration.scatter(Ctot_sand_to_plot, + sample_depth_to_plot_sand, + s=300, facecolor="None", edgecolor=color_list_sand, + alpha=0.5) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (%) VS z (m) --- + elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 0): + self.axis_total_concentration.scatter(Ctot_sand_percent_to_plot, sample_depth_to_plot_sand, + s=300, facecolor="None", edgecolor=color_list_sand, + alpha=0.5) + self.axis_total_concentration.set_xlim(0, 100) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (g/L) VS z / h --- + elif (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 1): + + if stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_sand_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + # stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_sand], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + elif stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_sand_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + # stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + # self.combobox_frequencies.currentIndex(), -1], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + else: + + self.axis_total_concentration.scatter( + Ctot_sand_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + # stg.depth[self.combobox_acoustic_data.currentIndex()][ + # self.combobox_frequencies.currentIndex(), -1], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + self.axis_total_concentration.set_ylim(-1, 0) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (%) VS z / h --- + elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 1): + + if stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_sand_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + # stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_sand], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + elif stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_sand_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + # stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + # self.combobox_frequencies.currentIndex(), -1], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + else: + + self.axis_total_concentration.scatter( + Ctot_sand_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + # stg.depth[self.combobox_acoustic_data.currentIndex()][ + # self.combobox_frequencies.currentIndex(), -1], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + self.axis_total_concentration.set_xlim(0, 100) + self.axis_total_concentration.set_ylim(-1, 0) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + self.figure_total_concentration.canvas.draw_idle() + + # --- FINE file uploaded / SAND file uploaded --- + elif (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand_sediment.text()): + + self.compute_Ctot_per_cent() + + # --- Read selected fine samples (checkboxes) --- + position_list_fine, color_list_fine = self.extract_position_list_and_color_list_from_table_checkboxes_fine() + Ctot_fine_to_plot = [] + Ctot_fine_percent_to_plot = [] + sample_depth_to_plot_fine = [] + indices_bottom_fine = [] + depth_bottom_to_plot_fine = [] + print("time fine ", stg.time_fine) + for k in range(len(position_list_fine)): + print("k = ", k, "type(k) = ", type(k)) + Ctot_fine_to_plot.append(stg.Ctot_fine[position_list_fine[k]]) + Ctot_fine_percent_to_plot.append(stg.Ctot_fine_per_cent[position_list_fine[k]]) + sample_depth_to_plot_fine.append(stg.depth_fine[position_list_fine[k]]) + if stg.depth_bottom[self.combobox_acoustic_data.currentIndex()].shape != (0,): + indices_bottom_fine.append(np.where(np.asarray(np.abs([stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_fine[position_list_fine[k]]])) == + np.nanmin(np.abs(stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_fine[position_list_fine[k]])))[1][0]) + print("indices_bottom_fine ", indices_bottom_fine) + depth_bottom_to_plot_fine.append( + stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_fine[-1]]) + + elif stg.time_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + indices_bottom_fine.append(np.where(np.asarray(np.abs([stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex()] - + stg.time_fine[ + position_list_fine[k]]])) == + np.nanmin(np.abs(stg.time_cross_section[ + self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex()] - + stg.time_fine[position_list_fine[k]])))[1][ + 0]) + print() + depth_bottom_to_plot_fine.append( + stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), -1]) + + else: + + indices_bottom_fine.append(np.where( + np.asarray(np.abs(stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_fine[k])) == + np.nanmin( + np.abs(stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] + - stg.time_fine[k])))[1][0]) + + depth_bottom_to_plot_fine.append( + stg.depth[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), + -1]) + + + + # print(stg.time_fine[k]) + # print(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()]) + # print(np.abs(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_fine[k])) + # print(np.nanmin(np.abs(np.asarray(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_fine[k])))) + # print(np.where(np.asarray(np.abs([stg.time_cross_section[ + # self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + # stg.time_fine[k]])) == + # np.nanmin(np.abs(stg.time_cross_section[ + # self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + # stg.time_fine[k])))) + # # plt.plot(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()], + # # (np.abs(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_fine[k]))) + # # plt.show() + # print("indices_bottom_fine ", indices_bottom_fine) + # print(stg.depth_bottom[self.combobox_acoustic_data.currentIndex()]) + # # depth_bottom_to_plot_fine.append(stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_fine[-1]]) + # print("depth_bottom_to_plot_fine ", depth_bottom_to_plot_fine) + + # --- Read selected sand samples (checkboxes) --- + position_list_sand, color_list_sand = self.extract_position_list_and_color_list_from_table_checkboxes_sand() + Ctot_sand_to_plot = [] + Ctot_sand_percent_to_plot = [] + sample_depth_to_plot_sand = [] + indices_bottom_sand = [] + depth_bottom_to_plot_sand = [] + for k in range(len(position_list_sand)): + Ctot_sand_to_plot.append(stg.Ctot_sand[position_list_sand[k]]) + Ctot_sand_percent_to_plot.append(stg.Ctot_sand_per_cent[position_list_sand[k]]) + sample_depth_to_plot_sand.append(stg.depth_sand[position_list_sand[k]]) + if stg.depth_bottom[self.combobox_acoustic_data.currentIndex()].shape != (0,): + indices_bottom_sand.append(np.where(np.abs( + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_sand[ + position_list_sand[k]]) == np.nanmin(np.abs(stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - + stg.time_sand[position_list_sand[k]])))[1][0]) + + depth_bottom_to_plot_sand.append(stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_sand[-1]]) + + elif stg.time_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + indices_bottom_sand.append(np.where(np.abs( + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex()] - + stg.time_sand[ + position_list_sand[k]]) == np.nanmin(np.abs( + stg.time_cross_section[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex()] - + stg.time_sand[position_list_sand[k]])))[0][0]) + + depth_bottom_to_plot_sand.append( + stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), -1]) + + else: + indices_bottom_sand.append(np.where( + np.abs( + stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_sand[position_list_sand[k]]) == + np.nanmin( + np.abs(stg.time[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex()] - stg.time_sand[position_list_sand[k]])))[1][0]) + + depth_bottom_to_plot_sand.append( + stg.depth[self.combobox_acoustic_data.currentIndex()][self.combobox_frequencies.currentIndex(), + -1]) + + # print("indices_bottom_sand ", indices_bottom_sand) + # print("depth_bottom_to_plot_sand ", depth_bottom_to_plot_sand) + + self.axis_total_concentration.cla() + + # --- Concentration (g/L) VS z (m) --- + if (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 0): + + self.axis_total_concentration.scatter(Ctot_fine_to_plot, + sample_depth_to_plot_fine, + s=100, facecolor=color_list_fine, edgecolor="None", + alpha=0.5) + self.axis_total_concentration.scatter(Ctot_sand_to_plot, + sample_depth_to_plot_sand, + s=300, facecolor="None", edgecolor=color_list_sand, + alpha=0.5) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (%) VS z (m) --- + elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 0): + print("Ctot_fine_percent_to_plot", Ctot_fine_percent_to_plot) + print("sample_depth_to_plot_fine", sample_depth_to_plot_fine) + self.axis_total_concentration.scatter(Ctot_fine_percent_to_plot, sample_depth_to_plot_fine, + s=100, facecolor=color_list_fine, edgecolor="None", + alpha=0.5) + self.axis_total_concentration.scatter(Ctot_sand_percent_to_plot, sample_depth_to_plot_sand, + s=300, facecolor="None", edgecolor=color_list_sand, + alpha=0.5) + self.axis_total_concentration.set_xlim(0, 100) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (g/L) VS z / h --- + elif (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 1): + + if stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()].shape != (0,): + print("x/y ", [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)]) + self.axis_total_concentration.scatter( + Ctot_fine_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + self.axis_total_concentration.scatter( + Ctot_sand_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + elif stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_fine_to_plot, + stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), -1], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + self.axis_total_concentration.scatter( + Ctot_sand_to_plot, + stg.depth_cross_section[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), -1], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + else: + + self.axis_total_concentration.scatter( + Ctot_fine_to_plot, + stg.depth[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), -1], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + self.axis_total_concentration.scatter( + Ctot_sand_to_plot, + stg.depth[self.combobox_acoustic_data.currentIndex()][ + self.combobox_frequencies.currentIndex(), -1], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + self.axis_total_concentration.set_ylim(-1, 0) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + # --- Concentration (%) VS z / h --- + elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 1): + + if stg.BS_stream_bed[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_fine_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + self.axis_total_concentration.scatter( + Ctot_sand_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + elif stg.BS_cross_section[self.combobox_acoustic_data.currentIndex()].shape != (0,): + + self.axis_total_concentration.scatter( + Ctot_fine_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + self.axis_total_concentration.scatter( + Ctot_sand_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + else: + + self.axis_total_concentration.scatter( + Ctot_fine_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)], + s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5) + + self.axis_total_concentration.scatter( + Ctot_sand_percent_to_plot, + [x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)], + s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5) + + self.axis_total_concentration.set_xlim(0, 100) + self.axis_total_concentration.set_ylim(-1, 0) + self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText()) + self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText()) + + self.figure_total_concentration.canvas.draw_idle() + + + # ------------------------------------------------------------------------------------------------------------------ # def empty_field_to_plot_fine_sediment_distribution(self): @@ -1540,162 +2037,313 @@ class SampleDataTab(QWidget): # self.pressedState.emit(True) # print(self.pressedState.emit(True)) - def update_plot_PSD_fine_and_sand_sediments(self): - if self.tableWidget_sample.columnCount() > 15: + def plot_PSD_fine_and_sand_sediments(self): - # --- Read selected samples (checkboxes) --- - position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() + """ Update the plot of Particle Size Distribution according to choices of x-axis and y-axis combo-boxes """ - if position_list == []: + if (self.tableWidget_fine.columnCount() == 10) and (self.tableWidget_sand.columnCount() == 10): - msgBox = QMessageBox() - msgBox.setWindowTitle("Axis choice Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Select sample(s) before changing axis") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - - elif (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand.text()): - - # --- Create canvas of Matplotlib figure --- - if self.canvas_plot_PSD == None: - self.figure_plot_PSD, self.axis_plot_PSD = plt.subplots(nrows=1, ncols=2, layout="constrained") - self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD) - self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) - else: - self.axis_plot_PSD[0].cla() - self.axis_plot_PSD[1].cla() - - if self.combobox_PSD_plot.currentIndex() == 0: - - for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot(stg.radius_grain, - stg.frac_vol_fine[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[0].set_xscale('log') - self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') - - self.axis_plot_PSD[1].plot() - self.axis_plot_PSD[1].set_xscale('log') - self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') - - elif self.combobox_PSD_plot.currentIndex() == 1: - - for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot(stg.radius_grain, - stg.frac_vol_fine_cumul[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[0].set_xscale('log') - self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') - - self.axis_plot_PSD[1].plot() - self.axis_plot_PSD[1].set_xscale('log') - self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') - - self.canvas_plot_PSD.draw() - - elif not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): - - # --- Create canvas of Matplotlib figure --- - if self.canvas_plot_PSD == None: - self.figure_plot_PSD, self.axis_plot_PSD = plt.subplots(nrows=1, ncols=2, layout="constrained") - self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD) - self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) - else: - self.axis_plot_PSD[0].cla() - self.axis_plot_PSD[1].cla() - - if self.combobox_PSD_plot.currentIndex() == 0: - - for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot() - self.axis_plot_PSD[0].set_xscale('log') - self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') - - self.axis_plot_PSD[1].plot(stg.radius_grain, - stg.frac_vol_sand[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[1].set_xscale('log') - self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') - - elif self.combobox_PSD_plot.currentIndex() == 1: - - for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot() - self.axis_plot_PSD[0].set_xscale('log') - self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') - - self.axis_plot_PSD[1].plot(stg.radius_grain, - stg.frac_vol_sand_cumul[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[1].set_xscale('log') - self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') - - self.canvas_plot_PSD.draw() - - elif (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): - - # --- Create canvas of Matplotlib figure --- - if self.canvas_plot_PSD == None: - self.figure_plot_PSD, self.axis_plot_PSD = plt.subplots(nrows=1, ncols=2, layout="constrained") - self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD) - self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) - else: - self.axis_plot_PSD[0].cla() - self.axis_plot_PSD[1].cla() - - if self.combobox_PSD_plot.currentIndex() == 0: - - for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot(stg.radius_grain, - stg.frac_vol_fine[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[0].set_xscale('log') - self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') - - self.axis_plot_PSD[1].plot(stg.radius_grain, - stg.frac_vol_sand[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[1].set_xscale('log') - self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') - - elif self.combobox_PSD_plot.currentIndex() == 1: - - for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot(stg.radius_grain, - stg.frac_vol_fine_cumul[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[0].set_xscale('log') - self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') - - self.axis_plot_PSD[1].plot(stg.radius_grain, - stg.frac_vol_sand_cumul[profil_position_num, :], - color=color_plot) - self.axis_plot_PSD[1].set_xscale('log') - self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') - self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') - - self.canvas_plot_PSD.draw() - - else: msgBox = QMessageBox() - msgBox.setWindowTitle("Plot PSD Error") + msgBox.setWindowTitle("Axis choice Error") msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Fill table and select sample(s) before plotting PSD") + msgBox.setText("Fill table and select sample(s) before changing axis") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() + # if (position_list_fine == []) and (position_list_sand == []): + # + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Axis choice Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Select sample(s) before changing axis") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + + else: + + self.verticalLayout_groupbox_plot_PSD.removeWidget(self.canvas_plot_PSD) + self.figure_plot_PSD, self.axis_plot_PSD \ + = plt.subplots(nrows=1, ncols=2, layout="constrained") + self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD) + self.verticalLayout_groupbox_plot_PSD.addWidget(self.canvas_plot_PSD) + + # --- FINE file uploaded / SAND file NOT uploaded --- + if (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand_sediment.text()): + + self.axis_plot_PSD[0].cla() + self.axis_plot_PSD[1].cla() + + position_list_fine, color_list_fine = self.extract_position_list_and_color_list_from_table_checkboxes_fine() + + if self.combobox_PSD_plot.currentIndex() == 0: + + for profil_position_num, color_plot in zip(position_list_fine, color_list_fine): + self.axis_plot_PSD[0].plot(stg.radius_grain_fine, + stg.frac_vol_fine[profil_position_num, :], + color=color_plot) + self.axis_plot_PSD[0].set_xscale('log') + self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') + + self.axis_plot_PSD[1].plot() + self.axis_plot_PSD[1].set_xscale('log') + self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + + elif self.combobox_PSD_plot.currentIndex() == 1: + + for profil_position_num, color_plot in zip(position_list_fine, color_list_fine): + self.axis_plot_PSD[0].plot(stg.radius_grain_fine, + stg.frac_vol_fine_cumul[profil_position_num, :], + color=color_plot) + self.axis_plot_PSD[0].set_xscale('log') + self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') + + self.axis_plot_PSD[1].plot() + self.axis_plot_PSD[1].set_xscale('log') + self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + + self.figure_plot_PSD.canvas.draw_idle() + + # --- FINE file NOT uploaded / SAND file uploaded --- + if not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand_sediment.text()): + + self.axis_plot_PSD[0].cla() + self.axis_plot_PSD[1].cla() + + position_list_sand, color_list_sand = self.extract_position_list_and_color_list_from_table_checkboxes_sand() + + if self.combobox_PSD_plot.currentIndex() == 0: + + for profil_position_num, color_plot in zip(position_list_sand, color_list_sand): + + self.axis_plot_PSD[0].plot() + self.axis_plot_PSD[0].set_xscale('log') + self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') + + self.axis_plot_PSD[1].plot(stg.radius_grain_sand, + stg.frac_vol_sand[profil_position_num, :], + color=color_plot) + self.axis_plot_PSD[1].set_xscale('log') + self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + + elif self.combobox_PSD_plot.currentIndex() == 1: + + for profil_position_num, color_plot in zip(position_list_sand, color_list_sand): + + self.axis_plot_PSD[0].plot() + self.axis_plot_PSD[0].set_xscale('log') + self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') + + self.axis_plot_PSD[1].plot(stg.radius_grain_sand, + stg.frac_vol_sand_cumul[profil_position_num, :], + color=color_plot) + self.axis_plot_PSD[1].set_xscale('log') + self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') + + self.figure_plot_PSD.canvas.draw_idle() + + # --- FINE file uploaded / SAND file uploaded --- + if (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand_sediment.text()): + + self.axis_plot_PSD[0].cla() + self.axis_plot_PSD[1].cla() + + position_list_fine, color_list_fine = self.extract_position_list_and_color_list_from_table_checkboxes_fine() + position_list_sand, color_list_sand = self.extract_position_list_and_color_list_from_table_checkboxes_sand() + + if self.combobox_PSD_plot.currentIndex() == 0: + + for profil_position_num_fine, color_plot_fine in zip(position_list_fine, color_list_fine): + + self.axis_plot_PSD[0].plot(stg.radius_grain_fine, + stg.frac_vol_fine[profil_position_num_fine, :], + color=color_plot_fine) + self.axis_plot_PSD[0].set_xscale('log') + self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') + + for profil_position_num_sand, color_plot_sand in zip(position_list_sand, color_list_sand): + + self.axis_plot_PSD[1].plot(stg.radius_grain_sand, + stg.frac_vol_sand[profil_position_num_sand, :], + color=color_plot_sand) + self.axis_plot_PSD[1].set_xscale('log') + self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + + elif self.combobox_PSD_plot.currentIndex() == 1: + + for profil_position_num_fine, color_plot_fine in zip(position_list_fine, color_list_fine): + self.axis_plot_PSD[0].plot(stg.radius_grain_fine, + stg.frac_vol_fine_cumul[profil_position_num_fine, :], + color=color_plot_fine) + self.axis_plot_PSD[0].set_xscale('log') + self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') + + for profil_position_num_sand, color_plot_sand in zip(position_list_sand, color_list_sand): + self.axis_plot_PSD[1].plot(stg.radius_grain_sand, + stg.frac_vol_sand_cumul[profil_position_num_sand, :], + color=color_plot_sand) + self.axis_plot_PSD[1].set_xscale('log') + self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') + + self.figure_plot_PSD.canvas.draw_idle() + + + + # # --- Read selected samples (checkboxes) --- + # position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() + # + # if position_list == []: + # + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Axis choice Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Select sample(s) before changing axis") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # + # elif (self.lineEdit_fine_sediment.text()) and not (self.lineEdit_sand.text()): + # + # if self.combobox_PSD_plot.currentIndex() == 0: + # + # for profil_position_num, color_plot in zip(position_list, color_list): + # self.axis_plot_PSD[0].plot(stg.radius_grain, + # stg.frac_vol_fine[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[0].set_xscale('log') + # self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') + # + # self.axis_plot_PSD[1].plot() + # self.axis_plot_PSD[1].set_xscale('log') + # self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + # + # elif self.combobox_PSD_plot.currentIndex() == 1: + # + # for profil_position_num, color_plot in zip(position_list, color_list): + # self.axis_plot_PSD[0].plot(stg.radius_grain, + # stg.frac_vol_fine_cumul[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[0].set_xscale('log') + # self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') + # + # self.axis_plot_PSD[1].plot() + # self.axis_plot_PSD[1].set_xscale('log') + # self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') + # + # self.canvas_plot_PSD.draw() + # + # elif not (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): + # + # # --- Create canvas of Matplotlib figure --- + # if self.canvas_plot_PSD == None: + # self.figure_plot_PSD, self.axis_plot_PSD = plt.subplots(nrows=1, ncols=2, layout="constrained") + # self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD) + # self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) + # else: + # self.axis_plot_PSD[0].cla() + # self.axis_plot_PSD[1].cla() + # + # if self.combobox_PSD_plot.currentIndex() == 0: + # + # for profil_position_num, color_plot in zip(position_list, color_list): + # self.axis_plot_PSD[0].plot() + # self.axis_plot_PSD[0].set_xscale('log') + # self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') + # + # self.axis_plot_PSD[1].plot(stg.radius_grain, + # stg.frac_vol_sand[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[1].set_xscale('log') + # self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + # + # elif self.combobox_PSD_plot.currentIndex() == 1: + # + # for profil_position_num, color_plot in zip(position_list, color_list): + # self.axis_plot_PSD[0].plot() + # self.axis_plot_PSD[0].set_xscale('log') + # self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') + # + # self.axis_plot_PSD[1].plot(stg.radius_grain, + # stg.frac_vol_sand_cumul[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[1].set_xscale('log') + # self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') + # + # self.canvas_plot_PSD.draw() + # + # elif (self.lineEdit_fine_sediment.text()) and (self.lineEdit_sand.text()): + # + # # --- Create canvas of Matplotlib figure --- + # if self.canvas_plot_PSD == None: + # self.figure_plot_PSD, self.axis_plot_PSD = plt.subplots(nrows=1, ncols=2, layout="constrained") + # self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD) + # self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) + # else: + # self.axis_plot_PSD[0].cla() + # self.axis_plot_PSD[1].cla() + # + # if self.combobox_PSD_plot.currentIndex() == 0: + # + # for profil_position_num, color_plot in zip(position_list, color_list): + # self.axis_plot_PSD[0].plot(stg.radius_grain, + # stg.frac_vol_fine[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[0].set_xscale('log') + # self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[0].set_ylabel('Class size volume fraction') + # + # self.axis_plot_PSD[1].plot(stg.radius_grain, + # stg.frac_vol_sand[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[1].set_xscale('log') + # self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[1].set_ylabel('Class size volume fraction') + # + # elif self.combobox_PSD_plot.currentIndex() == 1: + # + # for profil_position_num, color_plot in zip(position_list, color_list): + # self.axis_plot_PSD[0].plot(stg.radius_grain, + # stg.frac_vol_fine_cumul[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[0].set_xscale('log') + # self.axis_plot_PSD[0].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[0].set_ylabel('Cumulative size volume fraction') + # + # self.axis_plot_PSD[1].plot(stg.radius_grain, + # stg.frac_vol_sand_cumul[profil_position_num, :], + # color=color_plot) + # self.axis_plot_PSD[1].set_xscale('log') + # self.axis_plot_PSD[1].set_xlabel('Radius ($\mu m$)') + # self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction') + # + # self.canvas_plot_PSD.draw() + # + # else: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot PSD Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Fill table and select sample(s) before plotting PSD") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # def update_plot_fine_and_sand_sediments_PSD_cumul(self): # if self.tableWidget_sample.columnCount() > 15: # diff --git a/settings.py b/settings.py index dcbf758..affbd8d 100644 --- a/settings.py +++ b/settings.py @@ -109,36 +109,45 @@ lin_reg = tuple() # --- Sample Data --- -samples = [] +sample_fine = [] -fine_sediment_path = "" -fine_sediment_filename = "" -fine_sediment_columns = [] +path_fine = "" +filename_fine = "" +columns_fine = [] -sample_distance_from_bank = np.array([]) # distance from left bank (m) -sample_depth = np.array([]) # depth (m) -sample_time = np.array([]) +distance_from_bank_fine = [] # distance from left bank (m) +depth_fine = [] # depth (m) +time_fine = [] -radius_grain = np.array([]) # grain radius (um) +radius_grain_fine = [] # grain radius (um) -Ctot_fine = np.array([]) # Total concentration (g/L) -D50_fine = np.array([]) # median diameter (um) -frac_vol_fine = np.array([]) # Volume fraction (%) +Ctot_fine = [] # Total concentration (g/L) +D50_fine = [] # median diameter (um) +frac_vol_fine = [] +# Volume fraction (%) -frac_vol_fine_cumul = np.array([]) # Cumulated volume fraction (%) +frac_vol_fine_cumul = [] # Cumulated volume fraction (%) -sand_sediment_path = "" -sand_sediment_filename = "" -sand_sediment_columns = [] +sample_sand = [] -Ctot_sand = np.array([]) # Total concentration (g/L) -D50_sand = np.array([]) # median diameter (um) -frac_vol_sand = np.array([]) # Volume fraction (%) +path_sand = "" +filename_sand = "" +columns_sand = [] -frac_vol_sand_cumul = np.array([]) # Cumulated volume fraction (%) +distance_from_bank_sand = [] # distance from left bank (m) +depth_sand = [] # depth (m) +time_sand = [] -Ctot_fine_per_cent = np.array([]) -Ctot_sand_per_cent = np.array([]) +radius_grain_sand = [] + +Ctot_sand = [] # Total concentration (g/L) +D50_sand = [] # median diameter (um) +frac_vol_sand = [] # Volume fraction (%) + +frac_vol_sand_cumul = [] # Cumulated volume fraction (%) + +Ctot_fine_per_cent = [] +Ctot_sand_per_cent = [] # --- Acoustic inversion method ---