from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QLabel, QSpinBox, QSpacerItem, QSizePolicy, \ QTabWidget, QTableWidget, QPushButton, QLineEdit, QTableView, QCheckBox, \ QAbstractScrollArea, QTableWidgetItem, QComboBox, QFileDialog, QGridLayout, QMessageBox, \ QRadioButton from PyQt5.QtGui import QIcon, QPixmap from PyQt5.QtCore import Qt, QCoreApplication, pyqtSignal, pyqtSlot import numpy as np import pandas as pd import itertools import matplotlib.pyplot as plt from matplotlib.colors import CSS4_COLORS, LogNorm from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar from copy import deepcopy from os import path import csv from Model.granulo_loader import GranuloLoader from View.checkable_combobox import CheckableComboBox import Translation.constant_string as cs import settings as stg _translate = QCoreApplication.translate class SampleDataTab(QWidget): clickedState = pyqtSignal(bool) def __init__(self, widget_tab): super().__init__() path_icon = "./icons/" icon_folder = QIcon(path_icon + "folder.png") ### --- General layout of widgets --- self.verticalLayout_sampleDataTab = QVBoxLayout(widget_tab) self.horizontalLayoutTop_sampleDataTab = QHBoxLayout() self.verticalLayout_sampleDataTab.addLayout(self.horizontalLayoutTop_sampleDataTab, 5) self.horizontalLayoutBottom_sampleDataTab = QHBoxLayout() self.verticalLayout_sampleDataTab.addLayout(self.horizontalLayoutBottom_sampleDataTab, 5) # -------------------------------------------------------------------------------------------------------------- ### --- Layout of groupbox in the Top horizontal layout box # Table of values fines | Sample position # Table of values sand | Display options self.verticalLayout_groupboxes_fine_sand = QVBoxLayout() self.horizontalLayoutTop_sampleDataTab.addLayout(self.verticalLayout_groupboxes_fine_sand, 6) self.groupbox_fine = QGroupBox() self.verticalLayout_groupboxes_fine_sand.addWidget(self.groupbox_fine, 5) 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) # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # +++ --- GroupBox download and visualize tables of values --- +++ # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # --- Download + Table of values : fine sediments --- self.verticalLayout_groupbox_fine = QVBoxLayout(self.groupbox_fine) self.groupbox_fine.setTitle("Fine sediments") self.horizontalLayout_download_fine_sediment = QHBoxLayout() self.verticalLayout_groupbox_fine.addLayout(self.horizontalLayout_download_fine_sediment) self.pushbutton_fine_sediment = QPushButton() self.pushbutton_fine_sediment.setIcon(icon_folder) self.horizontalLayout_download_fine_sediment.addWidget(self.pushbutton_fine_sediment) self.lineEdit_fine_sediment = QLineEdit() self.horizontalLayout_download_fine_sediment.addWidget(self.lineEdit_fine_sediment) self.horizontalSpacerItem_fine = QSpacerItem(600, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_download_fine_sediment.addItem(self.horizontalSpacerItem_fine) # self.pushbutton_fine_sediment.clicked.connect(self.open_dialog_box_fine_sediment) self.tableWidget_fine = QTableWidget() self.row_fine = self.tableWidget_fine.setRowCount(10) self.column_fine = self.tableWidget_fine.setColumnCount(10) self.verticalLayout_groupbox_fine.addWidget(self.tableWidget_fine) # --- Download + Table of values : sand sediments --- self.verticalLayout_groupbox_sand = QVBoxLayout(self.groupbox_sand) self.groupbox_sand.setTitle("Sand sediments") self.horizontalLayout_download_sand_sediment = QHBoxLayout() self.verticalLayout_groupbox_sand.addLayout(self.horizontalLayout_download_sand_sediment) self.pushbutton_sand_sediment = QPushButton() self.pushbutton_sand_sediment.setIcon(icon_folder) self.horizontalLayout_download_sand_sediment.addWidget(self.pushbutton_sand_sediment) self.lineEdit_sand_sediment = QLineEdit() self.horizontalLayout_download_sand_sediment.addWidget(self.lineEdit_sand_sediment) self.horizontalSpacerItem_sand = QSpacerItem(600, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout_download_sand_sediment.addItem(self.horizontalSpacerItem_sand) self.tableWidget_sand = QTableWidget() self.row_sand = self.tableWidget_sand.setRowCount(10) self.column_sand = self.tableWidget_sand.setColumnCount(10) self.verticalLayout_groupbox_sand.addWidget(self.tableWidget_sand) # +++++++++++++++++++++++++++++++++++++++++++++ # +++ --- GroupBox plot sample position --- +++ # +++++++++++++++++++++++++++++++++++++++++++++ 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.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_display_option = QVBoxLayout(self.groupbox_display_option) self.groupbox_display_option.setTitle("Display options") # +++++++++++++++++++++++++++++++++++++++ # +++ --- GroupBox display option --- +++ # +++++++++++++++++++++++++++++++++++++++ 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) self.groupbox_option_total_concentration_plot = QGroupBox() self.groupbox_option_total_concentration_plot.setTitle("Total concentration plot") self.horizontalLayout_Ctot_PSD_plot.addWidget(self.groupbox_option_total_concentration_plot) self.gridLayout_groupbox_option_total_concentration_plot = QGridLayout( self.groupbox_option_total_concentration_plot) self.label_x_axis = QLabel() self.label_x_axis.setText("x axis") 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)', '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) self.combobox_y_axis = QComboBox() 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.update_plot_total_concentration) # --- Group box PSD plot --- self.groupbox_option_PSD_plot = QGroupBox() self.groupbox_option_PSD_plot.setTitle("Particle Size Distribution plot") self.horizontalLayout_Ctot_PSD_plot.addWidget(self.groupbox_option_PSD_plot) self.verticalLayout__groupbox_option_PSD_plot = QHBoxLayout(self.groupbox_option_PSD_plot) self.combobox_PSD_plot = QComboBox() 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 # Plot Ctot | Plot PSD fine + sand # --- Groupbox plot total concentration of sediments --- self.groupbox_plot_total_concentration = QGroupBox() self.horizontalLayoutBottom_sampleDataTab.addWidget(self.groupbox_plot_total_concentration, 3) self.verticalLayout_groupbox_plot_total_concentration = QVBoxLayout(self.groupbox_plot_total_concentration) self.groupbox_plot_total_concentration.setTitle("Plot total concentration") self.canvas_plot_total_concentration = FigureCanvas() self.toolbar_plot_total_concentration = NavigationToolBar(self.canvas_plot_total_concentration) self.verticalLayout_groupbox_plot_total_concentration.addWidget(self.toolbar_plot_total_concentration) self.verticalLayout_groupbox_plot_total_concentration.addWidget(self.canvas_plot_total_concentration) # --- Groupbox plot Particle Size Distributions --- self.groupbox_plot_PSD = QGroupBox() self.horizontalLayoutBottom_sampleDataTab.addWidget(self.groupbox_plot_PSD, 6) self.verticalLayout_groupbox_plot_PSD = QVBoxLayout(self.groupbox_plot_PSD) self.groupbox_plot_PSD.setTitle("Plot particle size distribution") self.canvas_plot_PSD = FigureCanvas() self.toolbar_plot_PSD = NavigationToolBar(self.canvas_plot_PSD) self.verticalLayout_groupbox_plot_PSD.addWidget(self.toolbar_plot_PSD) self.verticalLayout_groupbox_plot_PSD.addWidget(self.canvas_plot_PSD) # ______ _______ # | | | | \ # | | | | \ # | | | | | # | | | | / # |______| |________ |________/ # COMMENT OLD CODE LINE FROM HERE .... # ### --- Layout of groupbox in the Top horizontal layout box # # Download | Table of values | Sample position # # Display options # # self.groupbox_download = QGroupBox() # self.horizontalLayoutTop_sampleDataTab.addWidget(self.groupbox_download, 3) # # self.groupbox_table = QGroupBox() # self.horizontalLayoutTop_sampleDataTab.addWidget(self.groupbox_table, 4) # # self.verticalLayout_sampleposition_displayoption = QVBoxLayout() # self.horizontalLayoutTop_sampleDataTab.addLayout(self.verticalLayout_sampleposition_displayoption, 3) # # self.groupbox_plot_sample_position = QGroupBox() # self.verticalLayout_sampleposition_displayoption.addWidget(self.groupbox_plot_sample_position, 6) # # self.groupbox_display_option = QGroupBox() # self.verticalLayout_sampleposition_displayoption.addWidget(self.groupbox_display_option, 4) # # path_icon = "./icons/" # icon_folder = QIcon(path_icon + "folder.png") # # # ++++++++++++++++++++++++++++++++++++++++ # # +++ --- GroupBox Download Sample --- +++ # # ++++++++++++++++++++++++++++++++++++++++ # # self.verticalLayout_groupbox_download = QVBoxLayout(self.groupbox_download) # # self.tab_download_experimental_numerical_data = QTabWidget() # # self.tab_download_experimental_data = QWidget() # self.tab_download_experimental_numerical_data.addTab(self.tab_download_experimental_data, "Experimental data") # # self.verticalLayout_experimentalTab_groupbox_download = QVBoxLayout() # self.tab_download_experimental_data.setLayout(self.verticalLayout_experimentalTab_groupbox_download) # # self.groupbox_particle_size_file = QGroupBox() # self.verticalLayout_groupbox_particle_size_file = QVBoxLayout(self.groupbox_particle_size_file) # # self.groupbox_fine_sediment = QGroupBox() # self.horizontalLayout_fine_sediment = QHBoxLayout(self.groupbox_fine_sediment) # self.pushbutton_fine_sediment = QPushButton() # self.pushbutton_fine_sediment.setIcon(icon_folder) # self.horizontalLayout_fine_sediment.addWidget(self.pushbutton_fine_sediment) # self.lineEdit_fine_sediment = QLineEdit() # self.horizontalLayout_fine_sediment.addWidget(self.lineEdit_fine_sediment) # self.verticalLayout_groupbox_particle_size_file.addWidget(self.groupbox_fine_sediment) # # self.pushbutton_fine_sediment.clicked.connect(self.open_dialog_box_fine_sediment) # # self.groupbox_sand = QGroupBox() # self.horizontalLayout_sand = QHBoxLayout(self.groupbox_sand) # self.pushbutton_sand = QPushButton() # self.pushbutton_sand.setIcon(icon_folder) # self.horizontalLayout_sand.addWidget(self.pushbutton_sand) # self.lineEdit_sand = QLineEdit() # self.horizontalLayout_sand.addWidget(self.lineEdit_sand) # self.verticalLayout_groupbox_particle_size_file.addWidget(self.groupbox_sand) # # self.pushbutton_sand.clicked.connect(self.open_dialog_box_sand_sediment) # # self.verticalLayout_experimentalTab_groupbox_download.addWidget(self.groupbox_particle_size_file) # # # self.groupbox_total_concentration = QGroupBox() # # self.horizontalLayout_groupbox_total_concentration = QHBoxLayout(self.groupbox_total_concentration) # # self.pushbutton_total_concentration = QPushButton() # # self.pushbutton_total_concentration.setIcon(icon_folder) # # self.horizontalLayout_groupbox_total_concentration.addWidget(self.pushbutton_total_concentration) # # self.lineEdit_total_concentration = QLineEdit() # # self.horizontalLayout_groupbox_total_concentration.addWidget(self.lineEdit_total_concentration) # # # # self.pushbutton_total_concentration.clicked.connect(self.open_dialog_box_total_concentration) # # # # self.verticalLayout_groupbox_download.addWidget(self.groupbox_total_concentration) # # # self.verticalLayout_experimentalTab_groupbox_download.addWidget(self.groupbox_total_concentration) # # self.tab_compute_numerical_data = QWidget() # self.tab_download_experimental_numerical_data.addTab(self.tab_compute_numerical_data, "Numerical data") # # self.verticalLayout_groupbox_download.addWidget(self.tab_download_experimental_numerical_data) # # # ++++++++++++++++++++++++++++++++++++++++ # # +++ --- GroupBox Table of values --- +++ # # ++++++++++++++++++++++++++++++++++++++++ # # self.verticalLayout_groupbox_table = QVBoxLayout(self.groupbox_table) # # self.horizontalLayout_checkAll_spacer_exportTable = QHBoxLayout() # # # self.pushbutton_fill_table = QPushButton() # # self.horizontalLayout_checkAll_spacer_exportTable.addWidget(self.pushbutton_fill_table) # # self.horizontalSpacerItem_pushButton_fill_table = QSpacerItem(20, 10, QSizePolicy.Expanding, # QSizePolicy.Minimum) # self.horizontalLayout_checkAll_spacer_exportTable.addItem(self.horizontalSpacerItem_pushButton_fill_table) # # self.allChkBox = QCheckBox() # self.horizontalLayout_checkAll_spacer_exportTable.addWidget(self.allChkBox) # # self.horizontalSpacerItem_pushButton_export_table = QSpacerItem(340, 10, QSizePolicy.Expanding, # QSizePolicy.Minimum) # self.horizontalLayout_checkAll_spacer_exportTable.addItem(self.horizontalSpacerItem_pushButton_export_table) # # self.pushButton_export_table = QPushButton() # self.horizontalLayout_checkAll_spacer_exportTable.addWidget(self.pushButton_export_table) # # self.verticalLayout_groupbox_table.addLayout(self.horizontalLayout_checkAll_spacer_exportTable) # # # --- Table of values of fine sediments --- # self.groupbox_table_fine = QGroupBox() # self.verticalLayout_groupbox_table_fine = QVBoxLayout(self.groupbox_table_fine) # self.groupbox_table_fine.setTitle("Fine sediments") # self.verticalLayout_groupbox_table.addWidget(self.groupbox_table_fine) # # self.tableWidget_fine = QTableWidget() # self.row_fine = self.tableWidget_fine.setRowCount(10) # self.column_fine = self.tableWidget_fine.setColumnCount(10) # self.verticalLayout_groupbox_table_fine.addWidget(self.tableWidget_fine) # # # --- Table of values of sand sediments --- # self.groupbox_table_sand = QGroupBox() # self.verticalLayout_groupbox_table_sand = QVBoxLayout(self.groupbox_table_sand) # self.groupbox_table_sand.setTitle("Sand sediments") # self.verticalLayout_groupbox_table.addWidget(self.groupbox_table_sand) # # self.tableWidget_sand = QTableWidget() # self.row_sand = self.tableWidget_sand.setRowCount(10) # self.column_sand = self.tableWidget_sand.setColumnCount(10) # self.verticalLayout_groupbox_table_sand.addWidget(self.tableWidget_sand) # # # self.tableWidget_sample = QTableWidget() # # # # self.row = self.tableWidget_sample.setRowCount(10) # # self.column = self.tableWidget_sample.setColumnCount(10) # # # # self.pushbutton_fill_table.clicked.connect(self.fill_table) # # self.pushButton_export_table.clicked.connect(self.export_table) # # # # self.verticalLayout_groupbox_table.addWidget(self.tableWidget_sample) # # # +++++++++++++++++++++++++++++++++++++++++++++ # # +++ --- GroupBox plot sample position --- +++ # # +++++++++++++++++++++++++++++++++++++++++++++ # # self.verticalLayout_groupbox_plot_sample_position = QVBoxLayout(self.groupbox_plot_sample_position) # # self.canvas_plot_sample_position_on_transect = None # # # if self.canvas_transect_sample_position # # # self.figure_sample_position, self.axis_sample_position = plt.subplots(nrows=1, ncols=1, layout="constrained") # # self.canvas_sample_position = FigureCanvas(self.figure_sample_position) # # # self.toolbar_sampleposition = NavigationToolBar(self.canvas_sampleposition, self) # # self.empty_field_for_transect_plot() # # self.verticalLayout_groupbox_plot_sample_position.addWidget(self.canvas_sample_position) # # # +++++++++++++++++++++++++++++++++++++++ # # +++ --- GroupBox display option --- +++ # # +++++++++++++++++++++++++++++++++++++++ # # self.verticalLayout_groupbox_display_option = QVBoxLayout(self.groupbox_display_option) # # 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) # # self.groupbox_option_total_concentration_plot = QGroupBox() # self.groupbox_option_total_concentration_plot.setTitle("Total concentration plot") # self.horizontalLayout_Ctot_PSD_plot.addWidget(self.groupbox_option_total_concentration_plot) # # self.gridLayout_groupbox_option_total_concentration_plot = QGridLayout(self.groupbox_option_total_concentration_plot) # self.label_x_axis = QLabel() # self.label_x_axis.setText("x axis") # 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)', '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) # # self.combobox_y_axis = QComboBox() # 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.update_plot_total_concentration) # # # --- Group box PSD plot --- # self.groupbox_option_PSD_plot = QGroupBox() # self.groupbox_option_PSD_plot.setTitle("Particle Size Distribution plot") # self.horizontalLayout_Ctot_PSD_plot.addWidget(self.groupbox_option_PSD_plot) # # self.verticalLayout__groupbox_option_PSD_plot = QHBoxLayout(self.groupbox_option_PSD_plot) # self.combobox_PSD_plot = QComboBox() # 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) # # # self.horizontalLayout_groupbox_option_PSD_plot = QHBoxLayout(self.groupbox_option_PSD_plot) # # self.pushbutton_class_PSD = QPushButton() # # self.pushbutton_class_PSD.setText("Class PSD") # # self.horizontalLayout_groupbox_option_PSD_plot.addWidget(self.pushbutton_class_PSD) # # # self.pushbutton_class_PSD.clicked.connect(self.update_plot_fine_and_sand_sediments_PSD_class) # # # self.pushbutton_class_PSD.clicked_signal[str].connect(self.on_clicked) # # # if self.tableWidget_sample.columnCount() == 10: # # self.pushbutton_class_PSD.clicked.connect(self.empty_field_to_plot_fine_sediment_distribution) # # else: # # self.pushbutton_class_PSD.clicked.connect(self.update_plot_fine_sediment_PSD_class_cumul) # # # self.pushbutton_cumulative_PSD = QPushButton() # # self.pushbutton_cumulative_PSD.setText("Cumulative PSD") # # self.horizontalLayout_groupbox_option_PSD_plot.addWidget(self.pushbutton_cumulative_PSD) # # # self.pushbutton_cumulative_PSD.clicked.connect(self.update_plot_fine_and_sand_sediments_PSD_cumul) # # # if self.tableWidget_sample.columnCount() == 10: # # self.pushbutton_cumulative_PSD.clicked.connect(self.empty_field_to_plot_fine_sediment_distribution) # # else: # # self.pushbutton_cumulative_PSD.clicked.connect(self.update_plot_fine_sediment_PSD_class_cumul) # # # self.pushbutton_plot_PSD_distribution.setText("Class distribution") # # # self.horizontalLayout_calibration_sample_vertical_profile = QHBoxLayout() # # self.verticalLayout_groupbox_displayoption_sampletab.addLayout( # # self.horizontalLayout_calibration_sample_vertical_profile) # # # # self.label_calibration_sample_vertical_profile = QLabel() # # # self.label_calibration_sample_vertical_profile.setText("Calibration sample vertical profile :") # # self.horizontalLayout_calibration_sample_vertical_profile.addWidget( # # self.label_calibration_sample_vertical_profile) # # # # self.combobox_calibration_sample_vertical_profile = CheckableComboBox() # # self.combobox_calibration_sample_vertical_profile.addItems(["S1, S2, S3", "S4, S5, S6, S7", "S8, S9, S10, S11"]) # # self.horizontalLayout_calibration_sample_vertical_profile.addWidget( # # self.combobox_calibration_sample_vertical_profile) # # # -------------------------------------------------------------------------------------------------------------- # ### --- Layout of groupbox in the Bottom horizontal layout box # # # Plot Ctot | Plot PSD fine + sand # # self.groupbox_plot_total_concentration = QGroupBox() # self.horizontalLayoutBottom_sampleDataTab.addWidget(self.groupbox_plot_total_concentration, 3) # # self.groupbox_plot_PSD = QGroupBox() # 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 -------------------- def retranslate_data_sample_tab(self): self.groupbox_download.setTitle(_translate("CONSTANT_STRING", cs.DOWNLOAD)) self.groupbox_particle_size_file.setTitle(_translate("CONSTANT_STRING", cs.PARTICLE_SIZE_DISTRIBUTION_FILE)) self.groupbox_fine_sediment.setTitle(_translate("CONSTANT_STRING", cs.FINE_SEDIMENTS)) self.groupbox_sand.setTitle(_translate("CONSTANT_STRING", cs.SAND_SEDIMENTS)) # self.groupbox_total_concentration.setTitle(_translate("CONSTANT_STRING", cs.TOTAL_CONCENTRATION)) self.groupbox_table.setTitle(_translate("CONSTANT_STRING", cs.TABLE_VALUES)) self.pushbutton_fill_table.setText(_translate("CONSTANT_STRING", cs.FILL_TABLE)) self.allChkBox.setText(_translate("CONSTANT_STRING", cs.CHECK_ALL)) self.pushButton_export_table.setText(_translate("CONSTANT_STRING", cs.EXPORT_TABLE)) self.groupbox_plot_sample_position.setTitle(_translate("CONSTANT_STRING", cs.PLOT_SAMPLE_POSITION)) self.groupbox_display_option.setTitle(_translate("CONSTANT_STRING", cs.OPTIONS)) # self.pushbutton_plot_cumulative_distribution.setText(_translate("CONSTANT_STRING", cs.CUMULATIVE_DISTRIBUTION)) # self.pushbutton_plot_PSD_distribution.setText(_translate("CONSTANT_STRING", cs.CLASS_DISTRIBUTION)) # self.label_calibration_sample_vertical_profile.setText(_translate("CONSTANT_STRING", cs.VERTICAL_PROFILE_FOR_CALIBRATION)) self.groupbox_plot_total_concentration.setTitle(_translate("CONSTANT_STRING", cs.PLOT_TOTAL_CONCENTRATION)) self.groupbox_plot_PSD.setTitle(_translate("CONSTANT_STRING", cs.DISTRIBUTION_PLOT)) # ------------------------------------------------------------------------------------------------------------------ # --- Function to select directory and file name of fine sediments sample data --- def open_dialog_box_fine_sediment(self): filename_fine_sediment = QFileDialog.getOpenFileName(self, "Open file", "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data", "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]) self.load_fine_sediment_data() except IsADirectoryError: msgBox = QMessageBox() msgBox.setWindowTitle("Download Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText("Please select a file") 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) # --- Function to select directory and file name of sand sediments sample data --- def open_dialog_box_sand_sediment(self): filename_sand_sediment = QFileDialog.getOpenFileName(self, "Open file", "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data", "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]) self.load_sand_sediment_data() except IsADirectoryError: msgBox = QMessageBox() msgBox.setWindowTitle("Download Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText("Please select a file") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() else: self.lineEdit_sand.setText(stg.sand_sediment_filename) self.lineEdit_sand.setToolTip(stg.sand_sediment_path) 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 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 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) # ------------------------------------------------------------------------------------------------------------------ # --- Function to fill table of values --- def fill_table(self): if (self.lineEdit_fine_sediment.text()) and not (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.fine_sediment_columns[[0, 2]])), list(map(str, stg.fine_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]))) # --- 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") msgBox = QMessageBox() msgBox.setWindowTitle("Fill table Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText("Download files before fill table") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() # --- Function to extract position of sample from table checkboxes to update plots --- def extract_position_list_and_color_list_from_table_checkboxes(self): 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: position.append(i) eval(f"color_list.append(self.comboBox_sample_table{i}.currentText())") sample_checkbox[0, i] = 2 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) # --- Function to export data of table --- def export_table(self): pass # if self.tableWidget_sample.columnCount() > 10: # name = QFileDialog.getSaveFileName(self, 'Save File') # with open(fichiercsv, 'w', newline='') as csvfile: # csvwriter = csv.writer(csvfile, delimiter=';', quoting=csv.QUOTE_MINIMAL) # for row in range(0, self.tableWidget_sample.rowCount()): # ligne = [] # for col in range(0, self.tableWidget_sample.columnCount()): # valeurcase = self.tableWidget_sample.item(row, col).text().strip() # ligne.append(valeurcase) # csvwriter.writerow(ligne) # else: # msgBox = QMessageBox() # msgBox.setWindowTitle("Export table Error") # msgBox.setIcon(QMessageBox.Warning) # msgBox.setText("Fill table before export table") # msgBox.setStandardButtons(QMessageBox.Ok) # msgBox.exec() # ------------------------------------------------------------------------------------------------------------------ # --- Functions to plot samples positions on transect --- # 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]) # sample_checkbox[0, i] == self.tableWidget_sample.item(i, 1).checkState() # if self.tableWidget_sample.item(i, 1).checkState() == Qt.Unchecked: # print(f"S{i} = Unchecked") # elif np.sum(sample_checkbox) == 0: # self.plot_total_concentration() # print("position", position) # print("color_list", color_list) # print(self.tableWidget_sample.item(i, 1)) # print("sample_checkbox tot", sample_checkbox) # print(np.any(sample_checkbox == 0, axis=0)) # print(sample_checkbox.all()) # print(~sample_checkbox.all()) # if np.sum(sample_checkbox) == 0: # print("True") # # self.plot_transect_bottom_with_sample_position() # # self.plot_total_concentration() # else: # print("False") # def choice_color_sample_position_point(self): # row_value = self.tableWidget_sample.currentRow() # print("row = ", row_value) # print(eval(f"self.comboBox_sample_table{row_value}.currentText()")) # # print("row value", row_value) # # print("cell widget ", self.tableWidget_sample.cellWidget(row_value, 0)) # # print("isinstance(widget, QComboBox)", isinstance(self.tableWidget_sample.cellWidget(row_value, 0), QComboBox)) # # print("cell item ", self.tableWidget_sample.item(row_value, 0)) # # print("combobox tablewidget ", self.comboBox_sample_table.currentText()) # # print("combobox change value") # def plot_transect_bottom_with_sample_position(self): # frequency = self.model.Freq[0] # val_min = 0 # np.nanmin(self.model.BS_averaged_cross_section_corr.V[:, 0, :]) # val_max = np.nanmax(self.model.BS_averaged_cross_section_corr.V[:, 0, :]) # if val_min == 0: # val_min = 1e-5 # # if val_min == 0: # # val_min = 1e-5 # # self.axis_sampleposition.imshow(np.asarray(np.array(self.model.V[:, 0, :2300], dtype=float)), aspect='auto', # # extent=[0, 2300, self.model.depth[-1][0], self.model.depth[0][0]], # # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) # self.axis_sampleposition.pcolormesh(self.model.dist_BS_section, # np.flipud(self.model.BS_raw_cross_section.r), # self.model.BS_averaged_cross_section_corr.V[:, 0, :], # cmap='viridis', # norm=LogNorm(vmin=val_min, vmax=val_max), shading='gouraud') # self.axis_sampleposition.plot(self.model.dist_BS_section, # np.max(self.model.r_bottom_cross_section) - self.model.r_bottom_cross_section # + np.min(self.model.r_bottom_cross_section), # color='k', linewidth=2) # self.axis_sampleposition.set_xticks([]) # self.axis_sampleposition.set_yticks([]) # self.figure_sampleposition.canvas.draw_idle() def plot_sample_position_on_transect(self): if stg.BS_cross_section.size == 0: msgBox = QMessageBox() msgBox.setWindowTitle("Plot transect Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText("Load data from acoustic data tab before plotting transect with sample position") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() else: self.combobox_frequencies.addItems(stg.freq_text) 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.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) if stg.BS_stream_bed.size == 0: val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) if val_min == 0: val_min = 1e-5 self.axis_plot_sample_position_on_transect.pcolormesh( stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], stg.BS_cross_section[stg.freq_bottom_detection, :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) if stg.r_bottom.size != 0: self.axis_plot_sample_position_on_transect.plot( stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid") else: val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) if val_min == 0: val_min = 1e-5 self.axis_plot_sample_position_on_transect.pcolormesh( stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], stg.BS_stream_bed[stg.freq_bottom_detection, :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) if stg.r_bottom.size != 0: self.axis_plot_sample_position_on_transect.plot( stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid") self.axis_plot_sample_position_on_transect.set_xticks([]) self.axis_plot_sample_position_on_transect.set_yticks([]) self.figure_plot_sample_position_on_transect.canvas.draw_idle() def update_plot_sample_position_on_transect(self): # --- Read selected samples (checkboxes) --- position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() # --- Create canvas of Matplotlib figure --- 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() # ------------------------------------------------------------------------------------------------------------------ # --- 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 update_plot_total_concentration(self): if self.tableWidget_sample.columnCount() > 15: # --- Read selected samples (checkboxes) --- position_list, color_list = self.extract_position_list_and_color_list_from_table_checkboxes() self.compute_Ctot_per_cent() 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) msgBox.setText("Fill table and select sample(s) before changing axis") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() # ------------------------------------------------------------------------------------------------------------------ # 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 mouseClickEvent(self, event): # super().mousePressEvent(event) # if event.button() == Qt.LeftButton: # self.pressedState.emit(True) # print(self.pressedState.emit(True)) def update_plot_PSD_fine_and_sand_sediments(self): if self.tableWidget_sample.columnCount() > 15: # --- 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()): # --- 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.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: # # # --- 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_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() # # 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_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(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 ($\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_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() # 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() # 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 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_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()