From 85a816d922e40c4874440e243cb10481dd594b68 Mon Sep 17 00:00:00 2001 From: brahim Date: Tue, 13 Feb 2024 10:30:15 +0100 Subject: [PATCH] The signal processing tab is updated. The noise is uploaded and graphs are automatically plot: noise, SNR and filtered Vbs (SNR, average) 2D fields, and averaged profile (for one frequency). --- View/acoustic_data_tab.py | 97 +- View/signal_processing_tab.py | 1864 +++++++++++++++++++++++---------- settings.py | 3 + 3 files changed, 1390 insertions(+), 574 deletions(-) diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index be15b85..06b6489 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -130,11 +130,6 @@ class AcousticDataTab(QWidget): 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) @@ -266,10 +261,16 @@ class AcousticDataTab(QWidget): self.label_temperature = QLabel("Temperature : ") self.gridLayout_goupbox_info.addWidget(self.label_temperature, 0, 0, 1, 1) self.lineEdit_temperature = QLineEdit() + self.lineEdit_temperature.textChanged.connect(self.temperature) self.gridLayout_goupbox_info.addWidget(self.lineEdit_temperature, 0, 1, 1, 1) self.label_degreCelsius = QLabel("°C") self.gridLayout_goupbox_info.addWidget(self.label_degreCelsius, 0, 2, 1, 1) + self.label_date_acoustic_file = QLabel() + self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 2) + self.label_hour_acoustic_file = QLabel() + self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) + self.label_profiles = QLabel() self.label_profiles_per_sec = QLabel() self.label_cells = QLabel() # n_cell in UBSediFlow parameters @@ -388,23 +389,23 @@ class AcousticDataTab(QWidget): # --- Push buttons to trigger plot of transect with Backscatter acoustic raw data and SNR --- - self.gridLayout_plot_transect_frequency_profile = QGridLayout() - self.verticalLayout_display_option.addLayout(self.gridLayout_plot_transect_frequency_profile) - # self.horizontalLayout_pushbutton_plot_BS_SNR_data = QHBoxLayout() - # self.verticalLayout_display_option.addLayout(self.horizontalLayout_pushbutton_plot_BS_SNR_data) + # self.gridLayout_plot_transect_frequency_profile = QGridLayout() + # self.verticalLayout_display_option.addLayout(self.gridLayout_plot_transect_frequency_profile) + # # 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.gridLayout_plot_transect_frequency_profile.addWidget(self.pushbutton_plot_transect_with_BS_raw_data, 0, 0, 1, 3) + # # 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_BS_raw_data = QPushButton() - self.gridLayout_plot_transect_frequency_profile.addWidget(self.pushbutton_plot_transect_with_BS_raw_data, 0, 0, 1, 3) - # self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_BS_raw_data) + # self.label_profile_frequency = QLabel() + # self.label_profile_frequency.setText("Profile frequency : ") + # self.gridLayout_plot_transect_frequency_profile.addWidget(self.label_profile_frequency, 0, 4, 1, 1) - self.pushbutton_plot_transect_with_BS_raw_data.clicked.connect(self.plot_transect_with_BS_raw_data) - - self.label_profile_frequency = QLabel() - self.label_profile_frequency.setText("Profile frequency : ") - self.gridLayout_plot_transect_frequency_profile.addWidget(self.label_profile_frequency, 0, 4, 1, 1) - - self.combobox_frequency_profile = QComboBox() - self.gridLayout_plot_transect_frequency_profile.addWidget(self.combobox_frequency_profile, 0, 5, 1, 1) + # self.combobox_frequency_profile = QComboBox() + # self.gridLayout_plot_transect_frequency_profile.addWidget(self.combobox_frequency_profile, 0, 5, 1, 1) # self.pushbutton_plot_transect_with_SNR_data = QPushButton() # self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_SNR_data) @@ -622,8 +623,14 @@ class AcousticDataTab(QWidget): self.verticalLayout_groupbox_plot_profile = QVBoxLayout(self.groupbox_plot_profile) self.groupbox_plot_profile.setTitle("Profiles") - self.canvas_plot_profile = None + self.horizontalLayout_spacerItem_combobox_frequency_profile = QHBoxLayout() + self.verticalLayout_groupbox_plot_profile.addLayout(self.horizontalLayout_spacerItem_combobox_frequency_profile) + self.spacerItem_frequency_profile = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalLayout_spacerItem_combobox_frequency_profile.addSpacerItem(self.spacerItem_frequency_profile) + self.combobox_frequency_profile = QComboBox() + self.horizontalLayout_spacerItem_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) + self.canvas_plot_profile = None self.retranslate_acoustic_data_tab() @@ -634,8 +641,8 @@ class AcousticDataTab(QWidget): 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.label_date_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") + self.label_hour_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)) @@ -690,7 +697,7 @@ class AcousticDataTab(QWidget): 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_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)) @@ -728,17 +735,13 @@ class AcousticDataTab(QWidget): 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.clear() - 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.clear() - self.label_date_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ": ") - self.label_hour_groupbox_acoustic_file.clear() - self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ": ") + # 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.clear() + # 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() @@ -758,17 +761,17 @@ class AcousticDataTab(QWidget): self.label_rx.show() self.label_tx.show() - self.gridLayout_goupbox_info.addWidget(self.label_profiles, 1, 0, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 1, 1, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_cells, 2, 0, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 2, 1, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 3, 0, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 4, 0, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 4, 1, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_freq, 5, 0, 1, 2) - self.gridLayout_goupbox_info.addWidget(self.label_kt, 6, 0, 1, 2) - self.gridLayout_goupbox_info.addWidget(self.label_rx, 7, 0, 1, 2) - self.gridLayout_goupbox_info.addWidget(self.label_tx, 8, 0, 1, 2) + self.gridLayout_goupbox_info.addWidget(self.label_profiles, 2, 0, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 2, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_cells, 3, 0, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 3, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 4, 0, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 5, 0, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 5, 1, 1, 1) + self.gridLayout_goupbox_info.addWidget(self.label_freq, 6, 0, 1, 2) + self.gridLayout_goupbox_info.addWidget(self.label_kt, 7, 0, 1, 2) + self.gridLayout_goupbox_info.addWidget(self.label_rx, 8, 0, 1, 2) + self.gridLayout_goupbox_info.addWidget(self.label_tx, 9, 0, 1, 2) def groupbox_measurement_information_UBSediFlow(self): # self.gridLayout_goupbox_info.itemAt(0).widget().deleteLater() @@ -793,7 +796,9 @@ class AcousticDataTab(QWidget): self.gridLayout_goupbox_info.addWidget(self.label_freq, 0, 0, 1, 1) - + def temperature(self): + stg.temperature = float(self.lineEdit_temperature.text()) + print(f"stg.temperature : {stg.temperature}") def clicked_pushbutton_noise_level(self): self.WindowNoiseLevelTailAveragedProfile().show() @@ -849,9 +854,9 @@ class AcousticDataTab(QWidget): else: self.lineEdit_acoustic_file.setText(stg.filename_BS_raw_data) self.lineEdit_acoustic_file.setToolTip(stg.path_BS_raw_data) - self.label_date_groupbox_acoustic_file.setText( + self.label_date_acoustic_file.setText( _translate("CONSTANT_STRING", cs.DATE) + ": " + str(stg.date)) - self.label_hour_groupbox_acoustic_file.setText( + self.label_hour_acoustic_file.setText( _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour)) self.fill_measurements_information_groupbox() self.plot_transect_with_BS_raw_data() diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index 5d840ec..069d78d 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -2,7 +2,7 @@ import sys from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox, QLabel, QCheckBox, QSpinBox, QDoubleSpinBox, QComboBox, QLineEdit, QSlider, QGridLayout, QMessageBox, - QScrollArea) + QScrollArea, QRadioButton, QFileDialog, QSpacerItem, QSizePolicy, QTextEdit) from PyQt5.QtGui import QFont, QIcon, QPixmap from PyQt5.QtCore import Qt, QCoreApplication @@ -15,6 +15,7 @@ from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar from matplotlib.colors import LogNorm, BoundaryNorm from scipy import stats +from os import path import Translation.constant_string as cs @@ -22,8 +23,6 @@ from Model.acoustic_data_loader import AcousticDataLoader import settings as stg -from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration - _translate = QCoreApplication.translate @@ -34,185 +33,212 @@ class SignalProcessingTab(QWidget): def __init__(self, widget_tab): super().__init__() - self.inv_hc = AcousticInversionMethodHighConcentration() - - path_icon = "./icons/" - icon_triangle_left = QIcon(path_icon + "triangle_left.png") - icon_triangle_right = QIcon(path_icon + "triangle_right.png") + self.path_icon = "./icons/" + self.icon_folder = QIcon(self.path_icon + "folder.png") + self.icon_triangle_left = QIcon(self.path_icon + "triangle_left.png") + self.icon_triangle_right = QIcon(self.path_icon + "triangle_right.png") ### --- General layout of widgets --- - # ___________ ____________________________ - # | profile | | Profile | - # | position | | | - # | | | | - # | | | Averaged profile | - # | post | | | - # | proc | | | - # | options | | FCB option | - # |___________| |____________________________| + self.verticalLayoutMain = QVBoxLayout(widget_tab) - self.horizontalLayout_Main = QHBoxLayout(widget_tab) + self.horizontalLayout_Top = QHBoxLayout() + self.verticalLayoutMain.addLayout(self.horizontalLayout_Top, 5) - self.verticalLayout_Left = QVBoxLayout() - self.horizontalLayout_Main.addLayout(self.verticalLayout_Left, 2) - - self.verticalLayout_Right = QVBoxLayout() - self.horizontalLayout_Main.addLayout(self.verticalLayout_Right, 8) + self.horizontalLayout_Bottom = QHBoxLayout() + self.verticalLayoutMain.addLayout(self.horizontalLayout_Bottom, 5) # -------------------------------------------------------------------------------------------------------------- - ### --- Layout of groupbox in the Left vertical layout box + ### --- Layout of groupbox in the top layout box - # Push button Load data - # --------------------- - # Profile position - # --------------------- - # Post processing - # --------------------- - # FCB options + self.groupbox_study_data = QGroupBox() + self.horizontalLayout_Top.addWidget(self.groupbox_study_data, 2) - self.horizontalLayout_pushbutton_load_data_plot_bottom_line = QHBoxLayout() - self.verticalLayout_Left.addLayout(self.horizontalLayout_pushbutton_load_data_plot_bottom_line) + self.groupbox_plot_Noise_SNR = QGroupBox() + self.horizontalLayout_Top.addWidget(self.groupbox_plot_Noise_SNR, 4) - self.groupbox_display_profile_position = QGroupBox() - self.verticalLayout_Left.addWidget(self.groupbox_display_profile_position) + self.groupbox_plot_BS_signal_filtered_with_SNR = QGroupBox() + self.horizontalLayout_Top.addWidget(self.groupbox_plot_BS_signal_filtered_with_SNR, 4) - self.groupbox_post_processing = QGroupBox() - self.verticalLayout_Left.addWidget(self.groupbox_post_processing) + # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + # +++ --- Download noise file + compute noise data from profile tail + --- +++ + # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - self.groupbox_FCBoption = QGroupBox() - self.verticalLayout_Left.addWidget(self.groupbox_FCBoption) + self.verticalLayout_groupbox_study_data = QVBoxLayout(self.groupbox_study_data) - # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - # +++ --- Push button Load data + Push button plot bottom --- +++ - # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + self.groupbox_data_to_be_processed = QGroupBox() + self.verticalLayout_groupbox_data_to_be_processed = QVBoxLayout(self.groupbox_data_to_be_processed) + self.groupbox_data_to_be_processed.setTitle("Data to be processed") - self.pushbutton_load_data = QPushButton() - self.horizontalLayout_pushbutton_load_data_plot_bottom_line.addWidget(self.pushbutton_load_data) - self.pushbutton_load_data.clicked.connect(self.compute_BS_data_section) - # self.pushbutton_load_data.clicked.connect(self.plot_profile_position_on_transect) - # self.pushbutton_load_data.clicked.connect(self.plot_profile) + self.textEdit_acoustic_file_to_be_processed = QTextEdit() + self.verticalLayout_groupbox_data_to_be_processed.addWidget(self.textEdit_acoustic_file_to_be_processed) - self.combobox_frequency = QComboBox() - self.horizontalLayout_pushbutton_load_data_plot_bottom_line.addWidget(self.combobox_frequency) - # self.combobox_frequency.currentTextChanged.connect(self.update_plot_profile_position_on_transect) + self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_data_to_be_processed) - # +++++++++++++++++++++++++++++++++++++++++++++++++ - # +++ --- GroupBox Display Profile Position --- +++ - # +++++++++++++++++++++++++++++++++++++++++++++++++ + ### --- Radio button : File VS Profile tail VS Value --- - self.verticalLayout_groupbox_display_profile_position = QVBoxLayout(self.groupbox_display_profile_position) + self.gridLayout_radiobutton_noise_data = QGridLayout() + self.verticalLayout_groupbox_study_data.addLayout(self.gridLayout_radiobutton_noise_data) - self.label_profile_number = QLabel() - self.label_profile_number.setFont(QFont("Ubuntu", 16, QFont.Bold)) - self.label_profile_number.setAlignment(Qt.AlignCenter) - # self.label_profile_number.setText("Profile 1 / " + str(stg.nb_profiles)) - self.verticalLayout_groupbox_display_profile_position.addWidget(self.label_profile_number) + self.radiobutton_file = QRadioButton("File") + self.radiobutton_file.setChecked(True) + self.radiobutton_file.toggled.connect(self.onClicked_radiobutton_noise_data) + self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_file, 0, 0, 1, 1) - self.canvas_plot_profile_position_on_transect = None + self.radiobutton_profile_tail = QRadioButton("Profile tail") + # self.radiobutton_file.setChecked(False) + self.radiobutton_profile_tail.toggled.connect(self.onClicked_radiobutton_noise_data) + self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_profile_tail, 0, 1, 1, 1) - # 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.radiobutton_value = QRadioButton("Value") + self.radiobutton_value.toggled.connect(self.onClicked_radiobutton_noise_data) + self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_value, 0, 2, 1, 1) - # ++++++++++++++++++++++++++++++++++++++++ - # +++ --- GroupBox Post Processing --- +++ - # ++++++++++++++++++++++++++++++++++++++++ + ### --- Groupbox download noise file --- - self.verticalLayout_groupbox_post_processing = QVBoxLayout(self.groupbox_post_processing) + self.groupbox_download_noise_file = QGroupBox() + self.groupbox_download_noise_file.setVisible(True) + self.gridLayout_groupbox_noise_file = QGridLayout(self.groupbox_download_noise_file) - self.groupbox_acoustic_profile = QGroupBox() - self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_acoustic_profile) + self.pushbutton_noise_file = QPushButton() + self.pushbutton_noise_file.setObjectName("pushbutton_noise_file") + self.pushbutton_noise_file.setIcon(self.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.groupbox_rayleigh_criterion = QGroupBox() - self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_rayleigh_criterion) + # 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) - self.groupbox_window_size = QGroupBox() - self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_window_size) + # Download Push Button event : connect button clicked signal to open file slot + self.pushbutton_noise_file.clicked.connect(self.open_dialog_box) - # --- Groupbox acoustic profile --- + self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_download_noise_file) - self.gridLayout_groupbox_acoustic_profile = QGridLayout(self.groupbox_acoustic_profile) + ### --- Groupbox compute noise from profile tail --- - # self.checkbox_SNR_criterion = QCheckBox() - self.label_SNR_criterion = QLabel() - self.gridLayout_groupbox_acoustic_profile.addWidget(self.label_SNR_criterion, 0, 0, 1, 1) + self.groupbox_compute_noise_from_profile_tail = QGroupBox() + self.groupbox_compute_noise_from_profile_tail.setVisible(False) + + self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_profile_tail) + + ### --- Groupbox compute noise from value --- + + self.groupbox_compute_noise_from_value = QGroupBox() + self.groupbox_compute_noise_from_value.setVisible(False) + + self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_value) + + # +++++++++++++++++++++++++++++ + # +++ --- Plot SNR data --- +++ + # +++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_plot_Noise_SNR = QVBoxLayout(self.groupbox_plot_Noise_SNR) + + ### --- Groupbox plot noise data --- + + self.groupbox_plot_noise_data = QGroupBox() + self.horizontalLayout_groupbox_plot_noise_data = QHBoxLayout(self.groupbox_plot_noise_data) + + self.combobox_freq_noise = QComboBox() + self.horizontalLayout_groupbox_plot_noise_data.addWidget(self.combobox_freq_noise) + + self.spacerItem_frequency_noise = QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalLayout_groupbox_plot_noise_data.addItem(self.spacerItem_frequency_noise) + + self.canvas_noise = None + + self.verticalLayout_groupbox_plot_Noise_SNR.addWidget(self.groupbox_plot_noise_data, 3) + + ### --- Groupbox plot SNR --- + + self.groupbox_plot_SNR = QGroupBox() + self.verticalLayout_groupbox_SNR = QVBoxLayout(self.groupbox_plot_SNR) + + # self.pushbutton_plot_SNR = QPushButton() + # self.verticalLayout_groupbox_plot_Noise_SNR.addWidget(self.pushbutton_plot_SNR) + # self.pushbutton_plot_SNR.clicked.connect(self.plot_transect_with_SNR_data) + + self.canvas_SNR = None + self.scroll_SNR = None + + self.verticalLayout_groupbox_plot_Noise_SNR.addWidget(self.groupbox_plot_SNR, 7) + + # ++++++++++++++++++++++++++++++++++++++++++++++ + # +++ --- Plot BS data filtered with SNR --- +++ + # ++++++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_plot_BS_field = QVBoxLayout(self.groupbox_plot_BS_signal_filtered_with_SNR) + + ### --- Groupbox SNR criterion --- + self.groupbox_SNR_criterion = QGroupBox() + self.gridLayout_SNR_criterion = QGridLayout(self.groupbox_SNR_criterion) + + self.label_SNR_criterion = QLabel("SNR criterion : ") + self.gridLayout_SNR_criterion.addWidget(self.label_SNR_criterion, 0, 0, 1, 1) self.spinbox_SNR_criterion = QSpinBox() - self.spinbox_SNR_criterion.setRange(0, 9999) - self.spinbox_SNR_criterion.setValue(0) - # self.spinbox_SNR_criterion.setDisabled(True) - self.gridLayout_groupbox_acoustic_profile.addWidget(self.spinbox_SNR_criterion, 0, 1, 1, 1) + self.gridLayout_SNR_criterion.addWidget(self.spinbox_SNR_criterion, 0, 1, 1, 1) + self.pushbutton_Apply_SNR_filter = QPushButton() + self.gridLayout_SNR_criterion.addWidget(self.pushbutton_Apply_SNR_filter, 0, 2, 1, 1) - # self.spinbox_SNR_criterion.valueChanged.connect(self.remove_point_with_snr_filter) + self.pushbutton_Apply_SNR_filter.clicked.connect(self.remove_point_with_snr_filter) - self.pushbutton_snr_filter = QPushButton() - self.pushbutton_snr_filter.setText("Apply SNR") - self.gridLayout_groupbox_acoustic_profile.addWidget(self.pushbutton_snr_filter, 0, 2, 1, 1) + self.verticalLayout_groupbox_plot_BS_field.addWidget(self.groupbox_SNR_criterion, 2) - self.pushbutton_snr_filter.clicked.connect(self.remove_point_with_snr_filter) - # self.pushbutton_snr_filter.clicked.connect(self.update_plot_profile) - # self.pushbutton_snr_filter.clicked.connect(self.update_plot_profile_position_on_transect) + ### --- Groupbox plot BS signal filtered with SNR criterion --- + self.groupbox_BS_SNR_filter = QGroupBox() + self.verticalLayout_groupbox_BS_SNR_filter = QVBoxLayout(self.groupbox_BS_SNR_filter) - # --- Groupbox Rayleigh criterion --- + self.canvas_BS = None + self.scroll_BS = None - self.gridLayout_rayleigh_criterion = QGridLayout(self.groupbox_rayleigh_criterion) + self.verticalLayout_groupbox_plot_BS_field.addWidget(self.groupbox_BS_SNR_filter, 8) + + # -------------------------------------------------------------------------------------------------------------- + ### --- Layout of groupbox in the bottom layout box + + self.groupbox_pre_processing = QGroupBox() + self.horizontalLayout_Bottom.addWidget(self.groupbox_pre_processing, 4) + + self.groupbox_plot_pre_processed_data = QGroupBox() + self.horizontalLayout_Bottom.addWidget(self.groupbox_plot_pre_processed_data, 5) + + self.groupbox_list_pre_processed_data = QGroupBox() + self.horizontalLayout_Bottom.addWidget(self.groupbox_list_pre_processed_data, 1) + + # +++++++++++++++++++++++++++++++++++++ + # +++ --- Pre-processing option --- +++ + # +++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_pre_processing = QVBoxLayout(self.groupbox_pre_processing) + + # --- Rayleigh criterion groupbox --- + self.groupbox_Rayleigh_criterion = QGroupBox() + self.gridLayout_Rayleigh_criterion = QGridLayout(self.groupbox_Rayleigh_criterion) self.label_Rayleigh_criterion = QLabel() self.label_Rayleigh_criterion.setText("/² <=") - self.gridLayout_rayleigh_criterion.addWidget(self.label_Rayleigh_criterion, 0, 0, 1, 1) + self.gridLayout_Rayleigh_criterion.addWidget(self.label_Rayleigh_criterion, 0, 0, 1, 1) - self.spinbox_rayleigh_criterion = QSpinBox() - self.spinbox_rayleigh_criterion.setRange(0, 9999) - self.spinbox_rayleigh_criterion.setValue(10) - self.gridLayout_rayleigh_criterion.addWidget(self.spinbox_rayleigh_criterion, 0, 1, 1, 1) + self.spinbox_Rayleigh_criterion = QSpinBox() + self.spinbox_Rayleigh_criterion.setRange(0, 9999) + self.spinbox_Rayleigh_criterion.setValue(10) + self.gridLayout_Rayleigh_criterion.addWidget(self.spinbox_Rayleigh_criterion, 0, 1, 1, 1) self.label_4pi = QLabel() self.label_4pi.setText("% x 4/pi") - self.gridLayout_rayleigh_criterion.addWidget(self.label_4pi, 0, 2, 1, 1) + self.gridLayout_Rayleigh_criterion.addWidget(self.label_4pi, 0, 2, 1, 1) self.pushbutton_despiking_signal = QPushButton() self.pushbutton_despiking_signal.setText("Despiking the signal") - self.gridLayout_rayleigh_criterion.addWidget(self.pushbutton_despiking_signal, 0, 3, 1, 1) + self.gridLayout_Rayleigh_criterion.addWidget(self.pushbutton_despiking_signal, 0, 3, 1, 1) - # --- Groupbox Window size --- + self.verticalLayout_groupbox_pre_processing.addWidget(self.groupbox_Rayleigh_criterion) - # self.horizontalLayout_groupbox_window_size = QHBoxLayout(self.groupbox_window_size) + # --- Average signal groupbox --- + self.groupbox_window_size = QGroupBox() self.gridLayout_groupbox_window_size = QGridLayout(self.groupbox_window_size) self.label_signal_averaging_horizontal = QLabel() @@ -229,323 +255,68 @@ class SignalProcessingTab(QWidget): # self.horizontalLayout_groupbox_window_size.addWidget(self.label_cells) self.gridLayout_groupbox_window_size.addWidget(self.label_cells_horizontal, 0, 2, 1, 1) - # self.label_signal_averaging_vertical = QLabel() - # self.label_signal_averaging_vertical.setText("Vertical +/- ") - # # self.horizontalLayout_groupbox_window_size.addWidget(self.label_signal_averaging_over) - # self.gridLayout_groupbox_window_size.addWidget(self.label_signal_averaging_vertical, 1, 0, 1, 1) - # self.spinbox_average_vertical = QSpinBox() - # self.spinbox_average_vertical.setRange(0, 9999) - # self.spinbox_average_vertical.setValue(0) - # # self.horizontalLayout_groupbox_window_size.addWidget(self.spinbox_average) - # self.gridLayout_groupbox_window_size.addWidget(self.spinbox_average_vertical, 1, 1, 1, 1) - # self.label_cells_vertical = QLabel() - # self.label_cells_vertical.setText("cells = +/- ? sec") - # # self.horizontalLayout_groupbox_window_size.addWidget(self.label_cells) - # self.gridLayout_groupbox_window_size.addWidget(self.label_cells_vertical, 1, 2, 1, 1) - - # self.spinbox_average.valueChanged.connect(self.compute_averaged_profile) - self.pushbutton_average = QPushButton() self.pushbutton_average.setText("Apply averaging") - # self.pushbutton_snr_filter.setDisabled(True) - # self.horizontalLayout_groupbox_window_size.addWidget(self.pushbutton_average) - self.gridLayout_groupbox_window_size.addWidget(self.pushbutton_average, 0, 3, 2, 1) + self.gridLayout_groupbox_window_size.addWidget(self.pushbutton_average, 0, 3, 1, 1) - self.pushbutton_average.clicked.connect(self.compute_averaged_profile) - # self.pushbutton_average.clicked.connect(self.update_plot_profile_position_on_transect) - # self.pushbutton_average.clicked.connect(self.plot_averaged_profile) + self.pushbutton_average.clicked.connect(self.compute_averaged_BS_data) + self.pushbutton_average.clicked.connect(self.plot_profile_and_position_on_transect_with_slider) - # ++++++++++++++++++++++++++++++++++++ - # +++ --- GroupBox FCB options --- +++ - # ++++++++++++++++++++++++++++++++++++ + self.verticalLayout_groupbox_pre_processing.addWidget(self.groupbox_window_size) - self.verticalLayout_groupbox_FCBoption = QVBoxLayout(self.groupbox_FCBoption) + # +++++++++++++++++++++++++++++++++++++++ + # +++ --- Plot pre-processed data --- +++ + # +++++++++++++++++++++++++++++++++++++++ - self.groupbox_water_attenuation = QGroupBox() - self.verticalLayout_groupbox_FCBoption.addWidget(self.groupbox_water_attenuation) + self.verticalLayout_groupbox_plot_pre_processed_data = QVBoxLayout(self.groupbox_plot_pre_processed_data) - self.groupbox_fit_regression_line = QGroupBox() - self.verticalLayout_groupbox_FCBoption.addWidget(self.groupbox_fit_regression_line) - - # --- Groupbox water attenuation --- - - self.gridLayout_groupbox_water_attenuation = QGridLayout(self.groupbox_water_attenuation) - - 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.gridLayout_groupbox_water_attenuation.addWidget(self.combobox_water_attenuation_model, 0, 0, 1, 1) - - self.label_temperature_water_attenation = QLabel() - self.gridLayout_groupbox_water_attenuation.addWidget(self.label_temperature_water_attenation, 0, 1, 1, 1) - - self.spinbox_temperature_water_attenuation = QSpinBox() - self.gridLayout_groupbox_water_attenuation.addWidget(self.spinbox_temperature_water_attenuation, 0, 2, 1, 1) - - self.label_degre_celsius = QLabel() - self.label_degre_celsius.setText("°C") - self.gridLayout_groupbox_water_attenuation.addWidget(self.label_degre_celsius, 0, 3, 1, 1) - - self.combobox_freq_for_water_attenuation = QComboBox() - # self.combobox_water_attenuation.currentIndexChanged.connect(self.alpha_value_changed) - self.gridLayout_groupbox_water_attenuation.addWidget(self.combobox_freq_for_water_attenuation, 1, 0, 1, 1) - - self.pushbutton_water_attenuation = QPushButton() - self.pushbutton_water_attenuation.setText("Compute \u03B1w") - self.gridLayout_groupbox_water_attenuation.addWidget(self.pushbutton_water_attenuation, 1, 1, 1, 1) - self.pushbutton_water_attenuation.clicked.connect(self.compute_water_attenuation) - - self.label_water_attenuation = QLabel() - self.label_water_attenuation.setText("\u03B1w = 0.00 dB/m") - self.label_water_attenuation.setFont(QFont("Ubuntu", 14, QFont.Normal)) - self.gridLayout_groupbox_water_attenuation.addWidget(self.label_water_attenuation, 1, 2, 1, 1) - - # --- Groupbox fit regression line --- - - self.gridLayout_groupbox_fit_regression = QGridLayout(self.groupbox_fit_regression_line) - - self.label_alphaS_expression = QLabel() - # self.label_alphaS_expression.setText("For homogeneous suspension: dFCB/dr = -2\u03B1s<\sub>") - self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_expression, 0, 0, 1, 5) - - self.combobox_frequency_compute_alphaS = QComboBox() - self.gridLayout_groupbox_fit_regression.addWidget(self.combobox_frequency_compute_alphaS, 1, 0, 1, 1) - - self.label_alphaS_computation_from = QLabel() - self.label_alphaS_computation_from.setText("From -") - self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_computation_from, 1, 1, 1, 1) - - self.spinbox_alphaS_computation_from = QDoubleSpinBox() - self.spinbox_alphaS_computation_from.setRange(0, 9999) - self.gridLayout_groupbox_fit_regression.addWidget(self.spinbox_alphaS_computation_from, 1, 2, 1, 1) - - self.label_alphaS_computation_to = QLabel() - self.label_alphaS_computation_to.setText("To -") - self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_computation_to, 1, 3, 1, 1) - - self.spinbox_alphaS_computation_to = QDoubleSpinBox() - self.gridLayout_groupbox_fit_regression.addWidget(self.spinbox_alphaS_computation_to, 1, 4, 1, 1) - - self.pushbutton_plot_FCB = QPushButton() - self.pushbutton_plot_FCB.setText("Plot FCB") - self.gridLayout_groupbox_fit_regression.addWidget(self.pushbutton_plot_FCB, 2, 0, 1, 1) - - self.pushbutton_plot_FCB.clicked.connect(self.compute_FCB) - # self.pushbutton_plot_FCB.clicked.connect(self.plot_FCB) - - self.pushbutton_fit_linear_regression = QPushButton() - self.pushbutton_fit_linear_regression.setText("Fit && Compute \u03B1s") - self.gridLayout_groupbox_fit_regression.addWidget(self.pushbutton_fit_linear_regression, 2, 1, 1, 1) - - self.pushbutton_fit_linear_regression.clicked.connect(self.fit_FCB_profile_with_linear_regression_and_compute_alphaS) - self.pushbutton_fit_linear_regression.clicked.connect(self.plot_FCB) - - self.label_alphaS = QLabel() - self.label_alphaS.setText("\u03B1s = " + "0.0" + "dB/m") - self.label_alphaS.setFont(QFont("Ubuntu", 14, QFont.Normal)) - self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS, 2, 3, 1, 1) - - # self.verticalLayout_groupbox_fit_regression - - # -------------------------------------------------------------------------------------------------------------- - ### --- Layout of groupbox in the Right vertical layout box - - # Plot Profiles - # ------------------------- - # Plot averaged profile - # ------------------------- - # Plot FCB profiles - - self.groupbox_plot_profile = QGroupBox() - self.verticalLayout_Right.addWidget(self.groupbox_plot_profile) - - self.groupbox_plot_averaged_profile = QGroupBox() - self.verticalLayout_Right.addWidget(self.groupbox_plot_averaged_profile) - - self.groupbox_FCB_profile = QGroupBox() - self.verticalLayout_Right.addWidget(self.groupbox_FCB_profile) - - # +++++++++++++++++++++++++++++++++++++ - # +++ --- GroupBox Plot profile --- +++ - # +++++++++++++++++++++++++++++++++++++ - - self.verticalLayout_groupbox_plot_profile = QVBoxLayout(self.groupbox_plot_profile) + self.horizontalLayout_label_profile_number_combobox_frequency_profile = QHBoxLayout() + self.verticalLayout_groupbox_plot_pre_processed_data.addLayout(self.horizontalLayout_label_profile_number_combobox_frequency_profile) + self.label_profile_number = QLabel() + self.label_profile_number.setText("Profile ") + self.horizontalLayout_label_profile_number_combobox_frequency_profile.addWidget(self.label_profile_number) + self.spacerItem_frequency_profile = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalLayout_label_profile_number_combobox_frequency_profile.addSpacerItem(self.spacerItem_frequency_profile) + self.combobox_frequency_profile = QComboBox() + self.horizontalLayout_label_profile_number_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) self.canvas_profile = None - self.scroll_profile = None - # # 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.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) + # --- Figure to plot profiles and BS signal 2D field below--- + # self.verticalLayout_groupbox_plot_pre_processed_data.removeWidget(self.canvas_profile) - # ++++++++++++++++++++++++++++++++++++++++++++++ - # +++ --- GroupBox Plot averaged profile --- +++ - # ++++++++++++++++++++++++++++++++++++++++++++++ + self.figure_profile, self.axis_profile = plt.subplots(nrows=2, ncols=1)#, gridspec_kw={'width_ratios': [2, 1], + # 'height_ratios': [3, 1]}) + self.canvas_profile = FigureCanvas(self.figure_profile) - self.verticalLayout_groupbox_plot_averaged_profile = QVBoxLayout(self.groupbox_plot_averaged_profile) + self.scroll_profile = QScrollArea() + self.scroll_profile.setWidget(self.canvas_profile) + self.scroll_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + self.scroll_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_BS.setWidgetResizable(True) + self.scroll_profile.setAlignment(Qt.AlignCenter) + self.verticalLayout_groupbox_plot_pre_processed_data.addWidget(self.scroll_profile) - self.canvas_averaged_profile = None - self.scroll_averaged_profile = None - - # 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) - - # ++++++++++++++++++++++++++++++++++++++++++++++ - # +++ --- GroupBox Plot FCB profile --- +++ - # ++++++++++++++++++++++++++++++++++++++++++++++ - - self.verticalLayout_groupbox_plot_FCB_profile = QVBoxLayout(self.groupbox_FCB_profile) - - self.canvas_FCB_profile = None - self.scroll_FCB_profile = None - - # 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) - # - - - # --- Slider ---- + # self.verticalLayout_groupbox_plot_pre_processed_data.addWidget(self.canvas_profile) + # # --- Slider for moving the profile --- self.horizontalLayout_slider = QHBoxLayout() - self.verticalLayout_Right.addLayout(self.horizontalLayout_slider) + self.verticalLayout_groupbox_plot_pre_processed_data.addLayout(self.horizontalLayout_slider) self.pushbutton_slider_left = QPushButton() - self.pushbutton_slider_left.setIcon(icon_triangle_left) + self.pushbutton_slider_left.setIcon(self.icon_triangle_left) self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left) + self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left) + self.pushbutton_slider_right = QPushButton() - self.pushbutton_slider_right.setIcon(icon_triangle_right) + self.pushbutton_slider_right.setIcon(self.icon_triangle_right) self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right) - self.pushbutton_slider_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 = QLineEdit() self.lineEdit_slider.setText("1") - # # self.lineEdit_slider_acoustic_profile.setFixedWidth(self.pushButton_slider_plotprofile_left.size().width()) self.lineEdit_slider.setFixedWidth(50) self.horizontalLayout_slider.addWidget(self.lineEdit_slider) @@ -555,57 +326,1153 @@ class SignalProcessingTab(QWidget): self.horizontalLayout_slider.addWidget(self.slider, 9) self.slider.setOrientation(Qt.Horizontal) - # # self.slider_plotprofile.setTickPosition(QSlider.TicksBelow) self.slider.setCursor(Qt.OpenHandCursor) self.slider.setMinimum(1) - # self.slider.setMaximum(stg.nb_profiles)#self.model.BS_averaged_cross_section_corr.V.shape[2]) + self.slider.setMaximum(100) self.slider.setTickInterval(1) self.slider.setValue(1) self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) - self.slider.valueChanged.connect(self.update_plot_profile_position_on_transect) - self.slider.valueChanged.connect(self.update_plot_profile) - # self.slider.valueChanged.connect(self.update_plot_averaged_profile) - self.slider.valueChanged.connect(self.update_plot_FCB) + + self.slider.valueChanged.connect(self.plot_profile_and_position_on_transect_with_slider) + + # ++++++++++++++++++++++++++++++++++++++++++ + # +++ --- List of pre-processed data --- +++ + # ++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_list_pre_processed_data = QVBoxLayout(self.groupbox_list_pre_processed_data) + + self.textEdit_list_pre_processed_data = QTextEdit() + self.verticalLayout_list_pre_processed_data.addWidget(self.textEdit_list_pre_processed_data) + + + # ______ _______ + # | | | | \ + # | | | | \ + # | | | | | + # | | | | / + # |______| |________ |________/ + + # COMMENT OLD CODE LINE FROM HERE .... + + # ### --- General layout of widgets --- + # + # # ___________ ____________________________ + # # | profile | | Profile | + # # | position | | | + # # | | | | + # # | | | Averaged profile | + # # | post | | | + # # | proc | | | + # # | options | | FCB option | + # # |___________| |____________________________| + # + # self.horizontalLayout_Main = QHBoxLayout(widget_tab) + # + # self.verticalLayout_Left = QVBoxLayout() + # self.horizontalLayout_Main.addLayout(self.verticalLayout_Left, 2) + # + # self.verticalLayout_Right = QVBoxLayout() + # self.horizontalLayout_Main.addLayout(self.verticalLayout_Right, 8) + # + # + # # -------------------------------------------------------------------------------------------------------------- + # ### --- Layout of groupbox in the Left vertical layout box + # + # # Push button Load data + # # --------------------- + # # Profile position + # # --------------------- + # # Post processing + # # --------------------- + # # FCB options + # + # self.horizontalLayout_pushbutton_load_data_plot_bottom_line = QHBoxLayout() + # self.verticalLayout_Left.addLayout(self.horizontalLayout_pushbutton_load_data_plot_bottom_line) + # + # self.groupbox_display_profile_position = QGroupBox() + # self.verticalLayout_Left.addWidget(self.groupbox_display_profile_position) + # + # self.groupbox_post_processing = QGroupBox() + # self.verticalLayout_Left.addWidget(self.groupbox_post_processing) + # + # self.groupbox_FCBoption = QGroupBox() + # self.verticalLayout_Left.addWidget(self.groupbox_FCBoption) + # + # # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + # # +++ --- Push button Load data + Push button plot bottom --- +++ + # # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + # + # self.pushbutton_load_data = QPushButton() + # self.horizontalLayout_pushbutton_load_data_plot_bottom_line.addWidget(self.pushbutton_load_data) + # self.pushbutton_load_data.clicked.connect(self.compute_BS_data_section) + # # self.pushbutton_load_data.clicked.connect(self.plot_profile_position_on_transect) + # # self.pushbutton_load_data.clicked.connect(self.plot_profile) + # + # self.combobox_frequency = QComboBox() + # self.horizontalLayout_pushbutton_load_data_plot_bottom_line.addWidget(self.combobox_frequency) + # # self.combobox_frequency.currentTextChanged.connect(self.update_plot_profile_position_on_transect) + # + # # +++++++++++++++++++++++++++++++++++++++++++++++++ + # # +++ --- GroupBox Display Profile Position --- +++ + # # +++++++++++++++++++++++++++++++++++++++++++++++++ + # + # 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.label_profile_number.setText("Profile 1 / " + str(stg.nb_profiles)) + # self.verticalLayout_groupbox_display_profile_position.addWidget(self.label_profile_number) + # + # self.canvas_plot_profile_position_on_transect = None + # + # # 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) + # + # # ++++++++++++++++++++++++++++++++++++++++ + # # +++ --- GroupBox Post Processing --- +++ + # # ++++++++++++++++++++++++++++++++++++++++ + # + # self.verticalLayout_groupbox_post_processing = QVBoxLayout(self.groupbox_post_processing) + # + # self.groupbox_acoustic_profile = QGroupBox() + # self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_acoustic_profile) + # + # self.groupbox_rayleigh_criterion = QGroupBox() + # self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_rayleigh_criterion) + # + # self.groupbox_window_size = QGroupBox() + # self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_window_size) + # + # # --- Groupbox acoustic profile --- + # + # self.gridLayout_groupbox_acoustic_profile = QGridLayout(self.groupbox_acoustic_profile) + # + # # self.checkbox_SNR_criterion = QCheckBox() + # self.label_SNR_criterion = QLabel() + # self.gridLayout_groupbox_acoustic_profile.addWidget(self.label_SNR_criterion, 0, 0, 1, 1) + # self.spinbox_SNR_criterion = QSpinBox() + # self.spinbox_SNR_criterion.setRange(0, 9999) + # self.spinbox_SNR_criterion.setValue(0) + # # self.spinbox_SNR_criterion.setDisabled(True) + # self.gridLayout_groupbox_acoustic_profile.addWidget(self.spinbox_SNR_criterion, 0, 1, 1, 1) + # + # # self.spinbox_SNR_criterion.valueChanged.connect(self.remove_point_with_snr_filter) + # + # self.pushbutton_snr_filter = QPushButton() + # self.pushbutton_snr_filter.setText("Apply SNR") + # self.gridLayout_groupbox_acoustic_profile.addWidget(self.pushbutton_snr_filter, 0, 2, 1, 1) + # + # self.pushbutton_snr_filter.clicked.connect(self.remove_point_with_snr_filter) + # # self.pushbutton_snr_filter.clicked.connect(self.update_plot_profile) + # # self.pushbutton_snr_filter.clicked.connect(self.update_plot_profile_position_on_transect) + # + # # --- Groupbox Rayleigh criterion --- + # + # self.gridLayout_rayleigh_criterion = QGridLayout(self.groupbox_rayleigh_criterion) + # + # self.label_Rayleigh_criterion = QLabel() + # self.label_Rayleigh_criterion.setText("/² <=") + # self.gridLayout_rayleigh_criterion.addWidget(self.label_Rayleigh_criterion, 0, 0, 1, 1) + # + # self.spinbox_rayleigh_criterion = QSpinBox() + # self.spinbox_rayleigh_criterion.setRange(0, 9999) + # self.spinbox_rayleigh_criterion.setValue(10) + # self.gridLayout_rayleigh_criterion.addWidget(self.spinbox_rayleigh_criterion, 0, 1, 1, 1) + # + # self.label_4pi = QLabel() + # self.label_4pi.setText("% x 4/pi") + # self.gridLayout_rayleigh_criterion.addWidget(self.label_4pi, 0, 2, 1, 1) + # + # self.pushbutton_despiking_signal = QPushButton() + # self.pushbutton_despiking_signal.setText("Despiking the signal") + # self.gridLayout_rayleigh_criterion.addWidget(self.pushbutton_despiking_signal, 0, 3, 1, 1) + # + # # --- Groupbox Window size --- + # + # # self.horizontalLayout_groupbox_window_size = QHBoxLayout(self.groupbox_window_size) + # self.gridLayout_groupbox_window_size = QGridLayout(self.groupbox_window_size) + # + # self.label_signal_averaging_horizontal = QLabel() + # self.label_signal_averaging_horizontal.setText("Horizontal +/- ") + # # self.horizontalLayout_groupbox_window_size.addWidget(self.label_signal_averaging_over) + # self.gridLayout_groupbox_window_size.addWidget(self.label_signal_averaging_horizontal, 0, 0, 1, 1) + # self.spinbox_average_horizontal = QSpinBox() + # self.spinbox_average_horizontal.setRange(0, 9999) + # self.spinbox_average_horizontal.setValue(0) + # # self.horizontalLayout_groupbox_window_size.addWidget(self.spinbox_average) + # self.gridLayout_groupbox_window_size.addWidget(self.spinbox_average_horizontal, 0, 1, 1, 1) + # self.label_cells_horizontal = QLabel() + # self.label_cells_horizontal.setText("cells = +/- ? sec") + # # self.horizontalLayout_groupbox_window_size.addWidget(self.label_cells) + # self.gridLayout_groupbox_window_size.addWidget(self.label_cells_horizontal, 0, 2, 1, 1) + # + # # self.label_signal_averaging_vertical = QLabel() + # # self.label_signal_averaging_vertical.setText("Vertical +/- ") + # # # self.horizontalLayout_groupbox_window_size.addWidget(self.label_signal_averaging_over) + # # self.gridLayout_groupbox_window_size.addWidget(self.label_signal_averaging_vertical, 1, 0, 1, 1) + # # self.spinbox_average_vertical = QSpinBox() + # # self.spinbox_average_vertical.setRange(0, 9999) + # # self.spinbox_average_vertical.setValue(0) + # # # self.horizontalLayout_groupbox_window_size.addWidget(self.spinbox_average) + # # self.gridLayout_groupbox_window_size.addWidget(self.spinbox_average_vertical, 1, 1, 1, 1) + # # self.label_cells_vertical = QLabel() + # # self.label_cells_vertical.setText("cells = +/- ? sec") + # # # self.horizontalLayout_groupbox_window_size.addWidget(self.label_cells) + # # self.gridLayout_groupbox_window_size.addWidget(self.label_cells_vertical, 1, 2, 1, 1) + # + # # self.spinbox_average.valueChanged.connect(self.compute_averaged_profile) + # + # self.pushbutton_average = QPushButton() + # self.pushbutton_average.setText("Apply averaging") + # # self.pushbutton_snr_filter.setDisabled(True) + # # self.horizontalLayout_groupbox_window_size.addWidget(self.pushbutton_average) + # self.gridLayout_groupbox_window_size.addWidget(self.pushbutton_average, 0, 3, 2, 1) + # + # self.pushbutton_average.clicked.connect(self.compute_averaged_profile) + # # self.pushbutton_average.clicked.connect(self.update_plot_profile_position_on_transect) + # # self.pushbutton_average.clicked.connect(self.plot_averaged_profile) + # + # # ++++++++++++++++++++++++++++++++++++ + # # +++ --- GroupBox FCB options --- +++ + # # ++++++++++++++++++++++++++++++++++++ + # + # self.verticalLayout_groupbox_FCBoption = QVBoxLayout(self.groupbox_FCBoption) + # + # self.groupbox_water_attenuation = QGroupBox() + # self.verticalLayout_groupbox_FCBoption.addWidget(self.groupbox_water_attenuation) + # + # self.groupbox_fit_regression_line = QGroupBox() + # self.verticalLayout_groupbox_FCBoption.addWidget(self.groupbox_fit_regression_line) + # + # # --- Groupbox water attenuation --- + # + # self.gridLayout_groupbox_water_attenuation = QGridLayout(self.groupbox_water_attenuation) + # + # 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.gridLayout_groupbox_water_attenuation.addWidget(self.combobox_water_attenuation_model, 0, 0, 1, 1) + # + # self.label_temperature_water_attenation = QLabel() + # self.gridLayout_groupbox_water_attenuation.addWidget(self.label_temperature_water_attenation, 0, 1, 1, 1) + # + # self.spinbox_temperature_water_attenuation = QSpinBox() + # self.gridLayout_groupbox_water_attenuation.addWidget(self.spinbox_temperature_water_attenuation, 0, 2, 1, 1) + # + # self.label_degre_celsius = QLabel() + # self.label_degre_celsius.setText("°C") + # self.gridLayout_groupbox_water_attenuation.addWidget(self.label_degre_celsius, 0, 3, 1, 1) + # + # self.combobox_freq_for_water_attenuation = QComboBox() + # # self.combobox_water_attenuation.currentIndexChanged.connect(self.alpha_value_changed) + # self.gridLayout_groupbox_water_attenuation.addWidget(self.combobox_freq_for_water_attenuation, 1, 0, 1, 1) + # + # self.pushbutton_water_attenuation = QPushButton() + # self.pushbutton_water_attenuation.setText("Compute \u03B1w") + # self.gridLayout_groupbox_water_attenuation.addWidget(self.pushbutton_water_attenuation, 1, 1, 1, 1) + # self.pushbutton_water_attenuation.clicked.connect(self.compute_water_attenuation) + # + # self.label_water_attenuation = QLabel() + # self.label_water_attenuation.setText("\u03B1w = 0.00 dB/m") + # self.label_water_attenuation.setFont(QFont("Ubuntu", 14, QFont.Normal)) + # self.gridLayout_groupbox_water_attenuation.addWidget(self.label_water_attenuation, 1, 2, 1, 1) + # + # # --- Groupbox fit regression line --- + # + # self.gridLayout_groupbox_fit_regression = QGridLayout(self.groupbox_fit_regression_line) + # + # self.label_alphaS_expression = QLabel() + # # self.label_alphaS_expression.setText("For homogeneous suspension: dFCB/dr = -2\u03B1s<\sub>") + # self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_expression, 0, 0, 1, 5) + # + # self.combobox_frequency_compute_alphaS = QComboBox() + # self.gridLayout_groupbox_fit_regression.addWidget(self.combobox_frequency_compute_alphaS, 1, 0, 1, 1) + # + # self.label_alphaS_computation_from = QLabel() + # self.label_alphaS_computation_from.setText("From -") + # self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_computation_from, 1, 1, 1, 1) + # + # self.spinbox_alphaS_computation_from = QDoubleSpinBox() + # self.spinbox_alphaS_computation_from.setRange(0, 9999) + # self.gridLayout_groupbox_fit_regression.addWidget(self.spinbox_alphaS_computation_from, 1, 2, 1, 1) + # + # self.label_alphaS_computation_to = QLabel() + # self.label_alphaS_computation_to.setText("To -") + # self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_computation_to, 1, 3, 1, 1) + # + # self.spinbox_alphaS_computation_to = QDoubleSpinBox() + # self.gridLayout_groupbox_fit_regression.addWidget(self.spinbox_alphaS_computation_to, 1, 4, 1, 1) + # + # self.pushbutton_plot_FCB = QPushButton() + # self.pushbutton_plot_FCB.setText("Plot FCB") + # self.gridLayout_groupbox_fit_regression.addWidget(self.pushbutton_plot_FCB, 2, 0, 1, 1) + # + # self.pushbutton_plot_FCB.clicked.connect(self.compute_FCB) + # # self.pushbutton_plot_FCB.clicked.connect(self.plot_FCB) + # + # self.pushbutton_fit_linear_regression = QPushButton() + # self.pushbutton_fit_linear_regression.setText("Fit && Compute \u03B1s") + # self.gridLayout_groupbox_fit_regression.addWidget(self.pushbutton_fit_linear_regression, 2, 1, 1, 1) + # + # self.pushbutton_fit_linear_regression.clicked.connect(self.fit_FCB_profile_with_linear_regression_and_compute_alphaS) + # self.pushbutton_fit_linear_regression.clicked.connect(self.plot_FCB) + # + # self.label_alphaS = QLabel() + # self.label_alphaS.setText("\u03B1s = " + "0.0" + "dB/m") + # self.label_alphaS.setFont(QFont("Ubuntu", 14, QFont.Normal)) + # self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS, 2, 3, 1, 1) + # + # # self.verticalLayout_groupbox_fit_regression + # + # # -------------------------------------------------------------------------------------------------------------- + # ### --- Layout of groupbox in the Right vertical layout box + # + # # Plot Profiles + # # ------------------------- + # # Plot averaged profile + # # ------------------------- + # # Plot FCB profiles + # + # self.groupbox_plot_profile = QGroupBox() + # self.verticalLayout_Right.addWidget(self.groupbox_plot_profile) + # + # self.groupbox_plot_averaged_profile = QGroupBox() + # self.verticalLayout_Right.addWidget(self.groupbox_plot_averaged_profile) + # + # self.groupbox_FCB_profile = QGroupBox() + # self.verticalLayout_Right.addWidget(self.groupbox_FCB_profile) + # + # # +++++++++++++++++++++++++++++++++++++ + # # +++ --- GroupBox Plot profile --- +++ + # # +++++++++++++++++++++++++++++++++++++ + # + # self.verticalLayout_groupbox_plot_profile = QVBoxLayout(self.groupbox_plot_profile) + # + # self.canvas_profile = None + # self.scroll_profile = None + # + # # # 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.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) + # + # # ++++++++++++++++++++++++++++++++++++++++++++++ + # # +++ --- GroupBox Plot averaged profile --- +++ + # # ++++++++++++++++++++++++++++++++++++++++++++++ + # + # self.verticalLayout_groupbox_plot_averaged_profile = QVBoxLayout(self.groupbox_plot_averaged_profile) + # + # self.canvas_averaged_profile = None + # self.scroll_averaged_profile = None + # + # # 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) + # + # # ++++++++++++++++++++++++++++++++++++++++++++++ + # # +++ --- GroupBox Plot FCB profile --- +++ + # # ++++++++++++++++++++++++++++++++++++++++++++++ + # + # self.verticalLayout_groupbox_plot_FCB_profile = QVBoxLayout(self.groupbox_FCB_profile) + # + # self.canvas_FCB_profile = None + # self.scroll_FCB_profile = None + # + # # 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) + # # + # + # + # # --- Slider ---- + # + # self.horizontalLayout_slider = QHBoxLayout() + # self.verticalLayout_Right.addLayout(self.horizontalLayout_slider) + # + # self.pushbutton_slider_left = QPushButton() + # self.pushbutton_slider_left.setIcon(icon_triangle_left) + # self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left) + # + # self.pushbutton_slider_right = QPushButton() + # self.pushbutton_slider_right.setIcon(icon_triangle_right) + # self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) + # + # self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right) + # + # self.pushbutton_slider_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 = QLineEdit() + # self.lineEdit_slider.setText("1") + # # # self.lineEdit_slider_acoustic_profile.setFixedWidth(self.pushButton_slider_plotprofile_left.size().width()) + # self.lineEdit_slider.setFixedWidth(50) + # self.horizontalLayout_slider.addWidget(self.lineEdit_slider) + # + # self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit) + # + # self.slider = QSlider() + # self.horizontalLayout_slider.addWidget(self.slider, 9) + # + # self.slider.setOrientation(Qt.Horizontal) + # # # self.slider_plotprofile.setTickPosition(QSlider.TicksBelow) + # self.slider.setCursor(Qt.OpenHandCursor) + # self.slider.setMinimum(1) + # # self.slider.setMaximum(stg.nb_profiles)#self.model.BS_averaged_cross_section_corr.V.shape[2]) + # self.slider.setTickInterval(1) + # self.slider.setValue(1) + # + # self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) + # self.slider.valueChanged.connect(self.update_plot_profile_position_on_transect) + # self.slider.valueChanged.connect(self.update_plot_profile) + # # self.slider.valueChanged.connect(self.update_plot_averaged_profile) + # self.slider.valueChanged.connect(self.update_plot_FCB) + + # .... UP TO HERE. END OF COMMENT OF OLD LINE CODE self.retranslate_signal_processing_tab() # # -------------------- Functions for Signal processing Tab -------------------- + # def retranslate_signal_processing_tab(self): + # self.pushbutton_load_data.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.label_SNR_criterion.setText(_translate("CONSTANT_STRING", cs.SNR_CRITERION)) + # + # self.groupbox_window_size.setTitle(_translate("CONSTANT_STRING", cs.WINDOW_SIZE)) + # # self.label_averageH.setText(_translate("CONSTANT_STRING", cs.HORIZONTAL) + ": +/-") + # # self.label_cells.setText(_translate("CONSTANT_STRING", cs.CELLS) + " = +/- ? sec") + # + # 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 retranslate_signal_processing_tab(self): - self.pushbutton_load_data.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_study_data.setTitle("Study data") + self.groupbox_download_noise_file.setTitle("Download noise file") + self.groupbox_compute_noise_from_profile_tail.setTitle("Compute Noise from profile tail") + self.groupbox_compute_noise_from_value.setTitle("Compute Noise from value") + # self.groupbox_plot_noise_data.setTitle("Plot noise data") - self.groupbox_post_processing.setTitle(_translate("CONSTANT_STRING", cs.POST_PROCESSING)) + # 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_acoustic_profile.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_PROFILE)) - # self.checkbox_substract_noise.setText(_translate("CONSTANT_STRING", cs.SUBTRACT_THE_NOISE)) - self.label_SNR_criterion.setText(_translate("CONSTANT_STRING", cs.SNR_CRITERION)) + self.groupbox_plot_Noise_SNR.setTitle("Plot Noise and SNR 2D fields") + # self.pushbutton_plot_SNR.setText("Plot SNR") - self.groupbox_window_size.setTitle(_translate("CONSTANT_STRING", cs.WINDOW_SIZE)) - # self.label_averageH.setText(_translate("CONSTANT_STRING", cs.HORIZONTAL) + ": +/-") - # self.label_cells.setText(_translate("CONSTANT_STRING", cs.CELLS) + " = +/- ? sec") + self.pushbutton_Apply_SNR_filter.setText("Apply SNR") + self.groupbox_plot_BS_signal_filtered_with_SNR.setTitle("Plot BS signal filtered with SNR") - self.groupbox_rayleigh_criterion.setTitle(_translate("CONSTANT_STRING", cs.RAYLEIGH_CRITERION)) - # self.checkbox_despiked_acoustic_signal.setText(_translate("CONSTANT_STRING", cs.DESPIKING)) + self.groupbox_pre_processing.setTitle("Pre-processing") + self.groupbox_Rayleigh_criterion.setTitle("Rayleigh criterion") + self.groupbox_window_size.setTitle("Window size") - self.groupbox_FCBoption.setTitle(_translate("CONSTANT_STRING", cs.FCB_OPTIONS)) + self.groupbox_plot_pre_processed_data.setTitle("Plot pre-processed data") - 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_list_pre_processed_data.setTitle("List pre-processed data") + + def onClicked_radiobutton_noise_data(self): + # radiobutton = self.sender() + # if radiobutton.isChecked(): + if self.radiobutton_file.isChecked(): + self.groupbox_download_noise_file.setVisible(True) + self.groupbox_compute_noise_from_profile_tail.setVisible(False) + self.groupbox_compute_noise_from_value.setVisible(False) + + elif self.radiobutton_profile_tail.isChecked(): + self.groupbox_download_noise_file.setVisible(False) + self.groupbox_compute_noise_from_profile_tail.setVisible(True) + self.groupbox_compute_noise_from_value.setVisible(False) + + elif self.radiobutton_value.isChecked(): + self.groupbox_download_noise_file.setVisible(False) + self.groupbox_compute_noise_from_profile_tail.setVisible(False) + self.groupbox_compute_noise_from_value.setVisible(True) + + def open_dialog_box(self): + + if self.sender().objectName() == "pushbutton_noise_file": + 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]) + + try: + stg.path_BS_noise_data = dir_name + stg.filename_BS_noise_data = name + print("stg.path_BS_noise_data : ", stg.path_BS_noise_data) + print("stg.filename_BS_noise_data : ", stg.filename_BS_noise_data) + self.load_noise_data_and_compute_SNR() + + except ValueError as e: + print("error = ", e) + msgBox = QMessageBox() + msgBox.setWindowTitle("Download Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Please select a file") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + + else: + self.lineEdit_noise_file.setText(stg.filename_BS_raw_data) + self.lineEdit_noise_file.setToolTip(stg.path_BS_raw_data) + self.plot_noise() + self.plot_transect_with_SNR_data() + self.combobox_freq_noise.addItems([f for f in stg.freq_text]) + self.combobox_freq_noise.currentIndexChanged.connect(self.plot_noise) + self.spinbox_SNR_criterion.setValue(2) + self.remove_point_with_snr_filter() + + self.combobox_frequency_profile.addItems([f for f in stg.freq_text]) + self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_profile_and_position_on_transect_with_slider) + self.slider.setMaximum(stg.t.shape[1]) + + self.compute_averaged_BS_data() + + self.plot_profile_and_position_on_transect_with_slider() + + def load_noise_data_and_compute_SNR(self): + + noise_data = AcousticDataLoader(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data) + stg.BS_noise_raw_data = noise_data._BS_raw_data + stg.date_noise = noise_data._date + stg.hour_noise = noise_data._hour + stg.time_snr = noise_data._time + stg.time_snr_reshape = stg.time_reshape + print("stg.time_snr.shape : ", stg.time_snr.shape) + + if stg.BS_stream_bed.size == 0: + noise = np.zeros(stg.BS_cross_section.shape) + for f, _ in enumerate(noise_data._freq): + noise[f, :, :] = np.mean(stg.BS_noise_raw_data[f, :, :], axis=(0, 1)) + stg.BS_noise_averaged_data = noise + stg.SNR_cross_section = np.divide((stg.BS_cross_section - stg.BS_noise_averaged_data) ** 2, stg.BS_noise_averaged_data ** 2) + stg.SNR_reshape = np.reshape(stg.SNR_cross_section, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), order="F") + else: + noise = np.zeros(stg.BS_stream_bed.shape) + for f, _ in enumerate(noise_data._freq): + noise[f, :, :] = np.mean(stg.BS_noise_raw_data[f, :, :], axis=(0, 1)) + stg.BS_noise_averaged_data = noise + stg.SNR_stream_bed = np.divide((stg.BS_stream_bed - stg.BS_noise_averaged_data) ** 2, + stg.BS_noise_averaged_data ** 2) + stg.SNR_reshape = np.reshape(stg.SNR_stream_bed, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), + order="F") + + def plot_noise(self): + self.horizontalLayout_groupbox_plot_noise_data.removeWidget(self.canvas_noise) + + self.fig_noise, self.axis_noise = plt.subplots(nrows=1, ncols=1, layout="constrained") + self.canvas_noise = FigureCanvas(self.fig_noise) + + self.horizontalLayout_groupbox_plot_noise_data.addWidget(self.canvas_noise) + + val_min = np.nanmin(stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :]) + val_max = np.nanmax(stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_noise.pcolormesh(stg.time_snr[0, :], + -stg.r[self.combobox_freq_noise.currentIndex(), :], + stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + self.axis_noise.tick_params(axis='both', which='minor', labelsize=10) + + # cbar = self.fig_noise.colorbar(pcm, ax=self.axis_noise, shrink=1, location='top') + # cbar.set_label(label='Noise signal (V)', rotation=0, labelpad=8) + + # self.axis_noise.text(1, .70, stg.freq_text[self.combobox_freq_noise.currentIndex()], + # fontsize=10, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_noise.transAxes) + + def plot_transect_with_SNR_data(self): + # --- Condition if table is not filled --- + if not self.lineEdit_noise_file.text(): + msgBox = QMessageBox() + msgBox.setWindowTitle("Plot transect Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Load data before plot transect 2D field") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + + elif self.canvas_SNR == None: + + self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq.shape[0], ncols=1, sharex=True, sharey=False, layout='constrained') + self.canvas_SNR = FigureCanvas(self.fig_SNR) + # self.verticalLayout_groupbox_plot_Noise_SNR.addWidget(self.canvas_SNR) + + # self.verticalLayout_groupbox_plot_Noise_SNR.removeWidget(self.scroll_SNR) + self.scroll_SNR = QScrollArea() + self.scroll_SNR.setWidget(self.canvas_SNR) + self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + self.scroll_SNR.setAlignment(Qt.AlignCenter) + self.verticalLayout_groupbox_SNR.addWidget(self.scroll_SNR) + + x, y = np.meshgrid(stg.t[0, :], stg.r[0, :]) + + for f, _ in enumerate(stg.freq): + + if stg.SNR_stream_bed.size == 0: + + val_min = np.nanmin(stg.SNR_cross_section[f, :, :]) + val_max = np.nanmax(stg.SNR_cross_section[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, stg.SNR_cross_section[f, :, :], levels, cmap='gist_rainbow', norm=norm)) + + else: + + val_min = np.nanmin(stg.SNR_stream_bed[f, :, :]) + val_max = np.nanmax(stg.SNR_stream_bed[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, stg.SNR_stream_bed[f, :, :], levels, cmap='gist_rainbow', + norm=norm)) + + self.axis_SNR[f].text(1, .70, stg.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('Time (sec)', fontsize=10) + self.fig_SNR.supylabel('Depth (m)', fontsize=10) + 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() + + # # --- Plot red solid line on transect to visualize position of plotted profile --- + # self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + # stg.time[self.combobox_frequency_profile.currentIndex(), 0] * np.ones( + # stg.r.shape[1]), + # -stg.r[self.combobox_frequency_profile.currentIndex(), :], + # color='red', linestyle="solid", linewidth=2) + + def remove_point_with_snr_filter(self): + + if (stg.SNR_cross_section.size == 0) and (stg.SNR_stream_bed.size == 0): + msgBox = QMessageBox() + msgBox.setWindowTitle("SNR filter Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Load Noise data from acoustic data tab before using SNR filter") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + + else: + + if stg.BS_stream_bed.size == 0: + + stg.BS_cross_section_SNR_filter = deepcopy(stg.BS_cross_section) + # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) + # stg.SNR_data_average = np.divide( + # (stg.BS_stream_bed_SNR_filter - stg.Noise_data) ** 2, stg.Noise_data ** 2) + + for f, _ in enumerate(stg.freq): + stg.BS_cross_section_SNR_filter[ + f, + np.where(stg.SNR_cross_section[f, :, :] < self.spinbox_SNR_criterion.value())[0], + np.where(stg.SNR_cross_section[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ + = np.nan + + else: + + stg.BS_stream_bed_SNR_filter = deepcopy(stg.BS_stream_bed) + # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) + # stg.SNR_data_average = np.divide( + # (stg.BS_stream_bed_SNR_filter - stg.Noise_data) ** 2, stg.Noise_data ** 2) + + for f, _ in enumerate(stg.freq): + stg.BS_stream_bed_SNR_filter[ + f, + np.where(stg.SNR_stream_bed[f, :, :] < self.spinbox_SNR_criterion.value())[0], + np.where(stg.SNR_stream_bed[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ + = np.nan + + + # elif stg.BS_stream_bed_averaged.size != 0: + # stg.BS_stream_bed_SNR_filter = deepcopy(stg.BS_stream_bed_averaged) + # BS_noise_cross_section = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) + # print("BS_noise_cross_section.shape ", BS_noise_cross_section.shape) + # stg.SNR_data_average = np.divide( + # (stg.BS_stream_bed_SNR_filter - BS_noise_cross_section) ** 2, BS_noise_cross_section ** 2) + # + # print(stg.SNR_data_average[0, :, :]) + + # fig, ax = plt.subplots(nrows=1, ncols=1) + # x, y = np.meshgrid(list(range(stg.SNR_data_average.shape[2])), + # list(range(stg.SNR_data_average.shape[1]))) + # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + # bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2] + # norm = BoundaryNorm(boundaries=bounds, ncolors=300) + # cf = ax.contourf(x, -y, stg.SNR_data_average[0, :, :], cmap='gist_rainbow') # , levels, norm=norm) + # cbar = fig.colorbar(cf, ax=ax, shrink=1, location='right') + # plt.show() + # + # for f, _ in enumerate(stg.freq): + # print("----------------------------------------------") + # print(np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[0]) + # print(np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1]) + # stg.BS_stream_bed_SNR_filter[ + # f, + # np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[0], + # np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ + # = np.nan + + self.plot_BS_signal_filtered_with_SNR() + # self.update_plot_profile_position_on_transect() + # self.update_plot_averaged_profile() + + self.compute_averaged_BS_data() + self.plot_profile_and_position_on_transect_with_slider() + + + def plot_BS_signal_filtered_with_SNR(self): + + self.verticalLayout_groupbox_BS_SNR_filter.removeWidget(self.scroll_BS) + + self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq.shape[0], ncols=1, sharex=True, sharey=False) + self.canvas_BS = FigureCanvas(self.fig_BS) + # self.verticalLayout_groupbox_plot_SNR.addWidget(self.canvas_SNR) + + # self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR) + self.scroll_BS = QScrollArea() + self.scroll_BS.setWidget(self.canvas_BS) + self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + self.scroll_BS.setAlignment(Qt.AlignCenter) + self.verticalLayout_groupbox_BS_SNR_filter.addWidget(self.scroll_BS) + + for f, _ in enumerate(stg.freq): + + if stg.BS_stream_bed.size == 0: + + val_min = np.nanmin(stg.BS_cross_section_SNR_filter[f, :, :]) + val_max = np.nanmax(stg.BS_cross_section_SNR_filter[f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.t[f, :], -stg.r[f, :], stg.BS_cross_section_SNR_filter[f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + else: + + val_min = np.nanmin(stg.BS_stream_bed_SNR_filter[f, :, :]) + val_max = np.nanmax(stg.BS_stream_bed_SNR_filter[f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.t[f, :], -stg.r[f, :], stg.BS_stream_bed_SNR_filter[f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + self.axis_BS[f].plot(stg.t[f, :], -stg.r_bottom, + color='black', linewidth=1, linestyle="solid") + + self.axis_BS[f].text(1, .70, stg.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('Time (sec)', 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='Acoustic backscatter signal (V)', rotation=270, labelpad=10) + self.fig_BS.canvas.draw_idle() + + def compute_averaged_BS_data(self): + + if stg.BS_cross_section.size == 0: + msgBox = QMessageBox() + msgBox.setWindowTitle("Average Backscatter signal Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Load data from acoustic data tab before averaging backscatter signal") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + else: + + filter_convolve = np.ones(2*self.spinbox_average_horizontal.value()+1) + print(filter_convolve) + + if stg.BS_stream_bed_SNR_filter.size != 0: + + stg.BS_stream_bed_averaged_SNR = deepcopy(stg.BS_stream_bed_SNR_filter) + # print(f"1/ stg.BS_stream_bed_averaged : {stg.BS_stream_bed_averaged_SNR}") + for f, _ in enumerate(stg.freq): + for i in range(stg.r.shape[1]): + stg.BS_stream_bed_averaged_SNR[f, i, :] \ + = convolve1d(stg.BS_stream_bed_SNR_filter[f, i, :], weights=filter_convolve) / len(filter_convolve) + # stg.BS_stream_bed_averaged[i, f, :] \ + # = convolve1d(stg.BS_cross_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0] + + return stg.BS_stream_bed_averaged_SNR + + elif stg.BS_cross_section_SNR_filter.size != 0: + + stg.BS_cross_section_averaged_SNR = deepcopy(stg.BS_cross_section_SNR_filter) + print(f"2/ stg.BS_cross_section_averaged : {stg.BS_cross_section_averaged_SNR}") + for f, _ in enumerate(stg.freq): + for i in range(stg.r.shape[1]): + stg.BS_cross_section_averaged_SNR[f, i, :] \ + = convolve1d(stg.BS_cross_section_SNR_filter[f, i, :], + weights=filter_convolve) / len(filter_convolve) + + return stg.BS_cross_section_averaged_SNR + + elif stg.BS_stream_bed.size != 0: + + stg.BS_stream_bed_averaged = deepcopy(stg.BS_stream_bed) + # print(f"3/ stg.BS_stream_bed_averaged : {stg.BS_stream_bed_averaged.shape}") + print(stg.BS_stream_bed_averaged[0, 10, :50]) + for f, _ in enumerate(stg.freq): + for i in range(stg.r.shape[1]): + stg.BS_stream_bed_averaged[f, i, :] \ + = convolve1d(stg.BS_stream_bed[f, i, :], + weights=filter_convolve) / len(filter_convolve) + print(stg.BS_stream_bed_averaged[0, 10, :50]) + + return stg.BS_stream_bed_averaged + + elif stg.BS_cross_section.size != 0: + + stg.BS_cross_section_averaged = deepcopy(stg.BS_cross_section) + # print(f"4/ stg.BS_cross_section_averaged : {stg.BS_cross_section_averaged.shape}") + for f, _ in enumerate(stg.freq): + for i in range(stg.r.shape[1]): + stg.BS_cross_section_averaged[f, i, :] \ + = convolve1d(stg.BS_cross_section[f, i, :], + weights=filter_convolve) / len(filter_convolve) + + return stg.BS_cross_section_averaged + + if stg.ABS_name == "Aquascat 1000R": + self.label_cells_horizontal.clear() + self.label_cells_horizontal.setText( + "cells = +/- " + str((self.spinbox_average_horizontal.value() // 2)*(1/stg.nb_profiles_per_sec)) + " sec") + + # self.plot_profile_and_position_on_transect_with_slider() + + def plot_profile_and_position_on_transect_with_slider(self): + + # --- Update label "Profile N / max(N)" --- + self.label_profile_number.clear() + self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum())) + + self.axis_profile[0].cla() + self.axis_profile[1].cla() + + if stg.BS_stream_bed_averaged_SNR.size != 0: + + # --- Plot profile --- + self.axis_profile[0].plot( + stg.BS_stream_bed_averaged_SNR[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()], + fontsize=10, fontweight='bold', fontname="Ubuntu", + fontstyle="normal", c="black", alpha=0.2, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_profile[0].transAxes) + + # --- Plot transect with profile position --- + self.axis_profile[1].cla() + val_min = np.nanmin(stg.BS_stream_bed_averaged_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax(stg.BS_stream_bed_averaged_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + stg.BS_stream_bed_averaged_SNR[self.combobox_frequency_profile.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif stg.BS_cross_section_averaged_SNR.size != 0: + # --- Plot profile --- + self.axis_profile[0].plot( + stg.BS_cross_section_averaged_SNR[self.combobox_frequency_profile.currentIndex(), :, + self.slider.value() - 1], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()], + fontsize=10, fontweight='bold', fontname="Ubuntu", + fontstyle="normal", c="black", alpha=0.2, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_profile[0].transAxes) + + # --- Plot transect with profile position --- + self.axis_profile[1].cla() + val_min = np.nanmin(stg.BS_cross_section_averaged_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax(stg.BS_cross_section_averaged_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + stg.BS_cross_section_averaged_SNR[ + self.combobox_frequency_profile.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif stg.BS_stream_bed_SNR_filter.size != 0: + + # --- Plot profile --- + self.axis_profile[0].plot( + stg.BS_stream_bed_SNR_filter[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()], + fontsize=10, fontweight='bold', fontname="Ubuntu", + fontstyle="normal", c="black", alpha=0.2, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_profile[0].transAxes) + + # --- Plot transect with profile position --- + self.axis_profile[1].cla() + val_min = np.nanmin(stg.BS_stream_bed_SNR_filter[self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax(stg.BS_stream_bed_SNR_filter[self.combobox_frequency_profile.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + stg.BS_stream_bed_SNR_filter[self.combobox_frequency_profile.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif stg.BS_cross_section_SNR_filter.size != 0: + # --- Plot profile --- + self.axis_profile[0].plot( + stg.BS_cross_section_SNR_filter[self.combobox_frequency_profile.currentIndex(), :, + self.slider.value() - 1], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()], + fontsize=10, fontweight='bold', fontname="Ubuntu", + fontstyle="normal", c="black", alpha=0.2, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_profile[0].transAxes) + + # --- Plot transect with profile position --- + self.axis_profile[1].cla() + val_min = np.nanmin(stg.BS_cross_section_SNR_filter[self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax(stg.BS_cross_section_SNR_filter[self.combobox_frequency_profile.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + stg.BS_cross_section_SNR_filter[ + self.combobox_frequency_profile.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + self.axis_profile[0].set_xlabel("Acoustic Backscatter Signal (V)") + self.axis_profile[0].set_ylabel("Depth (m)") + + self.axis_profile[1].plot( + stg.t[self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * np.ones(stg.r.shape[1]), + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + color='red', linestyle="solid", linewidth=2) + + if stg.r_bottom.size != 0: + self.axis_profile[1].plot(stg.t[self.combobox_frequency_profile.currentIndex(), :], + -stg.r_bottom, + color='black', linewidth=1, linestyle="solid") + + self.axis_profile[1].set_xticks([]) + self.axis_profile[1].set_yticks([]) + + self.figure_profile.canvas.draw_idle() - 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)) # ------------------------------------- Connect Push Button Load Data + Slider ------------------------------------- @@ -624,6 +1491,18 @@ class SignalProcessingTab(QWidget): self.lineEdit_slider.setText(str(self.slider.value())) + + + # ______ _______ + # | | | | \ + # | | | | \ + # | | | | | + # | | | | / + # |______| |________ |________/ + + # COMMENT OLD CODE LINE FROM HERE .... + + def compute_BS_data_section(self): if stg.BS_cross_section.size == 0: msgBox = QMessageBox() @@ -662,78 +1541,7 @@ class SignalProcessingTab(QWidget): # ---------------------------------------- Connect Groupbox filter with SNR ---------------------------------------- - def remove_point_with_snr_filter(self): - if stg.SNR_data.size == 0: - msgBox = QMessageBox() - msgBox.setWindowTitle("SNR filter Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Load Noise data from acoustic data tab before using SNR filter") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - - else: - - if stg.BS_stream_bed.size == 0: - - stg.BS_cross_section_SNR_filter = deepcopy(stg.BS_cross_section) - # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) - # stg.SNR_data_average = np.divide( - # (stg.BS_stream_bed_SNR_filter - stg.Noise_data) ** 2, stg.Noise_data ** 2) - - for f, _ in enumerate(stg.freq): - stg.BS_cross_section_SNR_filter[ - f, - np.where(stg.SNR_cross_section[f, :, :] < self.spinbox_SNR_criterion.value())[0], - np.where(stg.SNR_cross_section[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ - = np.nan - - else: - - stg.BS_stream_bed_SNR_filter = deepcopy(stg.BS_stream_bed) - # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) - # stg.SNR_data_average = np.divide( - # (stg.BS_stream_bed_SNR_filter - stg.Noise_data) ** 2, stg.Noise_data ** 2) - - for f, _ in enumerate(stg.freq): - stg.BS_stream_bed_SNR_filter[ - f, - np.where(stg.SNR_cross_section[f, :, :] < self.spinbox_SNR_criterion.value())[0], - np.where(stg.SNR_cross_section[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ - = np.nan - - - # elif stg.BS_stream_bed_averaged.size != 0: - # stg.BS_stream_bed_SNR_filter = deepcopy(stg.BS_stream_bed_averaged) - # BS_noise_cross_section = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) - # print("BS_noise_cross_section.shape ", BS_noise_cross_section.shape) - # stg.SNR_data_average = np.divide( - # (stg.BS_stream_bed_SNR_filter - BS_noise_cross_section) ** 2, BS_noise_cross_section ** 2) - # - # print(stg.SNR_data_average[0, :, :]) - - # fig, ax = plt.subplots(nrows=1, ncols=1) - # x, y = np.meshgrid(list(range(stg.SNR_data_average.shape[2])), - # list(range(stg.SNR_data_average.shape[1]))) - # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - # bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2] - # norm = BoundaryNorm(boundaries=bounds, ncolors=300) - # cf = ax.contourf(x, -y, stg.SNR_data_average[0, :, :], cmap='gist_rainbow') # , levels, norm=norm) - # cbar = fig.colorbar(cf, ax=ax, shrink=1, location='right') - # plt.show() - # - # for f, _ in enumerate(stg.freq): - # print("----------------------------------------------") - # print(np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[0]) - # print(np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1]) - # stg.BS_stream_bed_SNR_filter[ - # f, - # np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[0], - # np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ - # = np.nan - - self.update_plot_profile_position_on_transect() - # self.update_plot_averaged_profile() # ----------------------------------------- Connect Groupbox average data ----------------------------------------- diff --git a/settings.py b/settings.py index bbd5c45..b38d7da 100644 --- a/settings.py +++ b/settings.py @@ -58,6 +58,7 @@ BS_cross_section = np.array([]) # BS data limited with tmin and tmax values BS_stream_bed = np.array([]) # BS_data_section = BS data in the section. Values NaN outside the bottom of the section are deleted BS_noise_cross_section = np.array([]) # BS_noise_cros_section = BS_noise_data[:, :, tmin:tmax] (former Noise_data) SNR_cross_section = np.array([]) # SNR_data = snr[:, :, tmin:tmax] +SNR_stream_bed = np.array([]) t = np.array([]) t_snr = np.array([]) r_bottom = np.array([]) @@ -70,6 +71,8 @@ BS_cross_section_SNR_filter = np.array([[[]]]) # BS data filtered with SNR BS_stream_bed_SNR_filter = np.array([]) # BS data filtered with SNR values (remove point if SNR < value) - bottom is detected BS_cross_section_averaged = np.array([[[]]]) # BS data averaged - bottom is not detected BS_stream_bed_averaged = np.array([]) # BS data averaged - bottom is detected +BS_cross_section_averaged_SNR = np.array([[[]]]) # BS data averaged and filtered with SNR - bottom is not detected +BS_stream_bed_averaged_SNR = np.array([]) # BS data averaged and filtered with SNR - bottom is detected time_average = np.array([]) SNR_data_average = np.array([]) # SNR data computed with BS signal averaged (not with BS raw signal)