diff --git a/View/sample_data_tab.py b/View/sample_data_tab.py index aa4c73d..b9d29c7 100644 --- a/View/sample_data_tab.py +++ b/View/sample_data_tab.py @@ -199,10 +199,10 @@ class SampleDataTab(QWidget): self.gridLayout_groupbox_option_total_concentration_plot.addWidget(self.label_x_axis, 0, 0) self.combobox_x_axis = QComboBox() - self.combobox_x_axis.addItems(['Concentration (g/L)', '% fine', '% sand', '% fine, % sand']) + 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.empty_field_for_total_concentration_plot) + self.combobox_x_axis.currentTextChanged.connect(self.update_plot_total_concentration) self.label_y_axis = QLabel() self.label_y_axis.setText("y axis") @@ -212,7 +212,7 @@ class SampleDataTab(QWidget): self.combobox_y_axis.addItems(['z (m)', 'z / h']) 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.empty_field_for_total_concentration_plot) self.combobox_y_axis.currentTextChanged.connect(self.update_plot_total_concentration) self.groupbox_option_PSD_plot = QGroupBox() @@ -264,27 +264,39 @@ class SampleDataTab(QWidget): # Plot Ctot | Plot PSD fine + sand self.groupbox_plot_total_concentration = QGroupBox() - self.verticalLayout_plot_total_concentration = QVBoxLayout(self.groupbox_plot_total_concentration) - 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.plotToolbar_sample_total_concentration = NavigationToolBar(self.canvas_sample_total_concentration, self) - self.empty_field_for_total_concentration_plot() - self.verticalLayout_plot_total_concentration.addWidget(self.canvas_total_concentration) - self.horizontalLayoutBottom_sampleDataTab.addWidget(self.groupbox_plot_total_concentration, 3) self.groupbox_plot_PSD = QGroupBox() - self.verticalLayout_plot_PSD = QVBoxLayout(self.groupbox_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.plotToolbar_sample_distribution = NavigationToolBar(self.canvas_sample_distribution, self) - self.empty_field_for_plot_fine_PSD_class() - self.empty_field_for_plot_sand_PSD_class() - self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) - self.horizontalLayoutBottom_sampleDataTab.addWidget(self.groupbox_plot_PSD, 6) + # +++++++++++++++++++++++++++++++++++++++++++++++++ + # +++ --- GroupBox plot total concentration --- +++ + # +++++++++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_plot_total_concentration = QVBoxLayout(self.groupbox_plot_total_concentration) + 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.plotToolbar_sample_total_concentration = NavigationToolBar(self.canvas_sample_total_concentration, self) + # self.empty_field_for_total_concentration_plot() + # self.verticalLayout_plot_total_concentration.addWidget(self.canvas_total_concentration) + + # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + # +++ --- GroupBox plot particle size distribution --- +++ + # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_plot_PSD = QVBoxLayout(self.groupbox_plot_PSD) + 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.plotToolbar_sample_distribution = NavigationToolBar(self.canvas_sample_distribution, self) + # self.empty_field_for_plot_fine_PSD_class() + # self.empty_field_for_plot_sand_PSD_class() + # self.verticalLayout_plot_PSD.addWidget(self.canvas_plot_PSD) + self.retranslate_data_sample_tab() # -------------------- Functions for Sample Data Tab -------------------- @@ -368,7 +380,12 @@ class SampleDataTab(QWidget): 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.connect(self.update_plots_from_table_checkboxes)") + 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_fine_and_sand_sediments_PSD_class)") # --- Fill Sample column with checkbox --- for i in range(self.tableWidget_sample.rowCount()): @@ -397,7 +414,10 @@ class SampleDataTab(QWidget): # 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.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_fine_and_sand_sediments_PSD_class) else: # print("PLease download first file") @@ -420,11 +440,6 @@ class SampleDataTab(QWidget): eval(f"color_list.append(self.comboBox_sample_table{i}.currentText())") sample_checkbox[0, i] = 2 - # Called functions to update plots simultaneously with table checkboxes selection - # if self.tableWidget_sample.columnCount() > 12: - # self.update_plot_fine_sediment_PSD_class_cumul(position, color_list) - self.update_plot_total_concentration(position, color_list) - return position, color_list # --- Function to export data of table --- @@ -441,39 +456,39 @@ class SampleDataTab(QWidget): # ------------------------------------------------------------------------------------------------------------------ # --- Functions to plot samples positions on transect --- - def empty_field_for_transect_plot(self): - self.axis_sample_position.set_xticks([]) - self.axis_sample_position.set_yticks([]) + # def empty_field_for_transect_plot(self): + # self.axis_sample_position.set_xticks([]) + # self.axis_sample_position.set_yticks([]) - def update_plots_from_table_checkboxes(self): - # color_value_row = self.tableWidget_sample.currentRow() - # exec("color_value = self.comboBox_sample_table{color_value_row}.currentText()") - # eval("color_list.append(color_value)") - # print(color_list) - position = [] - color_list = [] - sample_checkbox = np.zeros((1, len(range(self.tableWidget_sample.rowCount())))) - # print(sample_checkbox.shape) - for i in range(self.tableWidget_sample.rowCount()): - # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) - if self.tableWidget_sample.item(i, 1).checkState() == 2: - if self.tableWidget_sample.item(i, 1).checkState() == Qt.Checked: - # print(f"S{i} = Checked") - position.append(i) - eval(f"color_list.append(self.comboBox_sample_table{i}.currentText())") - # print("position", position) - # print("color_list", color_list) - # self.update_plot_transect_bottom_with_sample_position(position, color_list) - self.update_plot_total_concentration(position, color_list) - # self.update_plot_fine_and_sand_sediments_PSD(position, color_list) - if self.pushbutton_cumulative_PSD.sender(): - self.update_plot_fine_PSD_cumul(position, color_list) - self.update_plot_sand_PSD_cumul(position, color_list) - else: - self.update_plot_fine_PSD_class(position, color_list) - self.update_plot_sand_PSD_class(position, color_list) - sample_checkbox[0, i] = 2 - return position, color_list + # def update_plots_from_table_checkboxes(self): + # # color_value_row = self.tableWidget_sample.currentRow() + # # exec("color_value = self.comboBox_sample_table{color_value_row}.currentText()") + # # eval("color_list.append(color_value)") + # # print(color_list) + # position = [] + # color_list = [] + # sample_checkbox = np.zeros((1, len(range(self.tableWidget_sample.rowCount())))) + # # print(sample_checkbox.shape) + # for i in range(self.tableWidget_sample.rowCount()): + # # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) + # if self.tableWidget_sample.item(i, 1).checkState() == 2: + # if self.tableWidget_sample.item(i, 1).checkState() == Qt.Checked: + # # print(f"S{i} = Checked") + # position.append(i) + # eval(f"color_list.append(self.comboBox_sample_table{i}.currentText())") + # # print("position", position) + # # print("color_list", color_list) + # # self.update_plot_transect_bottom_with_sample_position(position, color_list) + # self.update_plot_total_concentration(position, color_list) + # # self.update_plot_fine_and_sand_sediments_PSD(position, color_list) + # if self.pushbutton_cumulative_PSD.sender(): + # self.update_plot_fine_PSD_cumul(position, color_list) + # self.update_plot_sand_PSD_cumul(position, color_list) + # else: + # self.update_plot_fine_PSD_class(position, color_list) + # self.update_plot_sand_PSD_class(position, color_list) + # sample_checkbox[0, i] = 2 + # return position, color_list # print("sample_checkbox", np.append(sample_checkbox, self.tableWidget_sample.item(i, 1).checkState())) # print(sample_checkbox[0self.tableWidget_sample.item(i, 1).checkState(), i]) @@ -568,166 +583,290 @@ class SampleDataTab(QWidget): # ------------------------------------------------------------------------------------------------------------------ # --- Functions to plot total concentration --- - def empty_field_for_total_concentration_plot(self): - self.axis_total_concentration.cla() - 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() + # def empty_field_for_total_concentration_plot(self): + # self.axis_total_concentration.cla() + # 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() + + def update_plot_total_concentration(self): + if self.tableWidget_sample.columnCount() > 15: + + # --- Read sample data --- + granulo_data = deepcopy( + GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), + self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) + + # --- 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() + + else: + + # --- 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_y_axis.currentIndex() == 0: + # self.axis_total_concentration.scatter(granulo_data._Ctot_fine[position_list], + # granulo_data._z[position_list], + # s=100, facecolor=color_list, edgecolor="None", alpha=0.5) + # self.axis_total_concentration.scatter(granulo_data._Ctot_sand[position_list], + # granulo_data._z[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_y_axis.currentIndex() == 1: + # self.axis_total_concentration.scatter(granulo_data._Ctot_fine[position_list], + # granulo_data._z[position_list] / np.max(granulo_data._z[position_list]), + # s=100, facecolor=color_list, edgecolor="None", alpha=0.5) + # self.axis_total_concentration.scatter(granulo_data._Ctot_sand[position_list], + # granulo_data._z[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()) + # self.canvas_total_concentration.draw() + + if (self.combobox_x_axis.currentIndex() == 0) and (self.combobox_y_axis.currentIndex() == 0): + self.axis_total_concentration.scatter(granulo_data._Ctot_fine[position_list], + granulo_data._z[position_list], + s=100, facecolor=color_list, edgecolor="None", alpha=0.5) + self.axis_total_concentration.scatter(granulo_data._Ctot_sand[position_list], + granulo_data._z[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): + self.axis_total_concentration.scatter(granulo_data._Ctot_fine[position_list], + granulo_data._z[position_list] / np.max(granulo_data._z[position_list]), + s=100, facecolor=color_list, edgecolor="None", alpha=0.5) + self.axis_total_concentration.scatter(granulo_data._Ctot_sand[position_list], + granulo_data._z[position_list] / np.max(granulo_data._z[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() == 1) and (self. combobox_y_axis.currentIndex() == 0): + self.axis_total_concentration.scatter(granulo_data._Ctot_fine_per_cent[position_list], + granulo_data._z[position_list], + s=100, facecolor=color_list, edgecolor="None", alpha=0.5) + self.axis_total_concentration.scatter(granulo_data._Ctot_sand_per_cent[position_list], + granulo_data._z[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() == 1) and (self. combobox_y_axis.currentIndex() == 1): + self.axis_total_concentration.scatter(granulo_data._Ctot_fine_per_cent[position_list], + granulo_data._z[position_list] / np.max(granulo_data._z[position_list]), + s=100, facecolor=color_list, edgecolor="None", alpha=0.5) + self.axis_total_concentration.scatter(granulo_data._Ctot_sand_per_cent[position_list], + granulo_data._z[position_list] / np.max(granulo_data._z[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()) + self.canvas_total_concentration.draw() - def update_plot_total_concentration(self, position_list, color_list): - if self.lineEdit_fine_sediment.text(): - if self.lineEdit_sand.text(): - granulo_data = deepcopy( - GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), - self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) - if self.tableWidget_sample.columnCount() > 15: - if self.combobox_x_axis.currentIndex() == 0: - # position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() - self.axis_total_concentration.cla() - self.axis_total_concentration.scatter(granulo_data._Ctot_fine[position_list], - granulo_data._z[position_list], - s=100, facecolor=color_list, edgecolor="None", alpha=0.5) - self.axis_total_concentration.scatter(granulo_data._Ctot_sand[position_list], - granulo_data._z[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()) - self.canvas_total_concentration.draw() - elif self. combobox_x_axis.currentIndex() == 1: - # position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() - self.axis_total_concentration.cla() - print(position_list) - self.axis_total_concentration.scatter(granulo_data._Ctot_fine[position_list], - granulo_data._z[position_list] / np.max(granulo_data._z[position_list]), - s=12, c=color_list) - self.axis_total_concentration.scatter(granulo_data._Ctot_sand[position_list], - granulo_data._z[position_list], - s=16, 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()) - self.canvas_total_concentration.draw() else: - self.empty_field_for_total_concentration_plot() + msgBox = QMessageBox() + msgBox.setWindowTitle("Axis choice Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Fill table and select sample(s) before changing axis") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() # ------------------------------------------------------------------------------------------------------------------ - def on_clicked(self): - self.pushbutton_class_PSD.clicked_signal.emit() + # def empty_field_to_plot_fine_sediment_distribution(self): + # if self.pushbutton_class_PSD.sender().text() == "Class PSD": + # print("button Class PSD") + # elif self.pushbutton_cumulative_PSD.sender().text() == "Cumulative PSD": + # print("button Cumulative PSD") + # # print("cumul button push ", self.pushbutton_cumulative_PSD.sender().text()) + # button = self.sender() + # self.axis_plot_PSD[0].cla() + # if self.tableWidget_sample.columnCount() == 10: + # if button.text() == "Class PSD": + # 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('Size class volume fraction') + # elif button.text() == "Cumulative PSD": + # 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('Cumulated size volume fraction') + # else: + # 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('Size class volume fraction') + # else: + # print("Table size is not equal to 10") + # self.canvas_plot_PSD.draw() - def empty_field_to_plot_fine_sediment_distribution(self): - if self.pushbutton_class_PSD.sender().text() == "Class PSD": - print("button Class PSD") - elif self.pushbutton_cumulative_PSD.sender().text() == "Cumulative PSD": - print("button Cumulative PSD") - # print("cumul button push ", self.pushbutton_cumulative_PSD.sender().text()) - button = self.sender() - self.axis_plot_PSD[0].cla() - if self.tableWidget_sample.columnCount() == 10: - if button.text() == "Class PSD": - 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('Size class volume fraction') - elif button.text() == "Cumulative PSD": - 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('Cumulated size volume fraction') - else: - 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('Size class volume fraction') - else: - print("Table size is not equal to 10") - self.canvas_plot_PSD.draw() + # def update_plot_fine_sediment_PSD_class_cumul(self, sample_position_list, color_list): + # granulo_data = deepcopy( + # GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), + # self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) + # + # 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) + # + # self.axis_plot_PSD[0].cla() + # if self.pushbutton_class_PSD.sender().text() == "Class PSD": + # for profil_position_num, color_plot in zip(sample_position_list, color_list): + # self.axis_plot_PSD[0].cla() + # self.axis_plot_PSD[0].plot(granulo_data._r_grain, + # granulo_data._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('Size class volume fraction') + # elif self.pushbutton_cumulative_PSD.sender().text() == "Cumulative PSD": + # for profil_position_num, color_plot in zip(sample_position_list, color_list): + # self.axis_plot_PSD[0].cla() + # self.axis_plot_PSD[0].plot(granulo_data._r_grain, + # granulo_data._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('Cumulated size volume fraction') + # else: + # for profil_position_num, color_plot in zip(sample_position_list, color_list): + # self.axis_plot_PSD[0].cla() + # self.axis_plot_PSD[0].plot(granulo_data._r_grain, + # granulo_data._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('Size class volume fraction') + # self.canvas_plot_PSD.draw() + + # def on_clicked_pushbutton_PSD_class(self): + # if self.pushbutton_class_PSD.sender(): + # print("button is clicked") + # if self.tableWidget_sample.columnCount() > 10: + # position, color_list = self.update_plots_from_table_checkboxes() + # self.update_plot_fine_PSD_class(position, color_list) + # self.update_plot_sand_PSD_class(position, color_list) + # else: + # self.empty_field_for_plot_fine_PSD_class() + # self.empty_field_for_plot_sand_PSD_class() + + # def on_clicked_pushbutton_PSD_cumul(self): + # print(self.pushbutton_cumulative_PSD.sender()) + # if self.tableWidget_sample.columnCount() > 10: + # position, color_list = self.update_plots_from_table_checkboxes() + # self.update_plot_fine_PSD_cumul(position, color_list) + # self.update_plot_sand_PSD_cumul(position, color_list) + # else: + # self.empty_field_for_plot_fine_PSD_cumul() + # self.empty_field_for_plot_sand_PSD_cumul() + + # def empty_field_for_plot_fine_PSD_class(self): + # self.axis_plot_PSD[0].cla() + # 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('Size class volume fraction') + # self.canvas_plot_PSD.draw() + + # def empty_field_for_plot_fine_sand_PSD_class(self): + # button = self.sender() + # print(button.text()) + # + # self.axis_plot_PSD[0].cla() + # self.axis_plot_PSD[1].cla() + # + # 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('Size class volume fraction') + # + # 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('Size class volume fraction') + # + # self.canvas_plot_PSD.draw() + + def update_plot_fine_and_sand_sediments_PSD_class(self): + position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() - def update_plot_fine_sediment_PSD_class_cumul(self, sample_position_list, color_list): granulo_data = deepcopy( GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) - self.axis_plot_PSD[0].cla() - if self.pushbutton_class_PSD.sender().text() == "Class PSD": - for profil_position_num, color_plot in zip(sample_position_list, color_list): - self.axis_plot_PSD[0].cla() + + 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) + + for profil_position_num, color_plot in zip(position_list, color_list): self.axis_plot_PSD[0].plot(granulo_data._r_grain, granulo_data._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('Size class volume fraction') - elif self.pushbutton_cumulative_PSD.sender().text() == "Cumulative PSD": - for profil_position_num, color_plot in zip(sample_position_list, color_list): - self.axis_plot_PSD[0].cla() - self.axis_plot_PSD[0].plot(granulo_data._r_grain, - granulo_data._frac_vol_fine_cumul[profil_position_num, :], + + self.axis_plot_PSD[1].plot(granulo_data._r_grain, + granulo_data._frac_vol_sand[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('Cumulated size volume fraction') + 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('Size class volume fraction') + + self.canvas_plot_PSD.draw() + else: - for profil_position_num, color_plot in zip(sample_position_list, color_list): - self.axis_plot_PSD[0].cla() + self.axis_plot_PSD[0].cla() + self.axis_plot_PSD[1].cla() + + for profil_position_num, color_plot in zip(position_list, color_list): self.axis_plot_PSD[0].plot(granulo_data._r_grain, granulo_data._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('Size class volume fraction') - self.canvas_plot_PSD.draw() - def on_clicked_pushbutton_PSD_class(self): - if self.pushbutton_class_PSD.sender(): - print("button is clicked") - if self.tableWidget_sample.columnCount() > 10: - position, color_list = self.update_plots_from_table_checkboxes() - self.update_plot_fine_PSD_class(position, color_list) - self.update_plot_sand_PSD_class(position, color_list) - else: - self.empty_field_for_plot_fine_PSD_class() - self.empty_field_for_plot_sand_PSD_class() + self.axis_plot_PSD[1].plot(granulo_data._r_grain, + granulo_data._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('Size class volume fraction') - def on_clicked_pushbutton_PSD_cumul(self): - print(self.pushbutton_cumulative_PSD.sender()) - if self.tableWidget_sample.columnCount() > 10: - position, color_list = self.update_plots_from_table_checkboxes() - self.update_plot_fine_PSD_cumul(position, color_list) - self.update_plot_sand_PSD_cumul(position, color_list) - else: - self.empty_field_for_plot_fine_PSD_cumul() - self.empty_field_for_plot_sand_PSD_cumul() + self.canvas_plot_PSD.draw() - def empty_field_for_plot_fine_PSD_class(self): - self.axis_plot_PSD[0].cla() - 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('Size class volume fraction') - self.canvas_plot_PSD.draw() - def empty_field_for_plot_fine_sand_PSD_class(self): - button = self.sender() - print(button.text()) - - self.axis_plot_PSD[0].cla() - self.axis_plot_PSD[1].cla() - - 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('Size class volume fraction') - - 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('Size class volume fraction') - - self.canvas_plot_PSD.draw() - - def update_plot_fine_and_sand_sediments_PSD(self): + def update_plot_fine_and_sand_sediments_PSD_cumul(self): granulo_data = deepcopy( GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) + + 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) + if self.pushbutton_class_PSD.sender(): if self.tableWidget_sample.columnCount() > 10: position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() self.axis_plot_PSD[0].cla() for profil_position_num, color_plot in zip(position_list, color_list): - self.axis_plot_PSD[0].plot(granulo_data._r_grain, granulo_data._frac_vol_fine[profil_position_num, :], + self.axis_plot_PSD[0].plot(granulo_data._r_grain, + granulo_data._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$)') @@ -747,96 +886,96 @@ class SampleDataTab(QWidget): 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('Cumulated size volume fraction') - self.canvas_plot_PSD.draw() - else: - self.empty_field_for_plot_fine_PSD_cumul() - self.empty_field_for_plot_sand_PSD_cumul() - - def update_plot_fine_PSD_class(self, profil_position, color_list): - granulo_data = deepcopy( - GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), - self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) - self.axis_plot_PSD[0].cla() - for profil_position_num, color_plot in zip(profil_position, color_list): - self.axis_plot_PSD[0].plot(granulo_data._r_grain, granulo_data._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('Size class volume fraction') self.canvas_plot_PSD.draw() + # else: + # self.empty_field_for_plot_fine_PSD_cumul() + # self.empty_field_for_plot_sand_PSD_cumul() - def empty_field_for_plot_fine_sand_PSD_cumul(self): - self.axis_plot_PSD[0].cla() - self.axis_plot_PSD[1].cla() + # def update_plot_fine_PSD_class(self, profil_position, color_list): + # granulo_data = deepcopy( + # GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), + # self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) + # self.axis_plot_PSD[0].cla() + # for profil_position_num, color_plot in zip(profil_position, color_list): + # self.axis_plot_PSD[0].plot(granulo_data._r_grain, granulo_data._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('Size class volume fraction') + # self.canvas_plot_PSD.draw() - 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('Cumulated size volume fraction') + # def empty_field_for_plot_fine_sand_PSD_cumul(self): + # self.axis_plot_PSD[0].cla() + # self.axis_plot_PSD[1].cla() + # + # 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('Cumulated size volume fraction') + # + # 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('Cumulated size volume fraction') + # + # self.canvas_plot_PSD.draw() + # def empty_field_for_plot_fine_PSD_cumul(self): + # self.axis_plot_PSD[0].cla() + # 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('Cumulated size volume fraction') + # self.canvas_plot_PSD.draw() - 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('Cumulated size volume fraction') + # def update_plot_fine_PSD_cumul(self, profil_position, color_list): + # granulo_data = deepcopy( + # GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), + # self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) + # self.axis_plot_PSD[0].cla() + # for profil_position_num, color_plot in zip(profil_position, color_list): + # self.axis_plot_PSD[0].plot(granulo_data._r_grain, granulo_data._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('Cumulated size volume fraction') + # self.canvas_plot_PSD.draw() - self.canvas_plot_PSD.draw() - def empty_field_for_plot_fine_PSD_cumul(self): - self.axis_plot_PSD[0].cla() - 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('Cumulated size volume fraction') - self.canvas_plot_PSD.draw() + # def empty_field_for_plot_sand_PSD_class(self): + # self.axis_plot_PSD[1].cla() + # 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('Size class volume fraction') + # self.canvas_plot_PSD.draw() - def update_plot_fine_PSD_cumul(self, profil_position, color_list): - granulo_data = deepcopy( - GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), - self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) - self.axis_plot_PSD[0].cla() - for profil_position_num, color_plot in zip(profil_position, color_list): - self.axis_plot_PSD[0].plot(granulo_data._r_grain, granulo_data._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('Cumulated size volume fraction') - self.canvas_plot_PSD.draw() + # def update_plot_sand_PSD_class(self, profil_position, color_list): + # granulo_data = deepcopy( + # GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), + # self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) + # self.axis_plot_PSD[1].cla() + # for profil_position_num, color_plot in zip(profil_position, color_list): + # self.axis_plot_PSD[1].plot(granulo_data._r_grain, granulo_data._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('Size class volume fraction') + # self.canvas_plot_PSD.draw() - def empty_field_for_plot_sand_PSD_class(self): - self.axis_plot_PSD[1].cla() - 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('Size class volume fraction') - self.canvas_plot_PSD.draw() + # def empty_field_for_plot_sand_PSD_cumul(self): + # self.axis_plot_PSD[1].cla() + # 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('Cumulated size volume fraction') + # self.canvas_plot_PSD.draw() - def update_plot_sand_PSD_class(self, profil_position, color_list): - granulo_data = deepcopy( - GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), - self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) - self.axis_plot_PSD[1].cla() - for profil_position_num, color_plot in zip(profil_position, color_list): - self.axis_plot_PSD[1].plot(granulo_data._r_grain, granulo_data._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('Size class volume fraction') - self.canvas_plot_PSD.draw() - - def empty_field_for_plot_sand_PSD_cumul(self): - self.axis_plot_PSD[1].cla() - 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('Cumulated size volume fraction') - self.canvas_plot_PSD.draw() - - def update_plot_sand_PSD_cumul(self, profil_position, color_list): - granulo_data = deepcopy( - GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), - self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) - self.axis_plot_PSD[1].cla() - for profil_position_num, color_plot in zip(profil_position, color_list): - self.axis_plot_PSD[1].plot(granulo_data._r_grain, granulo_data._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 (m)') - self.axis_plot_PSD[1].set_ylabel('Cumulated size volume fraction') - self.canvas_plot_PSD.draw() + # def update_plot_sand_PSD_cumul(self, profil_position, color_list): + # granulo_data = deepcopy( + # GranuloLoader(self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text(), + # self.lineEdit_sand.toolTip() + "/" + self.lineEdit_sand.text())) + # self.axis_plot_PSD[1].cla() + # for profil_position_num, color_plot in zip(profil_position, color_list): + # self.axis_plot_PSD[1].plot(granulo_data._r_grain, granulo_data._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 (m)') + # self.axis_plot_PSD[1].set_ylabel('Cumulated size volume fraction') + # self.canvas_plot_PSD.draw()