From a137bbf0cc183daa315661d572ca351e36641220 Mon Sep 17 00:00:00 2001 From: brahim Date: Mon, 17 Jun 2024 11:09:41 +0200 Subject: [PATCH] Signal processing tab is modified. According to the input data choice, the user can loaded a file for noise data and plot SNR field, BS corrected field with SNR criterion and averaged pre-processed signal. A button is added (close to the combobox of data to processed) to update the input data. --- Model/acoustic_data_loader.py | 2 +- View/acoustic_data_tab.py | 5 + View/signal_processing_tab.py | 2696 ++++++++++++++++++++------------- settings.py | 40 +- 4 files changed, 1685 insertions(+), 1058 deletions(-) diff --git a/Model/acoustic_data_loader.py b/Model/acoustic_data_loader.py index d559951..e068bfd 100644 --- a/Model/acoustic_data_loader.py +++ b/Model/acoustic_data_loader.py @@ -117,7 +117,7 @@ class AcousticDataLoader: print(r2D.shape) return r2D - def reshape_time(self): + def reshape_t(self): # t = np.reshape(np.repeat(self._time, self._r.shape[0]), (self._time.shape[0]*self._r.shape[0], 1)) t = np.zeros((self._r.shape[1] * self._time.shape[1], self._freq.shape[0])) for i, _ in enumerate(self._freq): diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index b9cff3a..d78044c 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -2988,6 +2988,7 @@ class AcousticDataTab(QWidget): self.fig_BS.supxlabel('Time (sec)', fontsize=10) self.fig_BS.supylabel('Depth (m)', fontsize=10) self.fig_BS.canvas.draw_idle() + # self.fig_BS.canvas.flush_events() # plt.close(self.fig_BS) def plot_profile(self): @@ -3083,7 +3084,9 @@ class AcousticDataTab(QWidget): self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.fig_profile.supylabel("Depth (m)") + # self.fig_profile.canvas.draw() self.fig_profile.canvas.draw_idle() + # self.fig_profile.canvas.flush_events() # plt.close(self.fig_profile) elif len(stg.BS_cross_section) != 0: @@ -3144,7 +3147,9 @@ class AcousticDataTab(QWidget): self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.fig_profile.supylabel("Depth (m)") + # self.fig_profile.canvas.draw() self.fig_profile.canvas.draw_idle() + # self.fig_profile.canvas.flush_events() # plt.close(self.fig_profile) def slide_profile_number_to_begin(self): diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index 0b80c9c..a0e518e 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -4,7 +4,7 @@ from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGr QSpinBox, QDoubleSpinBox, QComboBox, QLineEdit, QSlider, QGridLayout, QMessageBox, QScrollArea, QRadioButton, QFileDialog, QSpacerItem, QSizePolicy, QTextEdit) from PyQt5.QtGui import QFont, QIcon, QPixmap -from PyQt5.QtCore import Qt, QCoreApplication +from PyQt5.QtCore import Qt, QCoreApplication, QEvent, pyqtSignal import numpy as np from copy import deepcopy @@ -17,6 +17,8 @@ from matplotlib.colors import LogNorm, BoundaryNorm from scipy import stats from os import path +from View.show_popup_combobox import ComboBoxShowPopUpWindow + import Translation.constant_string as cs from Model.acoustic_data_loader import AcousticDataLoader @@ -30,6 +32,8 @@ class SignalProcessingTab(QWidget): ''' This class generates the Signal Processing Tab ''' + FillCombobox = pyqtSignal() + def __init__(self, widget_tab): super().__init__() @@ -37,6 +41,9 @@ class SignalProcessingTab(QWidget): 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") + self.icon_triangle_left_to_begin = QIcon(self.path_icon + "triangle_left_to_begin.png") + self.icon_triangle_right_to_end = QIcon(self.path_icon + "triangle_right_to_end.png") + self.icon_update = QIcon(self.path_icon + "update.png") ### --- General layout of widgets --- @@ -54,8 +61,8 @@ class SignalProcessingTab(QWidget): self.groupbox_study_data = QGroupBox() self.horizontalLayout_Top.addWidget(self.groupbox_study_data, 2) - self.groupbox_plot_Noise_SNR = QGroupBox() - self.horizontalLayout_Top.addWidget(self.groupbox_plot_Noise_SNR, 4) + self.groupbox_plot_SNR = QGroupBox() + self.horizontalLayout_Top.addWidget(self.groupbox_plot_SNR, 4) self.groupbox_plot_BS_signal_filtered_with_SNR = QGroupBox() self.horizontalLayout_Top.addWidget(self.groupbox_plot_BS_signal_filtered_with_SNR, 4) @@ -67,11 +74,22 @@ class SignalProcessingTab(QWidget): self.verticalLayout_groupbox_study_data = QVBoxLayout(self.groupbox_study_data) self.groupbox_data_to_be_processed = QGroupBox() - self.verticalLayout_groupbox_data_to_be_processed = QVBoxLayout(self.groupbox_data_to_be_processed) + self.horizontalLayout_groupbox_data_to_be_processed = QHBoxLayout(self.groupbox_data_to_be_processed) self.groupbox_data_to_be_processed.setTitle("Data to be processed") - self.textEdit_acoustic_file_to_be_processed = QTextEdit() - self.verticalLayout_groupbox_data_to_be_processed.addWidget(self.textEdit_acoustic_file_to_be_processed) + # 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_fileListWidget = ComboBoxShowPopUpWindow() + self.horizontalLayout_groupbox_data_to_be_processed.addWidget(self.combobox_fileListWidget) + + self.combobox_fileListWidget.ShowPopUpWindowSignal.connect(self.event_combobobx_fileListWidget) + + self.pushbutton_update = QPushButton() + self.pushbutton_update.setIcon(self.icon_update) + self.pushbutton_update.setMaximumWidth(40) + + self.horizontalLayout_groupbox_data_to_be_processed.addWidget(self.pushbutton_update) self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_data_to_be_processed) @@ -144,52 +162,18 @@ class SignalProcessingTab(QWidget): self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_value) - # +++++++++++++++++++++++++++++ - # +++ --- Plot SNR data --- +++ - # +++++++++++++++++++++++++++++ + ### --- Push button plot noise --- - 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) + self.pushbutton_plot_noise = QPushButton() + self.pushbutton_plot_noise.setText("Plot noise") + self.verticalLayout_groupbox_study_data.addWidget(self.pushbutton_plot_noise) ### --- Groupbox SNR criterion --- self.groupbox_SNR_criterion = QGroupBox() + self.groupbox_SNR_criterion.setTitle("SNR filter") self.gridLayout_SNR_criterion = QGridLayout(self.groupbox_SNR_criterion) - self.label_SNR_criterion = QLabel("SNR criterion : ") + self.label_SNR_criterion = QLabel("SNR < ") self.gridLayout_SNR_criterion.addWidget(self.label_SNR_criterion, 0, 0, 1, 1) self.spinbox_SNR_criterion = QSpinBox() self.gridLayout_SNR_criterion.addWidget(self.spinbox_SNR_criterion, 0, 1, 1, 1) @@ -198,16 +182,81 @@ class SignalProcessingTab(QWidget): self.pushbutton_Apply_SNR_filter.clicked.connect(self.remove_point_with_snr_filter) - self.verticalLayout_groupbox_plot_BS_field.addWidget(self.groupbox_SNR_criterion, 2) + self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_SNR_criterion) + + # +++++++++++++++++++++++++++++ + # +++ --- 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.groupbox_plot_SNR.setTitle("Plot SNR") + self.verticalLayout_groupbox_plot_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.canvas_SNR = FigureCanvas() + self.navigationToolBar_SNR = NavigationToolBar(self.canvas_SNR, ) + self.verticalLayout_groupbox_plot_SNR.addWidget(self.navigationToolBar_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_plot_SNR.addWidget(self.scroll_SNR) + + # self.verticalLayout_groupbox_plot_SNR.addWidget(self.groupbox_plot_SNR, 7) + + # ++++++++++++++++++++++++++++++++++++++++++++++ + # +++ --- Plot BS data filtered with SNR --- +++ + # ++++++++++++++++++++++++++++++++++++++++++++++ + + self.groupbox_plot_BS_signal_filtered_with_SNR.setTitle("Plot SNR Filter for recording of acoustic backscatter") + self.verticalLayout_groupbox_plot_BS_field = QVBoxLayout(self.groupbox_plot_BS_signal_filtered_with_SNR) + + # self.verticalLayout_groupbox_plot_BS_field.addWidget(self.groupbox_SNR_criterion, 2) ### --- 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) + # self.groupbox_BS_SNR_filter = QGroupBox() + # self.verticalLayout_groupbox_BS_SNR_filter = QVBoxLayout(self.groupbox_BS_SNR_filter) - self.canvas_BS = None - self.scroll_BS = None + # self.canvas_BS = None + # self.scroll_BS = None - self.verticalLayout_groupbox_plot_BS_field.addWidget(self.groupbox_BS_SNR_filter, 8) + self.canvas_BS = FigureCanvas() + + 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_plot_BS_field.addWidget(self.scroll_BS) + + # self.verticalLayout_groupbox_plot_BS_field.addWidget(self.groupbox_BS_SNR_filter, 8) # -------------------------------------------------------------------------------------------------------------- ### --- Layout of groupbox in the bottom layout box @@ -272,9 +321,6 @@ class SignalProcessingTab(QWidget): self.pushbutton_average.setText("Apply averaging") self.gridLayout_groupbox_window_size.addWidget(self.pushbutton_average, 0, 3, 1, 1) - self.pushbutton_average.clicked.connect(self.compute_averaged_BS_data) - self.pushbutton_average.clicked.connect(self.plot_profile_and_position_on_transect_with_slider) - self.verticalLayout_groupbox_pre_processing.addWidget(self.groupbox_window_size) # +++++++++++++++++++++++++++++++++++++++ @@ -298,9 +344,11 @@ class SignalProcessingTab(QWidget): # --- Figure to plot profiles and BS signal 2D field below--- # self.verticalLayout_groupbox_plot_pre_processed_data.removeWidget(self.canvas_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.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.canvas_profile = FigureCanvas() self.scroll_profile = QScrollArea() self.scroll_profile.setWidget(self.canvas_profile) @@ -312,28 +360,30 @@ class SignalProcessingTab(QWidget): # self.verticalLayout_groupbox_plot_pre_processed_data.addWidget(self.canvas_profile) - # # --- Slider for moving the profile --- + # --- Slider for moving the profile --- self.horizontalLayout_slider = QHBoxLayout() self.verticalLayout_groupbox_plot_pre_processed_data.addLayout(self.horizontalLayout_slider) + self.pushbutton_slider_left_to_begin = QPushButton() + self.pushbutton_slider_left_to_begin.setIcon(self.icon_triangle_left_to_begin) + self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left_to_begin) + self.pushbutton_slider_left = QPushButton() 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(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.lineEdit_slider = QLineEdit() self.lineEdit_slider.setText("1") self.lineEdit_slider.setFixedWidth(50) self.horizontalLayout_slider.addWidget(self.lineEdit_slider) - self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit) + self.pushbutton_slider_right = QPushButton() + self.pushbutton_slider_right.setIcon(self.icon_triangle_right) + self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) + + self.pushbutton_slider_right_to_end = QPushButton() + self.pushbutton_slider_right_to_end.setIcon(self.icon_triangle_right_to_end) + self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right_to_end) self.slider = QSlider() self.horizontalLayout_slider.addWidget(self.slider, 9) @@ -345,10 +395,6 @@ class SignalProcessingTab(QWidget): self.slider.setTickInterval(1) self.slider.setValue(1) - self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) - - self.slider.valueChanged.connect(self.plot_profile_and_position_on_transect_with_slider) - # ++++++++++++++++++++++++++++++++++++++++++ # +++ --- List of pre-processed data --- +++ # ++++++++++++++++++++++++++++++++++++++++++ @@ -358,6 +404,26 @@ class SignalProcessingTab(QWidget): self.textEdit_list_pre_processed_data = QTextEdit() self.verticalLayout_list_pre_processed_data.addWidget(self.textEdit_list_pre_processed_data) + # -------------------------------------------------------------------------------------------------------------- + + # --- Connect signal of widget --- + + self.pushbutton_average.clicked.connect(self.compute_averaged_BS_data) + self.pushbutton_average.clicked.connect(self.plot_profile_and_position_on_transect_with_slider) + + self.pushbutton_slider_left_to_begin.clicked.connect(self.slide_profile_number_to_begin) + + self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left) + + self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit) + + self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right) + + self.pushbutton_slider_right_to_end.clicked.connect(self.slide_profile_number_to_end) + + self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) + self.slider.valueChanged.connect(self.plot_profile_and_position_on_transect_with_slider) + # ______ _______ # | | | | \ @@ -949,7 +1015,7 @@ class SignalProcessingTab(QWidget): # 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_plot_Noise_SNR.setTitle("Plot Noise and SNR 2D fields") + # self.groupbox_plot_Noise_SNR.setTitle("Plot Noise and SNR 2D fields") # self.pushbutton_plot_SNR.setText("Plot SNR") self.pushbutton_Apply_SNR_filter.setText("Apply SNR") @@ -963,6 +1029,50 @@ class SignalProcessingTab(QWidget): self.groupbox_list_pre_processed_data.setTitle("List pre-processed data") + def event_combobobx_fileListWidget(self): + print("self.combobox_fileListWidget.maxCount()", self.combobox_fileListWidget.maxCount()) + print("self.combobox_fileListWidget.count()", self.combobox_fileListWidget.count()) + self.combobox_fileListWidget.clear() + self.combobox_fileListWidget.addItem("") + for i in range(len(stg.filename_BS_raw_data)): + self.combobox_fileListWidget.addItem(stg.filename_BS_raw_data[i]) + + print("len stg.BS_noise_raw_data : ", len(stg.BS_noise_raw_data)) + if len(stg.BS_noise_raw_data) == 0: + stg.BS_noise_raw_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] + print("stg.BS_noise_raw_data : ", stg.BS_noise_raw_data) + print("len stg.BS_noise_raw_data : ", len(stg.BS_noise_raw_data)) + stg.BS_noise_averaged_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] + stg.SNR_raw_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] + stg.SNR_cross_section = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] + stg.SNR_stream_bed = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] + stg.time_noise = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] + stg.noise_method = [0]*(self.combobox_fileListWidget.count() - 1) + elif len(stg.BS_noise_raw_data) < (self.combobox_fileListWidget.count() - 1): + stg.BS_noise_raw_data.append(np.array([])) + stg.BS_noise_averaged_data.append(np.array([])) + stg.SNR_raw_data.append(np.array([])) + stg.SNR_cross_section.append(np.array([])) + stg.SNR_stream_bed.append(np.array([])) + stg.time_noise.append(np.array([])) + stg.noise_method.append(0) + + if (stg.noise_method == 1) or (stg.noise_method == 0): + self.radiobutton_file.setChecked(True) + self.radiobutton_profile_tail.setChecked(False) + self.radiobutton_value.setChecked(False) + elif stg.noise_method == 2: + self.radiobutton_file.setChecked(False) + self.radiobutton_profile_tail.setChecked(True) + self.radiobutton_value.setChecked(False) + elif stg.noise_method == 3: + self.radiobutton_file.setChecked(False) + self.radiobutton_profile_tail.setChecked(False) + self.radiobutton_value.setChecked(True) + + def fill_combobox_fileListWidget(self): + self.combobox_fileListWidget.addItems([stg.filename_BS_raw_data]) + def onClicked_radiobutton_noise_data(self): # radiobutton = self.sender() # if radiobutton.isChecked(): @@ -1007,75 +1117,176 @@ class SignalProcessingTab(QWidget): 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.lineEdit_noise_file.setText(stg.filename_BS_noise_data) + self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_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.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.addItems([f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1]]) self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_profile_and_position_on_transect_with_slider) - self.slider.setMaximum(stg.t.shape[1]) + + if len(stg.BS_stream_bed) and stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape: + + self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + + elif (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[2] + < stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape[2]): + + self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + + else: + + self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) self.compute_averaged_BS_data() self.plot_profile_and_position_on_transect_with_slider() + stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] = 1 + 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) + stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] = 1 - if stg.BS_stream_bed.size == 0: - noise = np.zeros(stg.BS_cross_section.shape) + noise_data = AcousticDataLoader(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data) + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = noise_data._BS_raw_data + # stg.date_noise = noise_data._date + # stg.hour_noise = noise_data._hour + stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = noise_data._time + # stg.time_snr_reshape = stg.time_reshape + print("len(stg.BS_cross_section) : ", len(stg.BS_cross_section)) + print("stg.BS_cross_section[0] : ", stg.BS_cross_section[0].shape) + print("len(stg.BS_stream_bed) : ", len(stg.BS_stream_bed)) + + if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape): + print("Je suis dans raw") + + noise = np.zeros(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].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") + noise[f, :, :] = np.mean( + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise + stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = ( + np.divide((stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1] - + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) + + elif len(stg.BS_stream_bed) < len(stg.BS_cross_section): + print("Je suis dans cross section") + + noise = np.zeros(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape) + for f, _ in enumerate(noise_data._freq): + noise[f, :, :] = np.mean( + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise + stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1] = ( + np.divide((stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1] - + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 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) + print("Je suis dans stream bed") + + noise = np.zeros(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].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") + noise[f, :, :] = np.mean( + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise + stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] = ( + np.divide((stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] - + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) + # stg.SNR_reshape = np.reshape(stg.SNR_stream_bed, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), + # order="F") + + # print("stg.SNR_raw_data[0].shape ", stg.SNR_raw_data) + + print("C'est fait") + + + # def compute_noise_from_value(self): + # + # # --- Compute noise from value and compute SNR --- + # + # if stg.BS_stream_bed.size == 0: + # + # stg.time_snr = stg.t + # + # if self.spinbox_compute_noise_from_value.value() == 0: + # + # stg.BS_noise_raw_data = np.full(stg.BS_cross_section.shape, + # self.spinbox_compute_noise_from_value.value()) + # print(f"stg.BS_noise_raw_data.shape : {stg.BS_noise_raw_data.shape}") + # stg.SNR_cross_section = np.full(stg.BS_cross_section.shape, 1e3) + # + # else: + # + # stg.BS_noise_raw_data = np.full(stg.BS_cross_section.shape, self.spinbox_compute_noise_from_value.value()) + # stg.SNR_cross_section = np.divide((stg.BS_cross_section - stg.BS_noise_raw_data) ** 2, + # stg.BS_noise_raw_data ** 2) + # + # else: + # + # stg.time_snr = stg.t + # + # if self.spinbox_compute_noise_from_value.value() == 0: + # + # stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape, + # self.spinbox_compute_noise_from_value.value()) + # stg.SNR_stream_bed = np.full(stg.BS_stream_bed.shape, 1e3) + # + # else: + # + # stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape, + # self.spinbox_compute_noise_from_value.value()) + # stg.SNR_stream_bed = np.divide((stg.BS_stream_bed - stg.BS_noise_raw_data) ** 2, + # stg.BS_noise_raw_data ** 2) + # + # + # + # # --- Trigger graphic widgets --- + # + # self.combobox_freq_noise.addItems([f for f in stg.freq_text]) + # self.plot_noise() + # self.plot_transect_with_SNR_data() + # self.combobox_freq_noise.currentIndexChanged.connect(self.plot_noise) + # self.spinbox_SNR_criterion.setValue(0) + # 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 compute_noise_from_value(self): # --- Compute noise from value and compute SNR --- - if stg.BS_stream_bed.size == 0: - - stg.time_snr = stg.t + if len(stg.BS_stream_bed) == 0: if self.spinbox_compute_noise_from_value.value() == 0: - stg.BS_noise_raw_data = np.full(stg.BS_cross_section.shape, + stg.BS_noise_raw_data = np.full(stg.BS_cross_section[0].shape, self.spinbox_compute_noise_from_value.value()) print(f"stg.BS_noise_raw_data.shape : {stg.BS_noise_raw_data.shape}") - stg.SNR_cross_section = np.full(stg.BS_cross_section.shape, 1e3) + stg.SNR_cross_section = np.full(stg.BS_cross_section[0].shape, 1e3) else: - stg.BS_noise_raw_data = np.full(stg.BS_cross_section.shape, self.spinbox_compute_noise_from_value.value()) - stg.SNR_cross_section = np.divide((stg.BS_cross_section - stg.BS_noise_raw_data) ** 2, + stg.BS_noise_raw_data = np.full(stg.BS_cross_section[0].shape, + self.spinbox_compute_noise_from_value.value()) + stg.SNR_cross_section = np.divide((stg.BS_cross_section[0] - stg.BS_noise_raw_data) ** 2, stg.BS_noise_raw_data ** 2) else: - stg.time_snr = stg.t - if self.spinbox_compute_noise_from_value.value() == 0: stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape, @@ -1087,9 +1298,7 @@ class SignalProcessingTab(QWidget): stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape, self.spinbox_compute_noise_from_value.value()) stg.SNR_stream_bed = np.divide((stg.BS_stream_bed - stg.BS_noise_raw_data) ** 2, - stg.BS_noise_raw_data ** 2) - - + stg.BS_noise_raw_data ** 2) # --- Trigger graphic widgets --- @@ -1101,11 +1310,14 @@ class SignalProcessingTab(QWidget): 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.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() + stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] = 3 + def plot_noise(self): self.horizontalLayout_groupbox_plot_noise_data.removeWidget(self.canvas_noise) @@ -1123,7 +1335,7 @@ class SignalProcessingTab(QWidget): if val_min == val_max: pcm = self.axis_noise.pcolormesh(stg.time_snr[0, :], - -stg.r[self.combobox_freq_noise.currentIndex(), :], + -stg.depth[self.combobox_freq_noise.currentIndex(), :], stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :], cmap='viridis') @@ -1150,7 +1362,7 @@ class SignalProcessingTab(QWidget): def plot_transect_with_SNR_data(self): # --- Condition if table is not filled --- # if not self.lineEdit_noise_file.text(): - if stg.BS_noise_raw_data.size == 0: + if len(stg.BS_noise_raw_data) == 0: msgBox = QMessageBox() msgBox.setWindowTitle("Plot transect Error") msgBox.setIcon(QMessageBox.Warning) @@ -1161,26 +1373,33 @@ class SignalProcessingTab(QWidget): # elif self.canvas_SNR == None: else: - self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq.shape[0], ncols=1, sharex=True, sharey=False, layout='constrained') + self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq[self.combobox_fileListWidget.currentIndex() - 1].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_SNR + # self.verticalLayout_groupbox_plot_Noise_SNR.removeWidget(self.scroll_SNR) - self.scroll_SNR = QScrollArea() + # 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, :]) + self.navigationToolBar_SNR = NavigationToolBar(self.canvas_SNR, self.groupbox_plot_SNR) + # self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_SNR.setAlignment(Qt.AlignCenter) + # self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) - for f, _ in enumerate(stg.freq): + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - if stg.SNR_stream_bed.size == 0: + if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape): - val_min = np.nanmin(stg.SNR_cross_section[f, :, :]) - val_max = np.nanmax(stg.SNR_cross_section[f, :, :]) + x, y = np.meshgrid(stg.time[self.combobox_fileListWidget.currentIndex() - 1][0, :], + stg.depth[self.combobox_fileListWidget.currentIndex() - 1][0, :]) + + print("0 plot SNR with SNR_raw_data") + val_min = np.nanmin(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + val_max = np.nanmax(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) if val_min == val_max: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) else: @@ -1194,12 +1413,45 @@ class SignalProcessingTab(QWidget): 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)) + cf = (self.axis_SNR[f].contourf(x, -y, + stg.SNR_raw_data[ + self.combobox_fileListWidget.currentIndex() - 1][f, :, :], + levels, cmap='gist_rainbow', norm=norm)) + + + elif len(stg.BS_stream_bed) < len(stg.BS_cross_section): + + x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :], + stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :]) + + print("1 plot SNR with SNR_cross_section") + val_min = np.nanmin(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + val_max = np.nanmax(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + if val_min == val_max: + levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + else: + 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[self.combobox_fileListWidget.currentIndex() - 1][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, :, :]) + x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :], + stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :]) + + print("0 plot SNR with SNR_stream_bed") + val_min = np.nanmin(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + val_max = np.nanmax(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) if val_min == val_max: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) @@ -1214,10 +1466,12 @@ class SignalProcessingTab(QWidget): 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', + cf = (self.axis_SNR[f].contourf(x, -y, + stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], + levels, cmap='gist_rainbow', norm=norm)) - self.axis_SNR[f].text(1, .70, stg.freq_text[f], + self.axis_SNR[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_SNR[f].transAxes) @@ -1238,7 +1492,7 @@ class SignalProcessingTab(QWidget): def remove_point_with_snr_filter(self): - if (stg.SNR_cross_section.size == 0) and (stg.SNR_stream_bed.size == 0): + if len(stg.BS_noise_raw_data) == 0: msgBox = QMessageBox() msgBox.setWindowTitle("SNR filter Error") msgBox.setIcon(QMessageBox.Warning) @@ -1248,18 +1502,30 @@ class SignalProcessingTab(QWidget): else: - if stg.BS_stream_bed.size == 0: + if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape): + + stg.BS_raw_data_pre_process_SNR = deepcopy(stg.BS_raw_data) + + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][ + f, + np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[0], + np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ + = np.nan + + elif len(stg.BS_stream_bed) < len(stg.BS_cross_section): stg.BS_cross_section_pre_process_SNR = 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_pre_process_SNR - stg.Noise_data) ** 2, stg.Noise_data ** 2) - for f, _ in enumerate(stg.freq): - stg.BS_cross_section_pre_process_SNR[ + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][ 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.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[0], + np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ = np.nan else: @@ -1269,11 +1535,11 @@ class SignalProcessingTab(QWidget): # stg.SNR_data_average = np.divide( # (stg.BS_stream_bed_pre_process_SNR - stg.Noise_data) ** 2, stg.Noise_data ** 2) - for f, _ in enumerate(stg.freq): - stg.BS_stream_bed_pre_process_SNR[ + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][ 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.where(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[0], + np.where(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ = np.nan @@ -1310,54 +1576,75 @@ class SignalProcessingTab(QWidget): # 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() + # 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.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.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.combobox_fileListWidget.currentIndex() - 1].shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") 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 = 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) + # 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): + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - if stg.BS_stream_bed.size == 0: + if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape): - val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR[f, :, :]) - val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR[f, :, :]) + val_min = np.nanmin( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + val_max = np.nanmax( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][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_pre_process_SNR[f, :, :], + pcm = self.axis_BS[f].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex() - 1][f, :], + -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][f, :], + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif len(stg.BS_stream_bed) < len(stg.BS_cross_section): + + val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: - val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[f, :, :]) - val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[f, :, :]) + val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][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_pre_process_SNR[f, :, :], + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - self.axis_BS[f].plot(stg.t[f, :], -stg.r_bottom, + self.axis_BS[f].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], + -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], color='black', linewidth=1, linestyle="solid") - self.axis_BS[f].text(1, .70, stg.freq_text[f], + self.axis_BS[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_BS[f].transAxes) @@ -1370,75 +1657,175 @@ class SignalProcessingTab(QWidget): def compute_averaged_BS_data(self): - if stg.BS_cross_section.size == 0: + if len(stg.BS_noise_raw_data) == 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) + kernel = np.ones(2*self.spinbox_average_horizontal.value()+1) + print(kernel) - if stg.BS_stream_bed_pre_process_SNR.size != 0: + if len(stg.BS_stream_bed): - stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) - # print(f"1/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_SNR_average}") - for f, _ in enumerate(stg.freq): - for i in range(stg.r.shape[1]): - stg.BS_stream_bed_pre_process_SNR_average[f, i, :] \ - = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=filter_convolve) / len(filter_convolve) - # stg.BS_stream_bed_pre_process_average[i, f, :] \ - # = convolve1d(stg.BS_cross_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0] + # --- Données pré-traitées avec SNR : BS stream bed pre process SNR -> BS stream bed pre process SNR average --- - return stg.BS_stream_bed_pre_process_SNR_average + if len(stg.BS_stream_bed_pre_process_SNR): + # ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or + # (stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape))): - elif stg.BS_cross_section_pre_process_SNR.size != 0: + stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) - stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR) - print(f"2/ stg.BS_cross_section_averaged : {stg.BS_cross_section_pre_process_SNR_average}") - for f, _ in enumerate(stg.freq): - for i in range(stg.r.shape[1]): - stg.BS_cross_section_pre_process_SNR_average[f, i, :] \ - = convolve1d(stg.BS_cross_section_pre_process_SNR[f, i, :], - weights=filter_convolve) / len(filter_convolve) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1][f, i,:] \ + = convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + print("1 - Je suis dans stg.BS_stream_bed_pre_process_SNR_average") - return stg.BS_cross_section_pre_process_SNR_average + # --- Données BS stream bed : BS stream bed -> BS stream bed pre process average --- - elif stg.BS_stream_bed.size != 0: + else: + # elif ((stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or + # (stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape)): - stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) - # print(f"3/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_average.shape}") - print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) - for f, _ in enumerate(stg.freq): - for i in range(stg.r.shape[1]): - stg.BS_stream_bed_pre_process_average[f, i, :] \ - = convolve1d(stg.BS_stream_bed[f, i, :], - weights=filter_convolve) / len(filter_convolve) - print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) + stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) - return stg.BS_stream_bed_pre_process_average + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ + = convolve1d(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + print("2 - Je suis dans stg.BS_stream_bed_pre_process_average") - elif stg.BS_cross_section.size != 0: + elif (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[2] + < stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape[2]): - 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) + # --- Données pré-traitées avec SNR : BS cross section pre process SNR -> BS cross section pre process SNR average --- - return stg.BS_cross_section_averaged + if len(stg.BS_cross_section_pre_process_SNR): + # if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or + # (stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape)): - 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") + stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR) - # self.plot_profile_and_position_on_transect_with_slider() + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): + stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ + = convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + print("3 - Je suis dans stg.BS_cross_section_pre_process_SNR_average") + + # --- Données BS section : BS cross section -> BS cross section pre process average --- + + else: + # elif ((stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or + # (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape)): + + stg.BS_cross_section_pre_process_average = deepcopy(stg.BS_cross_section) + + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ + = convolve1d(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + print("4 - Je suis dans stg.BS_cross_section_pre_process_average") + + + + else: + + # --- Données pré-traitées avec SNR : BS raw data pre process SNR -> BS raw data pre process SNR average --- + + if len(stg.BS_cross_section_pre_process_SNR): + # if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or + # (stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape)): + + stg.BS_raw_data_pre_process_SNR_average = deepcopy(stg.BS_raw_data_pre_process_SNR) + + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): + stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ + = convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + print("5 - Je suis dans stg.BS_raw_data_pre_process_SNR_average") + + # --- Données BS brutes : BS raw data -> BS raw data pre process average --- + + else: + + stg.BS_raw_data_pre_process_average = deepcopy(stg.BS_raw_data) + + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1][f, i,:] \ + = convolve1d(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + print("6 - Je suis dans stg.BS_raw_data_pre_process_average") + + # if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == + # stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape): + # + # stg.BS_raw_data_pre_process_average = deepcopy(stg.BS_raw_data) + # + # for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): + # stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ + # = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=kernel) / len(kernel) + # + # stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) + # # print(f"1/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_SNR_average}") + # for f, _ in enumerate(stg.freq): + # for i in range(stg.r.shape[1]): + # stg.BS_stream_bed_pre_process_SNR_average[f, i, :] \ + # = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=kernel) / len(kernel) + # # stg.BS_stream_bed_pre_process_average[i, f, :] \ + # # = convolve1d(stg.BS_cross_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0] + # + # return stg.BS_stream_bed_pre_process_SNR_average + # + # elif stg.BS_cross_section_pre_process_SNR.size != 0: + # + # stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR) + # print(f"2/ stg.BS_cross_section_averaged : {stg.BS_cross_section_pre_process_SNR_average}") + # for f, _ in enumerate(stg.freq): + # for i in range(stg.r.shape[1]): + # stg.BS_cross_section_pre_process_SNR_average[f, i, :] \ + # = convolve1d(stg.BS_cross_section_pre_process_SNR[f, i, :], + # weights=kernel) / len(kernel) + # + # return stg.BS_cross_section_pre_process_SNR_average + # + # elif stg.BS_stream_bed.size != 0: + # + # stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) + # # print(f"3/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_average.shape}") + # print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) + # for f, _ in enumerate(stg.freq): + # for i in range(stg.r.shape[1]): + # stg.BS_stream_bed_pre_process_average[f, i, :] \ + # = convolve1d(stg.BS_stream_bed[f, i, :], + # weights=kernel) / len(kernel) + # print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) + # + # return stg.BS_stream_bed_pre_process_average + # + # 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=kernel) / len(kernel) + # + # 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): @@ -1446,41 +1833,23 @@ class SignalProcessingTab(QWidget): self.label_profile_number.clear() self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum())) + self.figure_profile, self.axis_profile = plt.subplots(nrows=2, ncols=1, layout="constrained") + self.canvas_profile = FigureCanvas(self.figure_profile) + self.scroll_profile.setWidget(self.canvas_profile) + self.axis_profile[0].cla() self.axis_profile[1].cla() - if stg.BS_stream_bed_pre_process_SNR_average.size != 0: + if ((len(stg.BS_stream_bed_pre_process_SNR_average)) and + (len(stg.BS_stream_bed_pre_process_SNR_average) == (self.combobox_fileListWidget.count() -1))): # --- Plot profile --- self.axis_profile[0].plot( - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.r[self.combobox_frequency_profile.currentIndex(), :], + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][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_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR_average[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_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - elif stg.BS_cross_section_pre_process_SNR_average.size != 0: - # --- Plot profile --- - self.axis_profile[0].plot( - stg.BS_cross_section_pre_process_SNR_average[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()], + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex()], fontsize=10, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, horizontalalignment='right', verticalalignment='bottom', @@ -1488,48 +1857,104 @@ class SignalProcessingTab(QWidget): # --- Plot transect with profile position --- self.axis_profile[1].cla() - val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) + val_min = np.nanmin( + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax( + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [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(), :], + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif (len(stg.BS_stream_bed_pre_process_average) + and (len(stg.BS_stream_bed_pre_process_average) == (self.combobox_fileListWidget.count() -1))): + + # --- Plot profile --- + self.axis_profile[0].plot( + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + 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_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax( + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + stg.BS_stream_bed_pre_process_average[ + self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif (len(stg.BS_cross_section_pre_process_SNR_average) and + (len(stg.BS_cross_section_pre_process_SNR_average) == (self.combobox_fileListWidget.count() -1))): + + # --- Plot profile --- + self.axis_profile[0].plot( + stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + 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_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax( + stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], stg.BS_cross_section_pre_process_SNR_average[ - self.combobox_frequency_profile.currentIndex(), :, :], + self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_stream_bed_pre_process_SNR.size != 0: + elif (len(stg.BS_cross_section_pre_process_average) + and (len(stg.BS_cross_section_pre_process_average) == (self.combobox_fileListWidget.count() - 1))): # --- Plot profile --- self.axis_profile[0].plot( - stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.r[self.combobox_frequency_profile.currentIndex(), :], + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + 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_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_stream_bed_pre_process_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_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - elif stg.BS_cross_section_pre_process_SNR.size != 0: - # --- Plot profile --- - self.axis_profile[0].plot( - stg.BS_cross_section_pre_process_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()], + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex()], fontsize=10, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, horizontalalignment='right', verticalalignment='bottom', @@ -1537,48 +1962,239 @@ class SignalProcessingTab(QWidget): # --- Plot transect with profile position --- self.axis_profile[1].cla() - val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) + val_min = np.nanmin( + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax( + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [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_pre_process_SNR[ - self.combobox_frequency_profile.currentIndex(), :, :], + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + stg.BS_cross_section_pre_process_average[ + self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif (len(stg.BS_raw_data_pre_process_SNR_average) + and (len(stg.BS_raw_data_pre_process_SNR_average) == (self.combobox_fileListWidget.count() - 1))): + + # --- Plot profile --- + self.axis_profile[0].plot( + stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + 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_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax( + stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + stg.BS_raw_data_pre_process_SNR_average[ + self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + else: + + # --- Plot profile --- + self.axis_profile[0].plot( + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + 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_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + val_max = np.nanmax( + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), :, :]) + if val_min == 0: + val_min = 1e-5 + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.combobox_frequency_profile.currentIndex(), :], + stg.BS_raw_data_pre_process_average[ + self.combobox_fileListWidget.currentIndex() - 1] + [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(), :], + stg.time[self.combobox_fileListWidget.currentIndex() - 1] + [self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + np.ones(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]), + -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][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, + if len(stg.depth_bottom): + if len(stg.time_cross_section): + self.axis_profile[1].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], color='black', linewidth=1, linestyle="solid") + else: + self.axis_profile[1].plot(stg.time[self.combobox_fileListWidget - 1][ + self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], + color='black', linewidth=1, linestyle="solid") self.axis_profile[1].set_xticks([]) self.axis_profile[1].set_yticks([]) self.figure_profile.canvas.draw_idle() + # if stg.BS_stream_bed_pre_process_SNR_average.size != 0: + # + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_stream_bed_pre_process_SNR_average[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_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR_average[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_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.BS_cross_section_pre_process_SNR_average.size != 0: + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_cross_section_pre_process_SNR_average[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_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR_average[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_pre_process_SNR_average[ + # self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.BS_stream_bed_pre_process_SNR.size != 0: + # + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_stream_bed_pre_process_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_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_stream_bed_pre_process_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_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.BS_cross_section_pre_process_SNR.size != 0: + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_cross_section_pre_process_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_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_cross_section_pre_process_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_pre_process_SNR[ + # self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) # ------------------------------------- Connect Push Button Load Data + Slider ------------------------------------- + def slide_profile_number_to_begin(self): + self.slider.setValue(int(self.slider.minimum())) + self.lineEdit_slider.setText(str(self.slider.value())) + def slide_profile_number_to_right(self): self.slider.setValue(int(self.slider.value()) + 1) self.lineEdit_slider.setText(str(self.slider.value())) + def profile_number_on_lineEdit(self): + self.slider.setValue(int(self.lineEdit_slider.text())) + def slide_profile_number_to_left(self): self.slider.setValue(int(self.slider.value()) - 1) self.lineEdit_slider.setText(str(self.slider.value())) - def profile_number_on_lineEdit(self): - self.slider.setValue(int(self.lineEdit_slider.text())) + def slide_profile_number_to_end(self): + self.slider.setValue(int(self.slider.maximum())) + self.lineEdit_slider.setText(str(self.slider.value())) def update_lineEdit_by_moving_slider(self): self.lineEdit_slider.setText(str(self.slider.value())) @@ -1596,764 +2212,764 @@ class SignalProcessingTab(QWidget): # COMMENT OLD CODE LINE FROM HERE .... - def compute_BS_data_section(self): - if stg.BS_cross_section.size == 0: - msgBox = QMessageBox() - msgBox.setWindowTitle("Load data Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Please check acoustic data Tab") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - # if stg.r_bottom.size == 0: - # stg.BS_stream_bed = deepcopy(stg.BS_cross_section) - if stg.r_bottom.size != 0: - stg.BS_stream_bed = deepcopy(stg.BS_cross_section) - for f, _ in enumerate(stg.freq): - for k, _ in enumerate(stg.r_bottom): - # print(k, np.where(stg.r >= stg.r_bottom[k])[0]) - stg.BS_stream_bed[f, np.where(stg.r[self.combobox_frequency.currentIndex(), :] >= stg.r_bottom[k])[0], k] = np.nan - - # --- Choose frequency (Combo box) to plot transect with profile position --- - self.combobox_frequency.addItems(stg.freq_text) - self.combobox_frequency.currentTextChanged.connect(self.update_plot_profile_position_on_transect) - - # --- Choose frequency (Combo box) to compute water attenuation --- - self.combobox_freq_for_water_attenuation.addItems(stg.freq_text) - - # --- Choose frequency (Combo box) to compute sediment attenuation --- - self.combobox_frequency_compute_alphaS.addItems(stg.freq_text) - - # --- Fix maximum value of slider + Edit Label Profile number --- - self.slider.setMaximum(stg.t.shape[1]) - self.label_profile_number.clear() - self.label_profile_number.setText("Vertical " + str(self.slider.value()) + " / " + str(self.slider.maximum())) - - self.plot_profile_position_on_transect() - self.plot_profile() - - # ---------------------------------------- Connect Groupbox filter with SNR ---------------------------------------- - - - - # ----------------------------------------- Connect Groupbox average data ----------------------------------------- - - def compute_averaged_profile(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: - if self.spinbox_average_horizontal.value() % 2 == 0: - msgBox = QMessageBox() - msgBox.setWindowTitle("Average Backscatter signal Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Please enter an odd number") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - - filter_convolve = np.ones(self.spinbox_average_horizontal.value()) - print(filter_convolve) - - if stg.BS_stream_bed_pre_process_SNR.size != 0: - - # stg.BS_stream_bed_pre_process_average = np.zeros((stg.r.shape[0], stg.freq.shape[0], stg.t.shape[0])) - # stg.BS_stream_bed_pre_process_average = np.zeros((stg.freq.shape[0], stg.r.shape[1], stg.t.shape[1])) - stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) - print(f"1/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_average}") - for f, _ in enumerate(stg.freq): - for i in range(stg.r.shape[1]): - stg.BS_stream_bed_pre_process_average[f, i, :] \ - = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=filter_convolve) / len(filter_convolve) - # stg.BS_stream_bed_pre_process_average[i, f, :] \ - # = convolve1d(stg.BS_cross_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0] - - elif stg.BS_cross_section_pre_process_SNR.size != 0: - - stg.BS_cross_section_averaged = deepcopy(stg.BS_cross_section_pre_process_SNR) - print(f"2/ stg.BS_cross_section_averaged : {stg.BS_cross_section_averaged}") - for f, _ in enumerate(stg.freq): - for i in range(stg.r.shape[1]): - stg.BS_stream_bed_pre_process_average[f, i, :] \ - = convolve1d(stg.BS_cross_section_pre_process_SNR[f, i, :], - weights=filter_convolve) / len(filter_convolve) - - elif stg.BS_stream_bed.size != 0: - - stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) - print(f"3/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_average.shape}") - print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) - for f, _ in enumerate(stg.freq): - for i in range(stg.r.shape[1]): - stg.BS_stream_bed_pre_process_average[f, i, :] \ - = convolve1d(stg.BS_stream_bed[f, i, :], - weights=filter_convolve) / len(filter_convolve) - print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) - - 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) - - 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.label_cells_vertical.clear() - # self.label_cells_vertical.setText( - # "cells = +/- " + str((self.spinbox_average_vertical.value() // 2) * (1 / stg.nb_profiles_per_sec)) + " sec") - - self.plot_averaged_profile() - self.update_plot_profile_position_on_transect() - - self.slider.valueChanged.connect(self.update_plot_averaged_profile) - - # fig, ax = plt.subplots(nrows=1, ncols=1) - # val_min = np.nanmin(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]) - # val_max = np.nanmax(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]) - # if val_min == 0: - # val_min = 1e-5 - # - # ax.pcolormesh(stg.t[self.combobox_frequency.currentIndex(), :], - # -stg.r[self.combobox_frequency.currentIndex(), :], - # stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :], - # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - # - # plt.show() - - def compute_water_attenuation(self): - if (stg.freq.size == 0) or (self.spinbox_temperature_water_attenuation.value() == 0): - msgBox = QMessageBox() - msgBox.setWindowTitle("Water attenuation Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Load Backscatter data from acoustic data tab and enter a value of temperature") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - - else: - - if self.combobox_water_attenuation_model.currentIndex() == 0: - self.Francois_and_Garrison_1982() - - else: - pass - - print(f"{stg.water_attenuation:.2f}") - self.label_water_attenuation.clear() - self.label_water_attenuation.setText("\u03B1w = " + f"{stg.water_attenuation:.4f}" + " dB/m") - - def Francois_and_Garrison_1982(self): - if self.spinbox_temperature_water_attenuation.value() > 20: - stg.water_attenuation = ((3.964 * 1e-4 - 1.146 * 1e-5 * self.spinbox_temperature_water_attenuation.value() + - 1.45 * 1e-7 * self.spinbox_temperature_water_attenuation.value() ** 2 - - 6.5 * 1e-10 * self.spinbox_temperature_water_attenuation.value() ** 3) * 1e-3 * - (np.log(10) / 20) * - (stg.freq[self.combobox_freq_for_water_attenuation.currentIndex()] * 1e-3) ** 2) - else: - stg.water_attenuation = ((4.937 * 1e-4 - 2.59 * 1e-5 * self.spinbox_temperature_water_attenuation.value() + - 9.11 * 1e-7 * self.spinbox_temperature_water_attenuation.value() ** 2 - - 1.5 * 1e-8 * self.spinbox_temperature_water_attenuation.value() ** 3) * 1e-3 * - (np.log(10) / 20) * - (stg.freq[self.combobox_freq_for_water_attenuation.currentIndex()] * 1e-3) ** 2) - - # ------------ Computing real cell size ------------ # - def range_cells_function(self): - """ Computing the real cell size, that depends on the temperature """ - # defaut Aquascat cell size - aquascat_cell_size = stg.r[0, 1] - stg.r[0, 0] - # Pulse duration - tau = aquascat_cell_size * 2 / 1500 # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat - # Sound speed - cel = self.inv_hc.water_velocity(self.spinbox_temperature_water_attenuation.value()) - # Real cell size - real_cell_size = cel * tau / 2 # voir fig 2.9 - - # Converting to real cell profile - real_r = stg.r / aquascat_cell_size * real_cell_size # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1 - # (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules - - # R with right shape (numpy array) - R_real = real_r # np.repeat(real_r, len(stg.freq), axis=1) - - return R_real - - def compute_FCB(self): - if stg.BS_stream_bed.size == 0: - msgBox = QMessageBox() - msgBox.setWindowTitle("FCB Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Load Backscatter data from acoustic data tab and compute water attenuation") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - print(f"self.range_cells_function() : {self.range_cells_function()}") - print(f"self.range_cells_function() shape : {self.range_cells_function().shape}") - R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[1], axis=2) - print(f"R_real shape : {R_real.shape}") - if (stg.BS_stream_bed_pre_process_average.size == 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0): - stg.FCB = (np.log(stg.BS_stream_bed) + np.log(R_real) + - 2 * stg.water_attenuation * R_real) - elif stg.BS_stream_bed_pre_process_SNR.size == 0: - stg.FCB = (np.log(stg.BS_stream_bed_pre_process_average) + np.log(R_real) + - 2 * stg.water_attenuation * R_real) - else: - stg.FCB = (np.log(stg.BS_stream_bed_pre_process_SNR) + np.log(R_real) + - 2 * stg.water_attenuation * R_real) - self.plot_FCB() - - def fit_FCB_profile_with_linear_regression_and_compute_alphaS(self): - - if stg.FCB.size == 0: - msgBox = QMessageBox() - msgBox.setWindowTitle("Linear regression error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Please compute FCB before") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - try: - y0 = stg.FCB[self.combobox_frequency_compute_alphaS.currentIndex(), :, self.slider.value()] - y = y0[np.where(np.isnan(y0) == False)] - - x0 = stg.r[0, :].reshape(-1) - x = x0[np.where(np.isnan(y0) == False)] - - value1 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2) - == np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2))) - value2 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2) - == np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2))) - - # print(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)) - # # print("value1 ", value1[0][0]) - # print(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)) - # print("value2 ", value2[0][0]) - - # print("y limited ", y[value1[0][0]:value2[0][0]]) - - lin_reg_compute = stats.linregress(x[value1[0][0]:value2[0][0]], y[value1[0][0]:value2[0][0]]) - except ValueError: - msgBox = QMessageBox() - msgBox.setWindowTitle("Linear regression error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Please check boundaries to fit a linear line") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - stg.lin_reg = (lin_reg_compute.slope, lin_reg_compute.intercept) - # print(f"y = {stg.lin_reg[0]}x + {stg.lin_reg[1]}") - - self.label_alphaS.clear() - self.label_alphaS.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m") - - # for i, value_freq in enumerate(stg.freq): - # for k, value_t in enumerate(stg.t): - # # print(f"indice i: {i}, indice k: {k}") - # # print(f"values of FCB: {stg.FCB[:, i, k]}") - # y = stg.FCB[:, i, k] - # # print("y : ", y) - # # print(f"values of FCB where FCB is not Nan {y[np.where(np.isnan(y) == False)]}") - # # print(f"values of r where FCB is not Nan {x[np.where(np.isnan(y) == False)]}") - # lin_reg_compute = stats.linregress(x[np.where(np.isnan(y) == False)], y[np.where(np.isnan(y) == False)]) - # lin_reg_tuple = (lin_reg_compute.slope, lin_reg_compute.intercept) - # stg.lin_reg.append(lin_reg_tuple) - - # print(f"y = {lin_reg.slope}x + {lin_reg.intercept}") - - # plt.figure() - # plt.plot(stg.r, stg.FCB[:, 0, 825], 'k-', stg.r, lin_reg.slope*stg.r + lin_reg.intercept, "b--") - # plt.show() - - # print("lin_reg length ", len(stg.lin_reg)) - # print("lin_reg ", stg.lin_reg) - - # ---------------------------------------- PLOT PROFILE POSITION ON TRANSECT --------------------------------------- - - def plot_profile_position_on_transect(self): - - # --- Create Matplotlib canvas (with figure and axis) to plot transect --- - self.canvas_plot_profile_position_on_transect = FigureCanvas() - 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.verticalLayout_groupbox_display_profile_position.addWidget(self.canvas_plot_profile_position_on_transect) - - # --- Plot transect with profile position --- - - if stg.ABS_name == "Aquascat 1000R": - if stg.BS_stream_bed.size != 0: - - val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) - if val_min == 0: - val_min = 1e-5 - - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], - stg.BS_stream_bed[stg.freq_bottom_detection, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - - val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) - val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) - if val_min == 0: - val_min = 1e-5 - - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], - stg.BS_cross_section[stg.freq_bottom_detection, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - elif stg.ABS_name == "UB-SediFlow": - - if stg.BS_stream_bed.size != 0: - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], - np.log(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]), - cmap='Blues') - else: - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], - np.log(stg.BS_cross_section[stg.freq_bottom_detection, :, :]), - cmap='Blues') - - if stg.r_bottom.size != 0: - self.axis_plot_profile_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid") - - self.axis_plot_profile_position_on_transect.plot( - stg.t[stg.freq_bottom_detection, self.slider.value() - 1] * np.ones(stg.r.shape[1]), -stg.r[stg.freq_bottom_detection, :], - color='red', linestyle="solid", linewidth=2) - - self.axis_plot_profile_position_on_transect.set_xticks([]) - self.axis_plot_profile_position_on_transect.set_yticks([]) - - self.figure_plot_profile_position_on_transect.canvas.draw_idle() - - def update_plot_profile_position_on_transect(self): - - # --- Update label "Profile N / max(N)" --- - self.label_profile_number.clear() - self.label_profile_number.setText("Vertical " + str(self.slider.value()) + " / " + str(self.slider.maximum())) - - # --- Update transect plot --- - - if self.canvas_plot_profile_position_on_transect is None: - msgBox = QMessageBox() - msgBox.setWindowTitle("Plot Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Load and post-process data before plotting transect with profile position") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - - else: - - if stg.BS_stream_bed.size != 0: - - if (stg.BS_stream_bed_pre_process_average.size == 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0): - - self.axis_plot_profile_position_on_transect.cla() - - val_min = np.nanmin(stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.ABS_name == "Aquascat 1000R": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.ABS_name == "UB-SediFlow": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - np.log(stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :]), - cmap='Blues') - - elif (stg.BS_stream_bed_pre_process_average.size != 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0): - - self.axis_plot_profile_position_on_transect.cla() - - val_min = np.nanmin(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.ABS_name == "Aquascat 1000R": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.ABS_name == "UB-SediFlow": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - np.log(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]), - cmap='Blues') - - elif stg.BS_stream_bed_pre_process_SNR.size != 0: - - self.axis_plot_profile_position_on_transect.cla() - - val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.ABS_name == "Aquascat 1000R": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.ABS_name == "UB-SediFlow": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - np.log(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]), - cmap='Blues') - - else: - - if (stg.BS_cross_section_averaged.size == 0) and (stg.BS_cross_section_pre_process_SNR.size == 0): - - self.axis_plot_profile_position_on_transect.cla() - - val_min = np.nanmin(stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.ABS_name == "Aquascat 1000R": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.ABS_name == "UB-SediFlow": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - np.log(stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :]), - cmap='Blues') - - elif (stg.BS_cross_section_averaged.size != 0) and (stg.BS_cross_section_pre_process_SNR.size == 0): - - self.axis_plot_profile_position_on_transect.cla() - - val_min = np.nanmin(stg.BS_cross_section_averaged[self.combobox_frequency.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_cross_section_averaged[self.combobox_frequency.currentIndex(), :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.ABS_name == "Aquascat 1000R": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - stg.BS_cross_section_averaged[self.combobox_frequency.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.ABS_name == "UB-SediFlow": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - np.log(stg.BS_cross_section_averaged[self.combobox_frequency.currentIndex(), :, :]), - cmap='Blues') - - elif stg.BS_cross_section_pre_process_SNR.size != 0: - - self.axis_plot_profile_position_on_transect.cla() - - val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.ABS_name == "Aquascat 1000R": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - stg.BS_cross_section_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.ABS_name == "UB-SediFlow": - self.axis_plot_profile_position_on_transect.pcolormesh( - stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r[self.combobox_frequency.currentIndex(), :], - np.log(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]), - cmap='Blues') - - if stg.r_bottom.size != 0: - self.axis_plot_profile_position_on_transect.plot(stg.t[self.combobox_frequency.currentIndex(), :], - -stg.r_bottom, - color='black', linewidth=1, linestyle="solid") - - self.axis_plot_profile_position_on_transect.plot( - stg.t[self.combobox_frequency.currentIndex(), self.slider.value() - 1] * np.ones(stg.r.shape[1]), - -stg.r[self.combobox_frequency.currentIndex(), :], - color='red', linestyle="solid", linewidth=2) - - self.axis_plot_profile_position_on_transect.set_xticks([]) - self.axis_plot_profile_position_on_transect.set_yticks([]) - - self.figure_plot_profile_position_on_transect.canvas.draw_idle() - - # -------------------------------------------------- PLOT PROFILE ------------------------------------------------- - - def plot_profile(self): - - # --- Raw profile --- - - self.figure_profile, self.axis_profile \ - = plt.subplots(nrows=1, ncols=stg.freq.shape[0], sharex=True, sharey=True, layout='constrained') - self.canvas_profile = FigureCanvas(self.figure_profile) - self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile) - # self.scroll_profile = QScrollArea() - # self.scroll_profile.setWidget(self.canvas_profile) - # self.scroll_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_profile.setAlignment(Qt.AlignCenter) - # self.verticalLayout_groupbox_plot_profile.addWidget(self.scroll_profile) - - if stg.BS_stream_bed.size == 0: - - for f, _ in enumerate(stg.freq): - self.axis_profile[f].cla() - self.axis_profile[f].plot(stg.BS_cross_section[f, :, self.slider.value() - 1], -stg.r[f, :], - linestyle='solid', color='k', linewidth=1) - self.axis_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_profile[f].transAxes) - - else: - - for f, _ in enumerate(stg.freq): - self.axis_profile[f].cla() - self.axis_profile[f].plot(stg.BS_stream_bed[f, :, self.slider.value() - 1], -stg.r[f, :], - linestyle='solid', color='k', linewidth=1) - self.axis_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_profile[f].transAxes) - - self.figure_profile.supxlabel("Acoustic Backscatter Signal (V)") - self.figure_profile.supylabel("Depth (m)") - - # --- Raw averaged profile --- - - self.figure_averaged_profile, self.axis_averaged_profile \ - = plt.subplots(nrows=1, ncols=stg.freq.shape[0], sharex=True, sharey=True, layout='constrained') - self.canvas_averaged_profile = FigureCanvas(self.figure_averaged_profile) - self.verticalLayout_groupbox_plot_averaged_profile.addWidget(self.canvas_averaged_profile) - # self.scroll_averaged_profile = QScrollArea() - # self.scroll_averaged_profile.setWidget(self.canvas_averaged_profile) - # self.scroll_averaged_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_averaged_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - # self.scroll_averaged_profile.setAlignment(Qt.AlignCenter) - # self.verticalLayout_groupbox_plot_averaged_profile.addWidget(self.scroll_averaged_profile) - - # self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], - # fontsize=10, fontweight='bold', fontname="Ubuntu", - # fontstyle="normal", c="black", alpha=0.2, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_averaged_profile[f].transAxes) - - # --- Raw FCB profile --- - - self.figure_FCB_profile, self.axis_FCB_profile \ - = plt.subplots(nrows=1, ncols=stg.freq.shape[0], sharex=True, sharey=True, layout='constrained') - self.canvas_FCB_profile = FigureCanvas(self.figure_FCB_profile) - self.verticalLayout_groupbox_plot_FCB_profile.addWidget(self.canvas_FCB_profile) - # self.scroll_FCB_profile = QScrollArea() - # self.scroll_FCB_profile.setWidget(self.canvas_FCB_profile) - # self.scroll_FCB_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_FCB_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - # self.scroll_FCB_profile.setAlignment(Qt.AlignCenter) - # self.verticalLayout_groupbox_plot_FCB_profile.addWidget(self.scroll_FCB_profile) - - # self.axis_FCB_profile[f].text(.95, .05, stg.freq_text[f], - # fontsize=10, fontweight='bold', fontname="Ubuntu", - # fontstyle="normal", c="black", alpha=0.2, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_FCB_profile[f].transAxes) - - def update_plot_profile(self): - if self.canvas_profile is None: - msgBox = QMessageBox() - msgBox.setWindowTitle("Plot Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Load and post-process data before plotting profiles") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - - else: - - if stg.BS_stream_bed.size == 0: - - for f, _ in enumerate(stg.freq): - self.axis_profile[f].cla() - self.axis_profile[f].plot(stg.BS_cross_section[f, :, self.slider.value() - 1], -stg.r[f, :], - linestyle='solid', color='k', linewidth=1) - self.axis_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_profile[f].transAxes) - - else: - - for f, _ in enumerate(stg.freq): - self.axis_profile[f].cla() - self.axis_profile[f].plot(stg.BS_stream_bed[f, :, self.slider.value() - 1], -stg.r[f, :], - linestyle='solid', color='k', linewidth=1) - self.axis_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_profile[f].transAxes) - - self.figure_profile.supxlabel("Acoustic Backscatter Signal (V)") - self.figure_profile.supylabel("Depth (m)") - self.figure_profile.canvas.draw_idle() - - # --------------------------------- PLOT AVERAGED PROFILE FILTERED OR NOT WITH SNR --------------------------------- - - def plot_averaged_profile(self): - - if stg.BS_stream_bed_pre_process_average.size == 0: - - for f, _ in enumerate(stg.freq): - self.axis_averaged_profile[f].cla() - self.axis_averaged_profile[f].plot(stg.BS_cross_section_averaged[f, :, self.slider.value()-1], -stg.r[f, :], - linestyle='solid', color='k', linewidth=1) - # self.axis_averaged_profile[f].set_ylim(-np.max(stg.r[f, :]), np.min(stg.r[f, :])) - self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_averaged_profile[f].transAxes) - - else: - - for f, _ in enumerate(stg.freq): - self.axis_averaged_profile[f].cla() - self.axis_averaged_profile[f].plot(stg.BS_stream_bed_pre_process_average[f, :, self.slider.value()-1], -stg.r[f, :], - linestyle='solid', color='k', linewidth=1) - # self.axis_averaged_profile[f].set_ylim(-np.max(stg.r[f, :]), np.min(stg.r[f, :])) - self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_averaged_profile[f].transAxes) - - self.figure_averaged_profile.supxlabel("Acoustic Backscatter Signal (V)") - self.figure_averaged_profile.supylabel("Depth (m)") - self.figure_averaged_profile.canvas.draw_idle() - - def update_plot_averaged_profile(self): - if self.canvas_averaged_profile is None: - msgBox = QMessageBox() - msgBox.setWindowTitle("Plot Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Load and post-process data before plotting averaged profiles") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - - else: - - if stg.BS_stream_bed_pre_process_average.size == 0: - - for f, _ in enumerate(stg.freq): - self.axis_averaged_profile[f].cla() - self.axis_averaged_profile[f].plot(stg.BS_cross_section_averaged[f, :, self.slider.value() - 1], - -stg.r[f, :], - linestyle='solid', color='k', linewidth=1) - # self.axis_averaged_profile[f].set_ylim(-np.max(stg.r[f, :]), np.min(stg.r[f, :])) - self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_averaged_profile[f].transAxes) - - else: - - for f, _ in enumerate(stg.freq): - self.axis_averaged_profile[f].cla() - self.axis_averaged_profile[f].plot(stg.BS_stream_bed_pre_process_average[f, :, self.slider.value() - 1], - -stg.r[f, :], - linestyle='solid', color='k', linewidth=1) - # self.axis_averaged_profile[f].set_ylim(-np.max(stg.r[f, :]), np.min(stg.r[f, :])) - self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_averaged_profile[f].transAxes) - - self.figure_averaged_profile.supxlabel("Acoustic Backscatter Signal (V)") - self.figure_averaged_profile.supylabel("Depth (m)") - self.figure_averaged_profile.canvas.draw_idle() - - # ---------------------------------------------------- PLOT FCB ---------------------------------------------------- - - def plot_FCB(self): - - for f in range(stg.freq.shape[0]): - - self.axis_FCB_profile[f].cla() - - self.axis_FCB_profile[f].plot(stg.r[f, :], stg.FCB[f, :, self.slider.value()], linestyle="solid", linewidth=1, color="k") - - # self.axis_FCB_profile[f].set_ylim(np.max(stg.r), np.min(stg.r)) - self.axis_FCB_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_FCB_profile[f].transAxes) - - if len(stg.lin_reg) != 0: - self.axis_FCB_profile[self.combobox_frequency_compute_alphaS.currentIndex()]. \ - plot(stg.r[f, :], stg.lin_reg[0]*stg.r[f, :] + stg.lin_reg[1], linestyle="dashed", linewidth=1, color="b") - - self.figure_FCB_profile.supylabel("FCB") - self.figure_FCB_profile.supxlabel("Depth (m)") - self.figure_FCB_profile.canvas.draw_idle() - - def update_plot_FCB(self): - - if stg.FCB.size != 0: - - for f in range(stg.freq.shape[0]): - - self.axis_FCB_profile[f].cla() - - self.axis_FCB_profile[f].plot(stg.r[f, :], stg.FCB[f, :, self.slider.value()], linestyle="solid", linewidth=1, color="k") - - # self.axis_FCB_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r)) - - self.axis_FCB_profile[f].text(.95, .05, stg.freq_text[f], - fontsize=10, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_FCB_profile[f].transAxes) - - self.figure_FCB_profile.supylabel("FCB") - self.figure_FCB_profile.supxlabel("Depth (m)") - self.figure_FCB_profile.canvas.draw_idle() - + # def compute_BS_data_section(self): + # if stg.BS_cross_section.size == 0: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Load data Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Please check acoustic data Tab") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # else: + # # if stg.r_bottom.size == 0: + # # stg.BS_stream_bed = deepcopy(stg.BS_cross_section) + # if stg.r_bottom.size != 0: + # stg.BS_stream_bed = deepcopy(stg.BS_cross_section) + # for f, _ in enumerate(stg.freq): + # for k, _ in enumerate(stg.r_bottom): + # # print(k, np.where(stg.r >= stg.r_bottom[k])[0]) + # stg.BS_stream_bed[f, np.where(stg.r[self.combobox_frequency.currentIndex(), :] >= stg.r_bottom[k])[0], k] = np.nan + # + # # --- Choose frequency (Combo box) to plot transect with profile position --- + # self.combobox_frequency.addItems(stg.freq_text) + # self.combobox_frequency.currentTextChanged.connect(self.update_plot_profile_position_on_transect) + # + # # --- Choose frequency (Combo box) to compute water attenuation --- + # self.combobox_freq_for_water_attenuation.addItems(stg.freq_text) + # + # # --- Choose frequency (Combo box) to compute sediment attenuation --- + # self.combobox_frequency_compute_alphaS.addItems(stg.freq_text) + # + # # --- Fix maximum value of slider + Edit Label Profile number --- + # self.slider.setMaximum(stg.t.shape[1]) + # self.label_profile_number.clear() + # self.label_profile_number.setText("Vertical " + str(self.slider.value()) + " / " + str(self.slider.maximum())) + # + # self.plot_profile_position_on_transect() + # self.plot_profile() + # + # # ---------------------------------------- Connect Groupbox filter with SNR ---------------------------------------- + # + # + # + # # ----------------------------------------- Connect Groupbox average data ----------------------------------------- + # + # def compute_averaged_profile(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: + # if self.spinbox_average_horizontal.value() % 2 == 0: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Average Backscatter signal Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Please enter an odd number") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # else: + # + # filter_convolve = np.ones(self.spinbox_average_horizontal.value()) + # print(filter_convolve) + # + # if stg.BS_stream_bed_pre_process_SNR.size != 0: + # + # # stg.BS_stream_bed_pre_process_average = np.zeros((stg.r.shape[0], stg.freq.shape[0], stg.t.shape[0])) + # # stg.BS_stream_bed_pre_process_average = np.zeros((stg.freq.shape[0], stg.r.shape[1], stg.t.shape[1])) + # stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) + # print(f"1/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_average}") + # for f, _ in enumerate(stg.freq): + # for i in range(stg.r.shape[1]): + # stg.BS_stream_bed_pre_process_average[f, i, :] \ + # = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=filter_convolve) / len(filter_convolve) + # # stg.BS_stream_bed_pre_process_average[i, f, :] \ + # # = convolve1d(stg.BS_cross_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0] + # + # elif stg.BS_cross_section_pre_process_SNR.size != 0: + # + # stg.BS_cross_section_averaged = deepcopy(stg.BS_cross_section_pre_process_SNR) + # print(f"2/ stg.BS_cross_section_averaged : {stg.BS_cross_section_averaged}") + # for f, _ in enumerate(stg.freq): + # for i in range(stg.r.shape[1]): + # stg.BS_stream_bed_pre_process_average[f, i, :] \ + # = convolve1d(stg.BS_cross_section_pre_process_SNR[f, i, :], + # weights=filter_convolve) / len(filter_convolve) + # + # elif stg.BS_stream_bed.size != 0: + # + # stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) + # print(f"3/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_average.shape}") + # print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) + # for f, _ in enumerate(stg.freq): + # for i in range(stg.r.shape[1]): + # stg.BS_stream_bed_pre_process_average[f, i, :] \ + # = convolve1d(stg.BS_stream_bed[f, i, :], + # weights=filter_convolve) / len(filter_convolve) + # print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) + # + # 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) + # + # 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.label_cells_vertical.clear() + # # self.label_cells_vertical.setText( + # # "cells = +/- " + str((self.spinbox_average_vertical.value() // 2) * (1 / stg.nb_profiles_per_sec)) + " sec") + # + # self.plot_averaged_profile() + # self.update_plot_profile_position_on_transect() + # + # self.slider.valueChanged.connect(self.update_plot_averaged_profile) + # + # # fig, ax = plt.subplots(nrows=1, ncols=1) + # # val_min = np.nanmin(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]) + # # val_max = np.nanmax(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]) + # # if val_min == 0: + # # val_min = 1e-5 + # # + # # ax.pcolormesh(stg.t[self.combobox_frequency.currentIndex(), :], + # # -stg.r[self.combobox_frequency.currentIndex(), :], + # # stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :], + # # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # # + # # plt.show() + # + # def compute_water_attenuation(self): + # if (stg.freq.size == 0) or (self.spinbox_temperature_water_attenuation.value() == 0): + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Water attenuation Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Load Backscatter data from acoustic data tab and enter a value of temperature") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # + # else: + # + # if self.combobox_water_attenuation_model.currentIndex() == 0: + # self.Francois_and_Garrison_1982() + # + # else: + # pass + # + # print(f"{stg.water_attenuation:.2f}") + # self.label_water_attenuation.clear() + # self.label_water_attenuation.setText("\u03B1w = " + f"{stg.water_attenuation:.4f}" + " dB/m") + # + # def Francois_and_Garrison_1982(self): + # if self.spinbox_temperature_water_attenuation.value() > 20: + # stg.water_attenuation = ((3.964 * 1e-4 - 1.146 * 1e-5 * self.spinbox_temperature_water_attenuation.value() + + # 1.45 * 1e-7 * self.spinbox_temperature_water_attenuation.value() ** 2 - + # 6.5 * 1e-10 * self.spinbox_temperature_water_attenuation.value() ** 3) * 1e-3 * + # (np.log(10) / 20) * + # (stg.freq[self.combobox_freq_for_water_attenuation.currentIndex()] * 1e-3) ** 2) + # else: + # stg.water_attenuation = ((4.937 * 1e-4 - 2.59 * 1e-5 * self.spinbox_temperature_water_attenuation.value() + + # 9.11 * 1e-7 * self.spinbox_temperature_water_attenuation.value() ** 2 - + # 1.5 * 1e-8 * self.spinbox_temperature_water_attenuation.value() ** 3) * 1e-3 * + # (np.log(10) / 20) * + # (stg.freq[self.combobox_freq_for_water_attenuation.currentIndex()] * 1e-3) ** 2) + # + # # ------------ Computing real cell size ------------ # + # def range_cells_function(self): + # """ Computing the real cell size, that depends on the temperature """ + # # defaut Aquascat cell size + # aquascat_cell_size = stg.r[0, 1] - stg.r[0, 0] + # # Pulse duration + # tau = aquascat_cell_size * 2 / 1500 # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat + # # Sound speed + # cel = self.inv_hc.water_velocity(self.spinbox_temperature_water_attenuation.value()) + # # Real cell size + # real_cell_size = cel * tau / 2 # voir fig 2.9 + # + # # Converting to real cell profile + # real_r = stg.r / aquascat_cell_size * real_cell_size # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1 + # # (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules + # + # # R with right shape (numpy array) + # R_real = real_r # np.repeat(real_r, len(stg.freq), axis=1) + # + # return R_real + # + # def compute_FCB(self): + # if stg.BS_stream_bed.size == 0: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("FCB Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Load Backscatter data from acoustic data tab and compute water attenuation") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # else: + # print(f"self.range_cells_function() : {self.range_cells_function()}") + # print(f"self.range_cells_function() shape : {self.range_cells_function().shape}") + # R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[1], axis=2) + # print(f"R_real shape : {R_real.shape}") + # if (stg.BS_stream_bed_pre_process_average.size == 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0): + # stg.FCB = (np.log(stg.BS_stream_bed) + np.log(R_real) + + # 2 * stg.water_attenuation * R_real) + # elif stg.BS_stream_bed_pre_process_SNR.size == 0: + # stg.FCB = (np.log(stg.BS_stream_bed_pre_process_average) + np.log(R_real) + + # 2 * stg.water_attenuation * R_real) + # else: + # stg.FCB = (np.log(stg.BS_stream_bed_pre_process_SNR) + np.log(R_real) + + # 2 * stg.water_attenuation * R_real) + # self.plot_FCB() + # + # def fit_FCB_profile_with_linear_regression_and_compute_alphaS(self): + # + # if stg.FCB.size == 0: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Linear regression error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Please compute FCB before") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # else: + # try: + # y0 = stg.FCB[self.combobox_frequency_compute_alphaS.currentIndex(), :, self.slider.value()] + # y = y0[np.where(np.isnan(y0) == False)] + # + # x0 = stg.r[0, :].reshape(-1) + # x = x0[np.where(np.isnan(y0) == False)] + # + # value1 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2) + # == np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2))) + # value2 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2) + # == np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2))) + # + # # print(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)) + # # # print("value1 ", value1[0][0]) + # # print(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)) + # # print("value2 ", value2[0][0]) + # + # # print("y limited ", y[value1[0][0]:value2[0][0]]) + # + # lin_reg_compute = stats.linregress(x[value1[0][0]:value2[0][0]], y[value1[0][0]:value2[0][0]]) + # except ValueError: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Linear regression error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Please check boundaries to fit a linear line") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # else: + # stg.lin_reg = (lin_reg_compute.slope, lin_reg_compute.intercept) + # # print(f"y = {stg.lin_reg[0]}x + {stg.lin_reg[1]}") + # + # self.label_alphaS.clear() + # self.label_alphaS.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m") + # + # # for i, value_freq in enumerate(stg.freq): + # # for k, value_t in enumerate(stg.t): + # # # print(f"indice i: {i}, indice k: {k}") + # # # print(f"values of FCB: {stg.FCB[:, i, k]}") + # # y = stg.FCB[:, i, k] + # # # print("y : ", y) + # # # print(f"values of FCB where FCB is not Nan {y[np.where(np.isnan(y) == False)]}") + # # # print(f"values of r where FCB is not Nan {x[np.where(np.isnan(y) == False)]}") + # # lin_reg_compute = stats.linregress(x[np.where(np.isnan(y) == False)], y[np.where(np.isnan(y) == False)]) + # # lin_reg_tuple = (lin_reg_compute.slope, lin_reg_compute.intercept) + # # stg.lin_reg.append(lin_reg_tuple) + # + # # print(f"y = {lin_reg.slope}x + {lin_reg.intercept}") + # + # # plt.figure() + # # plt.plot(stg.r, stg.FCB[:, 0, 825], 'k-', stg.r, lin_reg.slope*stg.r + lin_reg.intercept, "b--") + # # plt.show() + # + # # print("lin_reg length ", len(stg.lin_reg)) + # # print("lin_reg ", stg.lin_reg) + # + # # ---------------------------------------- PLOT PROFILE POSITION ON TRANSECT --------------------------------------- + # + # def plot_profile_position_on_transect(self): + # + # # --- Create Matplotlib canvas (with figure and axis) to plot transect --- + # self.canvas_plot_profile_position_on_transect = FigureCanvas() + # 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.verticalLayout_groupbox_display_profile_position.addWidget(self.canvas_plot_profile_position_on_transect) + # + # # --- Plot transect with profile position --- + # + # if stg.ABS_name == "Aquascat 1000R": + # if stg.BS_stream_bed.size != 0: + # + # val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + # val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], + # stg.BS_stream_bed[stg.freq_bottom_detection, :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # else: + # + # val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + # val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], + # stg.BS_cross_section[stg.freq_bottom_detection, :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.ABS_name == "UB-SediFlow": + # + # if stg.BS_stream_bed.size != 0: + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], + # np.log(stg.BS_stream_bed[stg.freq_bottom_detection, :, :]), + # cmap='Blues') + # else: + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :], + # np.log(stg.BS_cross_section[stg.freq_bottom_detection, :, :]), + # cmap='Blues') + # + # if stg.r_bottom.size != 0: + # self.axis_plot_profile_position_on_transect.plot( + # stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid") + # + # self.axis_plot_profile_position_on_transect.plot( + # stg.t[stg.freq_bottom_detection, self.slider.value() - 1] * np.ones(stg.r.shape[1]), -stg.r[stg.freq_bottom_detection, :], + # color='red', linestyle="solid", linewidth=2) + # + # self.axis_plot_profile_position_on_transect.set_xticks([]) + # self.axis_plot_profile_position_on_transect.set_yticks([]) + # + # self.figure_plot_profile_position_on_transect.canvas.draw_idle() + # + # def update_plot_profile_position_on_transect(self): + # + # # --- Update label "Profile N / max(N)" --- + # self.label_profile_number.clear() + # self.label_profile_number.setText("Vertical " + str(self.slider.value()) + " / " + str(self.slider.maximum())) + # + # # --- Update transect plot --- + # + # if self.canvas_plot_profile_position_on_transect is None: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Load and post-process data before plotting transect with profile position") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # + # else: + # + # if stg.BS_stream_bed.size != 0: + # + # if (stg.BS_stream_bed_pre_process_average.size == 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0): + # + # self.axis_plot_profile_position_on_transect.cla() + # + # val_min = np.nanmin(stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # if stg.ABS_name == "Aquascat 1000R": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # elif stg.ABS_name == "UB-SediFlow": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # np.log(stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :]), + # cmap='Blues') + # + # elif (stg.BS_stream_bed_pre_process_average.size != 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0): + # + # self.axis_plot_profile_position_on_transect.cla() + # + # val_min = np.nanmin(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # if stg.ABS_name == "Aquascat 1000R": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # elif stg.ABS_name == "UB-SediFlow": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # np.log(stg.BS_stream_bed_pre_process_average[self.combobox_frequency.currentIndex(), :, :]), + # cmap='Blues') + # + # elif stg.BS_stream_bed_pre_process_SNR.size != 0: + # + # self.axis_plot_profile_position_on_transect.cla() + # + # val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # if stg.ABS_name == "Aquascat 1000R": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # elif stg.ABS_name == "UB-SediFlow": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # np.log(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]), + # cmap='Blues') + # + # else: + # + # if (stg.BS_cross_section_averaged.size == 0) and (stg.BS_cross_section_pre_process_SNR.size == 0): + # + # self.axis_plot_profile_position_on_transect.cla() + # + # val_min = np.nanmin(stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # if stg.ABS_name == "Aquascat 1000R": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # elif stg.ABS_name == "UB-SediFlow": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # np.log(stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :]), + # cmap='Blues') + # + # elif (stg.BS_cross_section_averaged.size != 0) and (stg.BS_cross_section_pre_process_SNR.size == 0): + # + # self.axis_plot_profile_position_on_transect.cla() + # + # val_min = np.nanmin(stg.BS_cross_section_averaged[self.combobox_frequency.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_cross_section_averaged[self.combobox_frequency.currentIndex(), :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # if stg.ABS_name == "Aquascat 1000R": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # stg.BS_cross_section_averaged[self.combobox_frequency.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # elif stg.ABS_name == "UB-SediFlow": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # np.log(stg.BS_cross_section_averaged[self.combobox_frequency.currentIndex(), :, :]), + # cmap='Blues') + # + # elif stg.BS_cross_section_pre_process_SNR.size != 0: + # + # self.axis_plot_profile_position_on_transect.cla() + # + # val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]) + # val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # if stg.ABS_name == "Aquascat 1000R": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # stg.BS_cross_section_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # elif stg.ABS_name == "UB-SediFlow": + # self.axis_plot_profile_position_on_transect.pcolormesh( + # stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r[self.combobox_frequency.currentIndex(), :], + # np.log(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency.currentIndex(), :, :]), + # cmap='Blues') + # + # if stg.r_bottom.size != 0: + # self.axis_plot_profile_position_on_transect.plot(stg.t[self.combobox_frequency.currentIndex(), :], + # -stg.r_bottom, + # color='black', linewidth=1, linestyle="solid") + # + # self.axis_plot_profile_position_on_transect.plot( + # stg.t[self.combobox_frequency.currentIndex(), self.slider.value() - 1] * np.ones(stg.r.shape[1]), + # -stg.r[self.combobox_frequency.currentIndex(), :], + # color='red', linestyle="solid", linewidth=2) + # + # self.axis_plot_profile_position_on_transect.set_xticks([]) + # self.axis_plot_profile_position_on_transect.set_yticks([]) + # + # self.figure_plot_profile_position_on_transect.canvas.draw_idle() + # + # # -------------------------------------------------- PLOT PROFILE ------------------------------------------------- + # + # def plot_profile(self): + # + # # --- Raw profile --- + # + # self.figure_profile, self.axis_profile \ + # = plt.subplots(nrows=1, ncols=stg.freq.shape[0], sharex=True, sharey=True, layout='constrained') + # self.canvas_profile = FigureCanvas(self.figure_profile) + # self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile) + # # self.scroll_profile = QScrollArea() + # # self.scroll_profile.setWidget(self.canvas_profile) + # # self.scroll_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # # self.scroll_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # # self.scroll_profile.setAlignment(Qt.AlignCenter) + # # self.verticalLayout_groupbox_plot_profile.addWidget(self.scroll_profile) + # + # if stg.BS_stream_bed.size == 0: + # + # for f, _ in enumerate(stg.freq): + # self.axis_profile[f].cla() + # self.axis_profile[f].plot(stg.BS_cross_section[f, :, self.slider.value() - 1], -stg.r[f, :], + # linestyle='solid', color='k', linewidth=1) + # self.axis_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_profile[f].transAxes) + # + # else: + # + # for f, _ in enumerate(stg.freq): + # self.axis_profile[f].cla() + # self.axis_profile[f].plot(stg.BS_stream_bed[f, :, self.slider.value() - 1], -stg.r[f, :], + # linestyle='solid', color='k', linewidth=1) + # self.axis_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_profile[f].transAxes) + # + # self.figure_profile.supxlabel("Acoustic Backscatter Signal (V)") + # self.figure_profile.supylabel("Depth (m)") + # + # # --- Raw averaged profile --- + # + # self.figure_averaged_profile, self.axis_averaged_profile \ + # = plt.subplots(nrows=1, ncols=stg.freq.shape[0], sharex=True, sharey=True, layout='constrained') + # self.canvas_averaged_profile = FigureCanvas(self.figure_averaged_profile) + # self.verticalLayout_groupbox_plot_averaged_profile.addWidget(self.canvas_averaged_profile) + # # self.scroll_averaged_profile = QScrollArea() + # # self.scroll_averaged_profile.setWidget(self.canvas_averaged_profile) + # # self.scroll_averaged_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # # self.scroll_averaged_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + # # self.scroll_averaged_profile.setAlignment(Qt.AlignCenter) + # # self.verticalLayout_groupbox_plot_averaged_profile.addWidget(self.scroll_averaged_profile) + # + # # self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], + # # fontsize=10, fontweight='bold', fontname="Ubuntu", + # # fontstyle="normal", c="black", alpha=0.2, + # # horizontalalignment='right', verticalalignment='bottom', + # # transform=self.axis_averaged_profile[f].transAxes) + # + # # --- Raw FCB profile --- + # + # self.figure_FCB_profile, self.axis_FCB_profile \ + # = plt.subplots(nrows=1, ncols=stg.freq.shape[0], sharex=True, sharey=True, layout='constrained') + # self.canvas_FCB_profile = FigureCanvas(self.figure_FCB_profile) + # self.verticalLayout_groupbox_plot_FCB_profile.addWidget(self.canvas_FCB_profile) + # # self.scroll_FCB_profile = QScrollArea() + # # self.scroll_FCB_profile.setWidget(self.canvas_FCB_profile) + # # self.scroll_FCB_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # # self.scroll_FCB_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + # # self.scroll_FCB_profile.setAlignment(Qt.AlignCenter) + # # self.verticalLayout_groupbox_plot_FCB_profile.addWidget(self.scroll_FCB_profile) + # + # # self.axis_FCB_profile[f].text(.95, .05, stg.freq_text[f], + # # fontsize=10, fontweight='bold', fontname="Ubuntu", + # # fontstyle="normal", c="black", alpha=0.2, + # # horizontalalignment='right', verticalalignment='bottom', + # # transform=self.axis_FCB_profile[f].transAxes) + # + # def update_plot_profile(self): + # if self.canvas_profile is None: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Load and post-process data before plotting profiles") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # + # else: + # + # if stg.BS_stream_bed.size == 0: + # + # for f, _ in enumerate(stg.freq): + # self.axis_profile[f].cla() + # self.axis_profile[f].plot(stg.BS_cross_section[f, :, self.slider.value() - 1], -stg.r[f, :], + # linestyle='solid', color='k', linewidth=1) + # self.axis_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_profile[f].transAxes) + # + # else: + # + # for f, _ in enumerate(stg.freq): + # self.axis_profile[f].cla() + # self.axis_profile[f].plot(stg.BS_stream_bed[f, :, self.slider.value() - 1], -stg.r[f, :], + # linestyle='solid', color='k', linewidth=1) + # self.axis_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_profile[f].transAxes) + # + # self.figure_profile.supxlabel("Acoustic Backscatter Signal (V)") + # self.figure_profile.supylabel("Depth (m)") + # self.figure_profile.canvas.draw_idle() + # + # # --------------------------------- PLOT AVERAGED PROFILE FILTERED OR NOT WITH SNR --------------------------------- + # + # def plot_averaged_profile(self): + # + # if stg.BS_stream_bed_pre_process_average.size == 0: + # + # for f, _ in enumerate(stg.freq): + # self.axis_averaged_profile[f].cla() + # self.axis_averaged_profile[f].plot(stg.BS_cross_section_averaged[f, :, self.slider.value()-1], -stg.r[f, :], + # linestyle='solid', color='k', linewidth=1) + # # self.axis_averaged_profile[f].set_ylim(-np.max(stg.r[f, :]), np.min(stg.r[f, :])) + # self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_averaged_profile[f].transAxes) + # + # else: + # + # for f, _ in enumerate(stg.freq): + # self.axis_averaged_profile[f].cla() + # self.axis_averaged_profile[f].plot(stg.BS_stream_bed_pre_process_average[f, :, self.slider.value()-1], -stg.r[f, :], + # linestyle='solid', color='k', linewidth=1) + # # self.axis_averaged_profile[f].set_ylim(-np.max(stg.r[f, :]), np.min(stg.r[f, :])) + # self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_averaged_profile[f].transAxes) + # + # self.figure_averaged_profile.supxlabel("Acoustic Backscatter Signal (V)") + # self.figure_averaged_profile.supylabel("Depth (m)") + # self.figure_averaged_profile.canvas.draw_idle() + # + # def update_plot_averaged_profile(self): + # if self.canvas_averaged_profile is None: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Load and post-process data before plotting averaged profiles") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # + # else: + # + # if stg.BS_stream_bed_pre_process_average.size == 0: + # + # for f, _ in enumerate(stg.freq): + # self.axis_averaged_profile[f].cla() + # self.axis_averaged_profile[f].plot(stg.BS_cross_section_averaged[f, :, self.slider.value() - 1], + # -stg.r[f, :], + # linestyle='solid', color='k', linewidth=1) + # # self.axis_averaged_profile[f].set_ylim(-np.max(stg.r[f, :]), np.min(stg.r[f, :])) + # self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_averaged_profile[f].transAxes) + # + # else: + # + # for f, _ in enumerate(stg.freq): + # self.axis_averaged_profile[f].cla() + # self.axis_averaged_profile[f].plot(stg.BS_stream_bed_pre_process_average[f, :, self.slider.value() - 1], + # -stg.r[f, :], + # linestyle='solid', color='k', linewidth=1) + # # self.axis_averaged_profile[f].set_ylim(-np.max(stg.r[f, :]), np.min(stg.r[f, :])) + # self.axis_averaged_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_averaged_profile[f].transAxes) + # + # self.figure_averaged_profile.supxlabel("Acoustic Backscatter Signal (V)") + # self.figure_averaged_profile.supylabel("Depth (m)") + # self.figure_averaged_profile.canvas.draw_idle() + # + # # ---------------------------------------------------- PLOT FCB ---------------------------------------------------- + # + # def plot_FCB(self): + # + # for f in range(stg.freq.shape[0]): + # + # self.axis_FCB_profile[f].cla() + # + # self.axis_FCB_profile[f].plot(stg.r[f, :], stg.FCB[f, :, self.slider.value()], linestyle="solid", linewidth=1, color="k") + # + # # self.axis_FCB_profile[f].set_ylim(np.max(stg.r), np.min(stg.r)) + # self.axis_FCB_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_FCB_profile[f].transAxes) + # + # if len(stg.lin_reg) != 0: + # self.axis_FCB_profile[self.combobox_frequency_compute_alphaS.currentIndex()]. \ + # plot(stg.r[f, :], stg.lin_reg[0]*stg.r[f, :] + stg.lin_reg[1], linestyle="dashed", linewidth=1, color="b") + # + # self.figure_FCB_profile.supylabel("FCB") + # self.figure_FCB_profile.supxlabel("Depth (m)") + # self.figure_FCB_profile.canvas.draw_idle() + # + # def update_plot_FCB(self): + # + # if stg.FCB.size != 0: + # + # for f in range(stg.freq.shape[0]): + # + # self.axis_FCB_profile[f].cla() + # + # self.axis_FCB_profile[f].plot(stg.r[f, :], stg.FCB[f, :, self.slider.value()], linestyle="solid", linewidth=1, color="k") + # + # # self.axis_FCB_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r)) + # + # self.axis_FCB_profile[f].text(.95, .05, stg.freq_text[f], + # fontsize=10, fontweight='bold', fontname="Ubuntu", + # fontstyle="normal", c="black", alpha=0.2, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_FCB_profile[f].transAxes) + # + # self.figure_FCB_profile.supylabel("FCB") + # self.figure_FCB_profile.supxlabel("Depth (m)") + # self.figure_FCB_profile.canvas.draw_idle() + # diff --git a/settings.py b/settings.py index e7a3488..b3f2d9b 100644 --- a/settings.py +++ b/settings.py @@ -19,8 +19,10 @@ time = [] path_BS_noise_data = "" filename_BS_noise_data = "" -BS_noise_raw_data = np.array([]) # BS noise raw data : BS signal listen -BS_noise_averaged_data = np.array([]) # BS noise raw data averaged (array has the same shape than BS_raw_data shape) +BS_noise_raw_data = [] # BS noise raw data : BS signal listen +BS_noise_averaged_data = [] # BS noise raw data averaged (array has the same shape than BS_raw_data shape) + +noise_method = [] date = [] date_noise = [] @@ -38,8 +40,8 @@ kt_corrected = [] gain_rx = [] gain_tx = [] -SNR_data = np.array([]) # SNR is computed with BS_noise_averaged_data -time_snr = np.array([]) +SNR_raw_data = [] # SNR is computed with BS_noise_averaged_data +time_noise = [] # --- reshape raw data for table of values in Acoustic Data tab --- time_reshape = [] @@ -56,14 +58,14 @@ tmax = [] # maximum boundary of time (spin box tmin) tmax_snr = np.array([]) rmin = [] rmax = [] -BS_cross_section = [] # BS data limited with tmin and tmax values of spin box - # BS_data = stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])] -BS_stream_bed = [] # 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([]) +BS_cross_section = [] # BS data limited with tmin and tmax values of spin box + +BS_stream_bed = [] # BS_data_section = BS data in the section. Values NaN outside the bottom of the section are deleted +# BS_noise_cross_section = [] # BS_noise_cross_section = BS_noise_data[:, :, tmin:tmax] (former Noise_data) +SNR_cross_section = [] # SNR_data = snr[:, :, tmin:tmax] +SNR_stream_bed = [] time_cross_section = [] -t_snr = np.array([]) +time_snr = [] depth_cross_section = [] depth_bottom = [] val_bottom = [] @@ -80,13 +82,17 @@ depth_bottom_detection_1st_int_area = [] # BS_stream_bed_averaged = np.array([]) # BS data averaged - bottom is detected # BS_stream_bed_averaged_SNR = np.array([]) # BS data averaged and filtered with SNR - bottom is detected -BS_cross_section_pre_process_SNR = np.array([[[]]]) # BS data filtered with SNR values (remove point if SNR < value) - bottom is not detected -BS_cross_section_pre_process_average = np.array([[[]]]) # BS data averaged - bottom is not detected -BS_cross_section_pre_process_SNR_average = np.array([[[]]]) # BS data averaged and filtered with SNR - bottom is not detected +BS_raw_data_pre_process_SNR = [] +BS_raw_data_pre_process_average = [] +BS_raw_data_pre_process_SNR_average = [] -BS_stream_bed_pre_process_SNR = np.array([]) # BS data filtered with SNR values (remove point if SNR < value) - bottom is detected -BS_stream_bed_pre_process_average = np.array([]) # BS data averaged - bottom is detected -BS_stream_bed_pre_process_SNR_average = np.array([]) # BS data averaged and filtered with SNR - bottom is detected +BS_cross_section_pre_process_SNR = [] # BS data filtered with SNR values (remove point if SNR < value) - bottom is not detected +BS_cross_section_pre_process_average = [] # BS data averaged - bottom is not detected +BS_cross_section_pre_process_SNR_average = [] # BS data averaged and filtered with SNR - bottom is not detected + +BS_stream_bed_pre_process_SNR = [] # BS data filtered with SNR values (remove point if SNR < value) - bottom is detected +BS_stream_bed_pre_process_average = [] # BS data averaged - bottom is detected +BS_stream_bed_pre_process_SNR_average = [] # 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)