diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index 87e56da..a05ad03 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -9,6 +9,7 @@ from PyQt5.QtCore import Qt, QCoreApplication, QEvent, pyqtSignal import numpy as np from copy import deepcopy from scipy.ndimage import convolve1d +from astropy.convolution import convolve, Gaussian2DKernel import matplotlib.pyplot as plt from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas @@ -91,8 +92,11 @@ class SignalProcessingTab(QWidget): 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) + self.groupbox_pre_processing_option = QGroupBox() + self.horizontalLayout_Top.addWidget(self.groupbox_pre_processing_option, 4) + + # self.groupbox_plot_BS_signal_filtered_with_SNR = QGroupBox() + # self.horizontalLayout_Top.addWidget(self.groupbox_plot_BS_signal_filtered_with_SNR, 4) # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # +++ --- Download noise file + compute noise data from profile tail + --- +++ @@ -189,23 +193,9 @@ class SignalProcessingTab(QWidget): ### --- Push button plot noise --- - 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 < ") - 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) - self.pushbutton_Apply_SNR_filter = QPushButton() - self.gridLayout_SNR_criterion.addWidget(self.pushbutton_Apply_SNR_filter, 0, 2, 1, 1) - - self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_SNR_criterion) + # self.pushbutton_plot_noise = QPushButton() + # self.pushbutton_plot_noise.setText("Plot noise") + # self.verticalLayout_groupbox_study_data.addWidget(self.pushbutton_plot_noise) # +++++++++++++++++++++++++++++ # +++ --- Plot SNR data --- +++ @@ -242,8 +232,8 @@ class SignalProcessingTab(QWidget): # 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.toolbar_SNR = NavigationToolBar(self.canvas_SNR, self) + self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR) self.scroll_SNR = QScrollArea() self.scroll_SNR.setWidget(self.canvas_SNR) @@ -254,50 +244,26 @@ class SignalProcessingTab(QWidget): # 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.canvas_BS = None - # self.scroll_BS = None - - 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 - - self.groupbox_pre_processing = QGroupBox() - self.horizontalLayout_Bottom.addWidget(self.groupbox_pre_processing, 4) - - self.groupbox_plot_pre_processed_data = QGroupBox() - self.horizontalLayout_Bottom.addWidget(self.groupbox_plot_pre_processed_data, 5) - - self.groupbox_list_pre_processed_data = QGroupBox() - self.horizontalLayout_Bottom.addWidget(self.groupbox_list_pre_processed_data, 1) - # +++++++++++++++++++++++++++++++++++++ # +++ --- Pre-processing option --- +++ # +++++++++++++++++++++++++++++++++++++ - self.verticalLayout_groupbox_pre_processing = QVBoxLayout(self.groupbox_pre_processing) + self.verticalLayout_groupbox_pre_processing_option = QVBoxLayout(self.groupbox_pre_processing_option) + + ### --- 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 < ") + 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) + self.pushbutton_Apply_SNR_filter = QPushButton() + self.gridLayout_SNR_criterion.addWidget(self.pushbutton_Apply_SNR_filter, 0, 2, 1, 1) + + self.verticalLayout_groupbox_pre_processing_option.addWidget(self.groupbox_SNR_criterion) # --- Rayleigh criterion groupbox --- self.groupbox_Rayleigh_criterion = QGroupBox() @@ -320,7 +286,7 @@ class SignalProcessingTab(QWidget): self.pushbutton_despiking_signal.setText("Despiking the signal") self.gridLayout_Rayleigh_criterion.addWidget(self.pushbutton_despiking_signal, 0, 3, 1, 1) - self.verticalLayout_groupbox_pre_processing.addWidget(self.groupbox_Rayleigh_criterion) + self.verticalLayout_groupbox_pre_processing_option.addWidget(self.groupbox_Rayleigh_criterion) # --- Average signal groupbox --- self.groupbox_window_size = QGroupBox() @@ -344,25 +310,106 @@ class SignalProcessingTab(QWidget): self.pushbutton_average.setText("Apply averaging") self.gridLayout_groupbox_window_size.addWidget(self.pushbutton_average, 0, 3, 1, 1) - self.verticalLayout_groupbox_pre_processing.addWidget(self.groupbox_window_size) + self.verticalLayout_groupbox_pre_processing_option.addWidget(self.groupbox_window_size) - # +++++++++++++++++++++++++++++++++++++++ - # +++ --- Plot pre-processed data --- +++ - # +++++++++++++++++++++++++++++++++++++++ + # # ++++++++++++++++++++++++++++++++++++++++++++++ + # # +++ --- 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.canvas_BS = None + # # self.scroll_BS = None + # + # 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) - self.verticalLayout_groupbox_plot_pre_processed_data = QVBoxLayout(self.groupbox_plot_pre_processed_data) + # -------------------------------------------------------------------------------------------------------------- + ### --- Layout of groupbox in the bottom layout box + + # self.groupbox_pre_processing = QGroupBox() + # self.horizontalLayout_Bottom.addWidget(self.groupbox_pre_processing, 4) + + self.groupbox_plot_pre_processed_data_2D_field = QGroupBox() + self.horizontalLayout_Bottom.addWidget(self.groupbox_plot_pre_processed_data_2D_field, 5) + + self.groupbox_plot_pre_processed_data_profile = QGroupBox() + self.horizontalLayout_Bottom.addWidget(self.groupbox_plot_pre_processed_data_profile, 3) + + self.groupbox_list_pre_processed_data = QGroupBox() + self.horizontalLayout_Bottom.addWidget(self.groupbox_list_pre_processed_data, 2) + + # ++++++++++++++++++++++++++++++++++++++++++++++++ + # +++ --- Plot pre-processed data 2D field --- +++ + # ++++++++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field = QVBoxLayout( + self.groupbox_plot_pre_processed_data_2D_field) + + # self.horizontalLayout_label_profile_number_combobox_frequency_profile = QHBoxLayout() + # self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addLayout(self.horizontalLayout_label_profile_number_combobox_frequency_profile) + # self.label_profile_number = QLabel() + # self.label_profile_number.setText("Profile ") + # self.horizontalLayout_label_profile_number_combobox_frequency_profile.addWidget(self.label_profile_number) + # self.spacerItem_frequency_profile = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) + # self.horizontalLayout_label_profile_number_combobox_frequency_profile.addSpacerItem(self.spacerItem_frequency_profile) + # self.combobox_frequency_profile = QComboBox() + # self.horizontalLayout_label_profile_number_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) + + self.canvas_BS = FigureCanvas() + self.toolbar_BS = NavigationToolBar(self.canvas_BS, self) + + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.toolbar_BS) + + self.scroll_BS = QScrollArea() + self.scroll_BS.setWidget(self.canvas_BS) + self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_BS.setWidgetResizable(True) + self.scroll_BS.setAlignment(Qt.AlignCenter) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.scroll_BS) + + # +++++++++++++++++++++++++++++++++++++++++++++++ + # +++ --- Plot pre-processed data profile --- +++ + # +++++++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_plot_pre_processed_data_2D_profile = QVBoxLayout( + self.groupbox_plot_pre_processed_data_profile) + + self.horizontalLayout_profile_frequency = QHBoxLayout() + self.verticalLayout_groupbox_plot_pre_processed_data_2D_profile.addLayout( + self.horizontalLayout_profile_frequency) - self.horizontalLayout_label_profile_number_combobox_frequency_profile = QHBoxLayout() - self.verticalLayout_groupbox_plot_pre_processed_data.addLayout(self.horizontalLayout_label_profile_number_combobox_frequency_profile) - self.label_profile_number = QLabel() - self.label_profile_number.setText("Profile ") - self.horizontalLayout_label_profile_number_combobox_frequency_profile.addWidget(self.label_profile_number) self.spacerItem_frequency_profile = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) - self.horizontalLayout_label_profile_number_combobox_frequency_profile.addSpacerItem(self.spacerItem_frequency_profile) + self.horizontalLayout_profile_frequency.addSpacerItem(self.spacerItem_frequency_profile) self.combobox_frequency_profile = QComboBox() - self.horizontalLayout_label_profile_number_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) + self.horizontalLayout_profile_frequency.addWidget(self.combobox_frequency_profile) - self.canvas_profile = None + self.groupbox_plot_profile = QGroupBox() + self.verticalLayout_groupbox_plot_profile = QVBoxLayout(self.groupbox_plot_profile) + + self.canvas_profile = FigureCanvas() + self.toolbar_profile = NavigationToolBar(self.canvas_profile, self) + + self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile) + + self.verticalLayout_groupbox_plot_pre_processed_data_2D_profile.addWidget(self.groupbox_plot_profile) # --- Figure to plot profiles and BS signal 2D field below--- # self.verticalLayout_groupbox_plot_pre_processed_data.removeWidget(self.canvas_profile) @@ -371,21 +418,19 @@ class SignalProcessingTab(QWidget): # # '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) - self.scroll_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.scroll_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_BS.setWidgetResizable(True) - self.scroll_profile.setAlignment(Qt.AlignCenter) - self.verticalLayout_groupbox_plot_pre_processed_data.addWidget(self.scroll_profile) + # self.scroll_profile = QScrollArea() + # self.scroll_profile.setWidget(self.canvas_profile) + # self.scroll_profile.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + # self.scroll_profile.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # # self.scroll_BS.setWidgetResizable(True) + # self.scroll_profile.setAlignment(Qt.AlignCenter) + # self.verticalLayout_groupbox_plot_pre_processed_data.addWidget(self.scroll_profile) # self.verticalLayout_groupbox_plot_pre_processed_data.addWidget(self.canvas_profile) # --- Slider for moving the profile --- self.horizontalLayout_slider = QHBoxLayout() - self.verticalLayout_groupbox_plot_pre_processed_data.addLayout(self.horizontalLayout_slider) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_profile.addLayout(self.horizontalLayout_slider) self.pushbutton_slider_left_to_begin = QPushButton() self.pushbutton_slider_left_to_begin.setIcon(self.icon_triangle_left_to_begin) @@ -414,7 +459,7 @@ class SignalProcessingTab(QWidget): self.slider.setOrientation(Qt.Horizontal) self.slider.setCursor(Qt.OpenHandCursor) self.slider.setMinimum(1) - self.slider.setMaximum(100) + self.slider.setMaximum(10) self.slider.setTickInterval(1) self.slider.setValue(1) @@ -422,15 +467,40 @@ class SignalProcessingTab(QWidget): # +++ --- List of pre-processed data --- +++ # ++++++++++++++++++++++++++++++++++++++++++ - self.verticalLayout_list_pre_processed_data = QVBoxLayout(self.groupbox_list_pre_processed_data) + self.verticalLayout_groupbox_list_pre_processed_data = QVBoxLayout(self.groupbox_list_pre_processed_data) - self.plaintextedit_list_pre_processed_data = QPlainTextEdit() - self.verticalLayout_list_pre_processed_data.addWidget(self.plaintextedit_list_pre_processed_data) + # Create a scroll area + self.scrollArea_list_preprocessed_data = QScrollArea() + self.verticalLayout_groupbox_list_pre_processed_data.addWidget(self.scrollArea_list_preprocessed_data) + + # Set scrollbar policies + self.scrollArea_list_preprocessed_data.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + self.scrollArea_list_preprocessed_data.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + self.scroll_BS.setAlignment(Qt.AlignLeft) + + # Create a widget to be scrolled + self.widget_scrollArea_list_preprocessed_data = QWidget() + self.verticalLayout_scrollArea_list_pre_processed_data = QVBoxLayout() + self.widget_scrollArea_list_preprocessed_data.setLayout(self.verticalLayout_scrollArea_list_pre_processed_data) + + # Add content to the widget (labels in this example) + # QPlainTextEdit().setMaximumSize(maxw=10, maxh=) + for i in range(20): + exec("self.lineEdit_list_pre_processed_data_" + str(i) + "= QLineEdit()") + # eval("self.plaintextedit_" + str(i) + ".setMaximumSize(maxw=" + str(50)+ ", maxh=" + str(10) + ")") + eval("self.verticalLayout_scrollArea_list_pre_processed_data.addWidget(" + "self.lineEdit_list_pre_processed_data_" + str(i) + ")") + eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)") + # self.plaintextedit_list_pre_processed_data = QPlainTextEdit() + # self.verticalLayout_list_pre_processed_data.addWidget(self.plaintextedit_list_pre_processed_data) + + # Set the widget as the scroll area's widget + self.scrollArea_list_preprocessed_data.setWidget(self.widget_scrollArea_list_preprocessed_data) + self.scrollArea_list_preprocessed_data.setWidgetResizable(True) # self.plaintextedit_list_pre_processed_data.appendPlainText("blablabla \nblobloblo") # -------------------------------------------------------------------------------------------------------------- - # --- Connect signal of widget --- self.pushbutton_update.clicked.connect(self.update_SignalPreprocessingTab) @@ -449,9 +519,13 @@ class SignalProcessingTab(QWidget): self.pushbutton_compute_noise_from_value.clicked.connect(self.compute_noise_from_value) self.pushbutton_Apply_SNR_filter.clicked.connect(self.remove_point_with_snr_filter) + # self.pushbutton_Apply_SNR_filter.clicked.connect(self.plot_pre_processed_BS_signal) + # self.pushbutton_Apply_SNR_filter.clicked.connect(self.update_plot_pre_processed_profile) + self.spinbox_average_horizontal.valueChanged.connect(self.update_label_cells_sec) 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_average.clicked.connect(self.plot_pre_processed_BS_signal) + # self.pushbutton_average.clicked.connect(self.update_plot_pre_processed_profile) self.pushbutton_slider_left_to_begin.clicked.connect(self.slide_profile_number_to_begin) @@ -464,7 +538,7 @@ class SignalProcessingTab(QWidget): 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) + self.slider.valueChanged.connect(self.update_plot_pre_processed_profile) # ______ _______ # | | | | \ @@ -1060,13 +1134,15 @@ class SignalProcessingTab(QWidget): # self.pushbutton_plot_SNR.setText("Plot SNR") self.pushbutton_Apply_SNR_filter.setText("Apply SNR") - self.groupbox_plot_BS_signal_filtered_with_SNR.setTitle("Plot BS signal filtered with SNR") + # self.groupbox_plot_BS_signal_filtered_with_SNR.setTitle("Plot BS signal filtered with SNR") - self.groupbox_pre_processing.setTitle("Pre-processing") + self.groupbox_pre_processing_option.setTitle("Pre-processing options") self.groupbox_Rayleigh_criterion.setTitle("Rayleigh criterion") self.groupbox_window_size.setTitle("Window size") - self.groupbox_plot_pre_processed_data.setTitle("Plot pre-processed data") + self.groupbox_plot_pre_processed_data_2D_field.setTitle("Display pre-processed data 2D fields") + + self.groupbox_plot_pre_processed_data_profile.setTitle("Display pre-processed data profile") self.groupbox_list_pre_processed_data.setTitle("List pre-processed data") @@ -1135,11 +1211,17 @@ class SignalProcessingTab(QWidget): # self.combobox_fileListWidget.setCurrentIndex(0) # self.combobox_fileListWidget.currentIndexChanged.connect(self.combobox_fileListWidget_change_index) - self.plaintextedit_list_pre_processed_data.clear() for t in range(self.combobox_fileListWidget.count()): - self.plaintextedit_list_pre_processed_data.appendPlainText(stg.filename_BS_raw_data[t] + "\n") + eval("self.lineEdit_list_pre_processed_data_" + str(t) + ".clear()") + eval("self.lineEdit_list_pre_processed_data_" + str(t) + ".setText(stg.filename_BS_raw_data[t])") - self.plaintextedit_list_pre_processed_data.textChanged.connect(self.rename_data_preprocessed) + for i in range(self.combobox_fileListWidget.count()): + eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)") + + eval("self.lineEdit_list_pre_processed_data_" + str( + self.combobox_fileListWidget.currentIndex()) + ".setEnabled(True)") + eval("self.lineEdit_list_pre_processed_data_" + str( + self.combobox_fileListWidget.currentIndex()) + ".returnPressed.connect(self.rename_preprocessed_data)") # if self.combobox_fileListWidget.count() > 0: # for c in range(self.combobox_frequency_profile.count()): @@ -1212,20 +1294,31 @@ class SignalProcessingTab(QWidget): # stg.BS_cross_section_pre_process_average[c] = ( # stg.BS_cross_section_pre_process_average[c][:, stg.BS_cross_section[c].shape[1],stg.BS_cross_section[c].shape[2]]) - def rename_data_preprocessed(self): - print("stg.data_preprocessed ", stg.data_preprocessed) - print("QPlainTextEdit.textCursor().blockNumber() ", QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()) - line_number = int(QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()/2) - stg.data_preprocessed[line_number] = ( - QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()/2) - print("stg.data_preprocessed ", stg.data_preprocessed) - line = QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber() - print(self.plaintextedit_list_pre_processed_data.setTextCursor(QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data))) - # textCursor().currentList().itemText(line) + def rename_preprocessed_data(self): + print("Before : stg.data_preprocessed ", stg.data_preprocessed) + exec("stg.data_preprocessed[self.combobox_fileListWidget.currentIndex()] = " + "self.lineEdit_list_pre_processed_data_" + str(self.combobox_fileListWidget.currentIndex()) + ".text()") + print("After : stg.data_preprocessed ", stg.data_preprocessed) + # print("QPlainTextEdit.textCursor().blockNumber() ", QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()) + # line_number = int(QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()/2) + # stg.data_preprocessed[line_number] = ( + # QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()/2) + # print("stg.data_preprocessed ", stg.data_preprocessed) + # line = QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber() + # print(self.plaintextedit_list_pre_processed_data.setTextCursor(QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data))) + # # textCursor().currentList().itemText(line) + # stg.data_preprocessed def combobox_fileListWidget_change_index(self): + for i in range(self.combobox_fileListWidget.count()): + eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)") + eval("self.lineEdit_list_pre_processed_data_" + str( + self.combobox_fileListWidget.currentIndex()) + ".setEnabled(True)") + eval("self.lineEdit_list_pre_processed_data_" + str( + self.combobox_fileListWidget.currentIndex()) + ".returnPressed.connect(self.rename_preprocessed_data)") + if (stg.noise_method[self.combobox_fileListWidget.currentIndex()] == 1)\ or (stg.noise_method[self.combobox_fileListWidget.currentIndex()] == 0): self.radiobutton_file.setChecked(True) @@ -1244,9 +1337,15 @@ class SignalProcessingTab(QWidget): self.spinbox_SNR_criterion.setValue(stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex()]) self.plot_transect_with_SNR_data() - self.plot_BS_signal_filtered_with_SNR() + # self.plot_BS_signal_filtered_with_SNR() + self.plot_pre_processed_BS_signal() self.spinbox_average_horizontal.setValue(stg.Nb_cells_to_average_BS_signal[self.combobox_fileListWidget.currentIndex()]) - self.plot_profile_and_position_on_transect_with_slider() + # self.plot_profile_and_position_on_transect_with_slider() + + self.combobox_frequency_profile.clear() + self.combobox_frequency_profile.addItems( + [f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex()]]) + self.plot_pre_processed_profile() def onClicked_radiobutton_noise_data(self): # radiobutton = self.sender() @@ -1279,15 +1378,15 @@ class SignalProcessingTab(QWidget): stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()] = np.array([]) stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) + # stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()] = np.array([]) stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) + # stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()] = np.array([]) stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) + # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) print("All is clear") @@ -1301,33 +1400,48 @@ class SignalProcessingTab(QWidget): self.spinbox_compute_noise_from_value.setValue(0) self.spinbox_SNR_criterion.setValue(0) - self.spinbox_average_horizontal.setValue(0) - self.label_profile_number.clear() - self.label_profile_number.setText("Profile ") + # self.label_profile_number.clear() + # self.label_profile_number.setText("Profile ") + + # --- Clear SNR plot --- + self.verticalLayout_groupbox_plot_SNR.removeWidget(self.toolbar_SNR) + self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR) - self.canvas_SNR.figure.clear() - self.fig_SNR.clf() - self.axis_SNR.tolist().clear() self.canvas_SNR = FigureCanvas() + self.toolbar_SNR = NavigationToolBar(self.canvas_SNR, self) self.scroll_SNR.setWidget(self.canvas_SNR) + + self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR) + self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) print("SNR plot is clear") - self.canvas_BS.figure.clear() - self.fig_BS.clf() - self.axis_BS.tolist().clear() + # --- Clear BS plot --- + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.toolbar_BS) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.scroll_BS) + self.canvas_BS = FigureCanvas() + self.toolbar_BS = NavigationToolBar(self.canvas_BS, self) self.scroll_BS.setWidget(self.canvas_BS) + + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.toolbar_BS) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.scroll_BS) print("BS plot is clear") self.combobox_frequency_profile.clear() - self.canvas_profile.figure.clear() - self.figure_profile.clf() - self.axis_profile.tolist().clear() + self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile) + self.canvas_profile = FigureCanvas() - self.scroll_profile.setWidget(self.canvas_profile) + self.toolbar_profile = NavigationToolBar(self.canvas_profile, self) + + self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile) + + self.slider.setValue(1) + self.slider.setMaximum(10) print("Profile plot is clear") self.slider.setValue(0) @@ -1366,10 +1480,14 @@ class SignalProcessingTab(QWidget): # 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() + # !!!!! A DECOCHER !!!!!!!! + # self.remove_point_with_snr_filter() + + self.combobox_frequency_profile.clear() self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex()]]) - self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_profile_and_position_on_transect_with_slider) + self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_pre_processed_BS_signal) + self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_pre_processed_profile) if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): @@ -1392,9 +1510,14 @@ class SignalProcessingTab(QWidget): # # self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex()].shape[1]) - self.compute_averaged_BS_data() + # !!!!! A DECOCHER !!!!!!!! + # self.compute_averaged_BS_data() - self.plot_profile_and_position_on_transect_with_slider() + # !!!!! A DECOCHER !!!!!!!! + # self.plot_profile_and_position_on_transect_with_slider() + + self.plot_pre_processed_BS_signal() + self.plot_pre_processed_profile() stg.noise_method[self.combobox_fileListWidget.currentIndex()] = 1 @@ -1605,22 +1728,22 @@ class SignalProcessingTab(QWidget): else: self.spinbox_SNR_criterion.setValue(stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex()]) - self.plot_transect_with_SNR_data() + # self.remove_point_with_snr_filter() - self.remove_point_with_snr_filter() - - self.combobox_frequency_profile.addItems( - [f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex()]]) - self.combobox_frequency_profile.currentIndexChanged.connect( - self.plot_profile_and_position_on_transect_with_slider) + # self.combobox_frequency_profile.addItems( + # [f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex()]]) + # self.combobox_frequency_profile.currentIndexChanged.connect( + # self.update_plot_pre_processed_profile) if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]) else: self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex()].shape[1]) - self.compute_averaged_BS_data() - self.plot_profile_and_position_on_transect_with_slider() + self.plot_transect_with_SNR_data() + # self.compute_averaged_BS_data() + self.plot_pre_processed_BS_signal() + self.plot_pre_processed_profile() def plot_noise(self): self.horizontalLayout_groupbox_plot_noise_data.removeWidget(self.canvas_noise) @@ -1680,9 +1803,13 @@ class SignalProcessingTab(QWidget): if ((self.combobox_fileListWidget.currentIndex() != -1) and (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,))): + self.verticalLayout_groupbox_plot_SNR.removeWidget(self.toolbar_SNR) + self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR) + self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq[self.combobox_fileListWidget.currentIndex()].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.toolbar_SNR = NavigationToolBar(self.canvas_SNR, self) # self.verticalLayout_groupbox_plot_SNR @@ -1690,12 +1817,14 @@ class SignalProcessingTab(QWidget): # self.scroll_SNR = QScrollArea() self.scroll_SNR.setWidget(self.canvas_SNR) - 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) + self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR) + self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): if stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): @@ -1804,12 +1933,16 @@ class SignalProcessingTab(QWidget): else: - # self.canvas_SNR.figure.clear() - # self.fig_SNR.clf() - # self.axis_SNR.tolist().clear() + self.verticalLayout_groupbox_plot_SNR.removeWidget(self.toolbar_SNR) + self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR) + self.canvas_SNR = FigureCanvas() + self.toolbar_SNR = NavigationToolBar(self.canvas_SNR, self) self.scroll_SNR.setWidget(self.canvas_SNR) + self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR) + self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) + def remove_point_with_snr_filter(self): if len(stg.BS_noise_raw_data) == 0: @@ -1897,23 +2030,28 @@ class SignalProcessingTab(QWidget): # np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ # = np.nan - self.plot_BS_signal_filtered_with_SNR() + # self.plot_pre_processed_BS_signal() # self.update_plot_profile_position_on_transect() # self.update_plot_averaged_profile() + # !!! A DECOCHER !!! self.compute_averaged_BS_data() - self.plot_profile_and_position_on_transect_with_slider() + self.update_plot_pre_processed_profile() + def plot_pre_processed_BS_signal(self): - def plot_BS_signal_filtered_with_SNR(self): - - # self.verticalLayout_groupbox_BS_SNR_filter.removeWidget(self.scroll_BS) + self.spinbox_average_horizontal.setValue( + stg.Nb_cells_to_average_BS_signal[self.combobox_fileListWidget.currentIndex()]) if ((self.combobox_fileListWidget.currentIndex() != -1) and (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,))): + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.toolbar_BS) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.scroll_BS) + self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.combobox_fileListWidget.currentIndex()].shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") self.canvas_BS = FigureCanvas(self.fig_BS) + self.toolbar_BS = NavigationToolBar(self.canvas_BS, self) # self.verticalLayout_groupbox_plot_SNR.addWidget(self.canvas_SNR) # self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR) @@ -1924,9 +2062,61 @@ class SignalProcessingTab(QWidget): # self.scroll_BS.setAlignment(Qt.AlignCenter) # self.verticalLayout_groupbox_BS_SNR_filter.addWidget(self.scroll_BS) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.toolbar_BS) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.scroll_BS) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + if stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + val_min = np.nanmin(stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax(stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + self.axis_BS[f].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth_bottom[self.combobox_fileListWidget.currentIndex()], + color='black', linewidth=1, linestyle="solid") + + elif stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + val_min = np.nanmin( + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax( + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh( + stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + val_min = np.nanmin( + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax( + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_raw_data_pre_process_average[ + self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) @@ -1959,7 +2149,7 @@ class SignalProcessingTab(QWidget): stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: + elif stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): val_min = np.nanmin( stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) @@ -1975,11 +2165,105 @@ class SignalProcessingTab(QWidget): self.combobox_fileListWidget.currentIndex()][f, :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + elif stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + val_min = np.nanmin( + stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax( + stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_stream_bed[ + self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + val_min = np.nanmin( + stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax( + stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_cross_section[ + self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + elif stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + val_min = np.nanmin( + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax( + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :]) + + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_raw_data[ + self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + self.axis_BS[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex()][f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_BS[f].transAxes) + # --- Display red line on acoustic recording for profile position --- + # print("current freq profile ", self.combobox_frequency_profile.currentIndex()) + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle="solid", linewidth=2, color="red") + + elif stg.time[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + stg.time[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle="solid", linewidth=2, color="red") + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + np.ones(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle="solid", linewidth=2, color="red") + + elif stg.time[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + stg.time[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + np.ones(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle="solid", linewidth=2, color="red") + self.fig_BS.supxlabel('Time (sec)', fontsize=10) self.fig_BS.supylabel('Depth (m)', fontsize=10) cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right') @@ -1988,116 +2272,234 @@ class SignalProcessingTab(QWidget): else: - # self.canvas_BS.figure.clear() - # self.fig_BS.clf() - # self.axis_BS.tolist().clear() + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.toolbar_BS) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.scroll_BS) + self.canvas_BS = FigureCanvas() + self.toolbar_BS = NavigationToolBar(self.canvas_BS, self) self.scroll_BS.setWidget(self.canvas_BS) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.toolbar_BS) + self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.scroll_BS) + def update_label_cells_sec(self): + + print("Je change la valeur du moyennage") + print(stg.nb_profiles_per_sec) + print(stg.nb_profiles_per_sec[self.combobox_fileListWidget.currentIndex()][0]) + print(self.combobox_fileListWidget.currentIndex()) + self.label_cells_horizontal.clear() + self.label_cells_horizontal.setText( + "cells = +/- " + + str((self.spinbox_average_horizontal.value() // 2) * + (1 / stg.nb_profiles_per_sec[self.combobox_fileListWidget.currentIndex()][0])) + + " sec") def compute_averaged_BS_data(self): - 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() + kernel_avg = np.ones(2 * self.spinbox_average_horizontal.value() + 1) + print(kernel_avg) - else: + stg.Nb_cells_to_average_BS_signal[self.combobox_fileListWidget.currentIndex()] = ( + self.spinbox_average_horizontal.value()) - kernel = np.ones(2*self.spinbox_average_horizontal.value()+1) - print(kernel) + if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): - if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] = (deepcopy( + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()])) - # --- Données pré-traitées avec SNR : BS stream bed pre process SNR -> BS stream bed pre process SNR average --- + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i,:] = ( + # convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + convolve(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], + kernel_avg)) - if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): - # ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or - # (stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape))): + print("1 - Je suis dans stg.BS_stream_bed_pre_process_SNR") - stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) + elif stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i,:] \ - = convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) - print("1 - Je suis dans stg.BS_stream_bed_pre_process_SNR_average") + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] = (deepcopy( + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()])) - # --- Données BS stream bed : BS stream bed -> BS stream bed pre process average --- + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + # convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + convolve(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], + kernel_avg)) - else: - # elif ((stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape) or - # (stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape)): + print("2 - Je suis dans stg.BS_cross_section_pre_process_SNR") - stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) + elif stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): - stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ - = convolve1d(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) - print("2 - Je suis dans stg.BS_stream_bed_pre_process_average") + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] = (deepcopy( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()])) - elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + # convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + convolve(stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], + kernel_avg)) - # --- Données pré-traitées avec SNR : BS cross section pre process SNR -> BS cross section pre process SNR average --- + print("3 - Je suis dans stg.BS_raw_data_pre_process_SNR") - if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): - # if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or - # (stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape)): + elif stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): - stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR) + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] = (deepcopy( + stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()])) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ - = convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) - print("3 - Je suis dans stg.BS_cross_section_pre_process_SNR_average") + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + # convolve1d(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][ + # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + convolve(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][f, i, :], kernel_avg)) - # --- Données BS section : BS cross section -> BS cross section pre process average --- + print("4 - Je suis dans stg.BS_stream_bed") - else: - # elif ((stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape) or - # (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape)): + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): - stg.BS_cross_section_pre_process_average = deepcopy(stg.BS_cross_section) + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] = (deepcopy( + stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()])) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): - stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ - = convolve1d(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) - print("4 - Je suis dans stg.BS_cross_section_pre_process_average") + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + # convolve1d(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][ + # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + convolve(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][f, i, :], + kernel_avg)) - else: + print("5 - Je suis dans stg.BS_cross_section") - # --- Données pré-traitées avec SNR : BS raw data pre process SNR -> BS raw data pre process SNR average --- + elif stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,): - if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): - # if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or - # (stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape)): + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] = (deepcopy( + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()])) - 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()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + # convolve1d(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][ + # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] = ( + convolve(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][f, i, :], kernel_avg)) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ - = convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) - print("5 - Je suis dans stg.BS_raw_data_pre_process_SNR_average") + print("6 - Je suis dans stg.BS_raw_data") - # --- Données BS brutes : BS raw data -> BS raw data pre process average --- + self.plot_pre_processed_BS_signal() + self.update_plot_pre_processed_profile() - else: - - stg.BS_raw_data_pre_process_average = deepcopy(stg.BS_raw_data) - - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): - stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i,:] \ - = convolve1d(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) - print("6 - Je suis dans stg.BS_raw_data_pre_process_average") + # 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: + # + # kernel = np.ones(2*self.spinbox_average_horizontal.value()+1) + # print(kernel) + # + # if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # + # # --- Données pré-traitées avec SNR : BS stream bed pre process SNR -> BS stream bed pre process SNR average --- + # + # if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # # ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or + # # (stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape))): + # + # stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) + # + # for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i,:] \ + # = convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) + # print("1 - Je suis dans stg.BS_stream_bed_pre_process_SNR_average") + # + # # --- Données BS stream bed : BS stream bed -> BS stream bed pre process average --- + # + # else: + # # elif ((stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape) or + # # (stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape)): + # + # stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) + # + # for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ + # = convolve1d(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) + # print("2 - Je suis dans stg.BS_stream_bed_pre_process_average") + # + # elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # + # # --- Données pré-traitées avec SNR : BS cross section pre process SNR -> BS cross section pre process SNR average --- + # + # if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # # if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or + # # (stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape)): + # + # stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR) + # + # for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ + # = convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][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()].shape) or + # # (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape)): + # + # stg.BS_cross_section_pre_process_average = deepcopy(stg.BS_cross_section) + # + # for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ + # = convolve1d(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][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 stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # # if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or + # # (stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].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()]): + # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ + # = convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][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()]): + # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i,:] \ + # = convolve1d(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][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()].shape == # stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape): @@ -2163,263 +2565,741 @@ class SignalProcessingTab(QWidget): # 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() + # !!!!!!!!! A DECOCHER !!!!!!!!!!! + # self.plot_profile_and_position_on_transect_with_slider() - def plot_profile_and_position_on_transect_with_slider(self): - - # --- Update label "Profile N / max(N)" --- - self.label_profile_number.clear() - self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum())) + def plot_pre_processed_profile(self): if ((self.combobox_fileListWidget.currentIndex() != -1) and (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,))): - self.figure_profile, self.axis_profile = plt.subplots(nrows=2, ncols=1, layout="constrained") + self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile) + + self.figure_profile, self.axis_profile = plt.subplots(nrows=1, ncols=1, layout="constrained") self.canvas_profile = FigureCanvas(self.figure_profile) - self.scroll_profile.setWidget(self.canvas_profile) + # self.scroll_profile.setWidget(self.canvas_profile) + self.toolbar_profile = NavigationToolBar(self.canvas_profile, self) - self.axis_profile[0].cla() - self.axis_profile[1].cla() + self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile) - if stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # --- PLot profile --- - # --- Plot profile --- - self.axis_profile[0].plot( - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], + if stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + 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()][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_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax( - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] - [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()][self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): - elif stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + self.axis_profile.plot( + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) - # --- Plot profile --- - self.axis_profile[0].plot( - stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ - 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()][ - 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) + elif stg.BS_cross_section_pre_process_average[self.combobox_frequency_profile.currentIndex()].shape != (0,): - # --- 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()] - [self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax( - stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] - [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()][ - self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ - self.combobox_frequency_profile.currentIndex(), :], - stg.BS_stream_bed_pre_process_average[ - self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): - elif stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + self.axis_profile.plot( + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) - # --- Plot profile --- - self.axis_profile[0].plot( - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ - 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()][ - 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) + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): - # --- 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()] - [self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax( - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] - [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()][ - self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ - self.combobox_frequency_profile.currentIndex(), :], - stg.BS_cross_section_pre_process_SNR_average[ - self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - elif stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): - - # --- Plot profile --- - self.axis_profile[0].plot( - stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ - 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()][ - 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_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax( - stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] - [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()][ - self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ - self.combobox_frequency_profile.currentIndex(), :], - stg.BS_cross_section_pre_process_average[ - self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - elif stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): - - # --- Plot profile --- - self.axis_profile[0].plot( - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ - 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()][ - 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()] - [self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax( - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] - [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()][ - self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ - self.combobox_frequency_profile.currentIndex(), :], - stg.BS_raw_data_pre_process_SNR_average[ - self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + self.axis_profile.plot( + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) elif stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): - # --- Plot profile --- - self.axis_profile[0].plot( - stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth[self.combobox_fileListWidget.currentIndex()][ - 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()][ + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + self.axis_profile.text( + .95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex()][ 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) + fontsize=10, fontweight='bold', fontname="Ubuntu", + fontstyle="normal", c="black", alpha=0.2, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_profile.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()] - [self.combobox_frequency_profile.currentIndex(), :, :]) - val_max = np.nanmax( - stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :]) - if val_min == 0: - val_min = 1e-5 - self.axis_profile[1].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex()][ - self.combobox_frequency_profile.currentIndex(), :], - -stg.depth[self.combobox_fileListWidget.currentIndex()][ - self.combobox_frequency_profile.currentIndex(), :], - stg.BS_raw_data_pre_process_average[ - self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - - self.axis_profile[1].plot( - stg.time[self.combobox_fileListWidget.currentIndex()] - [self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * - np.ones(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]), - -stg.depth[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], - color='red', linestyle="solid", linewidth=2) - - self.axis_profile[0].set_xlabel("Acoustic Backscatter Signal (V)") - self.axis_profile[0].set_ylabel("Depth (m)") - - if len(stg.depth_bottom[self.combobox_fileListWidget.currentIndex()]) != 0: - if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): - self.axis_profile[1].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_bottom[self.combobox_fileListWidget.currentIndex()], - 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()], - color='black', linewidth=1, linestyle="solid") - - self.axis_profile[1].set_xticks([]) - self.axis_profile[1].set_yticks([]) + self.axis_profile.set_xlabel("Acoustic Backscatter Signal (V)") + self.axis_profile.set_ylabel("Depth (m)") self.figure_profile.canvas.draw_idle() else: - # self.canvas_profile.figure.clear() - # self.figure_profile.clf() - # self.axis_profile.tolist().clear() + self.combobox_frequency_profile.clear() + + self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile) + self.canvas_profile = FigureCanvas() - self.scroll_profile.setWidget(self.canvas_profile) + self.toolbar_profile = NavigationToolBar(self.canvas_profile, self) + + self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile) + + self.slider.setValue(1) + self.slider.setMaximum(10) + + def update_plot_pre_processed_profile(self): + + if ((self.combobox_fileListWidget.currentIndex() != -1) and + (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,))): + + self.axis_profile.cla() + + # --- PLot profile --- + + if stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.axis_profile.plot( + stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + + self.axis_profile.text( + .95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex()][ + 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.transAxes) + + self.axis_profile.set_xlabel("Acoustic Backscatter Signal (V)") + self.axis_profile.set_ylabel("Depth (m)") + + self.figure_profile.canvas.draw_idle() + + # --- Update red line position on transect --- + if stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.red_line_return.set_data( + stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value()-1] * + np.ones(stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :]) + + elif stg.time[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.red_line_return.set_data( + stg.time[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + np.ones(stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :]) + + elif stg.depth[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.red_line_return.set_data( + stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + np.ones(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :]) + + elif stg.time[self.combobox_fileListWidget.currentIndex()].shape != (0,): + + self.red_line_return.set_data( + stg.time[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + np.ones(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth[self.combobox_fileListWidget.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), :]) + + self.fig_BS.canvas.draw_idle() + + + # def plot_pre_processed_profile(self): + # + # # --- Update label "Profile N / max(N)" --- + # # self.label_profile_number.clear() + # # self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum())) + # + # if ((self.combobox_fileListWidget.currentIndex() != -1) and + # (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,))): + # + # self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile) + # self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile) + # + # 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.toolbar_profile = NavigationToolBar(self.canvas_profile, self) + # + # self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile) + # self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile) + # + # if stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # + # # --- Plot profile --- + # self.axis_profile.plot( + # stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][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()][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_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax( + # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] + # [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()][self.combobox_frequency_profile.currentIndex(), :], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], + # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + # 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()][ + # 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()] + # [self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax( + # stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] + # [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()][ + # self.combobox_frequency_profile.currentIndex(), :], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + # self.combobox_frequency_profile.currentIndex(), :], + # stg.BS_stream_bed_pre_process_average[ + # self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + # 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()][ + # 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()] + # [self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax( + # stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] + # [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()][ + # self.combobox_frequency_profile.currentIndex(), :], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + # self.combobox_frequency_profile.currentIndex(), :], + # stg.BS_cross_section_pre_process_SNR_average[ + # self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + # 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()][ + # 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_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax( + # stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] + # [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()][ + # self.combobox_frequency_profile.currentIndex(), :], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + # self.combobox_frequency_profile.currentIndex(), :], + # stg.BS_cross_section_pre_process_average[ + # self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + # 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()][ + # 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()] + # [self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax( + # stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] + # [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()][ + # self.combobox_frequency_profile.currentIndex(), :], + # -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ + # self.combobox_frequency_profile.currentIndex(), :], + # stg.BS_raw_data_pre_process_SNR_average[ + # self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # + # # --- Plot profile --- + # self.axis_profile[0].plot( + # stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + # -stg.depth[self.combobox_fileListWidget.currentIndex()][ + # 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()][ + # 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()] + # [self.combobox_frequency_profile.currentIndex(), :, :]) + # val_max = np.nanmax( + # stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :]) + # if val_min == 0: + # val_min = 1e-5 + # self.axis_profile[1].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex()][ + # self.combobox_frequency_profile.currentIndex(), :], + # -stg.depth[self.combobox_fileListWidget.currentIndex()][ + # self.combobox_frequency_profile.currentIndex(), :], + # stg.BS_raw_data_pre_process_average[ + # self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), :, :], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # + # self.axis_profile[1].plot( + # stg.time[self.combobox_fileListWidget.currentIndex()] + # [self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * + # np.ones(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]), + # -stg.depth[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], + # color='red', linestyle="solid", linewidth=2) + # + # self.axis_profile[0].set_xlabel("Acoustic Backscatter Signal (V)") + # self.axis_profile[0].set_ylabel("Depth (m)") + # + # if len(stg.depth_bottom[self.combobox_fileListWidget.currentIndex()]) != 0: + # if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # self.axis_profile[1].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], + # -stg.depth_bottom[self.combobox_fileListWidget.currentIndex()], + # 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()], + # color='black', linewidth=1, linestyle="solid") + # + # self.axis_profile[1].set_xticks([]) + # self.axis_profile[1].set_yticks([]) + # + # self.figure_profile.canvas.draw_idle() + # + # else: + # + # # self.canvas_profile.figure.clear() + # # self.figure_profile.clf() + # # self.axis_profile.tolist().clear() + # self.canvas_profile = FigureCanvas() + # self.scroll_profile.setWidget(self.canvas_profile) # if stg.BS_stream_bed_pre_process_SNR_average.size != 0: # @@ -2728,115 +3608,7 @@ class SignalProcessingTab(QWidget): # (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 --------------------------------------- # @@ -3269,55 +4041,3 @@ class SignalProcessingTab(QWidget): # 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() - # - - - - - -