diff --git a/Model/acoustic_data_loader.py b/Model/acoustic_data_loader.py index 91d52ef..478079b 100644 --- a/Model/acoustic_data_loader.py +++ b/Model/acoustic_data_loader.py @@ -15,7 +15,7 @@ class AcousticDataLoader: def __init__(self, path_BS_raw_data: str): - # self.path_BS_raw_data = path_BS_raw_data + self.path_BS_raw_data = path_BS_raw_data # --- Load Backscatter acoustic raw data with RawAquascatData class --- diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 852a9dc..da38d83 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -1,9 +1,9 @@ import sys -from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QPushButton, QComboBox, QLineEdit, QLabel, \ - QGridLayout, QSpinBox, QDoubleSpinBox, QTableView, QTableWidget, QSpacerItem, QSizePolicy, \ +from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QPushButton, QComboBox, QLineEdit, QLabel, + QGridLayout, QSpinBox, QDoubleSpinBox, QTableView, QTableWidget, QSpacerItem, QSizePolicy, QAbstractScrollArea, QFileDialog, QTableWidgetItem, QMessageBox, QScrollBar, QScrollArea, - QProgressBar) + QProgressBar, QRadioButton, QFormLayout, QSlider) from PyQt5.QtGui import QPixmap, QIcon from PyQt5.QtCore import Qt, QCoreApplication, pyqtSignal, pyqtSlot, QEvent @@ -24,6 +24,8 @@ locale.setlocale(locale.LC_ALL, '') from scipy.signal import savgol_filter +from pyqt_top_left_right_file_list_widget.topLeftRightFileListWidget import TopLeftRightFileListWidget + # import Translation.biblio_string as bs import Translation.constant_string as cs @@ -47,8 +49,10 @@ class AcousticDataTab(QWidget): def __init__(self, tab_widget): super().__init__() - path_icon = "./icons/" - icon_folder = QIcon(path_icon + "folder.png") + self.path_icon = "./icons/" + self.icon_folder = QIcon(self.path_icon + "folder.png") + self.icon_triangle_left = QIcon(self.path_icon + "triangle_left.png") + self.icon_triangle_right = QIcon(self.path_icon + "triangle_right.png") ### --- General layout of widgets --- @@ -70,21 +74,24 @@ class AcousticDataTab(QWidget): self.groupbox_info = QGroupBox() self.horizontalLayoutTop.addWidget(self.groupbox_info, 3) - self.groupbox_table = QGroupBox() - self.horizontalLayoutTop.addWidget(self.groupbox_table, 4) + # self.groupbox_table = QGroupBox() + # self.horizontalLayoutTop.addWidget(self.groupbox_table, 4) self.groupbox_display_option = QGroupBox() - self.horizontalLayoutTop.addWidget(self.groupbox_display_option, 3) + self.horizontalLayoutTop.addWidget(self.groupbox_display_option, 4) ### --- Layout of groupbox in the Bottom horizontal layout box # 2D field of raw acoustic backscatter data | 2D field of Signal to Noise ratio self.groupbox_transect_2Dplot_raw_BS_data = QGroupBox() - self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_raw_BS_data) + self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_raw_BS_data, 6) - self.groupbox_transect_2Dplot_snr_data = QGroupBox() - self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_snr_data) + self.groupbox_plot_profile = QGroupBox() + self.horizontalLayoutBottom.addWidget(self.groupbox_plot_profile, 4) + + # self.groupbox_transect_2Dplot_snr_data = QGroupBox() + # self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_snr_data) # ===================================================== # TOP HORIZONTAL BOX LAYOUT @@ -96,6 +103,18 @@ class AcousticDataTab(QWidget): self.verticalLayout_groupbox_download = QVBoxLayout(self.groupbox_download) + # --- Group box Download multiple file --- + + # self.groupbox_multiple_acoustic_file = QGroupBox() + # self.verticalLayout_groupbox_download_multiple_file = QVBoxLayout(self.groupbox_multiple_acoustic_file) + # + # self.groupbox_multiple_acoustic_file.setTitle("Multiple files") + + # self.topLeftRightFileListWidget = TopLeftRightFileListWidget() + # # self.topLeftRightFileListWidget.show() + # # self.verticalLayout_groupbox_download_multiple_file.addWidget(self.topLeftRightFileListWidget) + # self.topLeftRightFileListWidget.setLayout(self.verticalLayout_groupbox_download_multiple_file) + # --- Group box acoustic file --- self.groupbox_acoustic_file = QGroupBox() @@ -106,7 +125,7 @@ class AcousticDataTab(QWidget): self.gridLayout_groupbox_acoustic_file.addWidget(self.combobox_ABS_system_choice, 0, 0, 1, 1) self.pushbutton_acoustic_file = QPushButton() self.pushbutton_acoustic_file.setObjectName("pushbutton_acoustic_file") - self.pushbutton_acoustic_file.setIcon(icon_folder) + self.pushbutton_acoustic_file.setIcon(self.icon_folder) self.gridLayout_groupbox_acoustic_file.addWidget(self.pushbutton_acoustic_file, 0, 1, 1, 1) self.lineEdit_acoustic_file = QLineEdit() self.gridLayout_groupbox_acoustic_file.addWidget(self.lineEdit_acoustic_file, 0, 2, 1, 1) @@ -121,40 +140,67 @@ class AcousticDataTab(QWidget): self.verticalLayout_groupbox_download.addWidget(self.groupbox_acoustic_file) - # --- Group box noise file --- + # --- Group box noise file --- (move to signal processing tab) - self.groupbox_noise_file = QGroupBox() - self.gridLayout_groupbox_noise_file = QGridLayout(self.groupbox_noise_file) - - self.pushbutton_noise_level_with_tail_of_mean_profile = QPushButton() - self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_level_with_tail_of_mean_profile, 0, 0, 1, 1) - self.pushbutton_noise_file = QPushButton() - self.pushbutton_noise_file.setObjectName("pushbutton_noise_file") - self.pushbutton_noise_file.setIcon(icon_folder) - self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_file, 0, 1, 1, 1) - self.lineEdit_noise_file = QLineEdit() - self.gridLayout_groupbox_noise_file.addWidget(self.lineEdit_noise_file, 0, 2, 1, 1) - - self.label_date_groupbox_noise_file = QLabel() - self.gridLayout_groupbox_noise_file.addWidget(self.label_date_groupbox_noise_file, 1, 0, 1, 2) - self.label_hour_groupbox_noise_file = QLabel() - self.gridLayout_groupbox_noise_file.addWidget(self.label_hour_groupbox_noise_file, 1, 2, 1, 1) - - # Download Push Button event : connect button clicked signal to open file slot - self.pushbutton_noise_file.clicked.connect(self.open_dialog_box) - - self.verticalLayout_groupbox_download.addWidget(self.groupbox_noise_file) + # self.groupbox_noise_file = QGroupBox() + # self.gridLayout_groupbox_noise_file = QGridLayout(self.groupbox_noise_file) + # + # self.pushbutton_noise_level_with_tail_of_mean_profile = QPushButton() + # self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_level_with_tail_of_mean_profile, 0, 0, 1, 1) + # self.pushbutton_noise_file = QPushButton() + # self.pushbutton_noise_file.setObjectName("pushbutton_noise_file") + # self.pushbutton_noise_file.setIcon(icon_folder) + # self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_file, 0, 1, 1, 1) + # self.lineEdit_noise_file = QLineEdit() + # self.gridLayout_groupbox_noise_file.addWidget(self.lineEdit_noise_file, 0, 2, 1, 1) + # + # self.label_date_groupbox_noise_file = QLabel() + # self.gridLayout_groupbox_noise_file.addWidget(self.label_date_groupbox_noise_file, 1, 0, 1, 2) + # self.label_hour_groupbox_noise_file = QLabel() + # self.gridLayout_groupbox_noise_file.addWidget(self.label_hour_groupbox_noise_file, 1, 2, 1, 1) + # + # # Download Push Button event : connect button clicked signal to open file slot + # self.pushbutton_noise_file.clicked.connect(self.open_dialog_box) + # + # self.verticalLayout_groupbox_download.addWidget(self.groupbox_noise_file) # --- Group box GPS file --- + self.groupbox_gps = QGroupBox() + self.verticalLayout_gps_input_data = QVBoxLayout(self.groupbox_gps) + + self.horizontalLayout_radiobutton_gps = QHBoxLayout() + self.verticalLayout_gps_input_data.addLayout(self.horizontalLayout_radiobutton_gps) + + self.radiobutton_value = QRadioButton("Value") + self.radiobutton_value.setChecked(True) + self.radiobutton_value.toggled.connect(self.onClicked_radiobutton_gps) + self.horizontalLayout_radiobutton_gps.addWidget(self.radiobutton_value) + + self.radiobutton_file = QRadioButton("File") + # self.radiobutton_file.setChecked(False) + self.radiobutton_file.toggled.connect(self.onClicked_radiobutton_gps) + self.horizontalLayout_radiobutton_gps.addWidget(self.radiobutton_file) + + self.groupbox_gps_value = QGroupBox() + self.formLayout_gps_value = QFormLayout(self.groupbox_gps_value) + self.label_distance_value = QLabel() + self.label_distance_value.setText("Distance : ") + self.lineEdit_gps_value = QLineEdit() + self.formLayout_gps_value.addRow(self.label_distance_value, self.lineEdit_gps_value) + + self.verticalLayout_gps_input_data.addWidget(self.groupbox_gps_value) + self.groupbox_gps_file = QGroupBox() + self.groupbox_gps_file.setEnabled(False) + self.gridLayout_groupbox_gps_file = QGridLayout(self.groupbox_gps_file) self.combobox_gps_system_choice = QComboBox() self.combobox_gps_system_choice.addItems([" ", "GPS1", "GPS2", "no GPS"]) self.gridLayout_groupbox_gps_file.addWidget(self.combobox_gps_system_choice, 0, 0, 1, 1) self.pushbutton_gps_file = QPushButton() - self.pushbutton_gps_file.setIcon(icon_folder) + self.pushbutton_gps_file.setIcon(self.icon_folder) self.gridLayout_groupbox_gps_file.addWidget(self.pushbutton_gps_file, 0, 1, 1, 1) self.lineEdit_gps_file = QLineEdit() self.gridLayout_groupbox_gps_file.addWidget(self.lineEdit_gps_file, 0, 2, 1, 1) @@ -167,9 +213,11 @@ class AcousticDataTab(QWidget): # Download Push Button event : connect button clicked signal to open file slot # self.pushButton_gpsfile.clicked.connect(self.open_dialog_box) - self.verticalLayout_groupbox_download.addWidget(self.groupbox_gps_file) + self.verticalLayout_gps_input_data.addWidget(self.groupbox_gps_file) - # --- Time offset line between ABS system time and GPS time --- + self.verticalLayout_groupbox_download.addWidget(self.groupbox_gps) + + # # --- Time offset line between ABS system time and GPS time --- self.gridLayout_time_offset = QGridLayout() self.label_time_offset = QLabel() @@ -193,7 +241,16 @@ class AcousticDataTab(QWidget): # | Group Box Measurements information | # ++++++++++++++++++++++++++++++++++++++ - self.gridLayout_goupbox_info = QGridLayout(self.groupbox_info) + self.verticalLayout_groupbox_info = QVBoxLayout(self.groupbox_info) + + self.formLayout_temperature = QFormLayout() + self.label_temperature = QLabel("Temperature : ") + self.lineEdit_temperature = QLineEdit() + self.formLayout_temperature.addRow(self.label_temperature, self.lineEdit_temperature) + self.verticalLayout_groupbox_info.addLayout(self.formLayout_temperature) + + self.gridLayout_goupbox_info = QGridLayout() + self.verticalLayout_groupbox_info.addLayout(self.gridLayout_goupbox_info) # --- Information for Aquascat --- @@ -224,35 +281,35 @@ class AcousticDataTab(QWidget): # | Group Box Table of values | # +++++++++++++++++++++++++++++ - self.verticalLayout_groupbox_table = QVBoxLayout(self.groupbox_table) - - self.horizontalLayout_pushbutton_fill_export_table = QHBoxLayout() - self.pushbutton_fill_table = QPushButton() - self.horizontalLayout_pushbutton_fill_export_table.addWidget(self.pushbutton_fill_table) - - self.pushbutton_fill_table.clicked.connect(self.fill_table) - - self.horizontalSpacerItem_between_pushbutton_fill_export_table = QSpacerItem(50, 10, - QSizePolicy.Expanding, QSizePolicy.Minimum) - self.horizontalLayout_pushbutton_fill_export_table.addItem( - self.horizontalSpacerItem_between_pushbutton_fill_export_table) - - self.pushbutton_export_table = QPushButton() - self.horizontalLayout_pushbutton_fill_export_table.addWidget(self.pushbutton_export_table) - - self.pushbutton_export_table.clicked.connect(self.export_table) - - self.verticalLayout_groupbox_table.addLayout(self.horizontalLayout_pushbutton_fill_export_table) - - # self.tableWidget = QTableWidget() - # self.tableWidget.setRowCount(10) - # self.tableWidget.setColumnCount(10) - - self.tableView = QTableView() - data = pd.DataFrame(np.zeros((10, 10))) - self.tableModel = TableModel(data) - self.tableView.setModel(self.tableModel) - self.verticalLayout_groupbox_table.addWidget(self.tableView) + # self.verticalLayout_groupbox_table = QVBoxLayout(self.groupbox_table) + # + # self.horizontalLayout_pushbutton_fill_export_table = QHBoxLayout() + # self.pushbutton_fill_table = QPushButton() + # self.horizontalLayout_pushbutton_fill_export_table.addWidget(self.pushbutton_fill_table) + # + # self.pushbutton_fill_table.clicked.connect(self.fill_table) + # + # self.horizontalSpacerItem_between_pushbutton_fill_export_table = QSpacerItem(50, 10, + # QSizePolicy.Expanding, QSizePolicy.Minimum) + # self.horizontalLayout_pushbutton_fill_export_table.addItem( + # self.horizontalSpacerItem_between_pushbutton_fill_export_table) + # + # self.pushbutton_export_table = QPushButton() + # self.horizontalLayout_pushbutton_fill_export_table.addWidget(self.pushbutton_export_table) + # + # self.pushbutton_export_table.clicked.connect(self.export_table) + # + # self.verticalLayout_groupbox_table.addLayout(self.horizontalLayout_pushbutton_fill_export_table) + # + # # self.tableWidget = QTableWidget() + # # self.tableWidget.setRowCount(10) + # # self.tableWidget.setColumnCount(10) + # + # self.tableView = QTableView() + # data = pd.DataFrame(np.zeros((10, 10))) + # self.tableModel = TableModel(data) + # self.tableView.setModel(self.tableModel) + # self.verticalLayout_groupbox_table.addWidget(self.tableView) # #------------------------------------ # # self.tableView = QTableView() @@ -315,18 +372,28 @@ class AcousticDataTab(QWidget): # --- Push buttons to trigger plot of transect with Backscatter acoustic raw data and SNR --- - self.horizontalLayout_pushbutton_plot_BS_SNR_data = QHBoxLayout() - self.verticalLayout_display_option.addLayout(self.horizontalLayout_pushbutton_plot_BS_SNR_data) + self.gridLayout_plot_transect_frequency_profile = QGridLayout() + self.verticalLayout_display_option.addLayout(self.gridLayout_plot_transect_frequency_profile) + # self.horizontalLayout_pushbutton_plot_BS_SNR_data = QHBoxLayout() + # self.verticalLayout_display_option.addLayout(self.horizontalLayout_pushbutton_plot_BS_SNR_data) self.pushbutton_plot_transect_with_BS_raw_data = QPushButton() - self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_BS_raw_data) + self.gridLayout_plot_transect_frequency_profile.addWidget(self.pushbutton_plot_transect_with_BS_raw_data, 0, 0, 1, 3) + # self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_BS_raw_data) self.pushbutton_plot_transect_with_BS_raw_data.clicked.connect(self.plot_transect_with_BS_raw_data) - self.pushbutton_plot_transect_with_SNR_data = QPushButton() - self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_SNR_data) + self.label_profile_frequency = QLabel() + self.label_profile_frequency.setText("Profile frequency : ") + self.gridLayout_plot_transect_frequency_profile.addWidget(self.label_profile_frequency, 0, 4, 1, 1) - self.pushbutton_plot_transect_with_SNR_data.clicked.connect(self.plot_transect_with_SNR_data) + self.combobox_frequency_profile = QComboBox() + self.gridLayout_plot_transect_frequency_profile.addWidget(self.combobox_frequency_profile, 0, 5, 1, 1) + + # self.pushbutton_plot_transect_with_SNR_data = QPushButton() + # self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_SNR_data) + + # self.pushbutton_plot_transect_with_SNR_data.clicked.connect(self.plot_transect_with_SNR_data) # --- Group Box Plot x-axis in time --- @@ -377,7 +444,8 @@ class AcousticDataTab(QWidget): self.pushbutton_apply_transect_boundaries_in_time.setText("Apply") self.gridLayout_groupbox_xaxis_time.addWidget(self.pushbutton_apply_transect_boundaries_in_time, 0, 7, 1, 1) self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.update_xaxis_transect_with_BS_raw_data) - self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.update_xaxis_transect_with_SNR_data) + # self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.update_xaxis_transect_with_SNR_data) + self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.update_plot_profile) # --- Group Box Plot x-axis in space --- @@ -424,7 +492,7 @@ class AcousticDataTab(QWidget): self.pushbutton_apply_transect_boundaries_in_space.setText("Apply") self.gridLayout_groupbox_xaxis_space.addWidget(self.pushbutton_apply_transect_boundaries_in_space, 0, 8, 1, 1) self.pushbutton_apply_transect_boundaries_in_space.clicked.connect(self.update_xaxis_transect_with_BS_raw_data) - self.pushbutton_apply_transect_boundaries_in_space.clicked.connect(self.update_xaxis_transect_with_SNR_data) + # self.pushbutton_apply_transect_boundaries_in_space.clicked.connect(self.update_xaxis_transect_with_SNR_data) # --- Group Box bathymetry computation algorithm to detect and plot bottom of transect--- @@ -515,21 +583,31 @@ class AcousticDataTab(QWidget): # | Group Box Signal to Noise ratio 2D field | # ++++++++++++++++++++++++++++++++++++++++++++ - self.verticalLayout_groupbox_transect_2Dplot_snr_data = QVBoxLayout(self.groupbox_transect_2Dplot_snr_data) - - self.canvas_SNR = None - self.scroll_SNR = None - - # self.figure, self.axis = plt.subplots(nrows=4, ncols=1, sharex=True, sharey=False, layout="constrained") - # # self.canvas_snrdata = FigureCanvas(self.figure) + # self.verticalLayout_groupbox_transect_2Dplot_snr_data = QVBoxLayout(self.groupbox_transect_2Dplot_snr_data) # - # self.canvas_snrdata = FigureCanvas() - # # self.plotToolbar_snrdata = NavigationToolBar(self.canvas_snrdata, self) - # # self.plot_snr_data() - # # self.verticalLayout_plotsnrdata.addWidget(self.plotToolbar_snrdata) - # self.verticalLayout_plotsnrdata.addWidget(self.canvas_snrdata) + # self.canvas_SNR = None + # self.scroll_SNR = None # - # self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_snr_data) + # # self.figure, self.axis = plt.subplots(nrows=4, ncols=1, sharex=True, sharey=False, layout="constrained") + # # # self.canvas_snrdata = FigureCanvas(self.figure) + # # + # # self.canvas_snrdata = FigureCanvas() + # # # self.plotToolbar_snrdata = NavigationToolBar(self.canvas_snrdata, self) + # # # self.plot_snr_data() + # # # self.verticalLayout_plotsnrdata.addWidget(self.plotToolbar_snrdata) + # # self.verticalLayout_plotsnrdata.addWidget(self.canvas_snrdata) + # # + # # self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_snr_data) + + # +++++++++++++++++++++++++++++++++++++++++++ + # | Group Box Plot profile from BS 2D field | + # +++++++++++++++++++++++++++++++++++++++++++ + + self.verticalLayout_groupbox_plot_profile = QVBoxLayout(self.groupbox_plot_profile) + self.groupbox_plot_profile.setTitle("Profiles") + + self.canvas_plot_profile = None + self.retranslate_acoustic_data_tab() @@ -543,12 +621,12 @@ class AcousticDataTab(QWidget): self.label_date_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":") - self.groupbox_noise_file.setTitle(_translate("CONSTANT_STRING", cs.NOISE_FILE)) - self.pushbutton_noise_level_with_tail_of_mean_profile.setText(_translate("CONSTANT_STRING", cs.NOISE_LEVEL)) - self.label_date_groupbox_noise_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") - self.label_hour_groupbox_noise_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":") + # self.groupbox_noise_file.setTitle(_translate("CONSTANT_STRING", cs.NOISE_FILE)) + # self.pushbutton_noise_level_with_tail_of_mean_profile.setText(_translate("CONSTANT_STRING", cs.NOISE_LEVEL)) + # self.label_date_groupbox_noise_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") + # self.label_hour_groupbox_noise_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":") - self.groupbox_gps_file.setTitle(_translate("CONSTANT_STRING", cs.GPS_FILE)) + self.groupbox_gps.setTitle(_translate("CONSTANT_STRING", cs.GPS_FILE)) self.label_date_groupbox_gps_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") self.label_hour_groupbox_gps_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":") @@ -589,15 +667,15 @@ class AcousticDataTab(QWidget): self.label_tx.setText(_translate("CONSTANT_STRING", cs.GAIN_TX) + ":") self.label_tx.setToolTip(_translate("CONSTANT_STRING", cs.GAIN_TX_TOOLTIP)) - self.groupbox_table.setTitle(_translate("CONSTANT_STRING", cs.TABLE_VALUES)) + # self.groupbox_table.setTitle(_translate("CONSTANT_STRING", cs.TABLE_VALUES)) - self.pushbutton_fill_table.setText(_translate("CONSTANT_STRING", cs.SYNCHRONIZE_AND_FILL_TABLE)) - self.pushbutton_export_table.setText(_translate("CONSTANT_STRING", cs.EXPORT_TABLE)) + # self.pushbutton_fill_table.setText(_translate("CONSTANT_STRING", cs.SYNCHRONIZE_AND_FILL_TABLE)) + # self.pushbutton_export_table.setText(_translate("CONSTANT_STRING", cs.EXPORT_TABLE)) self.groupbox_display_option.setTitle(_translate("CONSTANT_STRING", cs.DISPLAY_OPTIONS)) self.pushbutton_plot_transect_with_BS_raw_data.setText(_translate("CONSTANT_STRING", cs.PLOT_TRANSECT)) - self.pushbutton_plot_transect_with_SNR_data.setText(_translate("CONSTANT_STRING", cs.PLOT_SNR)) + # self.pushbutton_plot_transect_with_SNR_data.setText(_translate("CONSTANT_STRING", cs.PLOT_SNR)) self.groupbox_xaxis_time.setTitle(_translate("CONSTANT_STRING", cs.PLOT_XAXIS_IN_TIME)) # self.label_tmin.setText(_translate("CONSTANT_STRING", cs.FROM) + " tmin = ") @@ -617,7 +695,18 @@ class AcousticDataTab(QWidget): self.groupbox_transect_2Dplot_raw_BS_data.setTitle(_translate("CONSTANT_STRING", cs.RAW_ACOUSTIC_DATA_2D_FIELD)) - self.groupbox_transect_2Dplot_snr_data.setTitle(_translate("CONSTANT_STRING", cs.SIGNAL_TO_NOISE_RATIO_2D_FIELD)) + # self.groupbox_transect_2Dplot_snr_data.setTitle(_translate("CONSTANT_STRING", cs.SIGNAL_TO_NOISE_RATIO_2D_FIELD)) + + def onClicked_radiobutton_gps(self): + radiobutton = self.sender() + + if radiobutton.isChecked(): + if self.radiobutton_value.isChecked(): + self.groupbox_gps_value.setEnabled(True) + self.groupbox_gps_file.setDisabled(True) + elif self.radiobutton_file.isChecked(): + self.groupbox_gps_value.setDisabled(True) + self.groupbox_gps_file.setEnabled(True) def ABS_system_choice(self): if self.combobox_ABS_system_choice.currentText() == "Aquascat 1000R": @@ -723,6 +812,7 @@ class AcousticDataTab(QWidget): # --- fill date, hour and measurements information + fill frequency combobox for bottom detection --- if self.combobox_ABS_system_choice.currentIndex() != 0: if self.sender().objectName() == "pushbutton_acoustic_file": + # if self.sender(): # stg.path_BS_raw_data = dir_name # stg.filename_BS_raw_data = name # self.load_BS_acoustic_raw_data() @@ -730,10 +820,10 @@ class AcousticDataTab(QWidget): stg.path_BS_raw_data = dir_name stg.filename_BS_raw_data = name self.load_BS_acoustic_raw_data() - print("0 Je suis sur la donnée BS") + # print("0 Je suis sur la donnée BS") except ValueError as e: - print("error : ", e) - print("1 Je suis sur la donnée BS") + # print("error : ", e) + # print("1 Je suis sur la donnée BS") msgBox = QMessageBox() msgBox.setWindowTitle("Download Error") msgBox.setIcon(QMessageBox.Warning) @@ -749,32 +839,33 @@ class AcousticDataTab(QWidget): _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour)) self.fill_measurements_information_groupbox() self.combobox_freq_choice.addItems([f for f in stg.freq_text]) + self.combobox_frequency_profile.addItems([f for f in stg.freq_text]) - if self.sender().objectName() == "pushbutton_noise_file": - print("--- 0. Je suis dans le push button noise file ---") - try: - print("--- 1. Je suis dans le push button noise file ---") - stg.path_BS_noise_data = dir_name - stg.filename_BS_noise_data = name - print("dir_name ", stg.path_BS_noise_data) - print("filename ", stg.filename_BS_noise_data) - self.load_noise_data_and_compute_SNR() - print("0 je suis sur la donnée SNR") - except ValueError as e: - print("1 je suis sur la donnée SNR") - msgBox = QMessageBox() - msgBox.setWindowTitle("Download Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Please select a file") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - else: - self.lineEdit_noise_file.setText(stg.filename_BS_noise_data) - self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data) - self.label_date_groupbox_noise_file.setText( - _translate("CONSTANT_STRING", cs.DATE) + ": " + str(stg.date_noise)) - self.label_hour_groupbox_noise_file.setText( - _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour_noise)) + # if self.sender().objectName() == "pushbutton_noise_file": + # print("--- 0. Je suis dans le push button noise file ---") + # try: + # print("--- 1. Je suis dans le push button noise file ---") + # stg.path_BS_noise_data = dir_name + # stg.filename_BS_noise_data = name + # print("dir_name ", stg.path_BS_noise_data) + # print("filename ", stg.filename_BS_noise_data) + # self.load_noise_data_and_compute_SNR() + # print("0 je suis sur la donnée SNR") + # except ValueError as e: + # print("1 je suis sur la donnée SNR") + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Download Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Please select a file") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # else: + # self.lineEdit_noise_file.setText(stg.filename_BS_noise_data) + # self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data) + # self.label_date_groupbox_noise_file.setText( + # _translate("CONSTANT_STRING", cs.DATE) + ": " + str(stg.date_noise)) + # self.label_hour_groupbox_noise_file.setText( + # _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour_noise)) def load_BS_acoustic_raw_data(self): if self.combobox_ABS_system_choice.currentIndex() == 1: @@ -819,37 +910,37 @@ class AcousticDataTab(QWidget): # stg.snr_reshape = acoustic_data.reshape_SNR_data() # print(f"r = {stg.r}") - def load_noise_data_and_compute_SNR(self): - if self.combobox_ABS_system_choice.currentIndex() == 1: - - noise_data = AcousticDataLoader(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data) - stg.BS_noise_raw_data = noise_data._BS_raw_data - stg.date_noise = noise_data._date - stg.hour_noise = noise_data._hour - stg.time_snr = stg.time - stg.time_snr_reshape = stg.time_reshape - print(stg.time_snr.shape) - noise = np.zeros(stg.BS_raw_data.shape) - for f, _ in enumerate(noise_data._freq): - noise[f, :, :] = np.mean(stg.BS_noise_raw_data[f, :, :], axis=(0, 1)) - stg.BS_noise_averaged_data = noise - stg.SNR_data = np.divide((stg.BS_raw_data - stg.BS_noise_averaged_data) ** 2, stg.BS_noise_averaged_data ** 2) - stg.SNR_reshape = np.reshape(stg.SNR_data, (stg.r.shape[1] * stg.time.shape[1], stg.freq.shape[0]), order="F") - - elif self.combobox_ABS_system_choice.currentIndex() == 2: - - noise_data = AcousticDataLoaderUBSediFlow(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data) - stg.BS_noise_raw_data = noise_data._BS_raw_data - print(f"BS noise raw data : {stg.BS_noise_raw_data}") - stg.date_noise = noise_data._date - print(f"date noise : {stg.date_noise}") - stg.hour_noise = noise_data._hour - print(f"hour noise : {stg.hour_noise}") - stg.time_snr = noise_data._time_snr - stg.time_snr_reshape = noise_data.reshape_t_snr() - print(f"BS shape : {stg.BS_noise_raw_data.shape}") - # stg.SNR_data = noise_data._SNR_data - # stg.SNR_reshape = noise_data.reshape_SNR_data() + # def load_noise_data_and_compute_SNR(self): + # if self.combobox_ABS_system_choice.currentIndex() == 1: + # + # noise_data = AcousticDataLoader(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data) + # stg.BS_noise_raw_data = noise_data._BS_raw_data + # stg.date_noise = noise_data._date + # stg.hour_noise = noise_data._hour + # stg.time_snr = stg.time + # stg.time_snr_reshape = stg.time_reshape + # print(stg.time_snr.shape) + # noise = np.zeros(stg.BS_raw_data.shape) + # for f, _ in enumerate(noise_data._freq): + # noise[f, :, :] = np.mean(stg.BS_noise_raw_data[f, :, :], axis=(0, 1)) + # stg.BS_noise_averaged_data = noise + # stg.SNR_data = np.divide((stg.BS_raw_data - stg.BS_noise_averaged_data) ** 2, stg.BS_noise_averaged_data ** 2) + # stg.SNR_reshape = np.reshape(stg.SNR_data, (stg.r.shape[1] * stg.time.shape[1], stg.freq.shape[0]), order="F") + # + # elif self.combobox_ABS_system_choice.currentIndex() == 2: + # + # noise_data = AcousticDataLoaderUBSediFlow(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data) + # stg.BS_noise_raw_data = noise_data._BS_raw_data + # print(f"BS noise raw data : {stg.BS_noise_raw_data}") + # stg.date_noise = noise_data._date + # print(f"date noise : {stg.date_noise}") + # stg.hour_noise = noise_data._hour + # print(f"hour noise : {stg.hour_noise}") + # stg.time_snr = noise_data._time_snr + # stg.time_snr_reshape = noise_data.reshape_t_snr() + # print(f"BS shape : {stg.BS_noise_raw_data.shape}") + # # stg.SNR_data = noise_data._SNR_data + # # stg.SNR_reshape = noise_data.reshape_SNR_data() def fill_measurements_information_groupbox(self): if self.combobox_ABS_system_choice.currentIndex() == 1: @@ -909,16 +1000,16 @@ class AcousticDataTab(QWidget): # msgBox.exec() # elif self.combobox_ABS_system_choice.currentIndex() == 1: - if ((self.lineEdit_acoustic_file.text()) and (self.lineEdit_noise_file.text())): - stg.DataFrame_acoustic = pd.DataFrame( - np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape, stg.time_snr_reshape, stg.SNR_reshape), axis=1), - columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] + - ["BS - " + f for f in stg.freq_text] + - ["Time SNR - " + f for f in stg.freq_text] + - ["SNR - " + f for f in stg.freq_text]))) - self.tableModel = TableModel(stg.DataFrame_acoustic) - self.tableView.setModel(self.tableModel) - elif self.lineEdit_acoustic_file.text(): + # if ((self.lineEdit_acoustic_file.text()) and (self.lineEdit_noise_file.text())): + # stg.DataFrame_acoustic = pd.DataFrame( + # np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape, stg.time_snr_reshape, stg.SNR_reshape), axis=1), + # columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] + + # ["BS - " + f for f in stg.freq_text] + + # ["Time SNR - " + f for f in stg.freq_text] + + # ["SNR - " + f for f in stg.freq_text]))) + # self.tableModel = TableModel(stg.DataFrame_acoustic) + # self.tableView.setModel(self.tableModel) + if self.lineEdit_acoustic_file.text(): stg.DataFrame_acoustic = pd.DataFrame( np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape), axis=1), columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] + ["BS - " + f for f in stg.freq_text]))) @@ -962,18 +1053,19 @@ class AcousticDataTab(QWidget): msgBox.setText("Load data before plot transect 2D field") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() - elif self.tableModel.rowCount(1) == 10: - msgBox = QMessageBox() - msgBox.setWindowTitle("Plot transect Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Fill table before plot transect 2D field") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() + # elif self.tableModel.rowCount(1) == 10: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot transect Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Fill table before plot transect 2D field") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() # --- Condition if table is filled and figure is not plotted --- # --- => Then plot transect for each frequency by pressing the button "Plot transect" - elif (self.tableModel.rowCount(1) > 10) and (self.canvas_BS == None): + # elif (self.tableModel.rowCount(1) > 10) and (self.canvas_BS == None): + elif self.canvas_BS == None: self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq.shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") self.canvas_BS = FigureCanvas(self.fig_BS) @@ -1013,7 +1105,7 @@ class AcousticDataTab(QWidget): np.nanmin(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmax.value())))[0][0]) ) - print(f"freq = {f}") + # print(f"freq = {f}") print(f"tmin {stg.tmin}") print(f"tmax {stg.tmax}") @@ -1029,6 +1121,13 @@ class AcousticDataTab(QWidget): np.log(stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]), cmap='Blues') + # --- 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) + self.axis_BS[f].text(1, .70, stg.freq_text[f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', @@ -1040,6 +1139,8 @@ class AcousticDataTab(QWidget): cbar.set_label(label='Backscatter acoustic signal (V)', rotation=270, labelpad=10) self.fig_BS.canvas.draw_idle() + self.plot_profile() + def update_xaxis_transect_with_BS_raw_data(self): # --- Condition if table is filled but transect is not plotted @@ -1052,6 +1153,44 @@ class AcousticDataTab(QWidget): msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() + # elif stg.BS_cross_section.size == 0: + # + # for f, _ in enumerate(stg.freq): + # + # self.axis_BS[f].cla() + # + # val_min = np.nanmin(stg.BS_raw_data[f, :, :]) + # val_max = np.nanmax(stg.BS_raw_data[f, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # if self.combobox_ABS_system_choice.currentIndex() == 1: + # pcm = self.axis_BS[f].pcolormesh(stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])], + # -stg.r[f, :], + # stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])], + # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + # + # elif self.combobox_ABS_system_choice.currentIndex() == 2: + # pcm = self.axis_BS[f].pcolormesh(stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])], + # -stg.r[f, :], + # np.log(stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]), + # cmap='Blues') + # + # # --- 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(), self.slider.value()] * np.ones(stg.r.shape[1]), + # -stg.r[self.combobox_frequency_profile.currentIndex(), :], + # color='red', linestyle="solid", linewidth=2) + # + # self.axis_BS[f].text(1, .70, stg.freq_text[f], + # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_BS[f].transAxes) + # + # self.fig_BS.supxlabel('Time (sec)', fontsize=10) + # self.fig_BS.supylabel('Depth (m)', fontsize=10) + # self.fig_BS.canvas.draw_idle() + else: # --- Backscatter acoustic signal is recorded for next tab --- @@ -1066,10 +1205,10 @@ class AcousticDataTab(QWidget): stg.tmax[f] = np.where(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmax.value()) == np.nanmin(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmax.value())))[0][0] - print("stg.tmin[f] ", stg.tmin[f]) - print("stg.tmax[f] ", stg.tmax[f]) - print("shape of BS_raw_data ", np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]).shape) - print("BS_data shape ", stg.BS_cross_section.shape) + # print("stg.tmin[f] ", stg.tmin[f]) + # print("stg.tmax[f] ", stg.tmax[f]) + # print("shape of BS_raw_data ", np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]).shape) + # print("BS_data shape ", stg.BS_cross_section.shape) if stg.BS_cross_section.shape[2] == 0: stg.BS_cross_section = np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]) else: @@ -1078,10 +1217,10 @@ class AcousticDataTab(QWidget): # stg.BS_cross_section = np.stack(np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) # stg.BS_cross_section = np.append(stg.BS_cross_section, np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=2) - print("stg.BS_cross_section.shape ", stg.BS_cross_section.shape) - print("stg.BS_cross_section.size ", stg.BS_cross_section.size) - print("stg.time shape ", stg.time.shape) - print("stg.t shape ", stg.t.shape) + # print("stg.BS_cross_section.shape ", stg.BS_cross_section.shape) + # print("stg.BS_cross_section.size ", stg.BS_cross_section.size) + # print("stg.time shape ", stg.time.shape) + # print("stg.t shape ", stg.t.shape) if stg.t.shape[1] == 0: stg.t = np.array([stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])]]) else: @@ -1093,6 +1232,16 @@ class AcousticDataTab(QWidget): # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]] # print("stg.r shape ", stg.r_2D.shape) + print("self.combobox_frequency_profile.currentIndex() ", self.combobox_frequency_profile.currentIndex()) + + print("slider value = ", [ + self.slider.value() - 1 if self.slider.value() - 1 <= stg.t.shape[1] - 1 else np.max( + stg.t.shape[1] - 1)][0]) + + print(stg.t[0, + [self.slider.value() - 1 if self.slider.value() - 1 <= stg.t.shape[1] - 1 else np.max( + stg.t.shape[1] - 1)][0]]) + self.axis_BS[f].cla() val_min = np.min(stg.BS_cross_section[f, :, :]) @@ -1110,6 +1259,13 @@ class AcousticDataTab(QWidget): pcm = self.axis_BS[f].pcolormesh(stg.t[f, :], -stg.r[f, :], np.log(stg.BS_cross_section[f, :, :]), cmap='Blues') + # --- Plot red solid line on transect to visualize position of plotted profile --- + self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + stg.t[0, # self.combobox_frequency_profile.currentIndex(), + [self.slider.value() - 1 if self.slider.value() -1 <= stg.t.shape[1]-1 else np.max(stg.t.shape[1]-1)][0]] * np.ones(stg.r.shape[1]), + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + color='red', linestyle="solid", linewidth=2) + self.axis_BS[f].text(1, .70, stg.freq_text[f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', @@ -1119,280 +1275,394 @@ class AcousticDataTab(QWidget): self.fig_BS.supylabel('Depth (m)', fontsize=10) self.fig_BS.canvas.draw_idle() - def plot_transect_with_SNR_data(self): - if not self.lineEdit_noise_file.text(): - msgBox = QMessageBox() - msgBox.setWindowTitle("Plot transect Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Load data before plot SNR 2D field") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - elif self.tableModel.rowCount(1) == 10: - msgBox = QMessageBox() - msgBox.setWindowTitle("Plot transect Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Fill table before plot SNR 2D field") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - elif self.canvas_BS == None: - msgBox = QMessageBox() - msgBox.setWindowTitle("Plot transect Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Plot backscatter acoustic raw data 2D field before plot SNR 2D field") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() - elif (self.lineEdit_noise_file.text()) and (self.tableModel.rowCount(1) > 11): + def plot_profile(self): - self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq.shape[0] , ncols=1, - sharex=True, sharey=False, layout="constrained") - self.canvas_SNR = FigureCanvas(self.fig_SNR) - self.verticalLayout_groupbox_transect_2Dplot_snr_data.addWidget(self.canvas_SNR) + # --- Figure to plot profiles --- + self.fig_profile, self.axis_profile = plt.subplots(nrows=1, ncols=1, layout="constrained") + self.canvas_plot_profile = FigureCanvas(self.fig_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) - self.verticalLayout_groupbox_transect_2Dplot_snr_data.removeWidget(self.scroll_SNR) - self.scroll_SNR = QScrollArea() - self.scroll_SNR.setWidget(self.canvas_SNR) - self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - self.scroll_SNR.setAlignment(Qt.AlignCenter) - self.verticalLayout_groupbox_transect_2Dplot_snr_data.addWidget(self.scroll_SNR) + # --- Slider for moving the profile --- + self.horizontalLayout_slider = QHBoxLayout() + self.verticalLayout_groupbox_plot_profile.addLayout(self.horizontalLayout_slider) - # self.spinbox_tmin.setValue(np.min(noise_data._time_snr)) - # self.spinbox_tmax.setValue(np.round(np.max(noise_data._time_snr), 2)) + self.pushbutton_slider_left = QPushButton() + self.pushbutton_slider_left.setIcon(self.icon_triangle_left) + self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left) - # if self.combobox_ABS_system_choice.currentIndex() == 1: - # - # x, y = np.meshgrid( - # stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: - # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], - # stg.r) - # - # for f in range(stg.freq.shape[0]): - # - # val_min = np.min(stg.snr[:, f, :]) - # val_max = np.max(stg.snr[:, f, :]) - # if val_min == 0: - # val_min = 1e-5 - # if val_max > 1000: - # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - # else: - # levels = np.array([00.1, 1, 2, 10, 100, val_max]) - # bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - # norm = BoundaryNorm(boundaries=bounds, ncolors=300) - # - # cf = (self.axis_SNR[f]. - # contourf(x, -y, - # stg.snr[:, f, - # np.where(np.round(stg.snr, 2) == self.spinbox_tmin.value())[0][0]: - # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], - # levels, cmap='gist_rainbow', norm=norm)) - # - # self.axis_SNR[f].text(1, .70, stg.freq_text[f], - # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_SNR[f].transAxes) - # - # self.fig_SNR.supxlabel('Time (sec)', fontsize=10) - # self.fig_SNR.supylabel('Depth (m)', fontsize=10) - # cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right') - # cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10) - # cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$']) - # self.fig_SNR.canvas.draw_idle() + self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left) - # elif self.combobox_ABS_system_choice.currentIndex() == 2: + self.pushbutton_slider_right = QPushButton() + self.pushbutton_slider_right.setIcon(self.icon_triangle_right) + self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) - x = np.array([[[]]]) - y = np.array([[[]]]) - print(f"x : {x.shape}, y : {y.shape}") - for f, freq in enumerate(stg.freq): + self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right) - if x.shape[2] == 0: - x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) - x = np.array([x]) - y = np.array([y]) - print(f"x : {x.shape}, y : {y.shape}") - else: - x0, y0 = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) - x = np.append(x, np.array([x0]), axis=0) - y = np.append(y, np.array([y0]), axis=0) - print(f"x : {x.shape}, y : {y.shape}") + self.lineEdit_slider = QLineEdit() + self.lineEdit_slider.setText("1") + self.lineEdit_slider.setFixedWidth(50) + self.horizontalLayout_slider.addWidget(self.lineEdit_slider) - val_min = np.nanmin(abs(stg.SNR_data[f, :, :])) - # print(f"val_min = {val_min}") - val_max = np.nanmax(abs(stg.SNR_data[f, :, :])) - # print(f"val_max = {val_max}") - if int(val_min) == 0: - val_min = 1e-5 - if int(val_max) < 1000: - levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2] - else: - levels = np.array([00.1, 1, 2, 10, 100, val_max]) - bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - norm = BoundaryNorm(boundaries=bounds, ncolors=300) + self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit) - # print(f"levels = {levels}") - # print(f"norm = {norm.boundaries}") - if self.combobox_ABS_system_choice.currentIndex() == 1: + self.slider = QSlider() + self.horizontalLayout_slider.addWidget(self.slider, 9) - cf = self.axis_SNR[f].contourf(x[f, :, :], -y[f, :, :], - stg.SNR_data[f, :, :], levels, cmap='gist_rainbow', norm=norm) + self.slider.setOrientation(Qt.Horizontal) + self.slider.setCursor(Qt.OpenHandCursor) + self.slider.setMinimum(1) + self.slider.setMaximum(stg.BS_raw_data.shape[2]) + self.slider.setTickInterval(1) + self.slider.setValue(1) - elif self.combobox_ABS_system_choice.currentIndex() == 2: + self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) - cf = self.axis_SNR[f].contourf(x[f, :, :], -y[f, :, :], stg.SNR_data[f, :, :])#, levels, cmap='gist_rainbow', norm=norm) + # self.slider.valueChanged.connect(self.update_plot_profile_position_on_transect) + self.slider.valueChanged.connect(self.update_plot_profile) + self.slider.valueChanged.connect(self.update_xaxis_transect_with_BS_raw_data) + self.combobox_frequency_profile.currentIndexChanged.connect(self.update_xaxis_transect_with_BS_raw_data) + self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_profile) - self.axis_SNR[f].text(1, .70, stg.freq_text[f], - fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_SNR[f].transAxes) + # for f, _ in enumerate(stg.freq[0]): - self.fig_SNR.supxlabel('Time (sec)', fontsize=10) - self.fig_SNR.supylabel('Depth (m)', fontsize=10) - cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right') - cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10) - self.fig_SNR.canvas.draw_idle() + self.axis_profile.cla() + self.axis_profile.plot(stg.BS_raw_data[ + 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.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.transAxes) - def update_xaxis_transect_with_SNR_data(self): + self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") + self.fig_profile.supylabel("Depth (m)") - # if self.canvas_SNR == None: - # msgBox = QMessageBox() - # msgBox.setWindowTitle("Plot transect Error") - # msgBox.setIcon(QMessageBox.Warning) - # msgBox.setText("Plot transect before change x-axis value") - # msgBox.setStandardButtons(QMessageBox.Ok) - # msgBox.exec() - if ((self.canvas_BS != None) and (self.canvas_SNR != None)): + def slide_profile_number_to_right(self): + self.slider.setValue(int(self.slider.value()) + 1) + self.lineEdit_slider.setText(str(self.slider.value())) - # --- Backscatter noise signal is recorded for next tab --- + def slide_profile_number_to_left(self): + self.slider.setValue(int(self.slider.value()) - 1) + self.lineEdit_slider.setText(str(self.slider.value())) - stg.tmin_snr = np.array([]) - stg.tmax_snr = np.array([]) + def profile_number_on_lineEdit(self): + self.slider.setValue(int(self.lineEdit_slider.text())) - stg.SNR_cross_section = np.array([[[]]]) - stg.t_snr = np.array([[]]) + def update_lineEdit_by_moving_slider(self): + self.lineEdit_slider.setText(str(self.slider.value())) - x = np.array([[[]]]) - y = np.array([[[]]]) - # print(f"x : {x.shape}, y : {y.shape}") - for f, _ in enumerate(stg.freq): + def update_plot_profile(self): - if x.shape[2] == 0: - x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) - x = np.array([x]) - y = np.array([y]) - # print(f"x : {x.shape}, y : {y.shape}") - else: - x0, y0 = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) - x = np.append(x, np.array([x0]), axis=0) - y = np.append(y, np.array([y0]), axis=0) - # print(f"x : {x.shape}, y : {y.shape}") + if stg.BS_cross_section.size == 0: - # print(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value())) - # print(np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value()) == - # np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value())))[0][0]) + self.axis_profile.cla() + self.axis_profile.plot(stg.BS_raw_data[ + 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.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.transAxes) - stg.tmin_snr = ( - np.append(stg.tmin_snr, - np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value()) == - np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value())))[0][ - 0]) - ) + else: - stg.tmax_snr = ( - np.append(stg.tmax_snr, - np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmax.value()) == - np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmax.value())))[0][ - 0]) - ) + self.slider.setMaximum(stg.t.shape[1]) - # print("stg.tmin[f] ", stg.tmin_snr[f]) - # print("stg.tmax[f] ", stg.tmax_snr[f]) + self.axis_profile.cla() + self.axis_profile.plot(stg.BS_cross_section[ + self.combobox_frequency_profile.currentIndex(), :, + [self.slider.value() - 1 if self.slider.value() -1 <= stg.t.shape[1]-1 else np.max(stg.t.shape[1]-1)][0]], + -stg.r[self.combobox_frequency_profile.currentIndex(), :], + linestyle='solid', color='k', linewidth=1) + self.axis_profile.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.transAxes) - if stg.SNR_cross_section.shape[2] == 0: - stg.SNR_cross_section = np.array([stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]) - else: - stg.SNR_cross_section = np.append(stg.SNR_cross_section, - np.array([stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]), - axis=0) + self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") + self.fig_profile.supylabel("Depth (m)") + self.fig_profile.canvas.draw_idle() - # stg.BS_cross_section = np.stack(np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) - # stg.BS_cross_section = np.append(stg.BS_cross_section, np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=2) + # def plot_transect_with_SNR_data(self): + # if not self.lineEdit_noise_file.text(): + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot transect Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Load data before plot SNR 2D field") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # elif self.tableModel.rowCount(1) == 10: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot transect Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Fill table before plot SNR 2D field") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # elif self.canvas_BS == None: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Plot transect Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Plot backscatter acoustic raw data 2D field before plot SNR 2D field") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() + # elif (self.lineEdit_noise_file.text()) and (self.tableModel.rowCount(1) > 11): + # + # self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq.shape[0] , ncols=1, + # sharex=True, sharey=False, layout="constrained") + # self.canvas_SNR = FigureCanvas(self.fig_SNR) + # self.verticalLayout_groupbox_transect_2Dplot_snr_data.addWidget(self.canvas_SNR) + # + # self.verticalLayout_groupbox_transect_2Dplot_snr_data.removeWidget(self.scroll_SNR) + # self.scroll_SNR = QScrollArea() + # self.scroll_SNR.setWidget(self.canvas_SNR) + # self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + # self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_SNR.setAlignment(Qt.AlignCenter) + # self.verticalLayout_groupbox_transect_2Dplot_snr_data.addWidget(self.scroll_SNR) + # + # # self.spinbox_tmin.setValue(np.min(noise_data._time_snr)) + # # self.spinbox_tmax.setValue(np.round(np.max(noise_data._time_snr), 2)) + # + # # if self.combobox_ABS_system_choice.currentIndex() == 1: + # # + # # x, y = np.meshgrid( + # # stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: + # # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], + # # stg.r) + # # + # # for f in range(stg.freq.shape[0]): + # # + # # val_min = np.min(stg.snr[:, f, :]) + # # val_max = np.max(stg.snr[:, f, :]) + # # if val_min == 0: + # # val_min = 1e-5 + # # if val_max > 1000: + # # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + # # else: + # # levels = np.array([00.1, 1, 2, 10, 100, val_max]) + # # bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + # # norm = BoundaryNorm(boundaries=bounds, ncolors=300) + # # + # # cf = (self.axis_SNR[f]. + # # contourf(x, -y, + # # stg.snr[:, f, + # # np.where(np.round(stg.snr, 2) == self.spinbox_tmin.value())[0][0]: + # # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], + # # levels, cmap='gist_rainbow', norm=norm)) + # # + # # self.axis_SNR[f].text(1, .70, stg.freq_text[f], + # # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # # horizontalalignment='right', verticalalignment='bottom', + # # transform=self.axis_SNR[f].transAxes) + # # + # # self.fig_SNR.supxlabel('Time (sec)', fontsize=10) + # # self.fig_SNR.supylabel('Depth (m)', fontsize=10) + # # cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right') + # # cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10) + # # cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$']) + # # self.fig_SNR.canvas.draw_idle() + # + # # elif self.combobox_ABS_system_choice.currentIndex() == 2: + # + # x = np.array([[[]]]) + # y = np.array([[[]]]) + # print(f"x : {x.shape}, y : {y.shape}") + # for f, freq in enumerate(stg.freq): + # + # if x.shape[2] == 0: + # x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) + # x = np.array([x]) + # y = np.array([y]) + # print(f"x : {x.shape}, y : {y.shape}") + # else: + # x0, y0 = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) + # x = np.append(x, np.array([x0]), axis=0) + # y = np.append(y, np.array([y0]), axis=0) + # print(f"x : {x.shape}, y : {y.shape}") + # + # val_min = np.nanmin(abs(stg.SNR_data[f, :, :])) + # # print(f"val_min = {val_min}") + # val_max = np.nanmax(abs(stg.SNR_data[f, :, :])) + # # print(f"val_max = {val_max}") + # if int(val_min) == 0: + # val_min = 1e-5 + # if int(val_max) < 1000: + # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + # bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2] + # else: + # levels = np.array([00.1, 1, 2, 10, 100, val_max]) + # bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + # norm = BoundaryNorm(boundaries=bounds, ncolors=300) + # + # # print(f"levels = {levels}") + # # print(f"norm = {norm.boundaries}") + # if self.combobox_ABS_system_choice.currentIndex() == 1: + # + # cf = self.axis_SNR[f].contourf(x[f, :, :], -y[f, :, :], + # stg.SNR_data[f, :, :], levels, cmap='gist_rainbow', norm=norm) + # + # elif self.combobox_ABS_system_choice.currentIndex() == 2: + # + # cf = self.axis_SNR[f].contourf(x[f, :, :], -y[f, :, :], stg.SNR_data[f, :, :])#, levels, cmap='gist_rainbow', norm=norm) + # + # self.axis_SNR[f].text(1, .70, stg.freq_text[f], + # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_SNR[f].transAxes) + # + # self.fig_SNR.supxlabel('Time (sec)', fontsize=10) + # self.fig_SNR.supylabel('Depth (m)', fontsize=10) + # cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right') + # cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10) + # self.fig_SNR.canvas.draw_idle() - if stg.t_snr.shape[1] == 0: - stg.t_snr = np.array([stg.time_snr[f, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]) - else: - stg.t_snr = np.append(stg.t_snr, np.array([stg.time_snr[f, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]), axis=0) - # stg.t = np.append(stg.t, np.array([stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) - # print("stg.t shape ", stg.t_snr.shape) - - self.axis_SNR[f].cla() - - # if self.combobox_ABS_system_choice.currentIndex() == 1: - # - # val_min = np.nanmin(stg.SNR_data[f, :, :]) - # val_max = np.nanmax(stg.snr[f, :, :]) - # if val_min == 0: - # val_min = 1e-5 - # if val_max < 1000: - # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - # else: - # levels = np.array([00.1, 1, 2, 10, 100, val_max]) - # - # bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - # norm = BoundaryNorm(boundaries=bounds, ncolors=300) - # - # cf = self.axis_SNR[f].contourf(x, -y, - # stg.snr[:, f, - # np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: - # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], - # levels, cmap='gist_rainbow', norm=norm) - # - # self.axis_SNR[f].text(1, .70, stg.freq_text[f], - # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, - # horizontalalignment='right', verticalalignment='bottom', - # transform=self.axis_SNR[f].transAxes) - # - # elif self.combobox_ABS_system_choice.currentIndex() == 2: - - val_min = np.nanmin(abs(stg.SNR_data[f, :, :])) - # print(f"val_min = {val_min}") - val_max = np.nanmax(abs(stg.SNR_data[f, :, :])) - # print(f"val_max = {val_max}") - if int(val_min) == 0: - val_min = 1e-5 - if int(val_max) < 1000: - levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2] - else: - levels = np.array([00.1, 1, 2, 10, 100, val_max]) - bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - norm = BoundaryNorm(boundaries=bounds, ncolors=300) - - # print(f"levels = {levels}") - # print(f"norm = {norm.boundaries}") - - if self.combobox_ABS_system_choice.currentIndex() == 1: - - cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - levels, cmap='gist_rainbow', norm=norm) - - elif self.combobox_ABS_system_choice.currentIndex() == 2: - - cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]) # , levels, cmap='gist_rainbow', norm=norm) - - self.axis_SNR[f].text(1, .70, stg.freq_text[f], - fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_SNR[f].transAxes) - - self.fig_SNR.supxlabel('Distance from left bank (m)', fontsize=10) - self.fig_SNR.supylabel('Depth (m)', fontsize=10) - self.fig_SNR.canvas.draw_idle() + # def update_xaxis_transect_with_SNR_data(self): + # + # # if self.canvas_SNR == None: + # # msgBox = QMessageBox() + # # msgBox.setWindowTitle("Plot transect Error") + # # msgBox.setIcon(QMessageBox.Warning) + # # msgBox.setText("Plot transect before change x-axis value") + # # msgBox.setStandardButtons(QMessageBox.Ok) + # # msgBox.exec() + # + # if ((self.canvas_BS != None) and (self.canvas_SNR != None)): + # + # # --- Backscatter noise signal is recorded for next tab --- + # + # stg.tmin_snr = np.array([]) + # stg.tmax_snr = np.array([]) + # + # stg.SNR_cross_section = np.array([[[]]]) + # stg.t_snr = np.array([[]]) + # + # x = np.array([[[]]]) + # y = np.array([[[]]]) + # # print(f"x : {x.shape}, y : {y.shape}") + # for f, _ in enumerate(stg.freq): + # + # if x.shape[2] == 0: + # x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) + # x = np.array([x]) + # y = np.array([y]) + # # print(f"x : {x.shape}, y : {y.shape}") + # else: + # x0, y0 = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) + # x = np.append(x, np.array([x0]), axis=0) + # y = np.append(y, np.array([y0]), axis=0) + # # print(f"x : {x.shape}, y : {y.shape}") + # + # # print(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value())) + # # print(np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value()) == + # # np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value())))[0][0]) + # + # stg.tmin_snr = ( + # np.append(stg.tmin_snr, + # np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value()) == + # np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value())))[0][ + # 0]) + # ) + # + # stg.tmax_snr = ( + # np.append(stg.tmax_snr, + # np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmax.value()) == + # np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmax.value())))[0][ + # 0]) + # ) + # + # # print("stg.tmin[f] ", stg.tmin_snr[f]) + # # print("stg.tmax[f] ", stg.tmax_snr[f]) + # + # if stg.SNR_cross_section.shape[2] == 0: + # stg.SNR_cross_section = np.array([stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]) + # else: + # stg.SNR_cross_section = np.append(stg.SNR_cross_section, + # np.array([stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]), + # axis=0) + # + # # stg.BS_cross_section = np.stack(np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) + # # stg.BS_cross_section = np.append(stg.BS_cross_section, np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=2) + # + # if stg.t_snr.shape[1] == 0: + # stg.t_snr = np.array([stg.time_snr[f, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]) + # else: + # stg.t_snr = np.append(stg.t_snr, np.array([stg.time_snr[f, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]), axis=0) + # # stg.t = np.append(stg.t, np.array([stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) + # # print("stg.t shape ", stg.t_snr.shape) + # + # self.axis_SNR[f].cla() + # + # # if self.combobox_ABS_system_choice.currentIndex() == 1: + # # + # # val_min = np.nanmin(stg.SNR_data[f, :, :]) + # # val_max = np.nanmax(stg.snr[f, :, :]) + # # if val_min == 0: + # # val_min = 1e-5 + # # if val_max < 1000: + # # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + # # else: + # # levels = np.array([00.1, 1, 2, 10, 100, val_max]) + # # + # # bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + # # norm = BoundaryNorm(boundaries=bounds, ncolors=300) + # # + # # cf = self.axis_SNR[f].contourf(x, -y, + # # stg.snr[:, f, + # # np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: + # # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], + # # levels, cmap='gist_rainbow', norm=norm) + # # + # # self.axis_SNR[f].text(1, .70, stg.freq_text[f], + # # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # # horizontalalignment='right', verticalalignment='bottom', + # # transform=self.axis_SNR[f].transAxes) + # # + # # elif self.combobox_ABS_system_choice.currentIndex() == 2: + # + # val_min = np.nanmin(abs(stg.SNR_data[f, :, :])) + # # print(f"val_min = {val_min}") + # val_max = np.nanmax(abs(stg.SNR_data[f, :, :])) + # # print(f"val_max = {val_max}") + # if int(val_min) == 0: + # val_min = 1e-5 + # if int(val_max) < 1000: + # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + # bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2] + # else: + # levels = np.array([00.1, 1, 2, 10, 100, val_max]) + # bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + # norm = BoundaryNorm(boundaries=bounds, ncolors=300) + # + # # print(f"levels = {levels}") + # # print(f"norm = {norm.boundaries}") + # + # if self.combobox_ABS_system_choice.currentIndex() == 1: + # + # cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # levels, cmap='gist_rainbow', norm=norm) + # + # elif self.combobox_ABS_system_choice.currentIndex() == 2: + # + # cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]) # , levels, cmap='gist_rainbow', norm=norm) + # + # self.axis_SNR[f].text(1, .70, stg.freq_text[f], + # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_SNR[f].transAxes) + # + # self.fig_SNR.supxlabel('Distance from left bank (m)', fontsize=10) + # self.fig_SNR.supylabel('Depth (m)', fontsize=10) + # self.fig_SNR.canvas.draw_idle() def detect_bottom(self): if self.lineEdit_acoustic_file.text() == "": @@ -1402,13 +1672,13 @@ class AcousticDataTab(QWidget): msgBox.setText("Load data before compute bathymety algorithm") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() - elif self.tableModel.rowCount(1) == 10: - msgBox = QMessageBox() - msgBox.setWindowTitle("Detect bottom Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Fill table before compute bathymety algorithm") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() + # elif self.tableModel.rowCount(1) == 10: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Detect bottom Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Fill table before compute bathymety algorithm") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() elif self.canvas_BS == None: msgBox = QMessageBox() msgBox.setWindowTitle("Detect bottom Error") @@ -1590,89 +1860,89 @@ class AcousticDataTab(QWidget): self.fig_BS.canvas.draw_idle() - # --- Plot transect SNR with bathymetry --- - if self.canvas_SNR != None: - # x, y = np.meshgrid( - # stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: - # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], - # stg.r) - - x = np.array([[[]]]) - y = np.array([[[]]]) - # print(f"x : {x.shape}, y : {y.shape}") - - for f, _ in enumerate(stg.freq): - - if x.shape[2] == 0: - x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) - x = np.array([x]) - y = np.array([y]) - # print(f"x : {x.shape}, y : {y.shape}") - else: - x0, y0 = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) - x = np.append(x, np.array([x0]), axis=0) - y = np.append(y, np.array([y0]), axis=0) - # print(f"x : {x.shape}, y : {y.shape}") - - self.axis_SNR[f].cla() - - val_min = abs(np.nanmin(stg.SNR_data[f, :, :])) - val_max = abs(np.nanmax(stg.SNR_data[f, :, :])) - if val_min == 0: - val_min = 1e-5 - if val_max < 1000: - levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - else: - levels = np.array([00.1, 1, 2, 10, 100, val_max]) - bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - norm = BoundaryNorm(boundaries=bounds, ncolors=300) - - # cf = self.axis_SNR[f].contourf(x, -y, - # stg.snr[:, f, - # np.where(np.round(stg.time, - # 2) == self.spinbox_tmin.value())[0][0]: - # np.where(np.round(stg.time, - # 2) == self.spinbox_tmax.value())[0][0]], - # levels, cmap='gist_rainbow', norm=norm) # , shading='gouraud') - - if self.combobox_ABS_system_choice.currentIndex() == 1: - - cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - levels, cmap='gist_rainbow', norm=norm) - - elif self.combobox_ABS_system_choice.currentIndex() == 2: - - cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[ - f])]) # , levels, cmap='gist_rainbow', norm=norm) - - self.axis_SNR[f].text(1, .70, stg.freq_text[f], - fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_SNR[f].transAxes) - - self.axis_SNR[f].plot(stg.t[self.combobox_freq_choice.currentIndex(), :], -stg.r_bottom, - color='black', linewidth=1, linestyle="solid") - - # self.axis_SNR[f].plot( - # stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: - # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], - # - r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: - # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], - # + np.min(r_bottom[np.where(np.round(noise_data._time, 2) == self.spinbox_tmin.value())[0][0]: - # np.where(np.round(noise_data._time, 2) == self.spinbox_tmax.value())[0][0]]), - # np.max(self._model.r_bottom_cross_section) - self._model.r_bottom_cross_section + np.min(self._model.r_bottom_cross_section), - # color='black', linewidth=1, linestyle="solid") - - self.axis_SNR[f].text(1, .70, stg.freq_text[f], - fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_SNR[f].transAxes) - - self.fig_SNR.canvas.draw_idle() + # # --- Plot transect SNR with bathymetry --- + # if self.canvas_SNR != None: + # # x, y = np.meshgrid( + # # stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: + # # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], + # # stg.r) + # + # x = np.array([[[]]]) + # y = np.array([[[]]]) + # # print(f"x : {x.shape}, y : {y.shape}") + # + # for f, _ in enumerate(stg.freq): + # + # if x.shape[2] == 0: + # x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) + # x = np.array([x]) + # y = np.array([y]) + # # print(f"x : {x.shape}, y : {y.shape}") + # else: + # x0, y0 = np.meshgrid(stg.time_snr[f, :], stg.r[f, :]) + # x = np.append(x, np.array([x0]), axis=0) + # y = np.append(y, np.array([y0]), axis=0) + # # print(f"x : {x.shape}, y : {y.shape}") + # + # self.axis_SNR[f].cla() + # + # val_min = abs(np.nanmin(stg.SNR_data[f, :, :])) + # val_max = abs(np.nanmax(stg.SNR_data[f, :, :])) + # if val_min == 0: + # val_min = 1e-5 + # if val_max < 1000: + # levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + # else: + # levels = np.array([00.1, 1, 2, 10, 100, val_max]) + # bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + # norm = BoundaryNorm(boundaries=bounds, ncolors=300) + # + # # cf = self.axis_SNR[f].contourf(x, -y, + # # stg.snr[:, f, + # # np.where(np.round(stg.time, + # # 2) == self.spinbox_tmin.value())[0][0]: + # # np.where(np.round(stg.time, + # # 2) == self.spinbox_tmax.value())[0][0]], + # # levels, cmap='gist_rainbow', norm=norm) # , shading='gouraud') + # + # if self.combobox_ABS_system_choice.currentIndex() == 1: + # + # cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # levels, cmap='gist_rainbow', norm=norm) + # + # elif self.combobox_ABS_system_choice.currentIndex() == 2: + # + # cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + # stg.SNR_data[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[ + # f])]) # , levels, cmap='gist_rainbow', norm=norm) + # + # self.axis_SNR[f].text(1, .70, stg.freq_text[f], + # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_SNR[f].transAxes) + # + # self.axis_SNR[f].plot(stg.t[self.combobox_freq_choice.currentIndex(), :], -stg.r_bottom, + # color='black', linewidth=1, linestyle="solid") + # + # # self.axis_SNR[f].plot( + # # stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: + # # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], + # # - r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: + # # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]], + # # + np.min(r_bottom[np.where(np.round(noise_data._time, 2) == self.spinbox_tmin.value())[0][0]: + # # np.where(np.round(noise_data._time, 2) == self.spinbox_tmax.value())[0][0]]), + # # np.max(self._model.r_bottom_cross_section) - self._model.r_bottom_cross_section + np.min(self._model.r_bottom_cross_section), + # # color='black', linewidth=1, linestyle="solid") + # + # self.axis_SNR[f].text(1, .70, stg.freq_text[f], + # fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + # horizontalalignment='right', verticalalignment='bottom', + # transform=self.axis_SNR[f].transAxes) + # + # self.fig_SNR.canvas.draw_idle() # else: