diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index a09add4..b9f9cee 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -22,24 +22,20 @@ from cProfile import label # -*- coding: utf-8 -*- -import sys - -from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox, QLabel, QCheckBox, - QSpinBox, QDoubleSpinBox, QComboBox, QLineEdit, QSlider, QGridLayout, QMessageBox, - QScrollArea, QRadioButton, QFileDialog, QSpacerItem, QSizePolicy, QTextEdit, QPlainTextEdit) -from PyQt5.QtGui import QFont, QIcon, QPixmap, QSyntaxHighlighter, QTextCharFormat +from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox, QLabel, + QSpinBox, QComboBox, QLineEdit, QSlider, QGridLayout, QMessageBox, + QScrollArea, QFileDialog, QSpacerItem, QSizePolicy) +from PyQt5.QtGui import QIcon from PyQt5.QtCore import Qt, QCoreApplication, QEvent, pyqtSignal, QPropertyAnimation, QSize import numpy as np from copy import deepcopy -from scipy.ndimage import convolve1d -from astropy.convolution import convolve, Gaussian2DKernel +from astropy.convolution import convolve import matplotlib.pyplot as plt from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar from matplotlib.colors import LogNorm, BoundaryNorm -from scipy import stats from os import path from View.show_popup_combobox import ComboBoxShowPopUpWindow @@ -50,37 +46,10 @@ import Translation.constant_string as cs from Model.acoustic_data_loader import AcousticDataLoader import settings as stg -from settings import depth_cross_section _translate = QCoreApplication.translate -class SyntaxHighlighter(QSyntaxHighlighter): - def __init__(self, parent): - super(SyntaxHighlighter, self).__init__(parent) - self._highlight_lines = dict() - - def highlight_line(self, line, fmt): - if isinstance(line, int) and line >= 0 and isinstance(fmt, QTextCharFormat): - self._highlight_lines[line] = fmt - tb = self.document().findBlockByLineNumber(line) - self.rehighlightBlock(tb) - print("self._highlight_lines ", self._highlight_lines[line]) - print("tb", tb) - print("self.rehighlightBlock(tb) ", self.rehighlightBlock(tb)) - - def clear_highlight(self): - self._highlight_lines = dict() - self.rehighlight() - print("self._highlight_lines ", self._highlight_lines) - - def highlightBlock(self, text): - line = self.currentBlock().blockNumber() - fmt = self._highlight_lines.get(line) - if fmt is not None: - self.setFormat(0, len(text), fmt) - - class SignalProcessingTab(QWidget): ''' This class generates the Signal Processing Tab ''' @@ -155,7 +124,6 @@ class SignalProcessingTab(QWidget): self.pushbutton_update = QPushButton() self.pushbutton_update.setIcon(self.icon_update) - # self.pushbutton_update.setMaximumWidth(50) self.gridLayout_groupbox_data_to_be_processed.addWidget(self.pushbutton_update, 0, 1, 1, 1, Qt.AlignCenter) self.horizontalLayout_groupbox_data_to_be_processed_Pushbutton_plot_clear_noise.addWidget( @@ -184,7 +152,6 @@ class SignalProcessingTab(QWidget): self.pushbutton_noise_file.setIcon(self.icon_folder) self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_file, 0, 0, 1, 1, Qt.AlignCenter) self.lineEdit_noise_file = QLineEdit() - # self.lineEdit_noise_file.setMaximumWidth(1000) self.gridLayout_groupbox_noise_file.addWidget(self.lineEdit_noise_file, 0, 1, 1, 2, Qt.AlignLeft) ### --- Groupbox compute noise from profile tail --- @@ -207,8 +174,7 @@ class SignalProcessingTab(QWidget): self.horizontalLayout_groupbox_compute_noise_from_profile_tail.addWidget(self.groupbox_plot_profile_tail) self.groupbox_option_profile_tail = QGroupBox() - # self.groupbox_option_profile_tail.setCheckable(True) - # self.groupbox_option_profile_tail.setChecked(False) + self.horizontalLayout_groupbox_compute_noise_from_profile_tail.addWidget(self.groupbox_option_profile_tail) self.gridLayout_groupbox_option_profile_tail = QGridLayout(self.groupbox_option_profile_tail) @@ -225,7 +191,6 @@ class SignalProcessingTab(QWidget): self.gridLayout_groupbox_option_profile_tail.addWidget(self.lineEdit_val2, 1, 1, 1, 1, Qt.AlignCenter) self.pushbutton_plot_profile_tail = QPushButton() - # self.pushbutton_plot_profile_tail.setText("Profile tail") self.pushbutton_plot_profile_tail.setIcon(self.icon_apply) self.gridLayout_groupbox_option_profile_tail.addWidget(self.pushbutton_plot_profile_tail, 1, 2, 1, 1, Qt.AlignCenter) @@ -241,26 +206,6 @@ class SignalProcessingTab(QWidget): self.pushbutton_apply_noise_from_profile_tail.setIcon(self.icon_apply) self.gridLayout_groupbox_option_profile_tail.addWidget(self.pushbutton_apply_noise_from_profile_tail, 2, 2, 1, 1, Qt.AlignCenter) - # --- Push button Plot/Clear noise data --- - # self.gridLayout_pushbutton_noise_data = QGridLayout() - # self.verticalLayout_groupbox_study_data.addLayout(self.gridLayout_pushbutton_noise_data) - # - # self.pushbutton_plot_noise_data = QPushButton() - # self.pushbutton_plot_noise_data.setText("Plot noise field") - # self.gridLayout_pushbutton_noise_data.addWidget(self.pushbutton_plot_noise_data, 0, 0, 1, 1, Qt.AlignCenter) - # - # self.pushbutton_clear_noise_data = QPushButton() - # self.pushbutton_clear_noise_data.setIcon(self.icon_clear) - # # self.pushbutton_clear_noise_data.setMaximumWidth(50) - # self.gridLayout_pushbutton_noise_data.addWidget(self.pushbutton_clear_noise_data, 0, 1, 1, 1, Qt.AlignCenter) - # self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_value) - - ### --- 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) - # ++++++++++++++++++++++++ # +++ --- Plot SNR --- +++ # ++++++++++++++++++++++++ @@ -298,7 +243,6 @@ class SignalProcessingTab(QWidget): self.lineEdit_SNR_criterion.setMaximumWidth(60) self.gridLayout_SNR_criterion.addWidget(self.lineEdit_SNR_criterion, 0, 1, 1, 1, Qt.AlignCenter) self.pushbutton_Apply_SNR_filter = QPushButton() - # self.pushbutton_Apply_SNR_filter.setText("Apply SNR") self.pushbutton_Apply_SNR_filter.setIcon(self.icon_apply) self.gridLayout_SNR_criterion.addWidget(self.pushbutton_Apply_SNR_filter, 0, 2, 1, 1, Qt.AlignCenter) @@ -338,26 +282,18 @@ class SignalProcessingTab(QWidget): self.label_signal_averaging_horizontal = QLabel() self.label_signal_averaging_horizontal.setText("Horizontal +/- ") - # self.horizontalLayout_groupbox_window_size.addWidget(self.label_signal_averaging_over) self.gridLayout_groupbox_window_size.addWidget(self.label_signal_averaging_horizontal, 0, 0, 1, 1, Qt.AlignCenter) - # self.spinbox_average_horizontal = QSpinBox() - # self.spinbox_average_horizontal.setRange(0, 9999) - # self.spinbox_average_horizontal.setValue(0) + self.lineEdit_horizontal_average = QLineEdit() self.lineEdit_horizontal_average.setText("0.00") self.lineEdit_horizontal_average.setMaximumWidth(60) - # self.horizontalLayout_groupbox_window_size.addWidget(self.spinbox_average) self.gridLayout_groupbox_window_size.addWidget(self.lineEdit_horizontal_average, 0, 1, 1, 1, Qt.AlignCenter) - # self.lineEdit_horizontal_average = QLineEdit() - # self.lineEdit_horizontal_average.setMaximumWidth(60) - # self.gridLayout_groupbox_window_size.addWidget(self.lineEdit_horizontal_average, 0, 1, 1, 1, Qt.AlignCenter) + self.label_cells_horizontal = QLabel() self.label_cells_horizontal.setText("cells = +/- ? sec") - # self.horizontalLayout_groupbox_window_size.addWidget(self.label_cells) self.gridLayout_groupbox_window_size.addWidget(self.label_cells_horizontal, 0, 2, 1, 1, Qt.AlignCenter) self.pushbutton_average = QPushButton() - # self.pushbutton_average.setText("Apply averaging") self.pushbutton_average.setIcon(self.icon_apply) self.gridLayout_groupbox_window_size.addWidget(self.pushbutton_average, 0, 3, 1, 1, Qt.AlignCenter) @@ -370,9 +306,6 @@ class SignalProcessingTab(QWidget): # -------------------------------------------------------------------------------------------------------------- ### --- 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) @@ -400,7 +333,6 @@ class SignalProcessingTab(QWidget): 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) @@ -491,22 +423,17 @@ class SignalProcessingTab(QWidget): 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 TO SLOT FUNCTION +++++++++ @@ -520,10 +447,8 @@ class SignalProcessingTab(QWidget): self.combobox_acoustic_data_choice.currentIndexChanged.connect(self.combobox_acoustic_data_choice_change_index) self.groupbox_download_noise_file.toggled.connect(self.groupbox_download_noise_file_toggle) - # self.groupbox_download_noise_file.toggled.connect(self.groupbox_download_noise_file_size_change) self.groupbox_compute_noise_from_profile_tail.toggled.connect(self.groupbox_option_profile_tail_toggle) - # self.groupbox_compute_noise_from_profile_tail.toggled.connect(self.groupbox_option_profile_tail_size_change) self.pushbutton_noise_file.clicked.connect(self.open_dialog_box) @@ -541,14 +466,9 @@ class SignalProcessingTab(QWidget): self.combobox_freq_noise_from_profile_tail.currentIndexChanged.connect(self.plot_averaged_profile_tail) 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.lineEdit_horizontal_average.returnPressed.connect(self.update_label_cells_sec) self.pushbutton_average.clicked.connect(self.compute_averaged_BS_data) - # 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) @@ -576,14 +496,9 @@ class SignalProcessingTab(QWidget): of data to be processed is updated, - the user change the limits of one or all the records in the first tab (Acoustic data) """ - print("filename BS_raw_data before clear ", stg.filename_BS_raw_data) self.combobox_acoustic_data_choice.clear() - print("filename BS_raw_data after clear ", stg.filename_BS_raw_data) self.combobox_acoustic_data_choice.addItems(stg.filename_BS_raw_data) - print("stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] ", - stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()]) - if stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] == 0: self.groupbox_download_noise_file.setChecked(True) @@ -609,25 +524,12 @@ class SignalProcessingTab(QWidget): eval("self.lineEdit_list_pre_processed_data_" + str( self.combobox_acoustic_data_choice.currentIndex()) + ".returnPressed.connect(self.rename_preprocessed_data)") - # for t in range(self.combobox_acoustic_data_choice.count()): - # eval("self.lineEdit_list_pre_processed_data_" + str(t) + ".clear()") eval("self.lineEdit_list_pre_processed_data_" + str(self.combobox_acoustic_data_choice.currentIndex()) + ".setText(stg.filename_BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()])") def rename_preprocessed_data(self): - print("Before : stg.data_preprocessed ", stg.data_preprocessed) exec("stg.data_preprocessed[self.combobox_acoustic_data_choice.currentIndex()] = " "self.lineEdit_list_pre_processed_data_" + str(self.combobox_acoustic_data_choice.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 # ------------------------------------------------------ @@ -637,7 +539,6 @@ class SignalProcessingTab(QWidget): elif self.groupbox_download_noise_file.isChecked() == False: self.groupbox_compute_noise_from_profile_tail.setChecked(True) - def groupbox_download_noise_file_size_change(self): duration = 500 self.animation_groupbox_download_noise_file = QPropertyAnimation(self.groupbox_download_noise_file, b"size") @@ -737,27 +638,9 @@ class SignalProcessingTab(QWidget): float(self.lineEdit_val2.text().replace(",", ".")))) )[0][0] - print("val1 ", val1) - print("val2 ", val2) - - # --- Compute averaged signal --- - # if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = ( - # np.nanmean(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2)) - # elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = ( - # np.nanmean(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2)) - # elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - print("self.combobox_acoustic_data_choice.currentIndex() ", self.combobox_acoustic_data_choice.currentIndex(), - self.combobox_acoustic_data_choice.currentText(), val1, val2, - stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape) stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = ( np.nanmean(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2)) - # for i in range(self.combobox_freq_noise_from_profile_tail.count()): - # print("BS_mean shape ", stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][i].shape) - # print("BS_mean ", stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][i]) - def plot_averaged_profile_tail(self): # --- Plot averaged signal --- @@ -771,24 +654,6 @@ class SignalProcessingTab(QWidget): self.verticalLayout_groupbox_plot_profile_tail.addWidget(self.canvas_profile_tail) - # if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # - # self.axis_profile_tail.plot( - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()], - # stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()], - # color="blue", linewidth=1) - # self.axis_profile_tail.plot( - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_freq_noise_from_profile_tail.currentIndex()], - # float(self.lineEdit_profile_tail_value.text().replace(",", ".")) * - # np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_freq_noise_from_profile_tail.currentIndex()].shape[0]), - # linestyle='dashed', linewidth=2, color='red') - # - # elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # - # print(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_freq_noise_from_profile_tail.currentIndex()].shape) self.axis_profile_tail.plot( -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()], stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()], @@ -803,7 +668,6 @@ class SignalProcessingTab(QWidget): self.axis_profile_tail.set_yscale('log') self.axis_profile_tail.tick_params(axis='both', labelsize=8) - # self.axis_profile_tail.set_yticklabels(fontsize=8) self.axis_profile_tail.text(.98, .03, "Depth (m)", fontsize=8, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.9, horizontalalignment='right', verticalalignment='bottom', rotation='horizontal', @@ -825,20 +689,14 @@ class SignalProcessingTab(QWidget): def combobox_acoustic_data_choice_change_index(self): - # self.combobox_freq_noise_from_profile_tail.currentIndexChanged.connect(self.compute_average_profile_tail) - # self.combobox_freq_noise_from_profile_tail.currentIndexChanged.connect(self.plot_averaged_profile_tail) - self.compute_average_profile_tail() self.plot_averaged_profile_tail() self.lineEdit_SNR_criterion.setText(str(stg.SNR_filter_value[self.combobox_acoustic_data_choice.currentIndex()])) self.plot_transect_with_SNR_data() - # 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_acoustic_data_choice.currentIndex()]) self.lineEdit_horizontal_average.setText(str(stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()])) - # self.plot_profile_and_position_on_transect_with_slider() self.combobox_frequency_profile.clear() self.combobox_frequency_profile.addItems( @@ -866,17 +724,12 @@ class SignalProcessingTab(QWidget): stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) - # stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) - # stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) - # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) - - print("All is clear") if stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] == 0: self.lineEdit_noise_file.clear() @@ -898,9 +751,6 @@ class SignalProcessingTab(QWidget): self.lineEdit_SNR_criterion.setText("0.00") self.lineEdit_horizontal_average.setText("0.00") - # 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) @@ -911,7 +761,6 @@ class SignalProcessingTab(QWidget): self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR) self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) - print("SNR plot is clear") # --- Clear BS plot --- self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.toolbar_BS) @@ -923,7 +772,6 @@ class SignalProcessingTab(QWidget): 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() @@ -938,7 +786,6 @@ class SignalProcessingTab(QWidget): self.slider.setValue(1) self.slider.setMaximum(10) - print("Profile plot is clear") self.slider.setValue(0) self.slider.setMaximum(10) @@ -950,7 +797,6 @@ class SignalProcessingTab(QWidget): [stg.path_BS_raw_data[-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0], "Aquascat file (*.aqa)", options=QFileDialog.DontUseNativeDialog) - print("filename noise ", filename) if filename[0]: dir_name = path.dirname(filename[0][0]) name = path.basename(filename[0][0]) @@ -959,12 +805,9 @@ class SignalProcessingTab(QWidget): try: - print("stg.path_BS_noise_data : ", stg.path_BS_noise_data) - print("stg.filename_BS_noise_data : ", stg.filename_BS_noise_data) self.load_noise_data_and_compute_SNR() except ValueError as e: - print("error = ", e) msgBox = QMessageBox() msgBox.setWindowTitle("Download Error") msgBox.setIcon(QMessageBox.Warning) @@ -975,14 +818,7 @@ class SignalProcessingTab(QWidget): else: self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()]) self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()]) - # self.plot_noise() self.plot_transect_with_SNR_data() - # self.combobox_freq_noise.addItems([f for f in stg.freq_text]) - # self.combobox_freq_noise.currentIndexChanged.connect(self.plot_noise) - # self.spinbox_SNR_criterion.setValue(2) - - # !!!!! 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_acoustic_data_choice.currentIndex()]]) @@ -997,25 +833,6 @@ class SignalProcessingTab(QWidget): self.slider.setMaximum(stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) - # if len(stg.BS_stream_bed) and stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape: - # - # self.slider.setMaximum(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) - # - # elif (stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[2] - # < stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape[2]): - # - # self.slider.setMaximum(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) - # - # else: - # - # self.slider.setMaximum(stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) - - # !!!!! A DECOCHER !!!!!!!! - # self.compute_averaged_BS_data() - - # !!!!! A DECOCHER !!!!!!!! - # self.plot_profile_and_position_on_transect_with_slider() - self.plot_pre_processed_BS_signal() self.plot_pre_processed_profile() @@ -1041,17 +858,11 @@ class SignalProcessingTab(QWidget): "/" + stg.filename_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()]) stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = noise_data._BS_raw_data - # stg.date_noise = noise_data._date - # stg.hour_noise = noise_data._hour + stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = noise_data._time stg.depth_noise[self.combobox_acoustic_data_choice.currentIndex()] = noise_data._r - # stg.time_snr_reshape = stg.time_reshape - # print("len(stg.BS_cross_section) : ", len(stg.BS_cross_section)) - # print("stg.BS_cross_section[0] : ", stg.BS_cross_section[0].shape) - # print("len(stg.BS_stream_bed) : ", len(stg.BS_stream_bed)) if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - print("Je suis dans stream bed") noise = np.zeros(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape) for f, _ in enumerate(noise_data._freq): @@ -1064,7 +875,6 @@ class SignalProcessingTab(QWidget): stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2)) elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - print("Je suis dans cross section") noise = np.zeros(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape) for f, _ in enumerate(noise_data._freq): @@ -1078,7 +888,6 @@ class SignalProcessingTab(QWidget): # stg.SNR_reshape = np.reshape(stg.SNR_cross_section, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), order="F") else: - print("Je suis dans raw") noise = np.zeros(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape) for f, _ in enumerate(noise_data._freq): @@ -1090,71 +899,10 @@ class SignalProcessingTab(QWidget): stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2, stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2)) - - - # print("stg.SNR_raw_data[0].shape ", stg.SNR_raw_data) - - print("C'est fait") - def open_plot_noise_window(self): pnw = PlotNoiseWindow() pnw.exec() - # def compute_noise_from_value(self): - # - # # --- Compute noise from value and compute SNR --- - # - # if stg.BS_stream_bed.size == 0: - # - # stg.time_snr = stg.t - # - # if self.spinbox_compute_noise_from_value.value() == 0: - # - # stg.BS_noise_raw_data = np.full(stg.BS_cross_section.shape, - # self.spinbox_compute_noise_from_value.value()) - # print(f"stg.BS_noise_raw_data.shape : {stg.BS_noise_raw_data.shape}") - # stg.SNR_cross_section = np.full(stg.BS_cross_section.shape, 1e3) - # - # else: - # - # stg.BS_noise_raw_data = np.full(stg.BS_cross_section.shape, self.spinbox_compute_noise_from_value.value()) - # stg.SNR_cross_section = np.divide((stg.BS_cross_section - stg.BS_noise_raw_data) ** 2, - # stg.BS_noise_raw_data ** 2) - # - # else: - # - # stg.time_snr = stg.t - # - # if self.spinbox_compute_noise_from_value.value() == 0: - # - # stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape, - # self.spinbox_compute_noise_from_value.value()) - # stg.SNR_stream_bed = np.full(stg.BS_stream_bed.shape, 1e3) - # - # else: - # - # stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape, - # self.spinbox_compute_noise_from_value.value()) - # stg.SNR_stream_bed = np.divide((stg.BS_stream_bed - stg.BS_noise_raw_data) ** 2, - # stg.BS_noise_raw_data ** 2) - # - # - # - # # --- Trigger graphic widgets --- - # - # self.combobox_freq_noise.addItems([f for f in stg.freq_text]) - # self.plot_noise() - # self.plot_transect_with_SNR_data() - # self.combobox_freq_noise.currentIndexChanged.connect(self.plot_noise) - # self.spinbox_SNR_criterion.setValue(0) - # self.remove_point_with_snr_filter() - # - # self.combobox_frequency_profile.addItems([f for f in stg.freq_text]) - # self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_profile_and_position_on_transect_with_slider) - # self.slider.setMaximum(stg.t.shape[1]) - # self.compute_averaged_BS_data() - # self.plot_profile_and_position_on_transect_with_slider() - def compute_noise_from_profile_tail_value(self): stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] = 1 @@ -1162,10 +910,6 @@ class SignalProcessingTab(QWidget): stg.noise_value[self.combobox_acoustic_data_choice.currentIndex()] = ( float(self.lineEdit_profile_tail_value.text().replace(",", "."))) - # stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = ( - # np.full(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape, - # self.spinbox_compute_noise_from_value.value())) - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = ( stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()]) @@ -1222,40 +966,6 @@ class SignalProcessingTab(QWidget): - stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2, stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2)) - - # print("stg.BS_noise_averaged_data ", stg.BS_noise_averaged_data) - - # if len(stg.BS_stream_bed) == 0: - # - # if self.spinbox_compute_noise_from_value.value() == 0: - # - # stg.BS_noise_raw_data = np.full(stg.BS_cross_section[0].shape, - # self.spinbox_compute_noise_from_value.value()) - # print(f"stg.BS_noise_raw_data.shape : {stg.BS_noise_raw_data.shape}") - # stg.SNR_cross_section = np.full(stg.BS_cross_section[0].shape, 1e3) - # - # else: - # - # stg.BS_noise_raw_data = np.full(stg.BS_cross_section[0].shape, - # self.spinbox_compute_noise_from_value.value()) - # stg.SNR_cross_section = np.divide((stg.BS_cross_section[0] - stg.BS_noise_raw_data) ** 2, - # stg.BS_noise_raw_data ** 2) - # - # else: - # - # if self.spinbox_compute_noise_from_value.value() == 0: - # - # stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape, - # self.spinbox_compute_noise_from_value.value()) - # stg.SNR_stream_bed = np.full(stg.BS_stream_bed.shape, 1e3) - # - # else: - # - # stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape, - # self.spinbox_compute_noise_from_value.value()) - # stg.SNR_stream_bed = np.divide((stg.BS_stream_bed - stg.BS_noise_raw_data) ** 2, - # stg.BS_noise_raw_data ** 2) - self.combobox_frequency_profile.clear() self.combobox_frequency_profile.addItems( [f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]]) @@ -1267,20 +977,12 @@ class SignalProcessingTab(QWidget): else: self.lineEdit_SNR_criterion.setText(str(stg.SNR_filter_value[self.combobox_acoustic_data_choice.currentIndex()])) - # self.remove_point_with_snr_filter() - - # self.combobox_frequency_profile.addItems( - # [f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]]) - # self.combobox_frequency_profile.currentIndexChanged.connect( - # self.update_plot_pre_processed_profile) - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): self.slider.setMaximum(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) else: self.slider.setMaximum(stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) self.plot_transect_with_SNR_data() - # self.compute_averaged_BS_data() self.plot_pre_processed_BS_signal() self.plot_pre_processed_profile() @@ -1297,8 +999,6 @@ class SignalProcessingTab(QWidget): val_min = np.nanmin(stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :]) val_max = np.nanmax(stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :]) - print(f"0/ val_min for plot noise = {val_min}") - print(f"0/ val_max for plot noise = {val_max}") if val_min == val_max: @@ -1319,14 +1019,6 @@ class SignalProcessingTab(QWidget): self.axis_noise.tick_params(axis='both', which='minor', labelsize=10) - # cbar = self.fig_noise.colorbar(pcm, ax=self.axis_noise, shrink=1, location='top') - # cbar.set_label(label='Noise signal (V)', rotation=0, labelpad=8) - - # self.axis_noise.text(1, .70, stg.freq_text[self.combobox_freq_noise.currentIndex()], - # fontsize=10, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_noise.transAxes) - def plot_transect_with_SNR_data(self): # --- Condition if table is not filled --- # if not self.lineEdit_noise_file.text(): @@ -1349,20 +1041,10 @@ class SignalProcessingTab(QWidget): self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq[self.combobox_acoustic_data_choice.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 - - # self.verticalLayout_groupbox_plot_Noise_SNR.removeWidget(self.scroll_SNR) - # self.scroll_SNR = QScrollArea() self.scroll_SNR.setWidget(self.canvas_SNR) - # self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_SNR.setAlignment(Qt.AlignCenter) - # self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) - self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR) self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) @@ -1398,13 +1080,10 @@ class SignalProcessingTab(QWidget): stg.time[self.combobox_acoustic_data_choice.currentIndex()][f, :], stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :]) - print("0 plot SNR with SNR_stream_bed") val_min = np.nanmin(stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :]) val_max = np.nanmax(stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :]) - print(f"val min = {val_min}, val max = {val_max}") if val_min == val_max: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - print("levels 0 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] norm = BoundaryNorm(boundaries=bounds, ncolors=300) else: @@ -1412,15 +1091,11 @@ class SignalProcessingTab(QWidget): val_min = 1e-5 if val_max > 1000: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - print("levels 1 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - print("bounds 1 = ", bounds) norm = BoundaryNorm(boundaries=bounds, ncolors=300) else: levels = np.array([00.1, 1, 2, 10, 100, val_max]) - print("levels 2 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max * 1000] - print("bounds 2 = ", bounds) norm = BoundaryNorm(boundaries=bounds, ncolors=300) bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] @@ -1461,13 +1136,10 @@ class SignalProcessingTab(QWidget): stg.time[self.combobox_acoustic_data_choice.currentIndex()][f, :], stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :]) - print("1 plot SNR with SNR_cross_section") val_min = np.nanmin(stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :, :]) val_max = np.nanmax(stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :, :]) - print(f"val min = {val_min}, val max = {val_max}") if val_min == val_max: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - print("levels 0 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] norm = BoundaryNorm(boundaries=bounds, ncolors=300) else: @@ -1475,16 +1147,12 @@ class SignalProcessingTab(QWidget): val_min = 1e-5 if val_max > 1000: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - print("levels 1 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - print("bounds 1 = ", bounds) norm = BoundaryNorm(boundaries=bounds, ncolors=300) else: levels = np.array([00.1, 1, 2, 10, 100, val_max]) - print("levels 2 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max * 1000] - print("bounds 2 = ", bounds) norm = BoundaryNorm(boundaries=bounds, ncolors=300) bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] @@ -1500,13 +1168,10 @@ class SignalProcessingTab(QWidget): x, y = np.meshgrid(stg.time[self.combobox_acoustic_data_choice.currentIndex()][0, :], stg.depth[self.combobox_acoustic_data_choice.currentIndex()][0, :]) - print("0 plot SNR with SNR_raw_data") val_min = np.nanmin(stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :]) val_max = np.nanmax(stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :]) - print(f"val min = {val_min}, val max = {val_max}") if val_min == val_max: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - print("levels 0 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] norm = BoundaryNorm(boundaries=bounds, ncolors=300) else: @@ -1514,22 +1179,13 @@ class SignalProcessingTab(QWidget): val_min = 1e-5 if val_max > 1000: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - print("levels 1 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - print("bounds 1 = ", bounds) norm = BoundaryNorm(boundaries=bounds, ncolors=300) else: levels = np.array([00.1, 1, 2, 10, 100, val_max]) - print("levels 2 = ", levels) bounds = [00.1, 1, 2, 10, 100, 1000, val_max * 1000] - print("bounds 2 = ", bounds) norm = BoundaryNorm(boundaries=bounds, ncolors=300) - print("self.combobox_acoustic_data_choice.currentIndex() ", self.combobox_acoustic_data_choice.currentIndex()) - print("x ", x.shape) - print("y ", y.shape) - print("stg.SNR_raw_data", stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape) - print("levels before cf ", levels) cf = (self.axis_SNR[f].contourf(x, -y, stg.SNR_raw_data[ self.combobox_acoustic_data_choice.currentIndex()][f, :, :], @@ -1548,13 +1204,6 @@ class SignalProcessingTab(QWidget): cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$']) self.fig_SNR.canvas.draw_idle() - # # --- Plot red solid line on transect to visualize position of plotted profile --- - # self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - # stg.time[self.combobox_frequency_profile.currentIndex(), 0] * np.ones( - # stg.r.shape[1]), - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # color='red', linestyle="solid", linewidth=2) - else: self.verticalLayout_groupbox_plot_SNR.removeWidget(self.toolbar_SNR) @@ -1585,9 +1234,6 @@ class SignalProcessingTab(QWidget): if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): stg.BS_stream_bed_pre_process_SNR = deepcopy(stg.BS_stream_bed) - # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) - # stg.SNR_data_average = np.divide( - # (stg.BS_stream_bed_pre_process_SNR - stg.Noise_data) ** 2, stg.Noise_data ** 2) for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ @@ -1601,9 +1247,6 @@ class SignalProcessingTab(QWidget): elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): stg.BS_cross_section_pre_process_SNR = deepcopy(stg.BS_cross_section) - # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) - # stg.SNR_data_average = np.divide( - # (stg.BS_stream_bed_pre_process_SNR - stg.Noise_data) ** 2, stg.Noise_data ** 2) for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ @@ -1627,48 +1270,11 @@ class SignalProcessingTab(QWidget): :] < float(self.lineEdit_SNR_criterion.text().replace(",", ".")))[1]] \ = np.nan - - # elif stg.BS_stream_bed_pre_process_average.size != 0: - # stg.BS_stream_bed_pre_process_SNR = deepcopy(stg.BS_stream_bed_pre_process_average) - # BS_noise_cross_section = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) - # print("BS_noise_cross_section.shape ", BS_noise_cross_section.shape) - # stg.SNR_data_average = np.divide( - # (stg.BS_stream_bed_pre_process_SNR - BS_noise_cross_section) ** 2, BS_noise_cross_section ** 2) - # - # print(stg.SNR_data_average[0, :, :]) - - # fig, ax = plt.subplots(nrows=1, ncols=1) - # x, y = np.meshgrid(list(range(stg.SNR_data_average.shape[2])), - # list(range(stg.SNR_data_average.shape[1]))) - # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - # bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2] - # norm = BoundaryNorm(boundaries=bounds, ncolors=300) - # cf = ax.contourf(x, -y, stg.SNR_data_average[0, :, :], cmap='gist_rainbow') # , levels, norm=norm) - # cbar = fig.colorbar(cf, ax=ax, shrink=1, location='right') - # plt.show() - # - # for f, _ in enumerate(stg.freq): - # print("----------------------------------------------") - # print(np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[0]) - # print(np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1]) - # stg.BS_stream_bed_pre_process_SNR[ - # f, - # np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[0], - # np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ - # = np.nan - - # self.plot_pre_processed_BS_signal() - # self.update_plot_profile_position_on_transect() - # self.update_plot_averaged_profile() - - # !!! A DECOCHER !!! self.compute_averaged_BS_data() self.update_plot_pre_processed_profile() def plot_pre_processed_BS_signal(self): - # self.spinbox_average_horizontal.setValue( - # stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()]) self.lineEdit_horizontal_average.setText(str(stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()])) if ((self.combobox_acoustic_data_choice.currentIndex() != -1) @@ -1680,15 +1286,8 @@ class SignalProcessingTab(QWidget): self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.combobox_acoustic_data_choice.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) - # self.scroll_BS = QScrollArea() self.scroll_BS.setWidget(self.canvas_BS) - # self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_BS.setAlignment(Qt.AlignCenter) - # self.verticalLayout_groupbox_BS_SNR_filter.addWidget(self.scroll_BS) self.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) @@ -1869,51 +1468,6 @@ class SignalProcessingTab(QWidget): -y_depth[self.combobox_frequency_profile.currentIndex(), :], linestyle="solid", linewidth=2, color="red") - # # print("current freq profile ", self.combobox_frequency_profile.currentIndex()) - # if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # - # if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # - # self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - # stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * - # np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]), - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # linestyle="solid", linewidth=2, color="red") - # - # elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # - # self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - # stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * - # np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]), - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # linestyle="solid", linewidth=2, color="red") - # - # elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # - # if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # - # self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - # stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * - # np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]), - # -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # linestyle="solid", linewidth=2, color="red") - # - # elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # - # self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - # stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * - # np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]), - # -stg.depth[self.combobox_acoustic_data_choice.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') @@ -1984,15 +1538,11 @@ class SignalProcessingTab(QWidget): for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): for i in range(y_depth.shape[1]): - # stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i,:] = ( - # convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ - # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( convolve(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) - print("1 - Je suis dans stg.BS_stream_bed_pre_process_SNR") - elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( @@ -2000,15 +1550,11 @@ class SignalProcessingTab(QWidget): for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): for i in range(y_depth.shape[1]): - # stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - # convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ - # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( convolve(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) - print("2 - Je suis dans stg.BS_cross_section_pre_process_SNR") - elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( @@ -2016,15 +1562,11 @@ class SignalProcessingTab(QWidget): for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): for i in range(y_depth.shape[1]): - # stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - # convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ - # f, i, :], weights=kernel_avg) / len(kernel_avg)) + stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( convolve(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) - print("3 - Je suis dans stg.BS_raw_data_pre_process_SNR") - elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( @@ -2032,14 +1574,9 @@ class SignalProcessingTab(QWidget): for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): for i in range(y_depth.shape[1]): - # stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - # convolve1d(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][ - # f, i, :], weights=kernel_avg) / len(kernel_avg)) stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( convolve(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) - print("4 - Je suis dans stg.BS_stream_bed") - elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( @@ -2047,15 +1584,10 @@ class SignalProcessingTab(QWidget): for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): for i in range(y_depth.shape[1]): - # stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - # convolve1d(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # f, i, :], weights=kernel_avg) / len(kernel_avg)) stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( convolve(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) - print("5 - Je suis dans stg.BS_cross_section") - elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( @@ -2063,185 +1595,12 @@ class SignalProcessingTab(QWidget): for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): for i in range(y_depth.shape[1]): - # stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - # convolve1d(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][ - # f, i, :], weights=kernel_avg) / len(kernel_avg)) stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( convolve(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) - print("6 - Je suis dans stg.BS_raw_data") - self.plot_pre_processed_BS_signal() self.update_plot_pre_processed_profile() - # 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_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # # ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()].shape) or - # # (stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()]): - # for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]): - # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()][f, i,:] \ - # = convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape) or - # # (stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape)): - # - # stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) - # - # for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - # for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]): - # stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \ - # = convolve1d(stg.BS_stream_bed[self.combobox_acoustic_data_choice.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_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # # if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()].shape) or - # # (stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()]): - # for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]): - # stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \ - # = convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape) or - # # (stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)): - # - # stg.BS_cross_section_pre_process_average = deepcopy(stg.BS_cross_section) - # - # for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - # for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]): - # stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \ - # = convolve1d(stg.BS_cross_section[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # # if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()].shape) or - # # (stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()]): - # for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]): - # stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \ - # = convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()]): - # for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]): - # stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i,:] \ - # = convolve1d(stg.BS_raw_data[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape == - # stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape): - # - # stg.BS_raw_data_pre_process_average = deepcopy(stg.BS_raw_data) - # - # for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - # for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]): - # stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \ - # = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=kernel) / len(kernel) - # - # stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) - # # print(f"1/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_SNR_average}") - # for f, _ in enumerate(stg.freq): - # for i in range(stg.r.shape[1]): - # stg.BS_stream_bed_pre_process_SNR_average[f, i, :] \ - # = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=kernel) / len(kernel) - # # stg.BS_stream_bed_pre_process_average[i, f, :] \ - # # = convolve1d(stg.BS_cross_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0] - # - # return stg.BS_stream_bed_pre_process_SNR_average - # - # elif stg.BS_cross_section_pre_process_SNR.size != 0: - # - # stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR) - # print(f"2/ stg.BS_cross_section_averaged : {stg.BS_cross_section_pre_process_SNR_average}") - # for f, _ in enumerate(stg.freq): - # for i in range(stg.r.shape[1]): - # stg.BS_cross_section_pre_process_SNR_average[f, i, :] \ - # = convolve1d(stg.BS_cross_section_pre_process_SNR[f, i, :], - # weights=kernel) / len(kernel) - # - # return stg.BS_cross_section_pre_process_SNR_average - # - # elif stg.BS_stream_bed.size != 0: - # - # stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) - # # print(f"3/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_average.shape}") - # print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) - # for f, _ in enumerate(stg.freq): - # for i in range(stg.r.shape[1]): - # stg.BS_stream_bed_pre_process_average[f, i, :] \ - # = convolve1d(stg.BS_stream_bed[f, i, :], - # weights=kernel) / len(kernel) - # print(stg.BS_stream_bed_pre_process_average[0, 10, :50]) - # - # return stg.BS_stream_bed_pre_process_average - # - # elif stg.BS_cross_section.size != 0: - # - # stg.BS_cross_section_averaged = deepcopy(stg.BS_cross_section) - # # print(f"4/ stg.BS_cross_section_averaged : {stg.BS_cross_section_averaged.shape}") - # for f, _ in enumerate(stg.freq): - # for i in range(stg.r.shape[1]): - # stg.BS_cross_section_averaged[f, i, :] \ - # = convolve1d(stg.BS_cross_section[f, i, :], - # weights=kernel) / len(kernel) - # - # return stg.BS_cross_section_averaged - # - # if stg.ABS_name == "Aquascat 1000R": - # self.label_cells_horizontal.clear() - # self.label_cells_horizontal.setText( - # "cells = +/- " + str((self.spinbox_average_horizontal.value() // 2)*(1/stg.nb_profiles_per_sec)) + " sec") - - # !!!!!!!!! A DECOCHER !!!!!!!!!!! - # self.plot_profile_and_position_on_transect_with_slider() - def plot_pre_processed_profile(self): if ((self.combobox_acoustic_data_choice.currentIndex() != -1) and @@ -2252,7 +1611,6 @@ class SignalProcessingTab(QWidget): 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.toolbar_profile = NavigationToolBar(self.canvas_profile, self) self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile) @@ -2714,366 +2072,6 @@ class SignalProcessingTab(QWidget): 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_acoustic_data_choice.currentIndex() != -1) and - # (stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # - # # --- Plot profile --- - # self.axis_profile.plot( - # stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax( - # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax( - # stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_stream_bed_pre_process_average[ - # self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax( - # stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_cross_section_pre_process_SNR_average[ - # self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax( - # stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_cross_section_pre_process_average[ - # self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax( - # stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_raw_data_pre_process_SNR_average[ - # self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()].shape != (0,): - # - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - # -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax( - # stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), :, :]) - # if val_min == 0: - # val_min = 1e-5 - # self.axis_profile[1].pcolormesh(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - # self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_raw_data_pre_process_average[ - # self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()] - # [self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * - # np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]), - # -stg.depth[self.combobox_acoustic_data_choice.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_acoustic_data_choice.currentIndex()]) != 0: - # if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - # self.axis_profile[1].plot(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], - # -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], - # color='black', linewidth=1, linestyle="solid") - # else: - # self.axis_profile[1].plot(stg.time[self.combobox_acoustic_data_choice - 1][ - # self.combobox_frequency_profile.currentIndex(), :], - # -stg.depth_bottom[self.combobox_acoustic_data_choice.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: - # - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()], - # fontsize=10, fontweight='bold', fontname="Ubuntu", - # fontstyle="normal", c="black", alpha=0.2, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_profile[0].transAxes) - # - # # --- Plot transect with profile position --- - # self.axis_profile[1].cla() - # val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) - # if val_min == 0: - # val_min = 1e-5 - # self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :], - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :], - # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - # - # elif stg.BS_cross_section_pre_process_SNR_average.size != 0: - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_cross_section_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, - # self.slider.value() - 1], - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()], - # fontsize=10, fontweight='bold', fontname="Ubuntu", - # fontstyle="normal", c="black", alpha=0.2, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_profile[0].transAxes) - # - # # --- Plot transect with profile position --- - # self.axis_profile[1].cla() - # val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :]) - # if val_min == 0: - # val_min = 1e-5 - # self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :], - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_cross_section_pre_process_SNR_average[ - # self.combobox_frequency_profile.currentIndex(), :, :], - # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - # - # elif stg.BS_stream_bed_pre_process_SNR.size != 0: - # - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()], - # fontsize=10, fontweight='bold', fontname="Ubuntu", - # fontstyle="normal", c="black", alpha=0.2, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_profile[0].transAxes) - # - # # --- Plot transect with profile position --- - # self.axis_profile[1].cla() - # val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) - # if val_min == 0: - # val_min = 1e-5 - # self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :], - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :], - # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - # - # elif stg.BS_cross_section_pre_process_SNR.size != 0: - # # --- Plot profile --- - # self.axis_profile[0].plot( - # stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, - # self.slider.value() - 1], - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # linestyle='solid', color='k', linewidth=1) - # self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()], - # fontsize=10, fontweight='bold', fontname="Ubuntu", - # fontstyle="normal", c="black", alpha=0.2, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_profile[0].transAxes) - # - # # --- Plot transect with profile position --- - # self.axis_profile[1].cla() - # val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) - # val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :]) - # if val_min == 0: - # val_min = 1e-5 - # self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :], - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # stg.BS_cross_section_pre_process_SNR[ - # self.combobox_frequency_profile.currentIndex(), :, :], - # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - # ------------------------------------- Connect Push Button Load Data + Slider ------------------------------------- def slide_profile_number_to_begin(self):