From ddb4f7f7a97efde573a34dad1544a5b9312ff483 Mon Sep 17 00:00:00 2001 From: brahim Date: Thu, 27 Jul 2023 12:07:40 +0200 Subject: [PATCH] First commit of View file --- View/__init__.py | 0 View/acoustic_data_tab.py | 1103 ++++++++++++++++++++++++++++++++ View/acoustic_inversion_tab.py | 142 ++++ View/mainwindow.py | 185 ++++++ View/note_tab.py | 190 ++++++ View/sample_data_tab.py | 842 ++++++++++++++++++++++++ View/signal_processing_tab.py | 783 +++++++++++++++++++++++ View/user_manual_tab.py | 31 + 8 files changed, 3276 insertions(+) create mode 100644 View/__init__.py create mode 100644 View/acoustic_data_tab.py create mode 100644 View/acoustic_inversion_tab.py create mode 100644 View/mainwindow.py create mode 100644 View/note_tab.py create mode 100644 View/sample_data_tab.py create mode 100644 View/signal_processing_tab.py create mode 100644 View/user_manual_tab.py diff --git a/View/__init__.py b/View/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py new file mode 100644 index 0000000..240f532 --- /dev/null +++ b/View/acoustic_data_tab.py @@ -0,0 +1,1103 @@ +import sys + +from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QPushButton, QComboBox, QLineEdit, QLabel, \ + QGridLayout, QSpinBox, QDoubleSpinBox, QTableView, QTableWidget, QSpacerItem, QSizePolicy, \ + QAbstractScrollArea, QFileDialog, QTableWidgetItem, QMessageBox, QScrollBar, QScrollArea +from PyQt5.QtGui import QPixmap, QIcon +from PyQt5.QtCore import Qt, QCoreApplication, pyqtSignal, pyqtSlot, QEvent + +import numpy as np +import pandas as pd + +import matplotlib.pyplot as plt +# import matplotlib +# matplotlib.use("Qt5Agg") +from matplotlib.colors import LogNorm, CSS4_COLORS, BoundaryNorm +from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas +from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar + +from os import path +from copy import deepcopy + +# import Translation.biblio_string as bs +import Translation.constant_string as cs + +from Model.TableModel import TableModel +from Model.AquascatDataLoader import RawAquascatData +from Model.acoustic_data_loader import AcousticDataLoader +from View.window_noise_level_averaged_profile import WindowNoiseLevelTailAveragedProfile + +from View.sample_data_tab import SampleDataTab + +_translate = QCoreApplication.translate + + +class AcousticDataTab(QWidget): + + ''' This class generates the Acoustic Data Tab ''' + + def __init__(self, tab_widget): + super().__init__() + + path_icon = "./icons/" + icon_folder = QIcon(path_icon + "folder.png") + + ### --- General layout of widgets --- + + self.verticalLayoutMain = QVBoxLayout(tab_widget) + + self.horizontalLayoutTop = QHBoxLayout() + self.verticalLayoutMain.addLayout(self.horizontalLayoutTop, 4) # 1O units is 100% , 1 units is 10% + + self.horizontalLayoutBottom = QHBoxLayout() + self.verticalLayoutMain.addLayout(self.horizontalLayoutBottom, 6) + + ### --- Layout of groupbox in the Top horizontal layout box + + # Download | Measurement information | Table of values | Display options + + self.groupbox_download = QGroupBox() + self.horizontalLayoutTop.addWidget(self.groupbox_download, 3) + + self.groupbox_info = QGroupBox() + self.horizontalLayoutTop.addWidget(self.groupbox_info, 3) + + self.groupbox_table = QGroupBox() + self.horizontalLayoutTop.addWidget(self.groupbox_table, 4) + + self.groupbox_display_option = QGroupBox() + self.horizontalLayoutTop.addWidget(self.groupbox_display_option, 3) + + ### --- Layout of groupbox in the Bottom horizontal layout box + + # 2D field of raw acoustic backscatter data | 2D field of Signal to Noise ratio + + self.groupbox_transect_2Dplot_raw_BS_data = QGroupBox() + self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_raw_BS_data) + + self.groupbox_transect_2Dplot_snr_data = QGroupBox() + self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_snr_data) + + # ===================================================== + # TOP HORIZONTAL BOX LAYOUT + # ===================================================== + + # +++++++++++++++++++++++++++ + # | Group box Download file | + # +++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_download = QVBoxLayout(self.groupbox_download) + + # --- Group box acoustic file --- + + self.groupbox_acoustic_file = QGroupBox() + self.gridLayout_groupbox_acoustic_file = QGridLayout(self.groupbox_acoustic_file) + + self.combobox_ABS_system_choice = QComboBox() + self.combobox_ABS_system_choice.addItems([" ", "Aquascat 1000R", "UB-SediFlow"]) + self.gridLayout_groupbox_acoustic_file.addWidget(self.combobox_ABS_system_choice, 0, 0, 1, 1) + self.pushbutton_acoustic_file = QPushButton() + self.pushbutton_acoustic_file.setObjectName("pushbutton_acoustic_file") + self.pushbutton_acoustic_file.setIcon(icon_folder) + self.gridLayout_groupbox_acoustic_file.addWidget(self.pushbutton_acoustic_file, 0, 1, 1, 1) + self.lineEdit_acoustic_file = QLineEdit() + self.gridLayout_groupbox_acoustic_file.addWidget(self.lineEdit_acoustic_file, 0, 2, 1, 1) + + self.label_date_groupbox_acoustic_file = QLabel() + self.gridLayout_groupbox_acoustic_file.addWidget(self.label_date_groupbox_acoustic_file, 1, 0, 1, 2) + self.label_hour_groupbox_acoustic_file = QLabel() + self.gridLayout_groupbox_acoustic_file.addWidget(self.label_hour_groupbox_acoustic_file, 1, 2, 1, 1) + + # Download Push Button event : connect button clicked signal to open file slot + self.pushbutton_acoustic_file.clicked.connect(self.open_dialog_box) + + self.verticalLayout_groupbox_download.addWidget(self.groupbox_acoustic_file) + + # --- Group box noise file --- + + self.groupbox_noise_file = QGroupBox() + self.gridLayout_groupbox_noise_file = QGridLayout(self.groupbox_noise_file) + + self.pushbutton_noise_level_with_tail_of_mean_profile = QPushButton() + self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_level_with_tail_of_mean_profile, 0, 0, 1, 1) + self.pushbutton_noise_file = QPushButton() + self.pushbutton_noise_file.setObjectName("pushbutton_noise_file") + self.pushbutton_noise_file.setIcon(icon_folder) + self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_file, 0, 1, 1, 1) + self.lineEdit_noise_file = QLineEdit() + self.gridLayout_groupbox_noise_file.addWidget(self.lineEdit_noise_file, 0, 2, 1, 1) + + self.label_date_groupbox_noise_file = QLabel() + self.gridLayout_groupbox_noise_file.addWidget(self.label_date_groupbox_noise_file, 1, 0, 1, 2) + self.label_hour_groupbox_noise_file = QLabel() + self.gridLayout_groupbox_noise_file.addWidget(self.label_hour_groupbox_noise_file, 1, 2, 1, 1) + + # Download Push Button event : connect button clicked signal to open file slot + self.pushbutton_noise_file.clicked.connect(self.open_dialog_box) + + self.verticalLayout_groupbox_download.addWidget(self.groupbox_noise_file) + + # --- Group box GPS file --- + + self.groupbox_gps_file = QGroupBox() + self.gridLayout_groupbox_gps_file = QGridLayout(self.groupbox_gps_file) + + self.combobox_gps_system_choice = QComboBox() + self.combobox_gps_system_choice.addItems([" ", "GPS1", "GPS2", "no GPS"]) + self.gridLayout_groupbox_gps_file.addWidget(self.combobox_gps_system_choice, 0, 0, 1, 1) + self.pushbutton_gps_file = QPushButton() + self.pushbutton_gps_file.setIcon(icon_folder) + self.gridLayout_groupbox_gps_file.addWidget(self.pushbutton_gps_file, 0, 1, 1, 1) + self.lineEdit_gps_file = QLineEdit() + self.gridLayout_groupbox_gps_file.addWidget(self.lineEdit_gps_file, 0, 2, 1, 1) + + self.label_date_groupbox_gps_file = QLabel() + self.gridLayout_groupbox_gps_file.addWidget(self.label_date_groupbox_gps_file, 1, 0, 1, 2) + self.label_hour_groupbox_gps_file = QLabel() + self.gridLayout_groupbox_gps_file.addWidget(self.label_hour_groupbox_gps_file, 1, 2, 1, 1) + + # Download Push Button event : connect button clicked signal to open file slot + # self.pushButton_gpsfile.clicked.connect(self.open_dialog_box) + + self.verticalLayout_groupbox_download.addWidget(self.groupbox_gps_file) + + # --- Time offset line between ABS system time and GPS time --- + + self.gridLayout_time_offset = QGridLayout() + self.label_time_offset = QLabel() + self.gridLayout_time_offset.addWidget(self.label_time_offset, 0, 0, 1, 1) + self.label_acoustic_gps_time = QLabel() + self.label_acoustic_gps_time.setText( + "Tacoustic =" + " Tgps") + self.gridLayout_time_offset.addWidget(self.label_acoustic_gps_time, 0, 1, 1, 1) + self.combobox_plus_minus = QComboBox() + self.combobox_plus_minus.addItem("+") + self.combobox_plus_minus.addItem("-") + self.gridLayout_time_offset.addWidget(self.combobox_plus_minus, 0, 2, 1, 1) + self.spinbox_time_offset_value = QSpinBox() + self.gridLayout_time_offset.addWidget(self.spinbox_time_offset_value, 0, 3, 1, 1) + self.label_seconds = QLabel() + self.label_seconds.setText("sec") + self.gridLayout_time_offset.addWidget(self.label_seconds, 0, 4, 1, 1) + self.verticalLayout_groupbox_download.addLayout(self.gridLayout_time_offset) + + # ++++++++++++++++++++++++++++++++++++++ + # | Group Box Measurements information | + # ++++++++++++++++++++++++++++++++++++++ + + self.gridLayout_goupbox_info = QGridLayout(self.groupbox_info) + + self.label_profiles = QLabel() + self.label_profiles_per_sec = QLabel() + self.label_cells = QLabel() + self.label_cell_size = QLabel() + self.label_pulse_length = QLabel() + self.label_pings_per_sec = QLabel() + self.label_pings_per_profile = QLabel() + self.label_freq = QLabel() + self.label_kt = QLabel() + self.label_rx = QLabel() + self.label_tx = QLabel() + + self.label_to_do = QLabel() + self.label_to_do.setText("UBSediFlow data : to do for Oct. 20th") + + # self.groupbox_measurement_information_Aquascat() + self.combobox_ABS_system_choice.currentTextChanged.connect(self.ABS_system_choice) + + # +++++++++++++++++++++++++++++ + # | Group Box Table of values | + # +++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_table = QVBoxLayout(self.groupbox_table) + + self.horizontalLayout_pushbutton_fill_export_table = QHBoxLayout() + self.pushbutton_fill_table = QPushButton() + self.horizontalLayout_pushbutton_fill_export_table.addWidget(self.pushbutton_fill_table) + + self.pushbutton_fill_table.clicked.connect(self.fill_table) + + self.horizontalSpacerItem_between_pushbutton_fill_export_table = QSpacerItem(50, 10, + QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalLayout_pushbutton_fill_export_table.addItem( + self.horizontalSpacerItem_between_pushbutton_fill_export_table) + + self.pushbutton_export_table = QPushButton() + self.horizontalLayout_pushbutton_fill_export_table.addWidget(self.pushbutton_export_table) + + self.pushbutton_export_table.clicked.connect(self.export_table) + + self.verticalLayout_groupbox_table.addLayout(self.horizontalLayout_pushbutton_fill_export_table) + + # self.tableWidget = QTableWidget() + # self.tableWidget.setRowCount(10) + # self.tableWidget.setColumnCount(10) + + self.tableView = QTableView() + data = pd.DataFrame(np.zeros((10, 10))) + self.tableModel = TableModel(data) + self.tableView.setModel(self.tableModel) + self.verticalLayout_groupbox_table.addWidget(self.tableView) + + # #------------------------------------ + # # self.tableView = QTableView() + # # self.tableView.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContentsOnFirstShow) + # # self.tableView.horizontalHeader().setStretchLastSection(True) + # # + # # df, tension, freq, depth = self._model.acoustic_data() + # # print(np.zeros(len(tension), dtype=int)) + # # print("dimension", list(tension)) + # # self.data = pd.DataFrame({'Time (sec)': np.zeros(10, dtype=int), + # # 'y (m)': np.zeros(10, dtype=int), + # # 'z (m)': np.zeros(10, dtype=int), + # # 'Frequency (MHz)': np.zeros(10, dtype=int), + # # 'Voltage (V)': np.zeros(10, dtype=int), + # # 'SNR': np.zeros(10, dtype=int)}) + # # self.data = pd.DataFrame({'Time (sec)': np.zeros(len(tension), dtype=int), + # # 'y (m)': np.zeros(len(tension), dtype=int), + # # 'z (m)': np.zeros(len(tension), dtype=int), + # # 'Frequency (Hz)': df['freq'], + # # 'Voltage (V)': df['tension'], + # # 'SNR': np.zeros(len(tension), dtype=int)}) + # # self.data.reset_index(drop=True, inplace=True) + # # self.data = self._model.acoustic_data_table + # # + # # self.tableModel = TableModel(self.data) + # # self.tableView.setModel(self.tableModel) + # # self.verticalLayout_groupboxtable.addWidget(self.tableView) + # # ------------------------------------ + # + # self.tableWidget = QTableWidget() + # self.tableWidget.setRowCount(10) + # self.tableWidget.setColumnCount(10) + # # + # # print("tablewidget = ", self.tableWidget) + # # + # # self.tableWidget2 = TableWidget(3, 3) + # # print("tablewidget2 = ", self.tableWidget2) + # + # # for i in range(10): + # # for j in range(10): + # # item_v = QTableWidgetItem() + # # self.tableWidget.setVerticalHeaderItem(i, item_v) + # # item_h = QTableWidgetItem() + # # self.tableWidget.setHorizontalHeaderItem(j, item_h) + # + # # Fill table Push Button event + # # 1st : connect widgets to controllers = fill table + # self.pushbutton_fill_table_acousic.clicked.connect(self.fill_table) # self.on_pushButtonFillTable_clicked + # # 2nd : listen for model event signals = table is filled + # # self._model.BS_data_updated.connect(self.on_BS_data_updated) + # + # self.verticalLayout_groupboxtable.addWidget(self.tableWidget) + # # self.verticalLayout_groupboxtable.addWidget(self.tableView) + + # ++++++++++++++++++++++++++++ + # | Group Box Display option | + # ++++++++++++++++++++++++++++ + + self.verticalLayout_display_option = QVBoxLayout(self.groupbox_display_option) + + # --- Push buttons to trigger plot of transect with Backscatter acoustic raw data and SNR --- + + self.horizontalLayout_pushbutton_plot_BS_SNR_data = QHBoxLayout() + self.verticalLayout_display_option.addLayout(self.horizontalLayout_pushbutton_plot_BS_SNR_data) + + self.pushbutton_plot_transect_with_BS_raw_data = QPushButton() + self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_BS_raw_data) + + self.pushbutton_plot_transect_with_BS_raw_data.clicked.connect(self.plot_transect_with_BS_raw_data) + + self.pushbutton_plot_transect_with_SNR_data = QPushButton() + self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_SNR_data) + + self.pushbutton_plot_transect_with_SNR_data.clicked.connect(self.plot_transect_with_SNR_data) + + # --- Group Box Plot x-axis in time --- + + self.groupbox_xaxis_time = QGroupBox() + # self.groupbox_xaxis_time.setCheckable(True) + # self.groupbox_xaxis_time.setChecked(True) + # self.groupbox_xaxis_time.clicked.connect(self.transect_xaxis_choice) + self.verticalLayout_display_option.addWidget(self.groupbox_xaxis_time) + + self.gridLayout_groupbox_xaxis_time = QGridLayout(self.groupbox_xaxis_time) + self.label_from = QLabel() + self.label_from.setText("From") + self.gridLayout_groupbox_xaxis_time.addWidget(self.label_from, 0, 0, 1, 1) + + self.label_tmin = QLabel() + self.label_tmin.setText("tmin = ") + self.gridLayout_groupbox_xaxis_time.addWidget(self.label_tmin, 0, 1, 1, 1) + + self.spinbox_tmin = QDoubleSpinBox() + self.spinbox_tmin.setRange(0, 9999) + self.gridLayout_groupbox_xaxis_time.addWidget(self.spinbox_tmin, 0, 2, 1, 1) + self.spinbox_tmin.valueChanged.connect(self.update_xaxis_transect_with_BS_raw_data) + self.spinbox_tmin.valueChanged.connect(self.update_xaxis_transect_with_SNR_data) + + self.label_tmin_unit = QLabel() + self.label_tmin_unit.setText("sec") + self.gridLayout_groupbox_xaxis_time.addWidget(self.label_tmin_unit, 0, 3, 1, 1) + + self.label_to = QLabel() + self.label_to.setText("to") + self.gridLayout_groupbox_xaxis_time.addWidget(self.label_to, 0, 4, 1, 1) + + self.label_tmax = QLabel() + self.label_tmax.setText("tmax = ") + self.gridLayout_groupbox_xaxis_time.addWidget(self.label_tmax, 0, 5, 1, 1) + + self.spinbox_tmax = QDoubleSpinBox() + self.spinbox_tmax.setRange(0, 9999) + self.gridLayout_groupbox_xaxis_time.addWidget(self.spinbox_tmax, 0, 6, 1, 1) + self.spinbox_tmax.valueChanged.connect(self.update_xaxis_transect_with_BS_raw_data) + self.spinbox_tmax.valueChanged.connect(self.update_xaxis_transect_with_SNR_data) + + self.label_tmax_unit = QLabel() + self.label_tmax_unit.setText("sec") + self.gridLayout_groupbox_xaxis_time.addWidget(self.label_tmax_unit, 0, 7, 1, 1) + + # --- Group Box Plot x-axis in space --- + + self.groupbox_xaxis_space = QGroupBox() + # self.groupbox_xaxis_space.setCheckable(True) + # self.groupbox_xaxis_space.setChecked(False) + # self.groupbox_xaxis_space.clicked.connect(self.transect_xaxis_choice) + self.verticalLayout_display_option.addWidget(self.groupbox_xaxis_space) + + self.gridLayout_groupbox_xaxis_space = QGridLayout(self.groupbox_xaxis_space) + self.label_from = QLabel() + self.label_from.setText("From") + self.gridLayout_groupbox_xaxis_space.addWidget(self.label_from, 0, 0, 1, 1) + self.label_xmin = QLabel() + self.label_xmin.setText("xmin = ") + self.gridLayout_groupbox_xaxis_space.addWidget(self.label_xmin, 0, 1, 1, 1) + self.spinbox_xmin = QSpinBox() + self.spinbox_xmin.setRange(0, 9999) + self.gridLayout_groupbox_xaxis_space.addWidget(self.spinbox_xmin, 0, 2, 1, 1) + self.label_xmin_m = QLabel() + self.label_xmin_m.setText("m") + self.gridLayout_groupbox_xaxis_space.addWidget(self.label_xmin_m, 0, 3, 1, 1) + self.label_to = QLabel() + self.label_to.setText("to") + self.gridLayout_groupbox_xaxis_space.addWidget(self.label_to, 0, 4, 1, 1) + self.label_xmax = QLabel() + self.label_xmax.setText("xmax = ") + self.gridLayout_groupbox_xaxis_space.addWidget(self.label_xmax, 0, 5, 1, 1) + self.spinbox_xmax = QSpinBox() + self.spinbox_xmax.setRange(0, 9999) + self.gridLayout_groupbox_xaxis_space.addWidget(self.spinbox_xmax, 0, 6, 1, 1) + self.label_xmax_m = QLabel() + self.label_xmax_m.setText("m") + self.gridLayout_groupbox_xaxis_space.addWidget(self.label_xmax_m, 0, 7, 1, 1) + + # --- Group Box bathymetry computation algorithm to plot bottom of transect--- + + self.groupbox_compute_bathymetry = QGroupBox() + # # self.groupbox_crosssectionbottom.setTitle("Plot bottom of cross section") + # self.groupbox_crosssectionbottom.setCheckable(True) + # self.groupbox_crosssectionbottom.setChecked(False) + self.verticalLayout_display_option.addWidget(self.groupbox_compute_bathymetry) + + self.gridlayout_compute_bathymetry = QGridLayout(self.groupbox_compute_bathymetry) + + self.combobox_freq_choice = QComboBox() + self.combobox_freq_choice.addItems(['', '0.3 MHz', '0.5 Mhz', '1 MHz', '5 MHz']) + self.gridlayout_compute_bathymetry.addWidget(self.combobox_freq_choice, 0, 0, 2, 1) + self.gridlayout_compute_bathymetry.addWidget(self.label_from, 0, 1, 1, 1) + self.spinbox_depth_min = QSpinBox() + self.spinbox_depth_min.setRange(0, 9999) + self.gridlayout_compute_bathymetry.addWidget(self.spinbox_depth_min, 0, 2, 1, 1) + self.label_depth_min_unit = QLabel() + self.label_depth_min_unit.setText("m") + self.gridlayout_compute_bathymetry.addWidget(self.label_depth_min_unit, 0, 3, 1, 1) + self.gridlayout_compute_bathymetry.addWidget(self.label_to, 0, 4, 1, 1) + self.spinbox_depth_max = QSpinBox() + self.spinbox_depth_max.setRange(0, 99999) + self.gridlayout_compute_bathymetry.addWidget(self.spinbox_depth_max, 0, 5, 1, 1) + self.label_depth_max_unit = QLabel() + self.label_depth_max_unit.setText("m") + self.gridlayout_compute_bathymetry.addWidget(self.label_depth_max_unit, 0, 6, 1, 1) + self.label_next_cell = QLabel() + self.label_next_cell.setText("Next cell : +/-") + self.gridlayout_compute_bathymetry.addWidget(self.label_next_cell, 1, 1, 1, 1) + self.doublespinbox_next_cell = QDoubleSpinBox() + self.doublespinbox_next_cell.setRange(0, 99999) + self.doublespinbox_next_cell.setDecimals(2) + self.gridlayout_compute_bathymetry.addWidget(self.doublespinbox_next_cell, 1, 2, 1, 1) + self.label_next_cell_unit = QLabel() + self.label_next_cell_unit.setText("m") + self.gridlayout_compute_bathymetry.addWidget(self.label_next_cell_unit, 1, 3, 1, 1) + self.pushbutton_compute_bathymetry_algorithm = QPushButton() + self.pushbutton_compute_bathymetry_algorithm.setText("Compute \n&& \nPlot") + self.gridlayout_compute_bathymetry.addWidget(self.pushbutton_compute_bathymetry_algorithm, 0, 7, 2, 1) + + # self.pushButton_plot = QPushButton() + # self.pushButton_plot.setText("Plot") + # self.verticalLayout_displayoption.addWidget(self.pushButton_plot) + + # ===================================================== + # BOTTOM HORIZONTAL BOX LAYOUT + # ===================================================== + + # +++++++++++++++++++++++++++++++++++++************+++ + # | Group Box Backscatter Acoustic Raw Data 2D field | + # ++++++++++++++++++++++++++************++++++++++++++ + + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data = QVBoxLayout(self.groupbox_transect_2Dplot_raw_BS_data) + + self.canvas_BS = None + + # self.fig_BS, self.axis_BS = plt.subplots(nrows=4, ncols=1, sharex=True, sharey=False, layout="constrained") + # self.fig, self.ax = plt.subplots(4, 1) + # self.canvas_BS = FigureCanvas(self.fig_BS) + # self.canvas_BS = FigureCanvas() + # self.plotToolbar_rawdata = NavigationToolBar(self.canvas_rawdata, self) + # self.plot_acoustic_raw_data() + # self.verticalLayout_plotrawdata.addWidget(self.plotToolbar_rawdata) + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_BS) + + # ++++++++++++++++++++++++++++++++++++++++++++ + # | Group Box Signal to Noise ratio 2D field | + # ++++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_transect_2Dplot_snr_data = QVBoxLayout(self.groupbox_transect_2Dplot_snr_data) + + self.canvas_SNR = None + + # self.figure, self.axis = plt.subplots(nrows=4, ncols=1, sharex=True, sharey=False, layout="constrained") + # # self.canvas_snrdata = FigureCanvas(self.figure) + # + # self.canvas_snrdata = FigureCanvas() + # # self.plotToolbar_snrdata = NavigationToolBar(self.canvas_snrdata, self) + # # self.plot_snr_data() + # # self.verticalLayout_plotsnrdata.addWidget(self.plotToolbar_snrdata) + # self.verticalLayout_plotsnrdata.addWidget(self.canvas_snrdata) + # + # self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_snr_data) + + self.retranslate_acoustic_data_tab() + + # -------------------- Functions for Acoustic dataTab -------------------- + + def retranslate_acoustic_data_tab(self): + + self.groupbox_download.setTitle(_translate("CONSTANT_STRING", cs.DOWNLOAD)) + + self.groupbox_acoustic_file.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_FILE)) + self.label_date_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") + self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":") + + self.groupbox_noise_file.setTitle(_translate("CONSTANT_STRING", cs.NOISE_FILE)) + self.pushbutton_noise_level_with_tail_of_mean_profile.setText(_translate("CONSTANT_STRING", cs.NOISE_LEVEL)) + self.label_date_groupbox_noise_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") + self.label_hour_groupbox_noise_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":") + + self.groupbox_gps_file.setTitle(_translate("CONSTANT_STRING", cs.GPS_FILE)) + self.label_date_groupbox_gps_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") + self.label_hour_groupbox_gps_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":") + + self.label_time_offset.setText(_translate("CONSTANT_STRING", cs.TIME_OFFSET)) + + self.groupbox_info.setTitle(_translate("CONSTANT_STRING", cs.MEASUREMENTS_INFORMATION)) + + self.label_profiles.setText(_translate("CONSTANT_STRING", cs.NB_PROFILES) + ":") + self.label_profiles.setToolTip(_translate("CONSTANT_STRING", cs.NB_PROFILES_TOOLTIP)) + + self.label_profiles_per_sec.setText(_translate("CONSTANT_STRING", cs.NB_PROFILES_PER_SEC) + ":") + self.label_profiles_per_sec.setToolTip(_translate("CONSTANT_STRING", cs.NB_PROFILES_PER_SEC_TOOLTIP)) + + self.label_cells.setText(_translate("CONSTANT_STRING", cs.NB_CELLS) + ":") + self.label_cells.setToolTip(_translate("CONSTANT_STRING", cs.NB_CELLS_TOOLTIP)) + + self.label_cell_size.setText(_translate("CONSTANT_STRING", cs.CELL_SIZE) + ":") + self.label_cell_size.setToolTip(_translate("CONSTANT_STRING", cs.CELL_SIZE_TOOLTIP)) + + self.label_pulse_length.setText(_translate("CONSTANT_STRING", cs.PULSE_LENGHT) + ":") + self.label_pulse_length.setToolTip(_translate("CONSTANT_STRING", cs.PULSE_LENGHT_TOOLTIP)) + + self.label_pings_per_sec.setText(_translate("CONSTANT_STRING", cs.NB_PINGS_PER_SEC)) + self.label_pings_per_sec.setToolTip(_translate("CONSTANT_STRING", cs.NB_PINGS_PER_SEC_TOOLTIP)) + + self.label_pings_per_profile.setText(_translate("CONSTANT_STRING", cs.NB_PINGS_PER_PROFILE) + ":") + self.label_pings_per_profile.setToolTip(_translate("CONSTANT_STRING", cs.NB_PINGS_PER_PROFILE_TOOLTIP)) + + self.label_freq.setText(_translate("CONSTANT_STRING", cs.FREQUENCY) + ":") + self.label_freq.setToolTip(_translate("CONSTANT_STRING", cs.FREQUENCY_TOOLTIP)) + + self.label_kt.setText(_translate("CONSTANT_STRING", cs.KT) + ":") + self.label_kt.setToolTip(_translate("CONSTANT_STRING", cs.KT_TOOLTIP)) + + self.label_rx.setText(_translate("CONSTANT_STRING", cs.GAIN_RX) + ":") + self.label_rx.setToolTip(_translate("CONSTANT_STRING", cs.GAIN_RX_TOOLTIP)) + + self.label_tx.setText(_translate("CONSTANT_STRING", cs.GAIN_TX) + ":") + self.label_tx.setToolTip(_translate("CONSTANT_STRING", cs.GAIN_TX_TOOLTIP)) + + self.groupbox_table.setTitle(_translate("CONSTANT_STRING", cs.TABLE_VALUES)) + + self.pushbutton_fill_table.setText(_translate("CONSTANT_STRING", cs.SYNCHRONIZE_AND_FILL_TABLE)) + self.pushbutton_export_table.setText(_translate("CONSTANT_STRING", cs.EXPORT_TABLE)) + + self.groupbox_display_option.setTitle(_translate("CONSTANT_STRING", cs.DISPLAY_OPTIONS)) + + self.pushbutton_plot_transect_with_BS_raw_data.setText(_translate("CONSTANT_STRING", cs.PLOT_TRANSECT)) + self.pushbutton_plot_transect_with_SNR_data.setText(_translate("CONSTANT_STRING", cs.PLOT_SNR)) + + self.groupbox_xaxis_time.setTitle(_translate("CONSTANT_STRING", cs.PLOT_XAXIS_IN_TIME)) + # self.label_tmin.setText(_translate("CONSTANT_STRING", cs.FROM) + " tmin = ") + # self.label_tmax.setText(_translate("CONSTANT_STRING", cs.TO) + " tmax = ") + # self.pushButton_plot_acoustic_transect_in_time.setText(_translate("CONSTANT_STRING", cs.PLOT_TRANSECT)) + + self.groupbox_xaxis_space.setTitle(_translate("CONSTANT_STRING", cs.PLOT_XAXIS_IN_SPACE)) + # self.label_zmin.setText(_translate("CONSTANT_STRING", cs.FROM) + " zmin = ") + # self.label_zmax.setText(_translate("CONSTANT_STRING", cs.TO) + " zmax = ") + # self.pushButton_plot_acoustic_transect_in_space.setText(_translate("CONSTANT_STRING", cs.PLOT_TRANSECT)) + + self.groupbox_compute_bathymetry.setTitle(_translate("CONSTANT_STRING", cs.PLOT_BOTTOM_CROSS_SECTION)) + # self.label_depthmin.setText(_translate("CONSTANT_STRING", cs.INITIAL_DEPTH_RANGE) + ":") + # self.label_depthmin.setText(_translate("CONSTANT_STRING", cs.FROM)) + # self.label_to.setText(_translate("CONSTANT_STRING", cs.TO)) + # self.pushButton_bottom_transect.setText(_translate("CONSTANT_STRING", cs.PLOT_BOTTOM)) + + self.groupbox_transect_2Dplot_raw_BS_data.setTitle(_translate("CONSTANT_STRING", cs.RAW_ACOUSTIC_DATA_2D_FIELD)) + + self.groupbox_transect_2Dplot_snr_data.setTitle(_translate("CONSTANT_STRING", cs.SIGNAL_TO_NOISE_RATIO_2D_FIELD)) + + def ABS_system_choice(self): + if self.combobox_ABS_system_choice.currentText() == "Aquascat 1000R": + self.groupbox_measurement_information_Aquascat() + self.lineEdit_acoustic_file.clear() + self.label_date_groupbox_acoustic_file.clear() + self.label_date_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ": ") + self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ": ") + elif self.combobox_ABS_system_choice.currentText() == "UB-SediFlow": + self.groupbox_measurement_information_UBSediFlow() + self.lineEdit_acoustic_file.clear() + self.label_date_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ": ") + self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ": ") + + def groupbox_measurement_information_Aquascat(self): + # self.gridLayout_goupbox_info.itemAt(0).widget().deleteLater() + self.label_to_do.hide() + + self.label_profiles.show() + self.label_profiles_per_sec.show() + self.label_cells.show() + self.label_cell_size.show() + self.label_pulse_length.show() + self.label_pings_per_sec.show() + self.label_pings_per_profile.show() + self.label_freq.show() + self.label_kt.show() + self.label_rx.show() + self.label_tx.show() + + self.gridLayout_goupbox_info.addWidget(self.label_profiles, 0, 0, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 0, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_cells, 1, 0, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 1, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 2, 0, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 3, 0, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 3, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_freq, 4, 0, 1, 2) + self.gridLayout_goupbox_info.addWidget(self.label_kt, 5, 0, 1, 2) + self.gridLayout_goupbox_info.addWidget(self.label_rx, 6, 0, 1, 2) + self.gridLayout_goupbox_info.addWidget(self.label_tx, 7, 0, 1, 2) + + def groupbox_measurement_information_UBSediFlow(self): + # self.gridLayout_goupbox_info.itemAt(0).widget().deleteLater() + + self.label_profiles.hide() + self.label_profiles_per_sec.hide() + self.label_cells.hide() + self.label_cell_size.hide() + self.label_pulse_length.hide() + self.label_pings_per_sec.hide() + self.label_pings_per_profile.hide() + self.label_freq.hide() + self.label_kt.hide() + self.label_rx.hide() + self.label_tx.hide() + + self.label_to_do.show() + + self.gridLayout_goupbox_info.addWidget(self.label_to_do, 0, 0, 1, 1) + + def clicked_pushbutton_noise_level(self): + self.WindowNoiseLevelTailAveragedProfile().show() + + def open_dialog_box(self): + if self.combobox_ABS_system_choice.currentIndex() == 0: + msgBox = QMessageBox() + msgBox.setWindowTitle("Download Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Choose ABS system before download acoustic files") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + elif self.combobox_ABS_system_choice.currentIndex() == 1: + filename = QFileDialog.getOpenFileName(self, "Open file", + "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data", + "Aquascat file (*.aqa)") + dir_name = path.dirname(filename[0]) + name = path.basename(filename[0]) + elif self.combobox_ABS_system_choice.currentIndex() == 2: + filename = QFileDialog.getOpenFileName(self, "Open file", "", "UBSediFlow file (*.udt)") + dir_name = path.dirname(filename[0]) + name = path.basename(filename[0]) + if self.combobox_ABS_system_choice.currentIndex() != 0: + if self.sender().objectName() == "pushbutton_acoustic_file": + self.lineEdit_acoustic_file.setText(name) + self.lineEdit_acoustic_file.setToolTip(dir_name) + acoustic_data = self.load_BS_acoustic_raw_data() + self.label_date_groupbox_acoustic_file.setText( + _translate("CONSTANT_STRING", cs.DATE) + ": " + str(acoustic_data._date)) + self.label_hour_groupbox_acoustic_file.setText( + _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(acoustic_data._hour)) + self.fill_measurements_information_groupbox() + if self.sender().objectName() == "pushbutton_noise_file": + self.lineEdit_noise_file.setText(name) + self.lineEdit_noise_file.setToolTip(dir_name) + noise_data = self.load_noise_data() + self.label_date_groupbox_noise_file.setText( + _translate("CONSTANT_STRING", cs.DATE) + ": " + str(noise_data._date)) + self.label_hour_groupbox_noise_file.setText( + _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(noise_data._hour)) + # return filename[0] + + def load_BS_acoustic_raw_data(self): + acoustic_data = \ + AcousticDataLoader(self.lineEdit_acoustic_file.toolTip() + "/" + self.lineEdit_acoustic_file.text()) + return acoustic_data + + def load_noise_data(self): + noise_data = AcousticDataLoader(self.lineEdit_noise_file.toolTip() + "/" + self.lineEdit_noise_file.text()) + return noise_data + + def compute_SNR(self): + acoustic_data = self.load_BS_acoustic_raw_data() + noise_data = self.load_noise_data() + noise = np.zeros(acoustic_data._BS_raw_data.shape) + for f in range(noise_data._freq.shape[0]): + # print(np.mean(self.V_noise[:, f, :], axis=(0, 1))) + # BS_noise_section[0:BS_noise_section.shape[0], f, 0:BS_noise_section.shape[2]] = \ + noise[:, f, :] = np.mean(noise_data._BS_raw_data[:, f, :], axis=(0, 1)) + noise_data._time_snr = acoustic_data._time + noise_data._snr = np.divide((acoustic_data._BS_raw_data - noise)**2, noise**2) + noise_data._snr_reshape = np.reshape(noise_data._snr, + (acoustic_data._r.shape[0] * acoustic_data._time.shape[0], + noise_data._freq.shape[0]), + order="F") + return noise_data + + def fill_measurements_information_groupbox(self): + acoustic_data = self.load_BS_acoustic_raw_data() + + self.label_profiles.setText( + _translate("CONSTANT_STRING", cs.NB_PROFILES) + ": " + str(acoustic_data._nb_profiles)) + self.label_profiles_per_sec.setText( + _translate("CONSTANT_STRING", cs.NB_PROFILES_PER_SEC) + ": " + + str(acoustic_data._nb_profiles_per_sec) + " Hz") + self.label_freq.setText( + _translate("CONSTANT_STRING", cs.FREQUENCY) + ": " + ', '.join(acoustic_data._freq_text)) + self.label_cells.setText( + _translate("CONSTANT_STRING", cs.NB_CELLS) + ": " + str(acoustic_data._nb_cells)) + self.label_cell_size.setText( + _translate("CONSTANT_STRING", cs.CELL_SIZE) + ": " + str(100*round(acoustic_data._cell_size, 3)) + " cm") + self.label_pulse_length.setText( + _translate("CONSTANT_STRING", cs.PULSE_LENGHT) + ": " + str(round(acoustic_data._pulse_length,6)) + "sec") + self.label_pings_per_sec.setText( + _translate("CONSTANT_STRING", cs.NB_PINGS_PER_SEC) + ": " + str(acoustic_data._nb_pings_per_sec) + " Hz") + self.label_pings_per_profile.setText( + _translate("CONSTANT_STRING", cs.NB_PINGS_PER_PROFILE) + ": " + + str(acoustic_data._nb_pings_averaged_per_profile)) + self.label_kt.setText( + _translate("CONSTANT_STRING", cs.KT) + ": " + ', '.join(map(str, acoustic_data._kt))) + self.label_rx.setText( + _translate("CONSTANT_STRING", cs.GAIN_RX) + ": " + ', '.join(map(str, acoustic_data._gain_rx))) + self.label_tx.setText( + _translate("CONSTANT_STRING", cs.GAIN_TX) + ": " + ', '.join(map(str, acoustic_data._gain_tx))) + + def fill_table(self): + if ((self.lineEdit_acoustic_file.text()) and (self.lineEdit_noise_file.text())): + # --- Load data --- + acoustic_data = self.load_BS_acoustic_raw_data() + noise_data = self.compute_SNR() + # --- Fill table with data --- + data = pd.DataFrame( + np.concatenate((acoustic_data.reshape_t(), acoustic_data.reshape_BS_raw_cross_section(), + noise_data._snr_reshape), axis=1), + columns=list(map(str, ["Time"] + ["BS - " + f for f in acoustic_data._freq_text] + + ["SNR - " + f for f in acoustic_data._freq_text]))) + self.tableModel = TableModel(data) + self.tableView.setModel(self.tableModel) + elif self.lineEdit_acoustic_file.text(): + # --- Load data --- + acoustic_data = self.load_BS_acoustic_raw_data() + # --- Fill table with data --- + data = pd.DataFrame( + np.concatenate((acoustic_data.reshape_t(), acoustic_data.reshape_BS_raw_cross_section()), axis=1), + columns=list(map(str, ["Time"] + ["BS - " + f for f in acoustic_data._freq_text]))) + self.tableModel = TableModel(data) + self.tableView.setModel(self.tableModel) + else: + msgBox = QMessageBox() + msgBox.setWindowTitle("Fill table Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Download files before fill table") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + + def export_table(self): + if self.tableWidget.columnCount() == 10: + msgBox = QMessageBox() + msgBox.setWindowTitle("Export table Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Fill table before export table") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + else: + print("export table") + + def transect_xaxis_choice(self): + if self.groupbox_xaxis_time.isChecked() == True: + # self.groupbox_xaxis_time.setDisabled(True) + self.groupbox_xaxis_space.setChecked(False) + # self.groupbox_xaxis_space.setDisabled(False) + elif self.groupbox_xaxis_space.isChecked() == True: + self.groupbox_xaxis_time.setChecked(False) + # self.groupbox_xaxis_time.setDisabled(False) + # self.groupbox_xaxis_space.setDisabled(True) + + + # def fill_lineEdit(self, dir_name, name): + # if self.pushbutton_acousticfile.isChecked(): + # self.lineEdit_acousticfile.setText(name) + # self.lineEdit_acousticfile.setToolTip(dir_name) + # self.fill_label_acoustic_file() + # self.fill_measurements_information_groupbox() + # self.pushbutton_acousticfile.setChecked(False) + # elif self.pushButton_noisefile.isChecked(): + # self.lineEdit_noisefile.setText(name) + # self.lineEdit_noisefile.setToolTip(dir_name) + # self.fill_label_noise_file() + # self.pushButton_noisefile.setChecked(False) + # elif self.pushButton_gpsfile.isChecked(): + # self.lineEdit_gpsfile.setText(name) + # self.lineEdit_gpsfile.setToolTip(dir_name) + # self.fill_label_gps_file() + # self.pushButton_gpsfile.setChecked(False) + # + # def fill_label_acoustic_file(self): + # self.label_date_acousticfile.setText( + # _translate("CONSTANT_STRING", cs.DATE) + ": " + str(self._model.data.date.date())) + # self.label_hour_acousticfile.setText( + # _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(self._model.data.date.time())) + # + # def fill_label_noise_file(self): + # self.label_date_noise_file.setText( + # _translate("CONSTANT_STRING", cs.DATE) + ": " + str(self._model.data.date.date())) + # self.label_hour_noise_file.setText( + # _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(self._model.data.date.time())) + # + # def fill_label_gps_file(self): + # pass + # # self.label_date_gps_file.setText( + # # _translate("CONSTANT_STRING", cs.DATE) + ": " + str(self._model.gps_load_date_hour.date())) + # # self.label_hour_gps_file.setText( + # # _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(self._model.gps_load_date_hour.time())) + + + + # def fill_table(self): + # print("it's clicked") + # print(AcousticData.concatenate_data(self)) + # # if event.type() == QEvent.MouseButtonPress: + # # print("Fill table") + # # print("event = ", event) + # # print("QEvent.MouseButtonPress ", QEvent.MouseButtonPress) + # # super(AcousticDataTab, self).mousePressEvent(event) + # # print("1 : connect widget to controller - fill table") + # # self._controller.update_table_data() + # # data = self._model.acoustic_data_table + # # tableModel = TableModel(data) + # # self.tableView.setModel(tableModel) + # # print("open dialog box ", self.open_dialog_box()) + # + # def on_BS_data_updated(self, value): + # pass + + def plot_transect_with_BS_raw_data(self): + if self.tableModel.rowCount(1) > 11: + acoustic_data = self.load_BS_acoustic_raw_data() + # print(np.max(acoustic_data._time)) + + # print("tmin value ", self.spinbox_tmin.value()) + # print("tmin index ", np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]) + + # print("tmax value ", self.spinbox_tmax.value()) + # print("tmax index ", np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]) + self.fig_BS, self.axis_BS = plt.subplots(nrows=acoustic_data._freq.shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") + self.canvas_BS = FigureCanvas(self.fig_BS) + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_BS) + + # self.scroll_BS = QScrollArea() + # self.scroll_BS.setWidget(self.canvas_BS) + + self.spinbox_tmin.setValue(np.min(acoustic_data._time)) + self.spinbox_tmax.setValue(np.round(np.max(acoustic_data._time), 2)) + + for f in range(acoustic_data._freq.shape[0]): + # self.ax = self.fig.add_subplot((4, 1, f+1), sharex=True, sharey=False) + # val_min = np.min(self.model.V[:, f, :2300]) + val_min = np.min(acoustic_data._BS_raw_data[:, f, :]) + # val_max = np.max(self.model.V[:, f, :2300]) + val_max = np.max(acoustic_data._BS_raw_data[:, f, :]) + if val_min == 0: + val_min = 1e-5 + # if val_min == 0: + # val_min = 1e-5 + # self.ax[f].imshow(np.asarray(np.array(self.model.BS_raw_cross_section.V[:, f, :], dtype=float)), aspect='auto', + # extent=[0, 1912, self.model.depth[-1][0], self.model.depth[0][0]], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # self.ax[f].plot(self.model.r_bottom_cross_section, color='red', linewidth=2) + pcm = self.axis_BS[f].pcolormesh( + acoustic_data._time[np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: + np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]], + acoustic_data._r , + np.flipud(acoustic_data._BS_raw_data[:, f, + np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: + np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]]), + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))#, shading='gouraud') + # self.axis_BS[f].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='red', linewidth=2) + # x, y = np.meshgrid(self.model.dist_BS_section, self.model.BS_raw_cross_section.r) + # z = np.cos(x) + np.sin(y) + # self.ax[f].contour(x, y, z, levels = 0, colors='k') + # self.ax[f].plot([25, 200], [5, 5], '-k') + self.axis_BS[f].text(1, .70, acoustic_data._freq_text[f], + fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + horizontalalignment='right', verticalalignment='bottom', transform=self.axis_BS[f].transAxes) + + self.fig_BS.supxlabel('Distance from left bank (m)', fontsize=10) + self.fig_BS.supylabel('Depth (m)', fontsize=10) + # plt.subplots_adjust(bottom=0.125, top=0.98, right=1.03, left=0.08, hspace=0.1) + # self.fig.tight_layout() + cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right') + cbar.set_label(label='Backscatter acoustic signal (V)', rotation=270, labelpad=10) + self.fig_BS.canvas.draw_idle() + else: + msgBox = QMessageBox() + msgBox.setWindowTitle("Plot transect Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Fill table before plot transect 2D field") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + + def plot_transect_with_SNR_data(self): + if self.tableModel.rowCount(1) == 10: + msgBox = QMessageBox() + msgBox.setWindowTitle("Plot transect Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Fill table before plot SNR 2D field") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + elif self.canvas_BS == None: + msgBox = QMessageBox() + msgBox.setWindowTitle("Plot transect Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Plot backscatter acoustic raw data 2D field before plot SNR 2D field") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + elif self.tableModel.rowCount(1) > 11: + noise_data = self.compute_SNR() + + self.fig_SNR, self.axis_SNR = plt.subplots(nrows=noise_data._freq.shape[0] , ncols=1, + sharex=True, sharey=False, layout="constrained") + self.canvas_SNR = FigureCanvas(self.fig_SNR) + self.verticalLayout_groupbox_transect_2Dplot_snr_data.addWidget(self.canvas_SNR) + + # self.spinbox_tmin.setValue(np.min(noise_data._time_snr)) + # self.spinbox_tmax.setValue(np.round(np.max(noise_data._time_snr), 2)) + + x, y = np.meshgrid( + noise_data._time_snr[np.where(np.round(noise_data._time_snr, 2) == self.spinbox_tmin.value())[0][0]: + np.where(np.round(noise_data._time_snr, 2) == self.spinbox_tmax.value())[0][0]], + noise_data._r) + + for f in range(noise_data._freq.shape[0]): + + val_min = np.min(noise_data._snr[:, f, :]) + val_max = np.max(noise_data._snr[:, f, :]) + if val_min == 0: + val_min = 1e-5 + if val_max > 1000: + levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + else: + levels = np.array([00.1, 1, 2, 10, 100, val_max]) + bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + norm = BoundaryNorm(boundaries=bounds, ncolors=300) + + cf = self.axis_SNR[f].contourf(x, y, + np.flipud(noise_data._snr[:, f, + np.where(np.round(noise_data._time_snr, 2) == self.spinbox_tmin.value())[0][0]: + np.where(np.round(noise_data._time_snr, 2) == self.spinbox_tmax.value())[0][0]]), + levels, cmap='gist_rainbow', norm=norm)#, shading='gouraud') + + self.axis_SNR[f].text(1, .70, noise_data._freq_text[f], + fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + horizontalalignment='right', verticalalignment='bottom', transform=self.axis_SNR[f].transAxes) + + self.fig_SNR.supxlabel('Distance from left bank (m)', fontsize=10) + self.fig_SNR.supylabel('Depth (m)', fontsize=10) + # plt.subplots_adjust(bottom=0.125, top=0.98, right=1.03, left=0.08, hspace=0.1) + # self.fig.tight_layout() + cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right') + cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10) + cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$']) + self.fig_SNR.canvas.draw_idle() + + def update_xaxis_transect_with_BS_raw_data(self): + if self.canvas_BS == None: + msgBox = QMessageBox() + msgBox.setWindowTitle("Plot transect Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Plot transect before change x-axis value") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + else: + # print(self.axis_BS.cla()) + # self.fig_BS.clf() + + acoustic_data = self.load_BS_acoustic_raw_data() + # self.fig_BS, self.axis_BS = plt.subplots(nrows=acoustic_data._freq.shape[0], ncols=1, sharex=True, + # sharey=False, layout="constrained") + # self.canvas_BS = FigureCanvas(self.fig_BS) + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_BS) + + for f in range(acoustic_data._freq.shape[0]): + self.axis_BS[f].cla() + val_min = np.min(acoustic_data._BS_raw_data[:, f, :]) + val_max = np.max(acoustic_data._BS_raw_data[:, f, :]) + if val_min == 0: + val_min = 1e-5 + pcm = self.axis_BS[f].pcolormesh( + acoustic_data._time[np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: + np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]], + acoustic_data._r , + np.flipud(acoustic_data._BS_raw_data[:, f, + np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: + np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]]), + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))#, shading='gouraud') + + self.axis_BS[f].text(1, .70, acoustic_data._freq_text[f], + fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + horizontalalignment='right', verticalalignment='bottom', transform=self.axis_BS[f].transAxes) + + self.fig_BS.supxlabel('Distance from left bank (m)', fontsize=10) + self.fig_BS.supylabel('Depth (m)', fontsize=10) + # cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right') + # cbar.set_label(label='Backscatter acoustic signal (V)', rotation=270, labelpad=10) + self.fig_BS.canvas.draw_idle() + + def update_xaxis_transect_with_SNR_data(self): + noise_data = self.compute_SNR() + if ((self.canvas_BS != None) and (self.canvas_SNR != None)): + + x, y = np.meshgrid( + noise_data._time_snr[np.where(np.round(noise_data._time_snr, 2) == self.spinbox_tmin.value())[0][0]: + np.where(np.round(noise_data._time_snr, 2) == self.spinbox_tmax.value())[0][0]], + noise_data._r) + + for f in range(noise_data._freq.shape[0]): + self.axis_SNR[f].cla() + + val_min = np.min(noise_data._snr[:, f, :]) + val_max = np.max(noise_data._snr[:, f, :]) + if val_min == 0: + val_min = 1e-5 + if val_max > 1000: + levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + else: + levels = np.array([00.1, 1, 2, 10, 100, val_max]) + bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + norm = BoundaryNorm(boundaries=bounds, ncolors=300) + + cf = self.axis_SNR[f].contourf(x, y, + np.flipud(noise_data._snr[:, f, + np.where(np.round(noise_data._time_snr, + 2) == self.spinbox_tmin.value())[0][0]: + np.where(np.round(noise_data._time_snr, + 2) == self.spinbox_tmax.value())[0][0]]), + levels, cmap='gist_rainbow', norm=norm) # , shading='gouraud') + + self.axis_SNR[f].text(1, .70, noise_data._freq_text[f], + fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_SNR[f].transAxes) + + self.fig_SNR.supxlabel('Distance from left bank (m)', fontsize=10) + self.fig_SNR.supylabel('Depth (m)', fontsize=10) + # plt.subplots_adjust(bottom=0.125, top=0.98, right=1.03, left=0.08, hspace=0.1) + # self.fig.tight_layout() + # cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right') + # cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10) + # cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$']) + self.fig_SNR.canvas.draw_idle() + + + # self.ax[f].plot(self.model.r_bottom_cross_section, color='red', linewidth=2) + # + # def plot_snr_data(self): + # + # # self.canvas_snrdata = FigureCanvas(self.figure) + # + # frequency = self._model.Freq + # for f in range(len(frequency)): + # # self.axis = self.figure.add_subplot(4, 1, f+1) + # val_min = np.nanmin(self._model.snr[:, f, :]) + # val_max = np.nanmax(self._model.snr[:, f, :]) + # # val_min = np.nanmin(self.model.V_noise[:, f, :]) + # # val_max = np.nanmax(self.model.V_noise[:, f, :]) + # # if val_min == 0: + # # val_min = 0.5 + # if val_min == 0: + # val_min = 0.5 + # # self.axis[f].imshow(np.asarray(np.array(self.model.V_noise[:, f, :], dtype=float)), aspect='auto', + # # extent=[0, 2300, self.model.depth[-1][0], self.model.depth[0][0]], + # # cmap='hsv', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # # self.axis[f].pcolormesh(self.model.dist_BS_section, np.flipud(self.model.BS_raw_cross_section.r), + # # self.model.snr[:, f, :], + # # cmap='hsv', norm=LogNorm(vmin=val_min, vmax=val_max), shading='gouraud') + # + # x, y = np.meshgrid(self._model.dist_BS_section, self._model.BS_raw_cross_section.r) + # if val_max > 1000: + # levels = np.array([00.1, 1, 2, 10, 100, 1000, val_max]) + # else: + # levels = np.array([00.1, 1, 2, 10, 100, val_max]) + # bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + # norm = BoundaryNorm(boundaries=bounds, ncolors=300) + # pcm_snr = self.axis[f].contourf(x, y, np.flipud(self._model.snr[:, f, :]), levels, + # cmap='gist_rainbow', linewidths=None, norm=norm, + # extent=[self._model.dist_BS_section[0], self._model.dist_BS_section[-1], + # self._model.BS_raw_cross_section.r[-1], self._model.BS_raw_cross_section.r[0]]) + # + # self.axis[f].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[f].text(1, .70, self._model.freq_text[f], + # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # horizontalalignment='right', verticalalignment='bottom', transform=self.axis[f].transAxes) + # + # self.figure.supxlabel('Distance from left bank (m)', fontsize=10) + # self.figure.supylabel('Depth (m)', fontsize=10) + # # self.figure.tight_layout() + # cbar_snr = self.figure.colorbar(pcm_snr, ax=self.axis[:], shrink=1, location='right') + # cbar_snr.set_label(label='SNR', rotation=270) + # self.figure.canvas.draw_idle() + # + # diff --git a/View/acoustic_inversion_tab.py b/View/acoustic_inversion_tab.py new file mode 100644 index 0000000..e663060 --- /dev/null +++ b/View/acoustic_inversion_tab.py @@ -0,0 +1,142 @@ +import sys + +from PyQt5.QtWidgets import QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox +from PyQt5.QtCore import QCoreApplication + +import numpy as np +import matplotlib.pyplot as plt + +from matplotlib.colors import LogNorm, BoundaryNorm, CSS4_COLORS +from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas +from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar + + +import Translation.constant_string as cs + +_translate = QCoreApplication.translate + + +class AcousticInversionTab(QWidget): + + ''' This class generates the Acoustic Inversion Tab ''' + + def __init__(self, widget_tab): + super().__init__() + +# +# self.verticalLayout_acoustic_inversion_tab = QVBoxLayout(widget_tab) +# +# self.horizontalLayout_Top_acousticInversionTab = QHBoxLayout() +# +# self.groupbox_AcousticInversionOption = QGroupBox() +# # self.groupbox_AcousticInversionOption.setTitle("Acoustic inversion option") +# +# self.horizontalLayout_Top_acousticInversionTab.addWidget(self.groupbox_AcousticInversionOption) +# +# self.verticalLayout_acoustic_inversion_tab.addLayout(self.horizontalLayout_Top_acousticInversionTab, 4) +# +# self.horizontalLayout_Bottom_acousticInversionTab = QHBoxLayout() +# +# self.groupbox_sediment_concentration_2Dplot = QGroupBox() +# # self.groupbox_sediment_concentration_2Dplot.setTitle("Fine and sand sediment concentration") +# +# self.verticalLayout_groupbox_sediment_concentration_2Dplot = QVBoxLayout(self.groupbox_sediment_concentration_2Dplot) +# +# self.figure_SSC_2Dplot, self.axis_SSC_2Dplot = plt.subplots(nrows=2, ncols=1) +# self.canvas_sediments2DPlot = FigureCanvas(self.figure_SSC_2Dplot) +# self.toolbar_concentration_2Dplot = NavigationToolBar(self.canvas_sediments2DPlot, self) +# self.plot_SSC_fine() +# self.plot_SSC_sand() +# # self.verticalLayout_groupbox_sediment_concentration_2Dplot.addWidget(self.toolbar_concentration_2Dplot) +# self.verticalLayout_groupbox_sediment_concentration_2Dplot.addWidget(self.canvas_sediments2DPlot) +# +# # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.canvas_sediments2DPlot) +# self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.groupbox_sediment_concentration_2Dplot, 7) +# +# self.groupbox_sediment_concentration_sample_vs_measurement = QGroupBox() +# # self.groupbox_sediment_concentration_sample_vs_measurement.setTitle( +# # "Suspended sediment concentration plot : acoustic inversion theory VS measurements") +# +# self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement = QVBoxLayout( +# self.groupbox_sediment_concentration_sample_vs_measurement) +# +# self.figure_inverseSSC_vs_measuredSSC, self.axis_inverseSSC_vs_measuredSSC = plt.subplots(nrows=1, ncols=1) +# self.canvas_InverseSSC_vs_MeasuredSSC = FigureCanvas(self.figure_inverseSSC_vs_measuredSSC) +# self.toolbar_InverseSSC_vs_MeasuredSSC = NavigationToolBar(self.canvas_InverseSSC_vs_MeasuredSSC, self) +# # self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement.addWidget( +# # self.toolbar_InverseSSC_vs_MeasuredSSC) +# self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement.addWidget( +# self.canvas_InverseSSC_vs_MeasuredSSC, 3) +# # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.canvas_InverseSSC_vs_MeasuredSSC) +# +# self.horizontalLayout_Bottom_acousticInversionTab.addWidget( +# self.groupbox_sediment_concentration_sample_vs_measurement) +# +# self.verticalLayout_acoustic_inversion_tab.addLayout(self.horizontalLayout_Bottom_acousticInversionTab, 6) +# +# self.retranslate_acoustic_inversion_tab() +# +# # --------------------------------------------------------------------------------------------- +# # -------------------- Functions -------------------- +# # --------------------------------------------------------------------------------------------- +# +# def retranslate_acoustic_inversion_tab(self): +# +# self.groupbox_AcousticInversionOption.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_INVERSION_OPTIONS)) +# self.groupbox_sediment_concentration_2Dplot.setTitle(_translate("CONSTANT_STRING", cs.FINE_AND_SAND_SEDIMENTS_CONCENTRATION_2D_FIELD)) +# self.groupbox_sediment_concentration_sample_vs_measurement.setTitle(_translate("CONSTANT_STRING", cs.SUSPENDED_SEDIMENT_CONCENTRATION_PLOT)) +# +# def plot_SSC_fine(self): +# frequency = 0 +# val_min = 1e-2 #np.nanmin(self.model.SSC_fine[:, :]) # +# val_max = 15 #np.nanmax(self.model.SSC_fine[:, :]) # +# # print('val_min=', val_min) +# # print('val_max=', val_max) +# # if val_min == 0: +# # val_min = 0.5 +# # print('val_min update =', val_min) +# pcm_SSC_fine = self.axis_SSC_2Dplot[0].pcolormesh(self.model.dist_BS_section, np.flipud(self.model.BS_averaged_cross_section.r), +# self.model.SSC_fine[:, :], +# cmap='rainbow', norm=LogNorm(vmin=val_min, vmax=val_max), shading='gouraud') +# self.axis_SSC_2Dplot[0].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.figure_SSC_2Dplot.supxlabel("Distance from left bank (m)", fontsize=10) +# self.figure_SSC_2Dplot.supylabel("Depth (m)", fontsize=10) +# self.figure_SSC_2Dplot.tight_layout() +# +# cbar_SSC_fine = self.figure_SSC_2Dplot.colorbar(pcm_SSC_fine, ax=self.axis_SSC_2Dplot[0], shrink=1, location='right') +# cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15) +# +# def plot_SSC_sand(self): +# frequency = 0 +# val_min = 1e-2 #np.nanmin(self.model.SSC_fine[:, :]) # +# val_max = 2 #np.nanmax(self.model.SSC_fine[:, :]) # +# # print('val_min=', val_min) +# # print('val_max=', val_max) +# # if val_min == 0: +# # val_min = 0.5 +# # print('val_min update =', val_min) +# pcm_SSC_sand = self.axis_SSC_2Dplot[1].pcolormesh(self.model.dist_BS_section, np.flipud(self.model.BS_averaged_cross_section.r), +# self.model.SSC_sand[:, :], +# cmap='rainbow', norm=LogNorm(vmin=val_min, vmax=val_max), shading='gouraud') +# self.axis_SSC_2Dplot[1].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.figure_SSC_2Dplot.supxlabel("Distance from left bank (m)", fontsize=10) +# self.figure_SSC_2Dplot.supylabel("Depth (m)", fontsize=10) +# self.figure_SSC_2Dplot.tight_layout() +# +# cbar_SSC_sand = self.figure_SSC_2Dplot.colorbar(pcm_SSC_sand, ax=self.axis_SSC_2Dplot[1], shrink=1, location='right') +# cbar_SSC_sand.set_label(label='Sand SSC (g/L', rotation=270, labelpad=15) +# +# # if __name__ == "__main__": +# # app = QApplication(sys.argv) +# # print("class acoustic inversion tab :", AcousticInversionTab()) +# # sys.exit(app.exec_()) +# +# + + diff --git a/View/mainwindow.py b/View/mainwindow.py new file mode 100644 index 0000000..e91dc47 --- /dev/null +++ b/View/mainwindow.py @@ -0,0 +1,185 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'mainwindow.ui' +# +# Created by: PyQt5 UI code generator 5.15.6 +# +# WARNING: Any manual changes made to this file will be lost when pyuic5 is +# run again. Do not edit this file unless you know what you are doing. + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(898, 498) + MainWindow.setLocale(QtCore.QLocale(QtCore.QLocale.French, QtCore.QLocale.France)) + MainWindow.setDocumentMode(False) + MainWindow.setDockNestingEnabled(False) + MainWindow.setUnifiedTitleAndToolBarOnMac(False) + self.centralwidget = QtWidgets.QWidget(MainWindow) + self.centralwidget.setObjectName("centralwidget") + self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") + self.tabWidget = QtWidgets.QTabWidget(self.centralwidget) + self.tabWidget.setAutoFillBackground(False) + self.tabWidget.setLocale(QtCore.QLocale(QtCore.QLocale.French, QtCore.QLocale.France)) + self.tabWidget.setDocumentMode(True) + self.tabWidget.setTabsClosable(False) + self.tabWidget.setTabBarAutoHide(False) + self.tabWidget.setObjectName("tabWidget") + self.tab1 = QtWidgets.QWidget() + self.tab1.setObjectName("tab1") + self.tabWidget.addTab(self.tab1, "") + self.tab2 = QtWidgets.QWidget() + self.tab2.setObjectName("tab2") + self.tabWidget.addTab(self.tab2, "") + self.tab3 = QtWidgets.QWidget() + self.tab3.setObjectName("tab3") + self.tabWidget.addTab(self.tab3, "") + self.tab4 = QtWidgets.QWidget() + self.tab4.setObjectName("tab4") + self.tabWidget.addTab(self.tab4, "") + self.tab5 = QtWidgets.QWidget() + self.tab5.setObjectName("tab5") + self.tabWidget.addTab(self.tab5, "") + self.tab6 = QtWidgets.QWidget() + self.tab6.setObjectName("tab6") + self.tabWidget.addTab(self.tab6, "") + self.verticalLayout.addWidget(self.tabWidget) + MainWindow.setCentralWidget(self.centralwidget) + self.menubar = QtWidgets.QMenuBar(MainWindow) + self.menubar.setGeometry(QtCore.QRect(0, 0, 898, 22)) + self.menubar.setObjectName("menubar") + self.menuFile = QtWidgets.QMenu(self.menubar) + self.menuFile.setLocale(QtCore.QLocale(QtCore.QLocale.French, QtCore.QLocale.France)) + self.menuFile.setObjectName("menuFile") + self.menuSettings = QtWidgets.QMenu(self.menuFile) + self.menuSettings.setObjectName("menuSettings") + self.menuLanguage = QtWidgets.QMenu(self.menuSettings) + self.menuLanguage.setObjectName("menuLanguage") + self.menuTools = QtWidgets.QMenu(self.menubar) + self.menuTools.setLocale(QtCore.QLocale(QtCore.QLocale.French, QtCore.QLocale.France)) + self.menuTools.setObjectName("menuTools") + MainWindow.setMenuBar(self.menubar) + self.statusbar = QtWidgets.QStatusBar(MainWindow) + self.statusbar.setObjectName("statusbar") + MainWindow.setStatusBar(self.statusbar) + self.toolBar = QtWidgets.QToolBar(MainWindow) + self.toolBar.setObjectName("toolBar") + MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) + self.actionNew = QtWidgets.QAction(MainWindow) + + # Rajouter par moi + path = "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/" \ + "graphical_interface_for_SSC_acoustic_meas/icons/" + # Re verifier tout les icones QPixmap + + icon = QtGui.QIcon() + # icon.addPixmap(QtGui.QPixmap("../icons/new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(path + "new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionNew.setIcon(icon) + self.actionNew.setObjectName("actionNew") + self.actionOpen = QtWidgets.QAction(MainWindow) + icon1 = QtGui.QIcon() + # icon1.addPixmap(QtGui.QPixmap("../icons/icon_folder.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap(path + "icon_folder.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionOpen.setIcon(icon1) + self.actionOpen.setObjectName("actionOpen") + self.actionSave = QtWidgets.QAction(MainWindow) + icon2 = QtGui.QIcon() + # icon2.addPixmap(QtGui.QPixmap("../icons/save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon2.addPixmap(QtGui.QPixmap(path + "save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionSave.setIcon(icon2) + self.actionSave.setObjectName("actionSave") + self.actionCopy = QtWidgets.QAction(MainWindow) + icon3 = QtGui.QIcon() + # icon3.addPixmap(QtGui.QPixmap("../icons/copy.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon3.addPixmap(QtGui.QPixmap(path + "copy.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionCopy.setIcon(icon3) + self.actionCopy.setObjectName("actionCopy") + self.actionCut = QtWidgets.QAction(MainWindow) + icon4 = QtGui.QIcon() + # icon4.addPixmap(QtGui.QPixmap("../icons/cut.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon4.addPixmap(QtGui.QPixmap(path + "cut.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionCut.setIcon(icon4) + self.actionCut.setObjectName("actionCut") + self.actionPaste = QtWidgets.QAction(MainWindow) + icon5 = QtGui.QIcon() + # icon5.addPixmap(QtGui.QPixmap("../icons/paste.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon5.addPixmap(QtGui.QPixmap(path + "paste.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionPaste.setIcon(icon5) + self.actionPaste.setObjectName("actionPaste") + self.actionEnglish = QtWidgets.QAction(MainWindow) + icon6 = QtGui.QIcon() + # icon6.addPixmap(QtGui.QPixmap("../icons/en.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon6.addPixmap(QtGui.QPixmap(path + "en.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionEnglish.setIcon(icon6) + self.actionEnglish.setObjectName("actionEnglish") + self.actionFrench = QtWidgets.QAction(MainWindow) + icon7 = QtGui.QIcon() + # icon7.addPixmap(QtGui.QPixmap("../icons/fr.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon7.addPixmap(QtGui.QPixmap(path + "fr.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + self.actionFrench.setIcon(icon7) + self.actionFrench.setObjectName("actionFrench") + self.menuLanguage.addAction(self.actionEnglish) + self.menuLanguage.addAction(self.actionFrench) + self.menuSettings.addAction(self.menuLanguage.menuAction()) + self.menuFile.addAction(self.actionNew) + self.menuFile.addAction(self.actionOpen) + self.menuFile.addAction(self.actionSave) + self.menuFile.addAction(self.menuSettings.menuAction()) + self.menuTools.addAction(self.actionCopy) + self.menuTools.addAction(self.actionCut) + self.menuTools.addAction(self.actionPaste) + self.menubar.addAction(self.menuFile.menuAction()) + self.menubar.addAction(self.menuTools.menuAction()) + self.toolBar.addAction(self.actionNew) + self.toolBar.addAction(self.actionOpen) + self.toolBar.addAction(self.actionSave) + self.toolBar.addSeparator() + self.toolBar.addAction(self.actionCopy) + self.toolBar.addAction(self.actionCut) + self.toolBar.addAction(self.actionPaste) + self.toolBar.addSeparator() + self.toolBar.addAction(self.actionEnglish) + self.toolBar.addAction(self.actionFrench) + + self.retranslateUi(MainWindow) + self.tabWidget.setCurrentIndex(0) + QtCore.QMetaObject.connectSlotsByName(MainWindow) + + def retranslateUi(self, MainWindow): + _translate = QtCore.QCoreApplication.translate + MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab1), _translate("MainWindow", "Acoustic data")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab2), _translate("MainWindow", "Signal processing")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab3), _translate("MainWindow", "Sample data")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab4), _translate("MainWindow", "Acoustic inversion")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab5), _translate("MainWindow", "Note")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab6), _translate("MainWindow", "User manual")) + self.menuFile.setTitle(_translate("MainWindow", "File")) + self.menuSettings.setTitle(_translate("MainWindow", "Settings")) + self.menuLanguage.setTitle(_translate("MainWindow", "Language")) + self.menuTools.setTitle(_translate("MainWindow", "Tools")) + self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar")) + self.actionNew.setText(_translate("MainWindow", "New")) + self.actionOpen.setText(_translate("MainWindow", "Open")) + self.actionSave.setText(_translate("MainWindow", "Save")) + self.actionCopy.setText(_translate("MainWindow", "Copy")) + self.actionCut.setText(_translate("MainWindow", "Cut")) + self.actionPaste.setText(_translate("MainWindow", "Paste")) + self.actionEnglish.setText(_translate("MainWindow", "English")) + self.actionFrench.setText(_translate("MainWindow", "French")) + + +if __name__ == "__main__": + import sys + app = QtWidgets.QApplication(sys.argv) + MainWindow = QtWidgets.QMainWindow() + ui = Ui_MainWindow() + ui.setupUi(MainWindow) + MainWindow.show() + sys.exit(app.exec_()) diff --git a/View/note_tab.py b/View/note_tab.py new file mode 100644 index 0000000..244cf80 --- /dev/null +++ b/View/note_tab.py @@ -0,0 +1,190 @@ +import sys + +from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QHBoxLayout, QTextEdit, QPushButton, QSpacerItem, \ + QSpinBox, QSizePolicy, QFontComboBox, QColorDialog +from PyQt5.QtGui import QPixmap, QIcon, QFont +from PyQt5.QtCore import Qt + + +class NoteTab(QWidget): + + ''' This class generates a enhanced notepad in Note Tab ''' + + def __init__(self, widget_tab): + super().__init__() + + path_icon = "./icons/" + + self.verticalLayout_main_note_tab = QVBoxLayout(widget_tab) + + self.horizontalLayout_toolbar = QHBoxLayout() + self.verticalLayout_main_note_tab.addLayout(self.horizontalLayout_toolbar) + + self.textEdit = QTextEdit() + + self.filename_text = "" + + self.pushbutton_new_txt = QPushButton() + self.icon_new_txt = QPixmap(path_icon + "new_txt.png") + self.pushbutton_new_txt.setIcon(QIcon(self.icon_new_txt)) + # self.pushbutton_new_txt.clicked.connect(self.new_text) + self.horizontalLayout_toolbar.addWidget(self.pushbutton_new_txt) + + self.pushbutton_save_txt = QPushButton() + self.icon_save_txt = QPixmap(path_icon + "save_txt.png") + self.pushbutton_save_txt.setIcon(QIcon(self.icon_save_txt)) + # self.pushbutton_save_txt.clicked.connect(self.save_text) + self.horizontalLayout_toolbar.addWidget(self.pushbutton_save_txt) + + self.pushbutton_open_txt = QPushButton() + self.icon_open_txt = QPixmap(path_icon + "open_txt.png") + self.pushbutton_open_txt.setIcon(QIcon(self.icon_open_txt)) + # self.pushbutton_open_txt.clicked.connect(self.open_text) + self.horizontalLayout_toolbar.addWidget(self.pushbutton_open_txt) + + self.fontbox = QFontComboBox() + self.fontbox.currentFontChanged.connect(lambda font : self.textEdit.setCurrentFont(font)) + self.horizontalLayout_toolbar.addWidget(self.fontbox) + + self.fontSize = QSpinBox() + self.fontSize.setSuffix("pt") + self.fontSize.valueChanged.connect(lambda size: self.textEdit.setFontPointSize(size)) + self.fontSize.setValue(14) + self.horizontalLayout_toolbar.addWidget(self.fontSize) + + self.fontColor = QPushButton() + self.icon_fontColor = QPixmap(path_icon + "font_color.png") + self.fontColor.setIcon(QIcon(self.icon_fontColor)) + # self.QAction(QIcon("couleur_police.png"), "Changer la couleur du texte", self)couleur_fond.png + self.fontColor.clicked.connect(self.fontColorChanged) + self.horizontalLayout_toolbar.addWidget(self.fontColor) + + self.backColor = QPushButton() + self.icon_backColor = QPixmap(path_icon + "background_color.png") + self.backColor.setIcon(QIcon(self.icon_backColor)) + self.backColor.clicked.connect(self.highlight) + self.horizontalLayout_toolbar.addWidget(self.backColor) + + self.boldAction = QPushButton() + self.icon_boldAction = QPixmap(path_icon + "bold.png") + self.boldAction.setIcon(QIcon(self.icon_boldAction)) + self.boldAction.clicked.connect(self.bold) + self.horizontalLayout_toolbar.addWidget(self.boldAction) + + self.italicAction = QPushButton() + self.icon_italicAction = QPixmap(path_icon + "italic.png") + self.italicAction.setIcon(QIcon(self.icon_italicAction)) + self.italicAction.clicked.connect(self.italic) + self.horizontalLayout_toolbar.addWidget(self.italicAction) + + self.underlineAction = QPushButton() + self.icon_underlineAction = QPixmap(path_icon + "underline.png") + self.underlineAction.setIcon(QIcon(self.icon_underlineAction)) + self.underlineAction.clicked.connect(self.underline) + self.horizontalLayout_toolbar.addWidget(self.underlineAction) + + self.strikeAction = QPushButton() + self.icon_strikeAction = QPixmap(path_icon + "strike.png") + self.strikeAction.setIcon(QIcon(self.icon_strikeAction)) + self.strikeAction.clicked.connect(self.strike) + self.horizontalLayout_toolbar.addWidget(self.strikeAction) + + self.alignLeftAction = QPushButton() + self.icon_alignLeftAction = QPixmap(path_icon + "left.png") + self.alignLeftAction.setIcon(QIcon(self.icon_alignLeftAction)) + self.alignLeftAction.clicked.connect(self.alignLeft) + self.horizontalLayout_toolbar.addWidget(self.alignLeftAction) + + self.alignCenterAction = QPushButton() + self.icon_alignCenterAction = QPixmap(path_icon + "centre.png") + self.alignCenterAction.setIcon(QIcon(self.icon_alignCenterAction)) + self.alignCenterAction.clicked.connect(self.alignCenter) + self.horizontalLayout_toolbar.addWidget(self.alignCenterAction) + + self.alignRightAction = QPushButton() + self.icon_alignRightAction = QPixmap(path_icon + "right.png") + self.alignRightAction.setIcon(QIcon(self.icon_alignRightAction)) + self.alignRightAction.clicked.connect(self.alignRight) + self.horizontalLayout_toolbar.addWidget(self.alignRightAction) + + self.alignJustifyAction = QPushButton() + self.icon_alignJustifyAction = QPixmap(path_icon + "justify.png") + self.alignJustifyAction.setIcon(QIcon(self.icon_alignJustifyAction)) + self.alignJustifyAction.clicked.connect(self.alignJustify) + self.horizontalLayout_toolbar.addWidget(self.alignJustifyAction) + + self.horizontalSpacerItem_toolbar_note_tab = QSpacerItem(500, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalLayout_toolbar.addItem(self.horizontalSpacerItem_toolbar_note_tab) + + self.verticalLayout_main_note_tab.addWidget(self.textEdit) + + ## ------------------------------- + ## ---------- Functions ---------- + ## ------------------------------- + + + # def new_text(self): + # window = self.ui_mainwindow.tab5 + # window.show() + + # def open_text(self): + # self.filename_text = QFileDialog.getOpenFileName(self, 'Open File', ".", "(*.txt") + # if self.filename_text: + # with open(self.filename_text, 'txt') as file: + # self.text.setText(file.read()) + + # def save_text(self): + # if not self.filename_text: + # self.filename_text = QFileDialog.getSaveFileName(self, 'Save File') + # + # if not self.filename_text.endswith(".txt"): + # self.filename_text += ".txt" + # + # with open(self.filename_text, "txt") as file: + # file.write(self.text.toHtml()) + + def fontColorChanged(self): + color = QColorDialog.getColor() + self.textEdit.setTextColor(color) + + def highlight(self): + color = QColorDialog.getColor() + self.textEdit.setTextBackgroundColor(color) + + def bold(self): + if self.textEdit.fontWeight() == QFont.Bold: + self.textEdit.setFontWeight(QFont.Normal) + else: + self.textEdit.setFontWeight(QFont.Bold) + + def italic(self): + state = self.textEdit.fontItalic() + self.textEdit.setFontItalic(not state) + + def underline(self): + state = self.textEdit.fontUnderline() + self.textEdit.setFontUnderline(not state) + + def strike(self): + fmt = self.textEdit.currentCharFormat() + fmt.setFontStrikeOut(not fmt.fontStrikeOut()) + self.textEdit.setCurrentCharFormat(fmt) + + def alignLeft(self): + self.textEdit.setAlignment(Qt.AlignLeft) + + def alignRight(self): + self.textEdit.setAlignment(Qt.AlignRight) + + def alignCenter(self): + self.textEdit.setAlignment(Qt.AlignCenter) + + def alignJustify(self): + self.textEdit.setAlignment(Qt.AlignJustify) + + +# if __name__ == "__main__": +# app = QApplication(sys.argv) +# window = NoteTab() +# window.show() +# sys.exit(app.exec_()) diff --git a/View/sample_data_tab.py b/View/sample_data_tab.py new file mode 100644 index 0000000..aa4c73d --- /dev/null +++ b/View/sample_data_tab.py @@ -0,0 +1,842 @@ +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 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 + +from Model.granulo_loader import GranuloLoader + +from View.checkable_combobox import CheckableComboBox + +import Translation.constant_string as cs + +_translate = QCoreApplication.translate + + +class SampleDataTab(QWidget): + + # clicked_signal = pyqtSignal(str) + + def __init__(self, widget_tab): + super().__init__() + + ### --- 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 + + # 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) + + 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(240, 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) + + 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.groupbox_plot_sample_position = QGroupBox() + self.verticalLayout_groupbox_plot_sample_position = QVBoxLayout(self.groupbox_plot_sample_position) + + self.canvas_transect_sample_position = 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) + + self.verticalLayout_sampleposition_displayoption.addWidget(self.groupbox_plot_sample_position, 5) + + # +++++++++++++++++++++++++++++++++++++++ + # +++ --- GroupBox display option --- +++ + # +++++++++++++++++++++++++++++++++++++++ + + self.groupbox_display_option = QGroupBox() + self.verticalLayout_groupbox_display_option = QVBoxLayout(self.groupbox_display_option) + + # self.pushbutton_plot_transect = QPushButton() + # self.pushbutton_plot_transect.setText("Plot transect to visualise sample position") + # self.verticalLayout_groupbox_display_option.addWidget(self.pushbutton_plot_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)', '% fine', '% sand', '% fine, % sand']) + 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.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) + + 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.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_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) + + # 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) + # + self.verticalLayout_sampleposition_displayoption.addWidget(self.groupbox_display_option, 5) + + # -------------------------------------------------------------------------------------------------------------- + ### --- Layout of groupbox in the Bottom horizontal layout box + + # 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) + + 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)") + path_name = path.dirname(filename_fine_sediment[0]) + file_name = path.basename(filename_fine_sediment[0]) + self.lineEdit_fine_sediment.setText(file_name) + self.lineEdit_fine_sediment.setToolTip(path_name) + return filename_fine_sediment[0] + + # --- 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)") + path_name = path.dirname(filename_sand_sediment[0]) + file_name = path.basename(filename_sand_sediment[0]) + self.lineEdit_sand.setText(file_name) + self.lineEdit_sand.setToolTip(path_name) + return filename_sand_sediment[0] + + # ------------------------------------------------------------------------------------------------------------------ + # --- Function to fill table of values --- + def fill_table(self): + if self.lineEdit_fine_sediment.text(): + # print("push button", self.pushbutton_fill_table.isChecked()) + # print("self.lineEdit_fine_sediment.text() ", self.lineEdit_fine_sediment.toolTip() + "/" + self.lineEdit_fine_sediment.text()) + # print("self.lineEdit_sand.text() ", self.lineEdit_sand.toolTip() + "/" + 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())) + self.row = self.tableWidget_sample.setRowCount(granulo_data._data_fine.shape[0]) + self.col = self.tableWidget_sample.setColumnCount(2*granulo_data._data_fine.shape[1]) + + # --- Set horizontal header --- + horizontal_header = list(map(str, ["Color", "Sample"] + granulo_data._data_fine.columns.values.tolist() + + granulo_data._data_sand.columns.values.tolist()[2:])) + # print(len(horizontal_header)) + 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.connect(self.update_plots_from_table_checkboxes)") + + # --- 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)) + # print(f"S{i+1} ", self.tableWidget_sample.item(i, 1).checkState()) + + # --- Fill table with data --- + for i in range(granulo_data._frac_vol_fine.shape[0]): + for j in range(granulo_data._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(granulo_data._y[i]))) + self.tableWidget_sample.setItem(i, 3, QTableWidgetItem(str(granulo_data._z[i]))) + + self.tableWidget_sample.setItem(i, 4, QTableWidgetItem(str(granulo_data._Ctot_fine[i]))) + self.tableWidget_sample.setItem(i, 5, QTableWidgetItem(str(granulo_data._D50_fine[i]))) + self.tableWidget_sample.setItem(i, j + 6, QTableWidgetItem(str(granulo_data._frac_vol_fine[i, j]))) + + self.tableWidget_sample.setItem(i, granulo_data._frac_vol_fine.shape[1] + 6, QTableWidgetItem(str(granulo_data._Ctot_sand[i]))) + self.tableWidget_sample.setItem(i, granulo_data._frac_vol_fine.shape[1] + 7, QTableWidgetItem(str(granulo_data._D50_sand[i]))) + self.tableWidget_sample.setItem(i, granulo_data._frac_vol_fine.shape[1] + 8 + j, QTableWidgetItem(str(granulo_data._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) + + 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 + + # 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 --- + def export_table(self): + if self.tableWidget_sample.columnCount() > 10: + print("Export table") + 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 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 + + # 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 update_plot_transect_bottom_with_sample_position(self, position_value, color_list): + # 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.cla() + # self.plot_transect_bottom_with_sample_position() + # 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) + # # marker_color = ["orange", "green"] + # # for i in range(len(marker_color)): + # self.axis_sampleposition.scatter(self.model._fine_sediment_file.iloc[position_value]["y"], + # np.max(self.model.r_bottom_cross_section) - self.model._fine_sediment_file.iloc[position_value]["z"] + # + np.min(self.model.r_bottom_cross_section), + # linestyle='None', marker="o", s=14, c=color_list) + # # markerfacecolor=["orange", "green"], markeredgecolor=["orange", "green"]) + # # self.axis_sampleposition.set_axis_off() + # self.axis_sampleposition.set_xticks([]) + # self.axis_sampleposition.set_yticks([]) + # self.figure_sampleposition.canvas.draw_idle() + # # self.figure_sampleposition.tight_layout() + + # ------------------------------------------------------------------------------------------------------------------ + # --- 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, 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() + + # ------------------------------------------------------------------------------------------------------------------ + + 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 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() + 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(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.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, :], + 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_class() + self.empty_field_for_plot_sand_PSD_class() + elif self.pushbutton_cumulative_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_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() + 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() + + 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() + + + diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py new file mode 100644 index 0000000..cf546ff --- /dev/null +++ b/View/signal_processing_tab.py @@ -0,0 +1,783 @@ +import sys + +from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox, QLabel, QCheckBox, \ + QSpinBox, QDoubleSpinBox, QComboBox, QLineEdit, QSlider +from PyQt5.QtGui import QFont, QIcon, QPixmap +from PyQt5.QtCore import Qt, QCoreApplication + +import numpy as np + +import matplotlib.pyplot as plt +from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas +from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar +from matplotlib.colors import LogNorm + +import Translation.constant_string as cs + +_translate = QCoreApplication.translate + + +class SignalProcessingTab(QWidget): + + ''' This class generates the Signal Processing Tab ''' + + def __init__(self, widget_tab): + super().__init__() + + path_icon = "./icons/" + + ### --- General layout of widgets --- + + # ___________ ____________________________ + # | profile | | Profile | + # | position | | | + # | | | | + # | | | Averaged profile | + # | post | | | + # | proc | | | + # | options | | FCB option | + # |___________| |____________________________| + + self.horizontalLayout_SignalProceesingTab = QHBoxLayout(widget_tab) + + self.verticalLayout_Left_SignalProcessingTab = QVBoxLayout() + self.horizontalLayout_SignalProceesingTab.addLayout(self.verticalLayout_Left_SignalProcessingTab, 2) + + self.verticalLayout_Right_SignalProcessingTab = QVBoxLayout() + self.horizontalLayout_SignalProceesingTab.addLayout(self.verticalLayout_Right_SignalProcessingTab, 8) + + # # -------------------------------------------------------------------------------------------------------------- + # ### --- Layout of groupbox in the Left vertical layout box + # + # # Profile position + # # -------------------- + # # Post processing + # # -------------------- + # # FCB options + # + # self.pushbutton_Load_data_from_acoustic_data_tab = QPushButton() + # + # self.verticalLayout_Left_SignalProcessingTab.addWidget(self.pushbutton_Load_data_from_acoustic_data_tab) + # + # self.groupbox_display_profile_position = QGroupBox() + # self.verticalLayout_groupbox_display_profile_position = QVBoxLayout(self.groupbox_display_profile_position) + # + # self.label_profile_number = QLabel() + # self.label_profile_number.setFont(QFont("Ubuntu", 16, QFont.Bold)) + # self.label_profile_number.setAlignment(Qt.AlignCenter) + # self.string_profile_number = 1 + # self.string_profile_number_max = 2300 + # self.verticalLayout_groupbox_display_profile_position.addWidget(self.label_profile_number) + # + # self.figure_plot_profile_position_on_transect, self.axis_plot_profile_position_on_transect = \ + # plt.subplots(nrows=1, ncols=1, layout="constrained") + # self.canvas_plot_profile_position_on_transect = FigureCanvas(self.figure_plot_profile_position_on_transect) + # self.plot_transect_bottom_with_profile_position(0) + # + # # self.axis_plot_profile_position_on_transect.plot( + # # 0 * np.ones(self.model.r_bottom_cross_section.shape[0]), + # # self.model.r_bottom_cross_section, color='red', linestyle="solid", linewidth=2) + # + # self.verticalLayout_groupbox_display_profile_position.addWidget(self.canvas_plot_profile_position_on_transect) + # + # self.horizontalLayout_slider_plot_profile_position = QHBoxLayout() + # self.verticalLayout_groupbox_display_profile_position.addLayout( + # self.horizontalLayout_slider_plot_profile_position) + # + # # self.icon_triangle_left = QPixmap(path_icon + "triangle_left.png") + # # self.pushButton_slider_plot_profile_position_left = QPushButton() + # # self.pushButton_slider_plot_profile_position_left.setIcon(QIcon(self.icon_triangle_left)) + # # self.icon_triangle_right = QPixmap(path_icon + "triangle_right.png") + # # self.pushButton_slider_plot_profile_position_right = QPushButton() + # # self.pushButton_slider_plot_profile_position_right.setIcon(QIcon(self.icon_triangle_right)) + # # + # # self.horizontalLayout_slider_plot_profile_position.addWidget(self.pushButton_slider_plot_profile_position_left) + # # self.horizontalLayout_slider_plot_profile_position.addWidget(self.pushButton_slider_plot_profile_position_right) + # # + # # self.lineEdit_slider_plot_profile_position = QLineEdit() + # # self.horizontalLayout_slider_plot_profile_position.addWidget(self.lineEdit_slider_plot_profile_position) + # # + # # self.slider_plot_profile_position = QSlider() + # # self.slider_plot_profile_position.setOrientation(Qt.Horizontal) + # # self.slider_plot_profile_position.setTickPosition(QSlider.TicksBelow) + # # self.slider_plot_profile_position.setCursor(Qt.OpenHandCursor) + # # self.slider_plot_profile_position.setMinimum(0) + # # self.slider_plot_profile_position.setMaximum(1) + # # self.slider_plot_profile_position.setTickInterval(1) + # # self.slider_plot_profile_position.setValue(0) + # # self.horizontalLayout_slider_plot_profile_position.addWidget(self.slider_plot_profile_position) + # + # # self.horizontalLayoutTop_signalProcessing.addWidget(self.groupbox_display_profile_position, 3) + # self.verticalLayout_left_SignalProcessingTab.addWidget(self.groupbox_display_profile_position) + # + # # self.checkbox_substract_noise = QCheckBox() + # # self.checkbox_substract_noise.setText("Substract the noise") + # # self.verticalLayout_averaged_profile = QVBoxLayout(self.checkbox_substract_noise) + # # self.pushbutton_averaged_profile = QPushButton() + # # self.pushbutton_averaged_profile.setText("Plot averaged profile") + # + # # self.verticalLayout_groupbox_plotacousticprofile.addWidget(self.checkbox_substract_noise) + # + # # self.groupbox_SNR_criterion = QGroupBox() + # # self.groupbox_SNR_criterion.setTitle("SNR criterion") + # # self.verticalLayout_SNR_criterion = QVBoxLayout(self.groupbox_SNR_criterion) + # # self.horizontalLayout_SNR_criterion = QHBoxLayout() + # # self.label_SNR_crterion = QLabel() + # # self.label_SNR_crterion.setText("Remove point if SNR <") + # # self.horizontalLayout_SNR_criterion.addWidget(self.label_SNR_crterion) + # # self.lineEdit_SNR_criterion = QLineEdit() + # # self.horizontalLayout_SNR_criterion.addWidget(self.lineEdit_SNR_criterion) + # # self.verticalLayout_SNR_criterion.addLayout(self.horizontalLayout_SNR_criterion) + # # self.pushbutton_SNR_criterion = QPushButton() + # # self.pushbutton_SNR_criterion.setText("Remove points on profile") + # # self.verticalLayout_SNR_criterion.addWidget(self.pushbutton_SNR_criterion) + # # self.verticalLayout_groupbox_plotacousticprofile.addWidget(self.groupbox_SNR_criterion) + # + # # self.horizontalLayoutTop_signalProcessing.addWidget(self.groupbox_profile, 3) + # + # # self.horizontalLayoutMid_signalProcessing = QHBoxLayout() + # # self.verticalLayout_signalProcessingTab.addLayout(self.horizontalLayoutMid_signalProcessing, 3) + # + # self.groupbox_post_processing = QGroupBox() + # # self.groupbox_post_processing.setTitle("Post processing") + # + # self.verticalLayout_groupbox_post_processing = QVBoxLayout(self.groupbox_post_processing) + # + # self.groupbox_acoustic_profile = QGroupBox() + # # self.groupbox_acoustic_profile.setTitle("Acoustic profile") + # + # # self.gridLayout_groupbox_acoustic_profile = QGridLayout(self.groupbox_acoustic_profile) + # self.horizontalLayout_acoustic_profile = QHBoxLayout(self.groupbox_acoustic_profile) + # # self.label_subtract_noise = QLabel() + # # self.label_subtract_noise.setText("Subtract the noise") + # self.checkbox_substract_noise = QCheckBox() + # self.checkbox_substract_noise.setChecked(False) + # # self.checkbox_substract_noise.setText("Subtract the noise") + # self.checkbox_substract_noise.setToolTip("Enable for further computation") + # self.horizontalLayout_acoustic_profile.addWidget(self.checkbox_substract_noise) + # # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_substract_noise, 0, 0, 1, 1) + # # self.checkbox_subtract_noise_enable = QCheckBox() + # # self.checkbox_subtract_noise_enable.setChecked(False) + # # self.checkbox_subtract_noise_enable.setText("Enable") + # # self.horizontalLayout_label_subtract_noise.addWidget(self.checkbox_subtract_noise_enable) + # # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_subtract_noise_enable, 0, 1, 1, 1) + # # self.checkbox_subtract_noise_disable = QCheckBox() + # # self.checkbox_subtract_noise_disable.setChecked(True) + # # self.checkbox_subtract_noise_disable.setText("Disable") + # # self.checkbox_subtract_noise_add_noisy_profile = QCheckBox() + # # self.checkbox_subtract_noise_add_noisy_profile.setText("Add noisy profile") + # # self.horizontalLayout_label_subtract_noise.addWidget(self.checkbox_subtract_noise_disable) + # # self.verticalLayout_post_processing.addLayout(self.horizontalLayout_label_subtract_noise) + # # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_subtract_noise_add_noisy_profile, 0, 2, 1, 1) + # # self.horizontalLayout_SNR_criterion = QHBoxLayout() + # # self.formLayout_SNR_criterion = QFormLayout() + # # self.formLayout_SNR_criterion.set + # # self.label_SNR_criterion = QLabel() + # # self.label_SNR_criterion.setText("SNR criterion") + # self.checkbox_SNR_criterion = QCheckBox() + # self.checkbox_SNR_criterion.setChecked(False) + # # self.checkbox_SNR_criterion.setText("SNR criterion") + # self.checkbox_SNR_criterion.setToolTip("Enable for further computation") + # self.horizontalLayout_acoustic_profile.addWidget(self.checkbox_SNR_criterion) + # # self.gridLayout_groupbox_acoustic_profile.addWidget(self.label_SNR_criterion, 1, 0, 1, 1) + # # self.lineEdit_SNR_criterion = QLineEdit() + # # self.lineEdit_SNR_criterion.setEnabled(True) + # # self.lineEdit_SNR_criterion.setText("10") + # self.spinbox_SNR_criterion = QSpinBox() + # self.spinbox_SNR_criterion.setRange(0, 9999) + # self.spinbox_SNR_criterion.setValue(10) + # # self.lineEdit_SNR_criterion.setFixedWidth(5) + # self.horizontalLayout_acoustic_profile.addWidget(self.spinbox_SNR_criterion) + # # self.gridLayout_groupbox_acoustic_profile.addWidget(self.lineEdit_SNR_criterion, 1, 1, 1, 1) + # # self.checkbox_SNR_criterion_enable = QCheckBox() + # # self.checkbox_SNR_criterion_enable.setChecked(False) + # # self.checkbox_SNR_criterion_enable.setText("Enable") + # # self.horizontalLayout_SNR_criterion.addWidget(self.checkbox_SNR_criterion_enable) + # # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_SNR_criterion_enable, 1, 2, 1, 1) + # # self.checkbox_SNR_criterion_disable = QCheckBox() + # # self.checkbox_SNR_criterion_disable.setChecked(True) + # # self.checkbox_SNR_criterion_disable.setText("Disable") + # # self.horizontalLayout_SNR_criterion.addWidget(self.checkbox_SNR_criterion_disable) + # # self.verticalLayout_post_processing.addLayout(self.horizontalLayout_SNR_criterion) + # # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_SNR_criterion_disable, 1, 3, 1, 1) + # + # self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_acoustic_profile) + # + # # self.horizontalLayout_averaged_profile_despiking_signal = QHBoxLayout() + # # self.verticalLayout_groupbox_post_processing.addLayout(self.horizontalLayout_averaged_profile_despiking_signal) + # + # self.groupbox_window_size = QGroupBox() + # # self.groupbox_window_size.setTitle("Window size") + # + # # self.gridLayout_groupbox_window_size = QGridLayout(self.groupbox_window_size) + # self.verticalLayout_windowsize = QVBoxLayout(self.groupbox_window_size) + # + # # self.groupbox_averageprofile_despikingsignal = QGroupBox() + # # self.groupbox_averageprofile_despikingsignal.setTitle("Averaged profiles && Despiking the signal") + # # self.verticalLayout_groupbox_averageprofile_despikingsignal = QVBoxLayout(self.groupbox_averageprofile_despikingsignal) + # + # # self.groupbox_plot_averaged_profile = QGroupBox() + # # self.groupbox_plot_averaged_profile.setTitle("Window size") + # # self.verticalLayout_plot_averaged_profile = QVBoxLayout(self.groupbox_plot_averaged_profile) + # + # self.horizontalLayout_horizontal_average = QHBoxLayout() + # self.verticalLayout_windowsize.addLayout(self.horizontalLayout_horizontal_average) + # # self.label_nb_horizontal_cells = QLabel() + # # self.label_nb_horizontal_cells.setText("Horizontal: +/-") + # self.checkbox_nb_horizontal_cells = QCheckBox() + # self.checkbox_nb_horizontal_cells.setChecked(False) + # # self.checkbox_nb_horizontal_cells.setText("Horizontal: +/-") + # self.checkbox_nb_horizontal_cells.setToolTip("Enable for further computation") + # self.horizontalLayout_horizontal_average.addWidget(self.checkbox_nb_horizontal_cells) + # # self.gridLayout_groupbox_window_size.addWidget(self.label_nb_horizontal_cells, 0, 0, 1, 1) + # # self.lineEdit_nb_horizontal_cells = QLineEdit() + # # self.lineEdit_nb_horizontal_cells.setText("1") + # self.spinbox_nb_horizontal_cells = QSpinBox() + # self.spinbox_nb_horizontal_cells.setRange(0, 9999) + # self.spinbox_nb_horizontal_cells.setValue(0) + # self.horizontalLayout_horizontal_average.addWidget(self.spinbox_nb_horizontal_cells) + # # self.gridLayout_groupbox_window_size.addWidget(self.lineEdit_nb_horizontal_cells, 0, 1, 1, 1) + # self.label_nb_horizontal_cells_cm = QLabel() + # # self.label_nb_horizontal_cells_cm.setText("cells = +/- ? cm") + # self.horizontalLayout_horizontal_average.addWidget(self.label_nb_horizontal_cells_cm) + # # self.verticalLayout_plot_averaged_profile.addLayout(self.horizontalLayout_horizontal_average) + # # self.gridLayout_groupbox_window_size.addWidget(self.label_nb_horizontal_cells_cm, 0, 2, 1, 1) + # # self.checkbox_nb_horizontal_cell_enable = QCheckBox() + # # self.checkbox_nb_horizontal_cell_enable.setText("Enable") + # # self.gridLayout_groupbox_window_size.addWidget(self.checkbox_nb_horizontal_cell_enable, 0, 3, 1, 1) + # # self.checkbox_nb_horizontal_cell_add_raw_profile = QCheckBox() + # # self.checkbox_nb_horizontal_cell_add_raw_profile.setText("Add raw profile") + # # self.gridLayout_groupbox_window_size.addWidget(self.checkbox_nb_horizontal_cell_add_raw_profile, 0, 4, 1, 1) + # + # self.horizontalLayout_vertical_average = QHBoxLayout() + # self.verticalLayout_windowsize.addLayout(self.horizontalLayout_vertical_average) + # # self.label_nb_vertical_cells = QLabel() + # # self.label_nb_vertical_cells.setText("Vertical: +/-") + # self.checkbox_nb_vertical_cells = QCheckBox() + # self.checkbox_nb_vertical_cells.setChecked(False) + # # self.checkbox_nb_vertical_cells.setText("Vertical: +/-") + # self.checkbox_nb_vertical_cells.setToolTip("Enable for further computation") + # self.horizontalLayout_vertical_average.addWidget(self.checkbox_nb_vertical_cells) + # # self.horizontalLayout_vertical_average.addWidget(self.label_nb_vertical_cells) + # # self.gridLayout_groupbox_window_size.addWidget(self.label_nb_vertical_cells, 1, 0, 1, 1) + # # self.lineEdit_nb_vertical_cells = QLineEdit() + # # self.lineEdit_nb_vertical_cells.setText("1") + # self.spinbox_nb_vertical_cells = QSpinBox() + # self.spinbox_nb_vertical_cells.setRange(0, 9999) + # self.spinbox_nb_vertical_cells.setValue(0) + # self.horizontalLayout_vertical_average.addWidget(self.spinbox_nb_vertical_cells) + # # self.horizontalLayout_vertical_average.addWidget(self.lineEdit_nb_vertical_cells) + # # self.gridLayout_groupbox_window_size.addWidget(self.lineEdit_nb_vertical_cells, 1, 1, 1, 1) + # self.label_nb_vertical_cells_cm = QLabel() + # # self.label_nb_vertical_cells_cm.setText("cells = +/- ? cm") + # self.horizontalLayout_vertical_average.addWidget(self.label_nb_vertical_cells_cm) + # # self.verticalLayout_plot_averaged_profile.addLayout(self.horizontalLayout_vertical_average) + # # self.gridLayout_groupbox_window_size.addWidget(self.label_nb_vertical_cells_cm, 1, 2, 1, 1) + # # self.checkbox_nb_vertical_cells_enable = QCheckBox() + # # self.checkbox_nb_vertical_cells_enable.setText("Enable") + # # self.gridLayout_groupbox_window_size.addWidget(self.checkbox_nb_vertical_cells_enable, 1, 3, 1, 1) + # # self.checkbox_nb_vertical_cells_add_raw_profile = QCheckBox() + # # self.checkbox_nb_vertical_cells_add_raw_profile.setText("Add raw profile") + # # self.gridLayout_groupbox_window_size.addWidget(self.checkbox_nb_vertical_cells_add_raw_profile, 1, 4, 1, 1) + # + # # self.pushbutton_plot_averaged_profile = QPushButton() + # # self.pushbutton_plot_averaged_profile.setText("Plot averaged profiles") + # # self.verticalLayout_plot_averaged_profile.addWidget(self.pushbutton_plot_averaged_profile) + # # + # # self.verticalLayout_groupbox_averageprofile_despikingsignal.addWidget(self.groupbox_plot_averaged_profile) + # + # # self.horizontalLayout_averaged_profile_despiking_signal.addWidget(self.groupbox_window_size) + # + # self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_window_size) + # + # self.groupbox_rayleigh_criterion = QGroupBox() + # # self.groupbox_rayleigh_criterion.setTitle("Rayleigh criterion") + # # self.groupbox_despiking_signal = QGroupBox() + # # self.groupbox_despiking_signal.setTitle("Despiking the signal") + # # self.verticalLayout_despiking_signal = QVBoxLayout(self.groupbox_despiking_signal) + # # self.horizontalLayout_despiking_signal_label = QHBoxLayout() + # + # # self.gridLayout_rayleigh_criterion = QGridLayout(self.groupbox_rayleigh_criterion) + # self.horizontalLayout_rayleigh_criterion = QHBoxLayout(self.groupbox_rayleigh_criterion) + # + # self.label_Rayleigh_criterion = QLabel() + # self.label_Rayleigh_criterion.setText("/² <=") + # # self.horizontalLayout_despiking_signal_label.addWidget(self.label_Rayleigh_criterion) + # # self.gridLayout_rayleigh_criterion.addWidget(self.label_Rayleigh_criterion, 0, 0, 1, 1) + # self.horizontalLayout_rayleigh_criterion.addWidget(self.label_Rayleigh_criterion) + # # self.lineEdit_despiking_signal_label = QLineEdit() + # # self.lineEdit_despiking_signal_label.setText("10") + # self.spinbox_rayleigh_criterion = QSpinBox() + # self.spinbox_rayleigh_criterion.setRange(0, 9999) + # self.spinbox_rayleigh_criterion.setValue(10) + # # self.horizontalLayout_despiking_signal_label.addWidget(self.lineEdit_despiking_signal_label) + # # self.gridLayout_rayleigh_criterion.addWidget(self.lineEdit_despiking_signal_label, 0, 1, 1, 1) + # self.horizontalLayout_rayleigh_criterion.addWidget(self.spinbox_rayleigh_criterion) + # self.label_4pi = QLabel() + # self.label_4pi.setText("% x 4/pi") + # # self.horizontalLayout_despiking_signal_label.addWidget(self.label_4pi) + # # self.gridLayout_rayleigh_criterion.addWidget(self.label_4pi, 0, 2, 1, 1) + # self.horizontalLayout_rayleigh_criterion.addWidget(self.label_4pi) + # # self.verticalLayout_despiking_signal.addLayout(self.horizontalLayout_despiking_signal_label) + # # self.pushbutton_despiking_signal = QPushButton() + # # self.pushbutton_despiking_signal.setText("Despiking the signal") + # # self.verticalLayout_despiking_signal.addWidget(self.pushbutton_despiking_signal) + # self.checkbox_despiked_acoustic_signal = QCheckBox() + # # self.checkbox_despiked_acoustic_signal.setText("Despiking") + # self.checkbox_despiked_acoustic_signal.setToolTip("Enable for further computation") + # # self.gridLayout_rayleigh_criterion.addWidget(self.checkbox_rayleigh_criterion_enable, 0, 3, 1, 1) + # self.horizontalLayout_rayleigh_criterion.addWidget(self.checkbox_despiked_acoustic_signal) + # # self.horizontalLayout_averaged_profile_despiking_signal.addWidget(self.groupbox_rayleigh_criterion) + # + # # self.verticalLayout_groupbox_averageprofile_despikingsignal.addWidget(self.groupbox_despiking_signal) + # + # self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_rayleigh_criterion) + # + # # self.horizontalLayoutMid_signalProcessing.addWidget(self.groupbox_post_processing, 3) + # self.verticalLayout_left_SignalProcessingTab.addWidget(self.groupbox_post_processing) + # + # # self.horizontalLayoutBottom_signalProcessing = QHBoxLayout() + # # self.verticalLayout_signalProcessingTab.addLayout(self.horizontalLayoutBottom_signalProcessing, 3) + # + # # --- GroupBox FCB options --- + # + # self.groupbox_FCBoption = QGroupBox() + # # self.groupbox_FCBoption.setTitle("FCB options") + # # self.horizontalLayoutBottom_signalProcessing.addWidget(self.groupbox_FCBoption, 3) + # self.verticalLayout_left_SignalProcessingTab.addWidget(self.groupbox_FCBoption) + # + # self.verticalLayout_groupbox_FCBoption = QVBoxLayout(self.groupbox_FCBoption) + # + # self.groupbox_water_attenuation = QGroupBox() + # # self.groupbox_water_attenuation.setTitle("Computing water attenuation") + # self.verticalLayout_groupbox_water_attenuation = QVBoxLayout(self.groupbox_water_attenuation) + # self.horizontalLayout_waterAttenuationModel_temperature = QHBoxLayout() + # self.verticalLayout_groupbox_water_attenuation.addLayout( + # self.horizontalLayout_waterAttenuationModel_temperature) + # + # self.combobox_water_attenuation_model = QComboBox() + # self.combobox_water_attenuation_model.addItem("François & Garrison 1982") + # self.combobox_water_attenuation_model.addItem("Other model") + # self.horizontalLayout_waterAttenuationModel_temperature.addWidget(self.combobox_water_attenuation_model) + # + # self.label_temperature_water_attenation = QLabel() + # # self.label_temperature_water_attenation.setText("Temperature:") + # self.horizontalLayout_waterAttenuationModel_temperature.addWidget(self.label_temperature_water_attenation) + # + # # self.lineEdit_temperature_water_attenuation = QLineEdit() + # self.spinbox_temperature_water_attenuation = QSpinBox() + # self.horizontalLayout_waterAttenuationModel_temperature.addWidget(self.spinbox_temperature_water_attenuation) + # + # self.label_degre_celsius = QLabel() + # self.label_degre_celsius.setText("°C") + # self.horizontalLayout_waterAttenuationModel_temperature.addWidget(self.label_degre_celsius) + # + # self.horizontalLayout_comboboxFrequencies_WaterAttenuationValue = QHBoxLayout() + # self.verticalLayout_groupbox_water_attenuation.addLayout( + # self.horizontalLayout_comboboxFrequencies_WaterAttenuationValue) + # + # self.combobox_water_attenuation = QComboBox() + # self.combobox_water_attenuation.addItem('0.3 MHz') + # self.combobox_water_attenuation.addItem('0.5 MHz') + # self.combobox_water_attenuation.addItem('1 MHz') + # self.combobox_water_attenuation.addItem('5 MHz') + # # self.combobox_water_attenuation.currentIndexChanged.connect(self.alpha_value_changed) + # + # self.horizontalLayout_comboboxFrequencies_WaterAttenuationValue.addWidget(self.combobox_water_attenuation) + # + # self.label_water_attenuation = QLabel() + # self.label_water_attenuation.setText("\u03B1w = 0.02 dB/m") + # self.label_water_attenuation.setFont(QFont("Ubuntu", 14, QFont.Normal)) + # self.horizontalLayout_comboboxFrequencies_WaterAttenuationValue.addWidget(self.label_water_attenuation) + # + # self.verticalLayout_groupbox_FCBoption.addWidget(self.groupbox_water_attenuation) + # + # self.groupbox_fit_regression_line = QGroupBox() + # # self.groupbox_fit_regression_line.setTitle("Fit regression line") + # self.verticalLayout_groupbox_fit_regression = QVBoxLayout(self.groupbox_fit_regression_line) + # + # self.label_alphaS_expression = QLabel() + # # self.label_alphaS_expression.setText("For homogeneous suspension: dFCB/dr = -2\u03B1s<\sub>") + # self.verticalLayout_groupbox_fit_regression.addWidget(self.label_alphaS_expression) + # + # self.horizontalLayout_alphaS_computation = QHBoxLayout() + # self.verticalLayout_groupbox_fit_regression.addLayout(self.horizontalLayout_alphaS_computation) + # + # self.combobox_frequency_compute_alphaS = QComboBox() + # self.combobox_frequency_compute_alphaS.addItem("0.3 MHz") + # self.combobox_frequency_compute_alphaS.addItem("0.5 MHz") + # self.combobox_frequency_compute_alphaS.addItem("1 MHz") + # self.combobox_frequency_compute_alphaS.addItem("5 MHz") + # self.combobox_frequency_compute_alphaS.addItem("All frequencies") + # self.horizontalLayout_alphaS_computation.addWidget(self.combobox_frequency_compute_alphaS) + # + # self.label_alphaS_computation_from = QLabel() + # # self.label_alphaS_computation_from.setText("From") + # self.horizontalLayout_alphaS_computation.addWidget(self.label_alphaS_computation_from) + # + # # self.lineEdit_alphaS_computation_from = QLineEdit() + # self.spinbox_alphaS_computation_from = QDoubleSpinBox() + # self.spinbox_alphaS_computation_from.setRange(0, 9999) + # self.horizontalLayout_alphaS_computation.addWidget(self.spinbox_alphaS_computation_from) + # + # self.label_alphaS_computation_to = QLabel() + # # self.label_alphaS_computation_to.setText("to") + # self.horizontalLayout_alphaS_computation.addWidget(self.label_alphaS_computation_to) + # + # # self.lineEdit_alphaS_computation_to = QLineEdit() + # self.spinbox_alphaS_computation_to = QDoubleSpinBox() + # self.horizontalLayout_alphaS_computation.addWidget(self.spinbox_alphaS_computation_to) + # + # self.horizontalLayout_fitButton_alphaWvalue = QHBoxLayout() + # self.verticalLayout_groupbox_fit_regression.addLayout(self.horizontalLayout_fitButton_alphaWvalue) + # + # self.pushbutton_fit_regression_line = QPushButton() + # self.pushbutton_fit_regression_line.setText("Fit && Compute \u03B1s") + # self.horizontalLayout_fitButton_alphaWvalue.addWidget(self.pushbutton_fit_regression_line) + # + # self.label_alphaS = QLabel() + # self.label_alphaS.setText("\u03B1s = " + "0.0" + "dB/m") + # self.label_alphaS.setFont(QFont("Ubuntu", 14, QFont.Normal)) + # self.horizontalLayout_fitButton_alphaWvalue.addWidget(self.label_alphaS) + # + # self.verticalLayout_groupbox_FCBoption.addWidget(self.groupbox_fit_regression_line) + # + # # self.verticalLayout_groupbox_fit_regression + # + # ### ---------- Plot Profile ---------- + # + # # self.data_test_slider = np.array([[0, 1, 2, 3, 4, 5], + # # [0, 1, 4, 9, 16, 25], + # # [0, 1, 8, 27, 64, 125]]) + # + # self.groupbox_plot_profile = QGroupBox() + # # self.groupbox_plot_profile.setTitle("Profile") + # + # self.verticalLayout_plotprofiles = QVBoxLayout(self.groupbox_plot_profile) + # self.figure_profile, self.axis_profile = plt.subplots(nrows=1, ncols=4, layout='constrained') + # self.canvas_profile = FigureCanvas(self.figure_profile) + # # self.toolbar_profile =import NavigationToolBar(self.canvas_profile, self) + # # self.addToolBar(Qt.RightToolBarArea, self.toolbar_profile) + # # self.linear(self.figure_profile, self.axis_profile) + # for i in range(4): + # self.axis_profile[i].plot(self.model.BS_raw_cross_section.V[:, i, 0], self.model.r, c='k') + # # self.axis_profile.plot(self.data_test_slider[0, :], self.data_test_slider[0, :]) + # + # self.toolbar_post_processing_tab = NavigationToolBar(self.canvas_profile, self) + # # self.addToolBar(Qt.RightToolBarArea, self.toolbar_post_processing_tab) + # + # # self.label_icon = QLabel() + # # self.label_icon.setPixmap(QPixmap("../icons/smiley1.jpg")) + # + # # self.verticalLayout_plotprofiles.addWidget(self.toolbar_profile) + # self.verticalLayout_plotprofiles.addWidget(self.canvas_profile) + # # self.verticalLayout_plotprofiles.addLayout(self.horizontalLayout_slider_plotprofil) + # + # # # self.verticalLayout_plotprofiles.addWidget(self.label_icon) + # # self.verticalLayout_plotprofiles.addWidget(self.slider_plotprofile) + # + # # self.slider_plotprofile.valueChanged.connect(self.changePlot) + # + # # self.horizontalLayoutTop_signalProcessing.addLayout(self.verticalLayout_plotprofiles, 7) + # # self.horizontalLayoutTop_signalProcessing.addWidget(self.groupbox_plot_profile, 7) + # # self.verticalLayout_right_SignalProcessingTab.addWidget(self.toolbar_profile) + # self.verticalLayout_right_SignalProcessingTab.addWidget(self.groupbox_plot_profile) + # + # ### ---------- Plot averaged profile ---------- + # + # self.groupbox_plot_averaged_profile = QGroupBox() + # # self.groupbox_plot_averaged_profile.setTitle("Averaged profile") + # + # self.verticalLayout_averagedprofile = QVBoxLayout(self.groupbox_plot_averaged_profile) + # self.figure_averagedprofile, self.axis_averagedprofile = plt.subplots(nrows=1, ncols=4, layout='constrained') + # self.canvas_averagedprofile = FigureCanvas(self.figure_averagedprofile) + # # self.toolbar_averagedprofile = NavigationToolBar(self.canvas_averagedprofile, self) + # # self.addToolBar(Qt.RightToolBarArea, self.toolbar_averagedprofile) + # # self.toolbar_profile = NavigationToolBar(self.canvas_averagedprofile, self) + # # self.polynome(self.figure_averagedprofile, self.axis_averagedprofile) + # for i in range(4): + # self.axis_averagedprofile[i].plot(self.model.BS_averaged_cross_section.V[:, i, 0], self.model.r, c='b') + # + # self.toolbar_post_processing_tab = NavigationToolBar(self.canvas_averagedprofile, self) + # + # # self.horizontalLayout_slider_averagedprofile = QHBoxLayout() + # # + # # self.pushButton_slider_averagedprofile_right = QPushButton() + # # self.pushButton_slider_averagedprofile_right.setIcon(icon_triangle_right) + # # + # # self.pushButton_slider_averagedprofile_left = QPushButton() + # # self.pushButton_slider_averagedprofile_left.setIcon(icon_triangle_left) + # # + # # self.horizontalLayout_slider_averagedprofile.addWidget(self.pushButton_slider_averagedprofile_left) + # # self.horizontalLayout_slider_averagedprofile.addWidget(self.pushButton_slider_averagedprofile_right) + # # + # # self.lineEdit_slider_averaged_profile = QLineEdit() + # # self.lineEdit_slider_averaged_profile.setFixedWidth(50) + # # self.lineEdit_slider_averaged_profile.setText("1") + # # self.horizontalLayout_slider_averagedprofile.addWidget(self.lineEdit_slider_averaged_profile) + # # + # # self.slider_averagedprofile = QSlider() + # # self.slider_averagedprofile.setOrientation(Qt.Horizontal) + # # self.slider_averagedprofile.setTickPosition(QSlider.TicksBelow) + # # self.slider_averagedprofile.setCursor(Qt.OpenHandCursor) + # # self.slider_averagedprofile.setMinimum(0) + # # self.slider_averagedprofile.setMaximum(1) + # # self.slider_averagedprofile.setTickInterval(1) + # # self.slider_averagedprofile.setValue(0) + # # # self.slider_plotprofile.valueChanged.connect(self.changePlot) + # # + # # self.horizontalLayout_slider_averagedprofile.addWidget(self.slider_averagedprofile) + # + # # self.verticalLayout_averagedprofile.addWidget(self.toolbar_averagedprofile) + # self.verticalLayout_averagedprofile.addWidget(self.canvas_averagedprofile) + # # self.verticalLayout_averagedprofile.addLayout(self.horizontalLayout_slider_averagedprofile) + # + # # self.horizontalLayoutMid_signalProcessing.addLayout(self.verticalLayout_averagedprofile, 7) + # # self.horizontalLayoutMid_signalProcessing.addWidget(self.groupbox_plot_averaged_profile, 7) + # self.verticalLayout_right_SignalProcessingTab.addWidget(self.groupbox_plot_averaged_profile) + # + # ### ---------- Plot FCB profile ---------- + # + # self.groupbox_FCB_profile = QGroupBox() + # # self.groupbox_FCB_profile.setTitle("FCB profile") + # + # self.verticalLayout_FCBoptions = QVBoxLayout(self.groupbox_FCB_profile) + # self.figure_FCBoptions, self.axis_FCBoptions = plt.subplots(nrows=1, ncols=4, layout="constrained") + # self.canvas_FCBoptions = FigureCanvas(self.figure_FCBoptions) + # self.toolbar_FCBoptions = NavigationToolBar(self.canvas_FCBoptions, self) + # # self.addToolBar(Qt.LeftToolBarArea, self.toolbar_FCBoptions) + # # self.toolbar_profile = NavigationToolBar(self.canvas_FCBoptions, self) + # # self.cubique(self.figure_FCBoptions, self.axis_FCBoptions) + # for i in range(4): + # self.axis_FCBoptions[i].plot(self.model.FCB[:, i, 0], self.model.r, c='r') + # + # self.toolbar_post_processing_tab = NavigationToolBar(self.canvas_FCBoptions, self) + # + # # self.horizontalLayout_slider_FCBoptions = QHBoxLayout() + # # + # # self.pushButton_slider_FCBoptions_right = QPushButton() + # # self.pushButton_slider_FCBoptions_right.setIcon(icon_triangle_right) + # # + # # self.pushButton_slider_FCBoptions_left = QPushButton() + # # self.pushButton_slider_FCBoptions_left.setIcon(icon_triangle_left) + # # + # # self.horizontalLayout_slider_FCBoptions.addWidget(self.pushButton_slider_FCBoptions_left) + # # self.horizontalLayout_slider_FCBoptions.addWidget(self.pushButton_slider_FCBoptions_right) + # # + # # self.lineEdit_slider_FCBplot = QLineEdit() + # # self.lineEdit_slider_FCBplot.setFixedWidth(50) + # # self.lineEdit_slider_FCBplot.setText("1") + # # self.horizontalLayout_slider_FCBoptions.addWidget(self.lineEdit_slider_FCBplot) + # # + # # self.slider_FCBoptions = QSlider() + # # self.slider_FCBoptions.setOrientation(Qt.Horizontal) + # # self.slider_FCBoptions.setTickPosition(QSlider.TicksBelow) + # # self.slider_FCBoptions.setCursor(Qt.OpenHandCursor) + # # self.slider_FCBoptions.setMinimum(0) + # # self.slider_FCBoptions.setMaximum(1) + # # self.slider_FCBoptions.setTickInterval(1) + # # self.slider_FCBoptions.setValue(0) + # # # self.slider_plotprofile.valueChanged.connect(self.changePlot) + # # + # # self.horizontalLayout_slider_FCBoptions.addWidget(self.slider_FCBoptions) + # + # # self.verticalLayout_FCBoptions.addWidget(self.toolbar_FCBoptions) + # self.verticalLayout_FCBoptions.addWidget(self.canvas_FCBoptions) + # # self.verticalLayout_FCBoptions.addLayout(self.horizontalLayout_slider_FCBoptions) + # + # # self.horizontalLayoutBottom_signalProcessing.addLayout(self.verticalLayout_FCBoptions, 7) + # # self.horizontalLayoutBottom_signalProcessing.addWidget(self.groupbox_FCB_profile, 7) + # self.verticalLayout_right_SignalProcessingTab.addWidget(self.groupbox_FCB_profile) + # + # self.horizontalLayout_slider_plotprofil = QHBoxLayout() + # + # icon_triangle_right = QIcon() + # icon_triangle_right.addPixmap(QPixmap(path_icon + "triangle_right.png")) + # icon_triangle_left = QIcon() + # icon_triangle_left.addPixmap(QPixmap(path_icon + "triangle_left.png")) + # + # self.pushButton_slider_plotprofile_right = QPushButton() + # self.pushButton_slider_plotprofile_right.setIcon(icon_triangle_right) + # + # self.pushButton_slider_plotprofile_right.clicked.connect(self.slide_profile_number_to_right) + # + # self.pushButton_slider_plotprofile_left = QPushButton() + # self.pushButton_slider_plotprofile_left.setIcon(icon_triangle_left) + # # print(self.pushButton_slider_plotprofile_left.size().width()) + # + # self.pushButton_slider_plotprofile_left.clicked.connect(self.slide_profile_number_to_left) + # + # self.horizontalLayout_slider_plotprofil.addWidget(self.pushButton_slider_plotprofile_left) + # self.horizontalLayout_slider_plotprofil.addWidget(self.pushButton_slider_plotprofile_right) + # + # self.lineEdit_slider_acoustic_profile = QLineEdit() + # self.lineEdit_slider_acoustic_profile.setText("1") + # # self.lineEdit_slider_acoustic_profile.setFixedWidth(self.pushButton_slider_plotprofile_left.size().width()) + # self.lineEdit_slider_acoustic_profile.setFixedWidth(50) + # self.horizontalLayout_slider_plotprofil.addWidget(self.lineEdit_slider_acoustic_profile) + # + # self.lineEdit_slider_acoustic_profile.returnPressed.connect(self.profile_number_on_lineEdit) + # + # self.slider_plotprofile = QSlider() + # self.slider_plotprofile.setOrientation(Qt.Horizontal) + # # self.slider_plotprofile.setTickPosition(QSlider.TicksBelow) + # self.slider_plotprofile.setCursor(Qt.OpenHandCursor) + # self.slider_plotprofile.setMinimum(1) + # self.slider_plotprofile.setMaximum(self.model.BS_averaged_cross_section_corr.V.shape[2]) + # self.slider_plotprofile.setTickInterval(1) + # self.slider_plotprofile.setValue(1) + # self.slider_plotprofile.valueChanged.connect(self.changePlot) + # + # self.horizontalLayout_slider_plotprofil.addWidget(self.slider_plotprofile, 9) + # + # self.verticalLayout_right_SignalProcessingTab.addLayout(self.horizontalLayout_slider_plotprofil) + # + # self.retranslate_signal_processing_tab() + # + # + # + # # -------------------- Functions for Signal processing Tab -------------------- + # + # def retranslate_signal_processing_tab(self): + # + # self.pushbutton_Load_data_from_acoustic_data_tab.setText( + # _translate("CONSTANT_STRING", cs.LOAD_DATA_FROM_ACOUSTIC_DATA_TAB)) + # + # self.groupbox_display_profile_position.setTitle(_translate("CONSTANT_STRING", cs.DISPLAY_PROFILE_POSITION)) + # self.label_profile_number.setText(_translate("CONSTANT_STRING", cs.PROFILE_NUMBER) + " " + + # str(self.string_profile_number) + " / " + str(self.string_profile_number_max)) + # + # self.groupbox_post_processing.setTitle(_translate("CONSTANT_STRING", cs.POST_PROCESSING)) + # + # self.groupbox_acoustic_profile.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_PROFILE)) + # self.checkbox_substract_noise.setText(_translate("CONSTANT_STRING", cs.SUBTRACT_THE_NOISE)) + # self.checkbox_SNR_criterion.setText(_translate("CONSTANT_STRING", cs.SNR_CRITERION)) + # + # self.groupbox_window_size.setTitle(_translate("CONSTANT_STRING", cs.WINDOW_SIZE)) + # self.checkbox_nb_horizontal_cells.setText(_translate("CONSTANT_STRING", cs.HORIZONTAL) + ": +/-") + # self.label_nb_horizontal_cells_cm.setText(_translate("CONSTANT_STRING", cs.CELLS) + " = +/- ? cm") + # self.checkbox_nb_vertical_cells.setText(_translate("CONSTANT_STRING", cs.VERTICAL) + ": +/-") + # self.label_nb_vertical_cells_cm.setText(_translate("CONSTANT_STRING", cs.CELLS) + " = +/- ? cm") + # + # self.groupbox_rayleigh_criterion.setTitle(_translate("CONSTANT_STRING", cs.RAYLEIGH_CRITERION)) + # self.checkbox_despiked_acoustic_signal.setText(_translate("CONSTANT_STRING", cs.DESPIKING)) + # + # self.groupbox_FCBoption.setTitle(_translate("CONSTANT_STRING", cs.FCB_OPTIONS)) + # + # self.groupbox_water_attenuation.setTitle(_translate("CONSTANT_STRING", cs.COMPUTING_WATER_ATTENUATION)) + # self.label_temperature_water_attenation.setText(_translate("CONSTANT_STRING", cs.TEMPERATURE) + ":") + # + # self.groupbox_fit_regression_line.setTitle(_translate("CONSTANT_STRING", cs.FIT_REGRESSION_LINE)) + # self.label_alphaS_expression.setText( + # _translate("CONSTANT_STRING", cs.FOR_HOMOGENEOUS_SUSPENSION) + ": dFCB/dr = -2\u03B1s<\sub>") + # self.label_alphaS_computation_from.setText(_translate("CONSTANT_STRING", cs.FROM)) + # self.label_alphaS_computation_to.setText(_translate("CONSTANT_STRING", cs.TO)) + # + # self.groupbox_plot_profile.setTitle(_translate("CONSTANT_STRING", cs.PROFILE)) + # self.groupbox_plot_averaged_profile.setTitle(_translate("CONSTANT_STRING", cs.AVERAGED_PROFILE)) + # self.groupbox_FCB_profile.setTitle(_translate("CONSTANT_STRING", cs.FCB_PROFILE)) + # + # + # def plot_transect_bottom_with_profile_position(self, profile_position): + # 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, :]) + # # print('val_min=', val_min) + # # print('val_max=', val_max) + # if val_min == 0: + # val_min = 1e-5 + # # print('val_min update=', val_min) + # # if val_min == 0: + # # val_min = 1e-5 + # # self.axis_plot_profile_position_on_transect.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_plot_profile_position_on_transect.cla() + # # self.figure_plot_profile_position_on_transect.clf() + # self.axis_plot_profile_position_on_transect.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_plot_profile_position_on_transect.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_plot_profile_position_on_transect.plot( + # self.model.dist_BS_section[profile_position] * np.ones(self.model.r_bottom_cross_section.shape[0]), + # self.model.r_bottom_cross_section, color='red', linestyle="solid", linewidth=2) + # self.axis_plot_profile_position_on_transect.set_xticks([]) + # self.axis_plot_profile_position_on_transect.set_yticks([]) + # self.figure_plot_profile_position_on_transect.canvas.draw_idle() + # + # + # def changePlot(self): + # value = self.slider_plotprofile.value() + # + # self.string_profile_number = value + # self.label_profile_number.setText("Profile " + str(value) + + # " / " + str(self.string_profile_number_max)) + # + # self.plot_transect_bottom_with_profile_position(value) + # + # self.lineEdit_slider_acoustic_profile.setText(str(value)) + # + # for i in range(4): + # self.axis_profile[i].cla() + # self.axis_profile[i].plot(self.model.BS_raw_cross_section.V[:, i, value-1], self.model.r, c='k') + # + # self.axis_averagedprofile[i].cla() + # self.axis_averagedprofile[i].plot(self.model.BS_averaged_cross_section.V[:, i, value-1], self.model.r, c='b') + # + # self.axis_FCBoptions[i].cla() + # self.axis_FCBoptions[i].plot(self.model.FCB[:, i, value-1], self.model.r, c='r') + # # self.axis_profile.plot(self.data_test_slider[0, :], self.data_test_slider[value-1, :]) + # + # self.figure_profile.canvas.draw_idle() + # # self.figure_profile.canvas.flush_events() + # self.figure_averagedprofile.canvas.draw_idle() + # # self.figure_averagedprofile.canvas.flush_events() + # self.figure_FCBoptions.canvas.draw_idle() + # # self.figure_FCBoptions.canvas.flush_events() + # + # def profile_number_on_lineEdit(self): + # self.slider_plotprofile.setValue(int(self.lineEdit_slider_acoustic_profile.text())) + # print("profile number = ", self.lineEdit_slider_acoustic_profile.text()) + # + # def slide_profile_number_to_right(self): + # self.slider_plotprofile.setValue(int(self.slider_plotprofile.value()) + 1) + # + # def slide_profile_number_to_left(self): + # self.slider_plotprofile.setValue(int(self.slider_plotprofile.value()) - 1) + # + # def linear(self, figure, axis, i): + # # for i in range(4): + # # axis[i].plot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], '*-') + # # figure.tight_layout() + # for i in range(4): + # axis[i].plot(self.model.BS_raw_cross_section.V[:, i, 800], self.model.r, c='k') + # + # def polynome(self, figure, axis): + # # for i in range(4): + # # axis[i].plot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100], '*-') + # # figure.tight_layout() + # for i in range(4): + # axis[i].plot(self.model.BS_averaged_cross_section.V[:, i, 800], self.model.r, c='b') + # + # def cubique(self, figure, axis): + # # for i in range(4): + # # axis[i].plot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000], '*-') + # # figure.tight_layout() + # for i in range(4): + # axis[i].plot(self.model.FCB[:, i, 800], self.model.r, c='r') + # + # + + + + + + diff --git a/View/user_manual_tab.py b/View/user_manual_tab.py new file mode 100644 index 0000000..48e909b --- /dev/null +++ b/View/user_manual_tab.py @@ -0,0 +1,31 @@ +import sys + +from PyQt5.QtWidgets import QWidget, QVBoxLayout, QLabel +from PyQt5.QtGui import QFont, QPixmap +from PyQt5.QtCore import Qt + +import numpy as np + + +class UserManualTab(QWidget): + + def __init__(self, widget_tab): + super().__init__() + + self.verticalLayout_main = QVBoxLayout(widget_tab) + + self.label_title = QLabel(self, alignment=Qt.AlignHCenter | Qt.AlignTop) + self.label_title.setText("User Manual") + self.label_title.setFont(QFont("Times", 30, weight=QFont.Bold)) + self.verticalLayout_main.addWidget(self.label_title) + + # pic = QPixmap("./View/acoustic_inversion_theory.png") + # self.label_picture_theory = QLabel() + # self.label_picture_theory.setPixmap(pic) + # print(pic.width()) + # # self.label_picture_theory.setScaledContents(True) + # self.label_picture_theory.resize(np.int(pic.width()/100), np.int(pic.height()/100)) + # self.verticalLayout_main.addWidget(self.label_picture_theory) + + +