import os.path import sys 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, QRadioButton, QFormLayout, QSlider, QAbstractItemView, QMenu, QItemDelegate, QCheckBox) from PyQt5.QtGui import QPixmap, QIcon, QFont, QMouseEvent from PyQt5.QtCore import Qt, QCoreApplication, pyqtSignal, pyqtSlot, QEvent import numpy as np import pandas as pd import matplotlib.pyplot as plt # import matplotlib # matplotlib.use("Qt5Agg") from matplotlib.colors import LogNorm, CSS4_COLORS, BoundaryNorm from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar from os import path from copy import deepcopy import locale locale.setlocale(locale.LC_ALL, '') from scipy.signal import savgol_filter from pyqt_svg_button import SvgButton from pyqt_file_list_widget.fileListWidget import FileListWidget from qtrangeslider import QLabeledDoubleRangeSlider # import Translation.biblio_string as bs import Translation.constant_string as cs from Model.TableModel import TableModel from Model.AquascatDataLoader import RawAquascatData from Model.acoustic_data_loader import AcousticDataLoader from Model.acoustic_data_loader_UBSediFlow import AcousticDataLoaderUBSediFlow # from View.window_noise_level_averaged_profile import WindowNoiseLevelTailAveragedProfile import settings as stg _translate = QCoreApplication.translate # class FloatDelegate(QItemDelegate): # def __init__(self, decimals, parent=None): # QItemDelegate.__init__(self, parent=parent) # self.nDecimals = decimals # # def paint(self, painter, option, index): # value = index.model().data(index, Qt.EditRole) # try: # number = float(value) # painter.drawText(option.rect, Qt.AlignLeft, "{:.{}f}".format(number, self.nDecimals)) # except : # QItemDelegate.paint(self, painter, option, index) # class WidgetPlot(QWidget): # def __init__(self, *args, **kwargs): # QWidget.__init__(self, *args, **kwargs) # self.setLayout(QVBoxLayout()) # self.canvas = FigureCanvas(self) # self.toolbar = NavigationToolBar(self.canvas, self) # self.layout().addWidget(self.toolbar) # self.layout().addWidget(self.canvas) class AcousticDataTab(QWidget): """ This class generates the Acoustic Data Tab """ fileAdded = pyqtSignal(list) fileRemoved = pyqtSignal(list) newValueChanged = pyqtSignal(float) # path_icon = "./icons/" # icon_triangle_left_to_begin = path_icon + "triangle_left_to_begin.png" def __init__(self, tab_widget): super().__init__() # Utiliser os.path.split() OU os.path.join() self.path_icon = "./icons/" self.icon_folder = QIcon(self.path_icon + "folder.png") self.icon_apply_limits = QIcon(self.path_icon + "circle_green_arrow_right.png") self.icon_triangle_left_to_begin = QIcon(self.path_icon + "triangle_left_to_begin.png") self.icon_triangle_left = QIcon(self.path_icon + "triangle_left.png") self.icon_triangle_right = QIcon(self.path_icon + "triangle_right.png") self.icon_triangle_right_to_end = QIcon(self.path_icon + "triangle_right_to_end.png") self.icon_add = QIcon(self.path_icon + "add.png") self.icon_delete = QIcon(self.path_icon + "delete.png") self.icon_clear = QIcon(self.path_icon + "clear.png") ### --- General layout of widgets --- self.verticalLayoutMain = QVBoxLayout(tab_widget) self.horizontalLayoutTop = QHBoxLayout() self.verticalLayoutMain.addLayout(self.horizontalLayoutTop, 5) # 1O units is 100% , 1 units is 10% self.horizontalLayoutBottom = QHBoxLayout() self.verticalLayoutMain.addLayout(self.horizontalLayoutBottom, 5) ### --- Layout of groupbox in the Top horizontal layout box # Download | Table of values | GPS file # Measurement information | | Display options self.groupbox_download = QGroupBox() self.horizontalLayoutTop.addWidget(self.groupbox_download, 3) self.groupbox_table = QGroupBox() self.horizontalLayoutTop.addWidget(self.groupbox_table, 3) # self.verticalLayout_goupbox_info_groupbox_table = QVBoxLayout() # self.horizontalLayoutTop.addLayout(self.verticalLayout_goupbox_info_groupbox_table, 3) # # self.groupbox_info = QGroupBox() # # self.verticalLayout_goupbox_info_groupbox_table.addWidget(self.groupbox_info, 5) # self.scrollbar_measurement_information = QScrollArea() # self.verticalLayout_goupbox_info_groupbox_table.addWidget(self.scrollbar_measurement_information, 4) # # self.groupbox_table = QGroupBox() # self.verticalLayout_goupbox_info_groupbox_table.addWidget(self.groupbox_table, 6) self.groupbox_display_option = QGroupBox() 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, 6) self.groupbox_plot_the_vertical_profile_for_a_frequency = QGroupBox() self.horizontalLayoutBottom.addWidget(self.groupbox_plot_the_vertical_profile_for_a_frequency, 4) # self.groupbox_transect_2Dplot_snr_data = QGroupBox() # self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_snr_data) # ===================================================== # TOP HORIZONTAL BOX LAYOUT # ===================================================== self.groupbox_download.setTitle("Acoustic recording") self.verticalLayout_groupbox_download = QVBoxLayout(self.groupbox_download) self.groupbox_acoustic_file = QGroupBox() self.groupbox_acoustic_file.setTitle("Download file") self.verticalLayout_groupbox_download.addWidget(self.groupbox_acoustic_file, 5) self.groupbox_info = QGroupBox() self.scrollbar_measurement_information = QScrollArea() # self.scrollbar_measurement_information.setWindowTitle("Measurements information") self.verticalLayout_groupbox_download.addWidget(self.scrollbar_measurement_information, 5) # +++++++++++++++++++++++++++ # | Group box Download file | # +++++++++++++++++++++++++++ # --- 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.gridLayout_groupbox_acoustic_file = QGridLayout(self.groupbox_acoustic_file) self.combobox_ABS_system_choice = QComboBox() self.combobox_ABS_system_choice.addItems([" ", "Aquascat 1000R", "UB-SediFlow"]) self.gridLayout_groupbox_acoustic_file.addWidget(self.combobox_ABS_system_choice, 0, 0, 1, 1) self.spacerItem_FileList = QSpacerItem(5, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout_groupbox_acoustic_file.addItem(self.spacerItem_FileList, 0, 1, 1, 1) # self.addBtn = SvgButton() # self.addBtn.setIcon("../icons/add.svg") self.addBtn = QPushButton() # self.addBtn.setText("Add") self.addBtn.setIcon(self.icon_add) # self.delBtn = SvgButton() # self.delBtn.setIcon("../icons/delete.svg") self.delBtn = QPushButton() # self.delBtn.setText("Del") self.delBtn.setIcon(self.icon_delete) # self.clearBtn = SvgButton() # self.clearBtn.setIcon("../icons/clear.svg") self.clearBtn = QPushButton() # self.clearBtn.setText("Clear") self.clearBtn.setIcon(self.icon_clear) self.gridLayout_groupbox_acoustic_file.addWidget(self.addBtn, 0, 2, 1, 1) self.gridLayout_groupbox_acoustic_file.addWidget(self.delBtn, 0, 3, 1, 1) self.gridLayout_groupbox_acoustic_file.addWidget(self.clearBtn, 0, 4, 1, 1) self.fileListWidget = FileListWidget() self.gridLayout_groupbox_acoustic_file.addWidget(self.fileListWidget, 1, 0, 1, 5) # self.pushbutton_acoustic_file = QPushButton() # self.pushbutton_acoustic_file.setObjectName("pushbutton_acoustic_file") # 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) # Download Push Button event : connect button clicked signal to open file slot # self.pushbutton_acoustic_file.clicked.connect(self.open_dialog_box) # ++++++++++++++++++++++++++++++++++++++ # | Group Box Measurements information | # ++++++++++++++++++++++++++++++++++++++ self.gridLayout_goupbox_info = QGridLayout() self.groupbox_info.setLayout(self.gridLayout_goupbox_info) self.scrollbar_measurement_information.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scrollbar_measurement_information.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scrollbar_measurement_information.setWidgetResizable(True) self.scrollbar_measurement_information.setWidget(self.groupbox_info) self.label_temperature = QLabel("Temperature : ") self.spinbox_temperature = QDoubleSpinBox() self.spinbox_temperature.setSuffix("°C") self.spinbox_temperature.setKeyboardTracking(False) self.label_speed_of_sound = QLabel("Speed of sound : ") self.spinbox_speed_of_sound = QDoubleSpinBox() self.spinbox_speed_of_sound.setSuffix("m/s") self.spinbox_speed_of_sound.setMaximum(1e5) self.label_sound_attenuation = QLabel("Sound attenuation : ") self.spinbox_sound_attenuation = QDoubleSpinBox() self.spinbox_sound_attenuation.setSuffix("/m") self.spinbox_sound_attenuation.setDecimals(5) self.label_ABS_name = QLabel() self.label_date_acoustic_file = QLabel() self.label_hour_acoustic_file = QLabel() self.label_freq = QLabel() self.combobox_frequency_information = QComboBox() self.label_profiles = QLabel() self.label_profiles_value = QLabel() self.label_profiles_per_sec = QLabel() self.label_profiles_per_sec_value = QLabel() self.label_cells = QLabel() # n_cell in UBSediFlow parameters self.label_cells_value = QLabel() self.label_cell_size = QLabel() # r_em in UBSediFlow parameters self.label_cell_size_value = QLabel() self.label_pulse_length = QLabel() # n_p / PRF with n_p = n_ech, nb of pulses to calculate one instantaneous profile self.label_pulse_length_value = QLabel() self.label_pings_per_sec = QLabel() # PRF in UBSediFlow parameters self.label_pings_per_sec_value = QLabel() self.label_pings_per_profile = QLabel() # n_profile/n_avg in UBSediFlow parameters self.label_pings_per_profile_value = QLabel() self.label_kt = QLabel() self.spinbox_kt = QDoubleSpinBox() self.spinbox_kt.setMaximum(1e6) self.checkbox_kt = QCheckBox() self.label_rx = QLabel() # a0 in UBSediFlow parameters self.spinbox_rx = QDoubleSpinBox() self.spinbox_rx.setMaximum(1e6) self.checkbox_rx = QCheckBox() self.label_tx = QLabel() # a1 in UBSediFlow parameters self.spinbox_tx = QDoubleSpinBox() self.spinbox_tx.setMaximum(1e6) self.checkbox_tx = QCheckBox() # --- 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) # # --- Group box GPS file --- # # self.groupbox_gps = QGroupBox() # self.horizontal_gps_input_data = QVBoxLayout(self.groupbox_gps) # # self.verticalLayout_radiobutton_gps = QHBoxLayout() # self.horizontal_gps_input_data.addLayout(self.verticalLayout_radiobutton_gps) # # self.radiobutton_value = QRadioButton("Value") # self.radiobutton_value.setChecked(True) # self.verticalLayout_radiobutton_gps.addWidget(self.radiobutton_value) # # self.radiobutton_file = QRadioButton("File") # # self.radiobutton_file.setChecked(False) # self.verticalLayout_radiobutton_gps.addWidget(self.radiobutton_file) # # self.groupbox_gps_value = QGroupBox() # self.gridLayout_gps_value = QGridLayout(self.groupbox_gps_value) # self.label_distance_value = QLabel() # self.label_distance_value.setText("Distance : ") # self.gridLayout_gps_value.addWidget(self.label_distance_value, 0, 0, 1, 1) # self.lineEdit_gps_value = QLineEdit() # self.gridLayout_gps_value.addWidget(self.lineEdit_gps_value, 0, 1, 1, 1) # self.label_m_per_record = QLabel("m / record") # self.gridLayout_gps_value.addWidget(self.label_m_per_record, 0, 2, 1, 1) # # self.horizontal_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, 2) # self.pushbutton_gps_file = QPushButton() # self.pushbutton_gps_file.setIcon(self.icon_folder) # self.gridLayout_groupbox_gps_file.addWidget(self.pushbutton_gps_file, 0, 2, 1, 1) # self.lineEdit_gps_file = QLineEdit() # self.gridLayout_groupbox_gps_file.addWidget(self.lineEdit_gps_file, 0, 3, 1, 2) # # self.label_date_groupbox_gps_file = QLabel() # self.gridLayout_groupbox_gps_file.addWidget(self.label_date_groupbox_gps_file, 1, 0, 1, 2) # self.label_hour_groupbox_gps_file = QLabel() # self.gridLayout_groupbox_gps_file.addWidget(self.label_hour_groupbox_gps_file, 1, 2, 1, 2) # # # Download Push Button event : connect button clicked signal to open file slot # # self.pushButton_gpsfile.clicked.connect(self.open_dialog_box) # # self.horizontal_gps_input_data.addWidget(self.groupbox_gps_file) # # 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() # # self.gridLayout_time_offset.addWidget(self.label_time_offset, 0, 0, 1, 1) # self.gridLayout_groupbox_gps_file.addWidget(self.label_time_offset, 2, 0, 1, 1) # self.label_acoustic_gps_time = QLabel() # self.label_acoustic_gps_time.setText( # "Tacoustic =" + " Tgps") # # self.gridLayout_time_offset.addWidget(self.label_acoustic_gps_time, 0, 1, 1, 1) # self.gridLayout_groupbox_gps_file.addWidget(self.label_acoustic_gps_time, 2, 1, 1, 1) # self.combobox_plus_minus = QComboBox() # self.combobox_plus_minus.addItem("+") # self.combobox_plus_minus.addItem("-") # # self.gridLayout_time_offset.addWidget(self.combobox_plus_minus, 0, 2, 1, 1) # self.gridLayout_groupbox_gps_file.addWidget(self.combobox_plus_minus, 2, 2, 1, 1) # self.spinbox_time_offset_value = QSpinBox() # # self.gridLayout_time_offset.addWidget(self.spinbox_time_offset_value, 0, 3, 1, 1) # self.gridLayout_groupbox_gps_file.addWidget(self.spinbox_time_offset_value, 2, 3, 1, 1) # self.label_seconds = QLabel() # self.label_seconds.setText("sec") # # self.gridLayout_time_offset.addWidget(self.label_seconds, 0, 4, 1, 1) # self.gridLayout_groupbox_gps_file.addWidget(self.label_seconds, 2, 4, 1, 1) # self.verticalLayout_groupbox_download.addLayout(self.gridLayout_time_offset) # # ++++++++++++++++++++++++++++++++++++++ # # | Group Box Measurements information | # # ++++++++++++++++++++++++++++++++++++++ # # # 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 --- # # self.verticalLayout_goupbox_info = QGridLayout(self.groupbox_info) # # self.gridLayout_goupbox_info = QGridLayout() # self.groupbox_info.setLayout(self.gridLayout_goupbox_info) # # self.scrollbar_measurement_information.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) # self.scrollbar_measurement_information.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # self.scrollbar_measurement_information.setWidgetResizable(True) # # self.scrollbar_measurement_information.setWidget(self.groupbox_info) # # self.self.gridLayout_goupbox_info = QGridLayout() # # self.scrollbar_measurement_information.setLayout(self.gridLayout_goupbox_info) # # self.verticalLayout_goupbox_info.addWidget(self.scrollbar_measurement_information) # # # scroll = QtWidgets.QScrollArea() # # scroll.setWidget(mygroupbox) # # scroll.setWidgetResizable(True) # # scroll.setFixedHeight(200) # # layout = QtWidgets.QVBoxLayout(self) # # layout.addWidget(scroll) # # self.label_temperature = QLabel("Temperature : ") # # self.gridLayout_goupbox_info.addWidget(self.label_temperature, 0, 0, 1, 1) # # self.label_temperature.setAlignment(Qt.AlignLeft | Qt.AlignTop) # self.spinbox_temperature = QDoubleSpinBox() # self.spinbox_temperature.setSuffix("°C") # # self.gridLayout_goupbox_info.addWidget(self.spinbox_temperature, 0, 1, 1, 1) # # self.label_degreCelsius = QLabel("°C") # # self.gridLayout_goupbox_info.addWidget(self.label_degreCelsius, 0, 2, 1, 1) # # # self.label_date_acoustic_file = QLabel() # # self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 2) # # self.label_hour_acoustic_file = QLabel() # # self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) # # self.label_ABS_name = QLabel() # # self.label_date_acoustic_file = QLabel() # self.label_hour_acoustic_file = QLabel() # # self.label_freq = QLabel() # self.combobox_frequency_information = QComboBox() # # self.label_profiles = QLabel() # self.label_profiles_value = QLabel() # self.label_profiles_per_sec = QLabel() # self.label_profiles_per_sec_value = QLabel() # self.label_cells = QLabel() # n_cell in UBSediFlow parameters # self.label_cells_value = QLabel() # self.label_cell_size = QLabel() # r_em in UBSediFlow parameters # self.label_cell_size_value = QLabel() # self.label_pulse_length = QLabel() # n_p / PRF with n_p = n_ech, nb of pulses to calculate one instantaneous profile # self.label_pulse_length_value = QLabel() # self.label_pings_per_sec = QLabel() # PRF in UBSediFlow parameters # self.label_pings_per_sec_value = QLabel() # self.label_pings_per_profile = QLabel() # n_profile/n_avg in UBSediFlow parameters # self.label_pings_per_profile_value = QLabel() # # self.label_kt = QLabel() # self.spinbox_kt = QDoubleSpinBox() # self.spinbox_kt.setMaximum(1e6) # self.checkbox_kt = QCheckBox() # # self.label_rx = QLabel() # a0 in UBSediFlow parameters # self.spinbox_rx = QDoubleSpinBox() # self.spinbox_rx.setMaximum(1e6) # self.checkbox_rx = QCheckBox() # # self.label_tx = QLabel() # a1 in UBSediFlow parameters # self.spinbox_tx = QDoubleSpinBox() # self.spinbox_tx.setMaximum(1e6) # self.checkbox_tx = QCheckBox() # # # # --- Parameters for UBSediFlow --- # # self.label_config = QLabel() # # self.combobox_config = QComboBox() # # self.label_transducer = QLabel() # # # # # --- Information for UBSediFlow --- # # self.label_tr_out = QLabel() # # self.label_tr_out.setText("Channel : ") # # self.label_r_cell1 = QLabel() # # self.label_r_cell1.setText("1st cell size : ") # # self.label_r_dcell = QLabel() # # self.label_r_dcell.setText("Inter-cell distance : ") # # # self.groupbox_measurement_information_Aquascat() # +++++++++++++++++++++++++++++ # | Group Box Table of values | # +++++++++++++++++++++++++++++ self.groupbox_table.setTitle("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.verticalLayout_groupbox_table.addWidget(self.tableWidget) 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() # # self.tableView.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContentsOnFirstShow) # # self.tableView.horizontalHeader().setStretchLastSection(True) # # # # df, tension, freq, depth = self._model.acoustic_data() # # print(np.zeros(len(tension), dtype=int)) # # print("dimension", list(tension)) # # self.data = pd.DataFrame({'Time (sec)': np.zeros(10, dtype=int), # # 'y (m)': np.zeros(10, dtype=int), # # 'z (m)': np.zeros(10, dtype=int), # # 'Frequency (MHz)': np.zeros(10, dtype=int), # # 'Voltage (V)': np.zeros(10, dtype=int), # # 'SNR': np.zeros(10, dtype=int)}) # # self.data = pd.DataFrame({'Time (sec)': np.zeros(len(tension), dtype=int), # # 'y (m)': np.zeros(len(tension), dtype=int), # # 'z (m)': np.zeros(len(tension), dtype=int), # # 'Frequency (Hz)': df['freq'], # # 'Voltage (V)': df['tension'], # # 'SNR': np.zeros(len(tension), dtype=int)}) # # self.data.reset_index(drop=True, inplace=True) # # self.data = self._model.acoustic_data_table # # # # self.tableModel = TableModel(self.data) # # self.tableView.setModel(self.tableModel) # # self.verticalLayout_groupboxtable.addWidget(self.tableView) # # ------------------------------------ # # self.tableWidget = QTableWidget() # self.tableWidget.setRowCount(10) # self.tableWidget.setColumnCount(10) # # # # print("tablewidget = ", self.tableWidget) # # # # self.tableWidget2 = TableWidget(3, 3) # # print("tablewidget2 = ", self.tableWidget2) # # # for i in range(10): # # for j in range(10): # # item_v = QTableWidgetItem() # # self.tableWidget.setVerticalHeaderItem(i, item_v) # # item_h = QTableWidgetItem() # # self.tableWidget.setHorizontalHeaderItem(j, item_h) # # # Fill table Push Button event # # 1st : connect widgets to controllers = fill table # self.pushbutton_fill_table_acousic.clicked.connect(self.fill_table) # self.on_pushButtonFillTable_clicked # # 2nd : listen for model event signals = table is filled # # self._model.BS_data_updated.connect(self.on_BS_data_updated) # # self.verticalLayout_groupboxtable.addWidget(self.tableWidget) # # self.verticalLayout_groupboxtable.addWidget(self.tableView) # ++++++++++++++++++++++++++++ # | Group Box Display option | # ++++++++++++++++++++++++++++ self.verticalLayout_groupbox_display_option = QVBoxLayout(self.groupbox_display_option) # o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o # --- Group box GPS file --- self.groupbox_gps = QGroupBox() self.horizontal_gps_input_data = QHBoxLayout(self.groupbox_gps) self.verticalLayout_radiobutton_gps = QVBoxLayout() self.horizontal_gps_input_data.addLayout(self.verticalLayout_radiobutton_gps) self.radiobutton_value = QRadioButton("Value") self.radiobutton_value.setChecked(True) self.verticalLayout_radiobutton_gps.addWidget(self.radiobutton_value) self.radiobutton_file = QRadioButton("File") # self.radiobutton_file.setChecked(False) self.verticalLayout_radiobutton_gps.addWidget(self.radiobutton_file) self.groupbox_gps_value = QGroupBox() self.groupbox_gps_value.setVisible(True) self.gridLayout_gps_value = QGridLayout(self.groupbox_gps_value) self.label_distance_value = QLabel() self.label_distance_value.setText("Distance : ") self.gridLayout_gps_value.addWidget(self.label_distance_value, 0, 0, 1, 1) self.lineEdit_gps_value = QLineEdit() self.gridLayout_gps_value.addWidget(self.lineEdit_gps_value, 0, 1, 1, 1) self.label_m_per_record = QLabel("m / record") self.gridLayout_gps_value.addWidget(self.label_m_per_record, 0, 2, 1, 1) self.horizontal_gps_input_data.addWidget(self.groupbox_gps_value) self.groupbox_gps_file = QGroupBox() self.groupbox_gps_file.setVisible(False) # 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(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) self.label_date_groupbox_gps_file = QLabel() self.gridLayout_groupbox_gps_file.addWidget(self.label_date_groupbox_gps_file, 0, 3, 1, 1) self.label_hour_groupbox_gps_file = QLabel() self.gridLayout_groupbox_gps_file.addWidget(self.label_hour_groupbox_gps_file, 0, 4, 1, 1) # Download Push Button event : connect button clicked signal to open file slot # self.pushButton_gpsfile.clicked.connect(self.open_dialog_box) self.horizontal_gps_input_data.addWidget(self.groupbox_gps_file) self.verticalLayout_groupbox_display_option.addWidget(self.groupbox_gps) # # --- Time offset line between ABS system time and GPS time --- self.gridLayout_time_offset = QGridLayout() self.label_time_offset = QLabel() # self.gridLayout_time_offset.addWidget(self.label_time_offset, 0, 0, 1, 1) self.gridLayout_groupbox_gps_file.addWidget(self.label_time_offset, 1, 0, 1, 1) self.label_acoustic_gps_time = QLabel() self.label_acoustic_gps_time.setText( "Tacoustic =" + " Tgps") # self.gridLayout_time_offset.addWidget(self.label_acoustic_gps_time, 0, 1, 1, 1) self.gridLayout_groupbox_gps_file.addWidget(self.label_acoustic_gps_time, 1, 2, 1, 1) self.combobox_plus_minus = QComboBox() self.combobox_plus_minus.addItem("+") self.combobox_plus_minus.addItem("-") # self.gridLayout_time_offset.addWidget(self.combobox_plus_minus, 0, 2, 1, 1) self.gridLayout_groupbox_gps_file.addWidget(self.combobox_plus_minus, 1, 3, 1, 1) self.spinbox_time_offset_value = QSpinBox() # self.gridLayout_time_offset.addWidget(self.spinbox_time_offset_value, 0, 3, 1, 1) self.gridLayout_groupbox_gps_file.addWidget(self.spinbox_time_offset_value, 1, 4, 1, 1) self.label_seconds = QLabel() self.label_seconds.setText("sec") # self.gridLayout_time_offset.addWidget(self.label_seconds, 0, 4, 1, 1) self.gridLayout_groupbox_gps_file.addWidget(self.label_seconds, 1, 5, 1, 1) self.verticalLayout_groupbox_display_option.addLayout(self.gridLayout_time_offset) # ---------------------------------------------------------------------------- # o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o # --- Groupbox display option limits --- self.groupbox_display_option_limits = QGroupBox() self.gridLayout_groupbox_display_option_limits = QGridLayout(self.groupbox_display_option_limits) self.verticalLayout_groupbox_display_option.addWidget(self.groupbox_display_option_limits) self.label_depth = QLabel("Depth: ") self.gridLayout_groupbox_display_option_limits.addWidget(self.label_depth, 0, 0, 1, 1) # self.spinbox_depth_min = QDoubleSpinBox() # self.spinbox_depth_min.setRange(0, 100000) # self.gridLayout_groupbox_display_option.addWidget(self.spinbox_depth_min, 0, 1, 1, 1) self.doubleRangeSlider_depth = QLabeledDoubleRangeSlider() self.doubleRangeSlider_depth.setOrientation(Qt.Horizontal) # self.doubleRangeSlider_depth.setMinimumWidth(350) self.doubleRangeSlider_depth.setRange(min=0, max=50) self.doubleRangeSlider_depth.setValue(value=(5, 40)) # print(self.doubleRangeSlider_depth.value()[0]) self.doubleRangeSlider_depth.setFont(QFont("Ubuntu", 5)) self.gridLayout_groupbox_display_option_limits.addWidget(self.doubleRangeSlider_depth, 0, 1, 1, 1) # self.spinbox_depth_max = QDoubleSpinBox() # self.spinbox_depth_max.setRange(0, 100000) # self.gridLayout_groupbox_display_option.addWidget(self.spinbox_depth_max, 0, 3, 1, 1) self.label_depth_unit_meter = QLabel("meters") self.gridLayout_groupbox_display_option_limits.addWidget(self.label_depth_unit_meter, 0, 2, 1, 1) self.pushbutton_apply_depth_limits = QPushButton() self.pushbutton_apply_depth_limits.setIcon(self.icon_apply_limits) self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_depth_limits, 0, 3, 1, 1) # -------------------------------- self.label_recording_time = QLabel("Recording time: ") self.gridLayout_groupbox_display_option_limits.addWidget(self.label_recording_time, 1, 0, 1, 1) # self.spinbox_recording_time_min = QDoubleSpinBox() # self.spinbox_recording_time_min.setRange(0, 100000) # self.gridLayout_groupbox_display_option.addWidget(self.spinbox_recording_time_min, 1, 1, 1, 1) self.doubleRangeSlider_recording_time = QLabeledDoubleRangeSlider() self.doubleRangeSlider_recording_time.setOrientation(Qt.Horizontal) # self.doubleRangeSlider_recording_time.setStyleSheet() # self.doubleRangeSlider_recording_time.setMinimumWidth(350) # self.doubleRangeSlider_recording_time.setRange(min=0, max=50) # self.doubleRangeSlider_recording_time.setValue(value=(5, 40)) self.gridLayout_groupbox_display_option_limits.addWidget(self.doubleRangeSlider_recording_time, 1, 1, 1, 1) # self.spinbox_recording_time_max = QDoubleSpinBox() # self.spinbox_recording_time_max.setRange(0, 100000) # self.gridLayout_groupbox_display_option.addWidget(self.spinbox_recording_time_max, 1, 3, 1, 1) self.label_recording_time_unit_meter = QLabel("seconds") self.gridLayout_groupbox_display_option_limits.addWidget(self.label_recording_time_unit_meter, 1, 2, 1, 1) self.pushbutton_apply_recording_time_limits = QPushButton() self.pushbutton_apply_recording_time_limits.setIcon(self.icon_apply_limits) self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_recording_time_limits, 1, 3, 1, 1) # --------------------------------- self.label_distance_from_bank = QLabel("Distance from bank: ") self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank, 2, 0, 1, 1) # self.spinbox_distance_from_bank_min = QDoubleSpinBox() # self.spinbox_distance_from_bank_min.setRange(0, 100000) # self.gridLayout_groupbox_display_option.addWidget(self.spinbox_distance_from_bank_min, 2, 1, 1, 1) self.doubleRangeSlider_distance_from_bank = QLabeledDoubleRangeSlider() self.doubleRangeSlider_distance_from_bank.setOrientation(Qt.Horizontal) # self.doubleRangeSlider_distance_from_bank.setMinimumWidth(350) self.doubleRangeSlider_distance_from_bank.setRange(min=0, max=50) self.doubleRangeSlider_distance_from_bank.setValue(value=(5, 40)) self.gridLayout_groupbox_display_option_limits.addWidget(self.doubleRangeSlider_distance_from_bank, 2, 1, 1, 1) # self.spinbox_distance_from_bank_max = QDoubleSpinBox() # self.spinbox_distance_from_bank_max.setRange(0, 100000) # self.gridLayout_groupbox_display_option.addWidget(self.spinbox_distance_from_bank_max, 2, 3, 1, 1) self.label_distance_from_bank_unit_meter = QLabel("meters") self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank_unit_meter, 2, 2, 1, 1) self.pushbutton_apply_distance_from_bank_limits = QPushButton() self.pushbutton_apply_distance_from_bank_limits.setIcon(self.icon_apply_limits) self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_distance_from_bank_limits, 2, 3, 1, 1) # --------------------------------------- self.groupbox_display_option_bathymetry = QGroupBox() self.gridLayout_groupbox_display_option_bathymetry = QGridLayout(self.groupbox_display_option_bathymetry) self.verticalLayout_groupbox_display_option.addWidget(self.groupbox_display_option_bathymetry) self.combobox_frequency_bathymetry = QComboBox() self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.combobox_frequency_bathymetry, 0, 0, 1, 1) # self.label_1st_intg_area = QLabel("1st intg area") # self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.label_1st_intg_area, 0, 1, 1, 1) # # self.doubleRangeSlider_intg_area = QLabeledDoubleRangeSlider() # self.doubleRangeSlider_intg_area.setOrientation(Qt.Vertical) # # self.doubleRangeSlider_distance_from_bank.setMinimumWidth(350) # self.doubleRangeSlider_intg_area.setRange(min=0, max=50) # self.doubleRangeSlider_intg_area.setValue(value=(5, 40)) # self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.doubleRangeSlider_intg_area, 0, 2, 1, 1) # # self.label_offset = QLabel("Offset") # self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.label_offset, 0, 3, 1, 1) # # self.spinbox_offset_next_cell = QDoubleSpinBox() # self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.spinbox_offset_next_cell, 0, 4, 1, 1) self.label_from_bathy = QLabel() self.label_from_bathy.setText("From -") self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.label_from_bathy, 0, 1, 1, 1) self.spinbox_depth_min_bathy = QDoubleSpinBox() self.spinbox_depth_min_bathy.setRange(0, 9999) self.spinbox_depth_min_bathy.setDecimals(2) self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.spinbox_depth_min_bathy, 0, 2, 1, 1) self.label_depth_min_unit = QLabel() self.label_depth_min_unit.setText("m") self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.label_depth_min_unit, 0, 3, 1, 1) self.label_to_bathy = QLabel() self.label_to_bathy.setText("to -") self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.label_to_bathy, 0, 4, 1, 1) self.spinbox_depth_max_bathy = QDoubleSpinBox() self.spinbox_depth_max_bathy.setRange(0, 99999) self.spinbox_depth_max_bathy.setDecimals(2) self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.spinbox_depth_max_bathy, 0, 5, 1, 1) self.label_depth_max_unit = QLabel() self.label_depth_max_unit.setText("m") self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.label_depth_max_unit, 0, 6, 1, 1) self.label_next_cell = QLabel() self.label_next_cell.setText("+/-") self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.label_next_cell, 0, 7, 1, 1) self.doublespinbox_next_cell_bathy = QDoubleSpinBox() self.doublespinbox_next_cell_bathy.setRange(0, 99999) self.doublespinbox_next_cell_bathy.setDecimals(2) self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.doublespinbox_next_cell_bathy, 0, 8, 1, 1) self.label_next_cell_unit = QLabel() self.label_next_cell_unit.setText("m") self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.label_next_cell_unit, 0, 9, 1, 1) self.pushbutton_apply_bathymetry = QPushButton() self.pushbutton_apply_bathymetry.setIcon(self.icon_apply_limits) self.gridLayout_groupbox_display_option_bathymetry.addWidget(self.pushbutton_apply_bathymetry, 0, 10, 1, 1) # o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o-o # --- Push buttons to trigger plot of transect with Backscatter acoustic raw data and SNR --- # self.gridLayout_plot_transect_frequency_profile = QGridLayout() # self.verticalLayout_display_option.addLayout(self.gridLayout_plot_transect_frequency_profile) # # self.horizontalLayout_pushbutton_plot_BS_SNR_data = QHBoxLayout() # # self.verticalLayout_display_option.addLayout(self.horizontalLayout_pushbutton_plot_BS_SNR_data) # # self.pushbutton_plot_transect_with_BS_raw_data = QPushButton() # self.gridLayout_plot_transect_frequency_profile.addWidget(self.pushbutton_plot_transect_with_BS_raw_data, 0, 0, 1, 3) # # self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_BS_raw_data) # # self.pushbutton_plot_transect_with_BS_raw_data.clicked.connect(self.plot_transect_with_BS_raw_data) # self.label_profile_frequency = QLabel() # self.label_profile_frequency.setText("Profile frequency : ") # self.gridLayout_plot_transect_frequency_profile.addWidget(self.label_profile_frequency, 0, 4, 1, 1) # self.combobox_frequency_profile = QComboBox() # self.gridLayout_plot_transect_frequency_profile.addWidget(self.combobox_frequency_profile, 0, 5, 1, 1) # self.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 --- # # self.groupbox_xaxis_time = QGroupBox() # # self.verticalLayout_groupbox_xaxis_time = QVBoxLayout(self.groupbox_xaxis_time) # # self.groupbox_xaxis_time.setCheckable(True) # # self.groupbox_xaxis_time.setChecked(True) # # self.groupbox_xaxis_time.clicked.connect(self.transect_xaxis_choice) # self.verticalLayout_display_option.addWidget(self.groupbox_xaxis_time) # # self.gridLayout_groupbox_xaxis_time = QGridLayout(self.groupbox_xaxis_time) # self.label_from_time = QLabel() # self.label_from_time.setText("From") # # self.gridLayout_groupbox_xaxis_time.addWidget(self.label_from_time, 0, 0, 1, 1) # # # self.label_tmin = QLabel() # self.label_tmin.setText("tmin = ") # self.gridLayout_groupbox_xaxis_time.addWidget(self.label_tmin, 0, 1, 1, 1) # # self.spinbox_tmin = QDoubleSpinBox() # self.spinbox_tmin.setRange(0, 9999) # self.gridLayout_groupbox_xaxis_time.addWidget(self.spinbox_tmin, 0, 2, 1, 1) # # self.spinbox_tmin.valueChanged.connect(self.update_xaxis_transect_with_BS_raw_data) # # self.spinbox_tmin.valueChanged.connect(self.update_xaxis_transect_with_SNR_data) # # self.label_tmin_unit = QLabel() # self.label_tmin_unit.setText("sec") # self.gridLayout_groupbox_xaxis_time.addWidget(self.label_tmin_unit, 0, 3, 1, 1) # # self.label_to_time = QLabel() # self.label_to_time.setText("to") # self.gridLayout_groupbox_xaxis_time.addWidget(self.label_to_time, 0, 4, 1, 1) # # self.label_tmax = QLabel() # self.label_tmax.setText("tmax = ") # self.gridLayout_groupbox_xaxis_time.addWidget(self.label_tmax, 0, 5, 1, 1) # # self.spinbox_tmax = QDoubleSpinBox() # self.spinbox_tmax.setRange(0, 9999) # self.gridLayout_groupbox_xaxis_time.addWidget(self.spinbox_tmax, 0, 6, 1, 1) # # self.spinbox_tmax.valueChanged.connect(self.update_xaxis_transect_with_BS_raw_data) # # self.spinbox_tmax.valueChanged.connect(self.update_xaxis_transect_with_SNR_data) # # self.spinbox_tmax.keyPressEvent.connect(self.onValueChanged) # # self.label_tmax_unit = QLabel() # self.label_tmax_unit.setText("sec") # self.gridLayout_groupbox_xaxis_time.addWidget(self.label_tmax_unit, 0, 7, 1, 1) # # self.pushbutton_apply_transect_boundaries_in_time = QPushButton() # 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) # # # --- Group Box Plot x-axis in space --- # # self.groupbox_xaxis_space = QGroupBox() # # self.groupbox_xaxis_space.setCheckable(True) # # self.groupbox_xaxis_space.setChecked(False) # # self.groupbox_xaxis_space.clicked.connect(self.transect_xaxis_choice) # self.verticalLayout_display_option.addWidget(self.groupbox_xaxis_space) # # self.gridLayout_groupbox_xaxis_space = QGridLayout(self.groupbox_xaxis_space) # self.label_from_space = QLabel() # self.label_from_space.setText("From ") # self.gridLayout_groupbox_xaxis_space.addWidget(self.label_from_space, 0, 0, 1, 1) # # self.label_xmin = QLabel() # self.label_xmin.setText("xmin = ") # self.gridLayout_groupbox_xaxis_space.addWidget(self.label_xmin, 0, 1, 1, 1) # # self.spinbox_xmin = QSpinBox() # self.spinbox_xmin.setRange(0, 9999) # self.gridLayout_groupbox_xaxis_space.addWidget(self.spinbox_xmin, 0, 2, 1, 1) # # self.label_xmin_m = QLabel() # self.label_xmin_m.setText("m") # self.gridLayout_groupbox_xaxis_space.addWidget(self.label_xmin_m, 0, 3, 1, 1) # # self.label_to_space = QLabel() # self.label_to_space.setText("to") # self.gridLayout_groupbox_xaxis_space.addWidget(self.label_to_space, 0, 4, 1, 1) # # self.label_xmax = QLabel() # self.label_xmax.setText("xmax = ") # self.gridLayout_groupbox_xaxis_space.addWidget(self.label_xmax, 0, 5, 1, 1) # # self.spinbox_xmax = QSpinBox() # self.spinbox_xmax.setRange(0, 9999) # self.gridLayout_groupbox_xaxis_space.addWidget(self.spinbox_xmax, 0, 6, 1, 1) # # self.label_xmax_m = QLabel() # self.label_xmax_m.setText("m") # self.gridLayout_groupbox_xaxis_space.addWidget(self.label_xmax_m, 0, 7, 1, 1) # # self.pushbutton_apply_transect_boundaries_in_space = QPushButton() # 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) # # # --- Group Box bathymetry computation algorithm to detect and plot bottom of transect--- # # self.groupbox_compute_bathymetry = QGroupBox() # # # self.groupbox_crosssectionbottom.setTitle("Plot bottom of cross section") # # self.groupbox_crosssectionbottom.setCheckable(True) # # self.groupbox_crosssectionbottom.setChecked(False) # self.verticalLayout_display_option.addWidget(self.groupbox_compute_bathymetry) # # self.gridlayout_compute_bathymetry = QGridLayout(self.groupbox_compute_bathymetry) # # self.combobox_freq_choice = QComboBox() # # self.combobox_freq_choice.addItems(['', '0.3 MHz', '0.5 Mhz', '1 MHz', '5 MHz']) # self.gridlayout_compute_bathymetry.addWidget(self.combobox_freq_choice, 0, 0, 2, 1) # # self.label_from_bathy = QLabel() # self.label_from_bathy.setText("From - ") # self.gridlayout_compute_bathymetry.addWidget(self.label_from_bathy, 0, 1, 1, 1) # # # self.spinbox_depth_min = QSpinBox() # self.spinbox_depth_min = QDoubleSpinBox() # self.spinbox_depth_min.setRange(0, 9999) # self.spinbox_depth_min.setDecimals(2) # self.gridlayout_compute_bathymetry.addWidget(self.spinbox_depth_min, 0, 2, 1, 1) # # self.label_depth_min_unit = QLabel() # self.label_depth_min_unit.setText("m") # self.gridlayout_compute_bathymetry.addWidget(self.label_depth_min_unit, 0, 3, 1, 1) # # self.label_to_bathy = QLabel() # self.label_to_bathy.setText("to - ") # self.gridlayout_compute_bathymetry.addWidget(self.label_to_bathy, 0, 4, 1, 1) # # # self.spinbox_depth_max = QSpinBox() # self.spinbox_depth_max = QDoubleSpinBox() # self.spinbox_depth_max.setRange(0, 99999) # self.spinbox_depth_max.setDecimals(2) # self.gridlayout_compute_bathymetry.addWidget(self.spinbox_depth_max, 0, 5, 1, 1) # # self.label_depth_max_unit = QLabel() # self.label_depth_max_unit.setText("m") # self.gridlayout_compute_bathymetry.addWidget(self.label_depth_max_unit, 0, 6, 1, 1) # # self.label_next_cell = QLabel() # self.label_next_cell.setText("Next cell : +/-") # self.gridlayout_compute_bathymetry.addWidget(self.label_next_cell, 1, 1, 1, 1) # # self.doublespinbox_next_cell = QDoubleSpinBox() # self.doublespinbox_next_cell.setRange(0, 99999) # self.doublespinbox_next_cell.setDecimals(2) # self.gridlayout_compute_bathymetry.addWidget(self.doublespinbox_next_cell, 1, 2, 1, 1) # # self.label_next_cell_unit = QLabel() # self.label_next_cell_unit.setText("m") # self.gridlayout_compute_bathymetry.addWidget(self.label_next_cell_unit, 1, 3, 1, 1) # # self.pushbutton_compute_bathymetry_algorithm = QPushButton() # self.pushbutton_compute_bathymetry_algorithm.setText("Compute \n&& \nPlot") # self.gridlayout_compute_bathymetry.addWidget(self.pushbutton_compute_bathymetry_algorithm, 0, 7, 2, 1) # ===================================================== # BOTTOM HORIZONTAL BOX LAYOUT # ===================================================== # +++++++++++++++++++++++++++++++++++++************+++ # | Group Box Backscatter Acoustic Raw Data 2D field | # ++++++++++++++++++++++++++************++++++++++++++ self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data = QVBoxLayout(self.groupbox_transect_2Dplot_raw_BS_data) # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.setContentsMargins(0, 0, 0, 0) # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.setSpacing(0) # self.canvas_BS = None # self.scroll_BS = None # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.toolbar_BS) # self.fig_BS, self.axis_BS = plt.subplots(nrows=4, ncols=1, sharex=True, sharey=False, # layout="constrained") # self.canvas_BS = FigureCanvas(self.fig_BS) self.canvas_BS = FigureCanvas() self.toolbar_BS = NavigationToolBar(self.canvas_BS, ) self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.toolbar_BS) # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) 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.setWidgetResizable(True) self.scroll_BS.setAlignment(Qt.AlignCenter) self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) # self.fig_BS, self.axis_BS = plt.subplots(nrows=4, ncols=1, sharex=True, sharey=False, layout="constrained") # self.fig, self.ax = plt.subplots(4, 1) # self.canvas_BS = FigureCanvas(self.fig_BS) # self.canvas_BS = FigureCanvas() # self.plotToolbar_rawdata = NavigationToolBar(self.canvas_rawdata, self) # self.plot_acoustic_raw_data() # self.verticalLayout_plotrawdata.addWidget(self.plotToolbar_rawdata) # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_BS) # ++++++++++++++++++++++++++++++++++++++++++++ # | 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.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_the_vertical_profile_for_a_frequency = QVBoxLayout(self.groupbox_plot_the_vertical_profile_for_a_frequency) self.groupbox_plot_the_vertical_profile_for_a_frequency.setTitle("Plot the vertical profile for one frequency") self.horizontalLayout_spacerItem_combobox_frequency_profile = QHBoxLayout() self.verticalLayout_groupbox_plot_the_vertical_profile_for_a_frequency.addLayout(self.horizontalLayout_spacerItem_combobox_frequency_profile) self.spacerItem_frequency_profile = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) # self.horizontalLayout_spacerItem_combobox_frequency_profile.addSpacerItem(self.spacerItem_frequency_profile) self.combobox_frequency_profile = QComboBox() # self.horizontalLayout_spacerItem_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) self.groupbox_plot_profile = QGroupBox() self.groupbox_plot_profile.setTitle("Profile") self.verticalLayout_groupbox_plot_profile = QVBoxLayout(self.groupbox_plot_profile) self.verticalLayout_groupbox_plot_the_vertical_profile_for_a_frequency.addWidget(self.groupbox_plot_profile) # self.fig_profile, self.axis_profile = plt.subplots(nrows=1, ncols=1, layout="constrained") # self.canvas_plot_profile = FigureCanvas(self.fig_profile) self.canvas_plot_profile = FigureCanvas() self.toolbar_profile = NavigationToolBar(self.canvas_plot_profile, ) # print("navigation toolbar item", self.toolbar_profile.toolitems) self.horizontalLayout_spacerItem_combobox_frequency_profile.addWidget(self.toolbar_profile) self.horizontalLayout_spacerItem_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) # self.canvas_plot_profile = None # --- Slider for moving the profile --- self.horizontalLayout_slider = QHBoxLayout() self.verticalLayout_groupbox_plot_the_vertical_profile_for_a_frequency.addLayout(self.horizontalLayout_slider) self.pushbutton_slider_left_to_begin = QPushButton() self.pushbutton_slider_left_to_begin.setIcon(self.icon_triangle_left_to_begin) self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left_to_begin) self.pushbutton_slider_left = QPushButton() self.pushbutton_slider_left.setIcon(self.icon_triangle_left) self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left) self.lineEdit_slider = QLineEdit() self.lineEdit_slider.setText("1") self.lineEdit_slider.setFixedWidth(50) self.horizontalLayout_slider.addWidget(self.lineEdit_slider) self.pushbutton_slider_right = QPushButton() self.pushbutton_slider_right.setIcon(self.icon_triangle_right) self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) self.pushbutton_slider_right_to_end = QPushButton() self.pushbutton_slider_right_to_end.setIcon(self.icon_triangle_right_to_end) self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right_to_end) self.slider = QSlider() self.horizontalLayout_slider.addWidget(self.slider, 9) self.slider.setOrientation(Qt.Horizontal) self.slider.setCursor(Qt.OpenHandCursor) self.slider.setMinimum(1) self.slider.setMaximum(10) self.slider.setTickInterval(1) self.slider.setValue(1) # self.slider.valueChanged.connect(self.plot_transect_with_BS_raw_data) # self.slider.valueChanged.connect(self.plot_profile) self.retranslate_acoustic_data_tab() self.max_selected_file = 1 # self.btnToggled() plt.rcParams['figure.max_open_warning'] = 100 print("plt.rcParams['figure.max_open_warning'] ", plt.rcParams['figure.max_open_warning']) # -------------------------------------------------------------------------------------------------------------- # --- Connect signal of widget --- self.combobox_ABS_system_choice.currentTextChanged.connect(self.ABS_system_choice) self.addBtn.clicked.connect(self.open_dialog_box) self.delBtn.clicked.connect(self.remove_file_from_ListWidget) self.clearBtn.clicked.connect(self.clear_files_from_ListWidget) self.fileListWidget.itemSelectionChanged.connect(self.print_selected_file) self.fileListWidget.itemSelectionChanged.connect(self.fill_measurements_information_groupbox) self.fileListWidget.itemSelectionChanged.connect(self.fill_table) self.fileListWidget.itemSelectionChanged.connect(self.compute_time) self.fileListWidget.itemSelectionChanged.connect(self.compute_depth) # self.fileListWidget.itemSelectionChanged.connect(self.compute_BS_cross_section) self.fileListWidget.itemSelectionChanged.connect(self.update_frequency_combobox) self.fileListWidget.itemSelectionChanged.connect(self.plot_backscattered_acoustic_signal_recording) self.fileListWidget.itemSelectionChanged.connect(self.plot_profile) self.fileListWidget.itemSelectionChanged.connect(self.update_plot_backscattered_acoustic_signal_recording) self.fileListWidget.itemSelectionChanged.connect(self.update_plot_profile) self.fileListWidget.itemSelectionChanged.connect(self.set_range_for_spinboxes_bathymetry) # self.fileListWidget.clicked.connect(self.rename_file_in_ListWidget) self.radiobutton_value.toggled.connect(self.onClicked_radiobutton_gps) self.radiobutton_file.toggled.connect(self.onClicked_radiobutton_gps) # self.spinbox_temperature.valueChanged.connect(self.temperature_value) self.spinbox_temperature.lineEdit().returnPressed.connect(self.temperature_value) # self.spinbox_tmax.lineEdit().returnPressed.connect(self.time_spin_box_value) # self.spinbox_tmax.lineEdit().returnPressed.connect(self.compute_time) # self.spinbox_tmax.lineEdit().returnPressed.connect(self.compute_BS_cross_section) # self.spinbox_tmax.lineEdit().returnPressed.connect(self.update_plot_backscattered_acoustic_signal_recording) # self.spinbox_tmax.lineEdit().returnPressed.connect(self.update_plot_profile) # self.doubleRangeSlider_recording_time.lab .connect(self.print_value_doubleRangeSlider) self.pushbutton_apply_depth_limits.clicked.connect(self.set_rmin_rmax_for_doubleRangeSider_depth) # self.pushbutton_apply_depth_limits.clicked.connect(self.compute_depth) self.pushbutton_apply_depth_limits.clicked.connect(self.compute_BS_cross_section) self.pushbutton_apply_depth_limits.clicked.connect(self.update_plot_backscattered_acoustic_signal_recording) self.pushbutton_apply_depth_limits.clicked.connect(self.update_plot_profile) self.pushbutton_apply_depth_limits.clicked.connect(self.set_range_for_spinboxes_bathymetry) self.pushbutton_apply_recording_time_limits.clicked.connect(self.set_tmin_tmax_for_doubleRangeSider_time) # self.pushbutton_apply_recording_time_limits.clicked.connect(self.compute_time) self.pushbutton_apply_recording_time_limits.clicked.connect(self.compute_BS_cross_section) self.pushbutton_apply_recording_time_limits.clicked.connect(self.detect_bottom) self.pushbutton_apply_recording_time_limits.clicked.connect(self.update_plot_backscattered_acoustic_signal_recording) self.pushbutton_apply_recording_time_limits.clicked.connect(self.update_plot_profile) # self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.compute_time) # self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.compute_BS_cross_section) # self.pushbutton_apply_transect_boundaries_in_time.clicked.connect( # self.update_plot_backscattered_acoustic_signal_recording) # self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.update_plot_profile) self.pushbutton_apply_bathymetry.clicked.connect(self.detect_bottom) self.pushbutton_slider_left_to_begin.clicked.connect(self.slide_profile_number_to_begin) self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left) self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right) self.pushbutton_slider_right_to_end.clicked.connect(self.slide_profile_number_to_end) self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit) self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) self.slider.valueChanged.connect(self.update_plot_profile) self.slider.valueChanged.connect(self.update_plot_backscattered_acoustic_signal_recording) # -------------------- Functions for Acoustic dataTab -------------------- def print_value_doubleRangeSlider(self): if Qt.Key_Return: print(f"value of double range slider {self.doubleRangeSlider_recording_time.value()}") def print_range_changed(self): print(f"tmax = {self.doubleRangeSlider_depth.value()[1]}") def retranslate_acoustic_data_tab(self): # self.groupbox_download.setTitle(_translate("CONSTANT_STRING", cs.DOWNLOAD)) self.groupbox_info.setTitle(_translate("CONSTANT_STRING", cs.MEASUREMENTS_INFORMATION)) # self.groupbox_acoustic_file.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_FILE)) self.label_date_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":") self.label_hour_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":") # self.groupbox_noise_file.setTitle(_translate("CONSTANT_STRING", cs.NOISE_FILE)) # self.pushbutton_noise_level_with_tail_of_mean_profile.setText(_translate("CONSTANT_STRING", cs.NOISE_LEVEL)) # 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.label_profiles.setText(_translate("CONSTANT_STRING", cs.NB_PROFILES) + ":") self.label_profiles.setToolTip(_translate("CONSTANT_STRING", cs.NB_PROFILES_TOOLTIP)) self.label_profiles_per_sec.setText(_translate("CONSTANT_STRING", cs.NB_PROFILES_PER_SEC) + ":") self.label_profiles_per_sec.setToolTip(_translate("CONSTANT_STRING", cs.NB_PROFILES_PER_SEC_TOOLTIP)) self.label_cells.setText(_translate("CONSTANT_STRING", cs.NB_CELLS) + ":") self.label_cells.setToolTip(_translate("CONSTANT_STRING", cs.NB_CELLS_TOOLTIP)) self.label_cell_size.setText(_translate("CONSTANT_STRING", cs.CELL_SIZE) + ":") self.label_cell_size.setToolTip(_translate("CONSTANT_STRING", cs.CELL_SIZE_TOOLTIP)) self.label_pulse_length.setText(_translate("CONSTANT_STRING", cs.PULSE_LENGHT) + ":") self.label_pulse_length.setToolTip(_translate("CONSTANT_STRING", cs.PULSE_LENGHT_TOOLTIP)) self.label_pings_per_sec.setText(_translate("CONSTANT_STRING", cs.NB_PINGS_PER_SEC)) self.label_pings_per_sec.setToolTip(_translate("CONSTANT_STRING", cs.NB_PINGS_PER_SEC_TOOLTIP)) self.label_pings_per_profile.setText(_translate("CONSTANT_STRING", cs.NB_PINGS_PER_PROFILE) + ":") self.label_pings_per_profile.setToolTip(_translate("CONSTANT_STRING", cs.NB_PINGS_PER_PROFILE_TOOLTIP)) self.label_freq.setText(_translate("CONSTANT_STRING", cs.FREQUENCY) + ":") self.label_freq.setToolTip(_translate("CONSTANT_STRING", cs.FREQUENCY_TOOLTIP)) self.label_kt.setText(_translate("CONSTANT_STRING", cs.KT) + ":") self.label_kt.setToolTip(_translate("CONSTANT_STRING", cs.KT_TOOLTIP)) self.label_rx.setText(_translate("CONSTANT_STRING", cs.GAIN_RX) + ":") self.label_rx.setToolTip(_translate("CONSTANT_STRING", cs.GAIN_RX_TOOLTIP)) 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.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_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) + ":") self.label_time_offset.setText(_translate("CONSTANT_STRING", cs.TIME_OFFSET)) 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.groupbox_xaxis_time.setTitle(_translate("CONSTANT_STRING", cs.PLOT_XAXIS_IN_TIME)) # self.label_tmin.setText(_translate("CONSTANT_STRING", cs.FROM) + " tmin = ") # self.label_tmax.setText(_translate("CONSTANT_STRING", cs.TO) + " tmax = ") # self.pushButton_plot_acoustic_transect_in_time.setText(_translate("CONSTANT_STRING", cs.PLOT_TRANSECT)) # self.groupbox_xaxis_space.setTitle(_translate("CONSTANT_STRING", cs.PLOT_XAXIS_IN_SPACE)) # self.label_zmin.setText(_translate("CONSTANT_STRING", cs.FROM) + " zmin = ") # self.label_zmax.setText(_translate("CONSTANT_STRING", cs.TO) + " zmax = ") # self.pushButton_plot_acoustic_transect_in_space.setText(_translate("CONSTANT_STRING", cs.PLOT_TRANSECT)) # self.groupbox_compute_bathymetry.setTitle(_translate("CONSTANT_STRING", cs.PLOT_BOTTOM_CROSS_SECTION)) # self.label_depthmin.setText(_translate("CONSTANT_STRING", cs.INITIAL_DEPTH_RANGE) + ":") # self.label_depthmin.setText(_translate("CONSTANT_STRING", cs.FROM)) # self.label_to.setText(_translate("CONSTANT_STRING", cs.TO)) # self.pushButton_bottom_transect.setText(_translate("CONSTANT_STRING", cs.PLOT_BOTTOM)) 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)) # def currentItemChanged(self, i1, i2): # self.btnToggled() # def btnToggled(self): # # f1 = self.fileListWidget.count() > 0 # # f2 = True if self.fileListWidget.currentItem() else False # # print(f"f1 {f1}") # # print(f"f2 {f2}") # # self.delBtn.setEnabled(f1 and f2) # # self.clearBtn.setEnabled(f1) # print("self.fileListWidget.selectedItems()[1:] : ", self.fileListWidget.selectedItems()[1:]) # if len(self.fileListWidget.selectedItems()) > self.max_selected_file: # self.fileListWidget.selectedItems()[1:].setSelected(False) def print_selected_file(self): print(f"Selected file in list widget : {self.fileListWidget.selectedItems()}") print("self.fileListWidget.selectedItems()[1:] : ", self.fileListWidget.selectedItems()[1:]) if len(self.fileListWidget.selectedItems()) > self.max_selected_file: self.fileListWidget.setSelectionMode(1) # def add(self): # # ext_lst = self.__extensions if self.__extensions else 'All Files (*.*)' # filenames = QFileDialog.getOpenFileNames(self, 'Open Files', '', ext_lst) # if filenames[0]: # filenames = filenames[0] # self.fileListWidget.addFilenames(filenames) # self.fileAdded.emit(filenames) # # self.__btnToggled() def onClicked_radiobutton_gps(self): radiobutton = self.sender() if radiobutton.isChecked(): if self.radiobutton_value.isChecked(): self.groupbox_gps_value.setVisible(True) self.groupbox_gps_file.setVisible(False) elif self.radiobutton_file.isChecked(): self.groupbox_gps_value.setVisible(False) self.groupbox_gps_file.setVisible(True) def ABS_system_choice(self): if self.combobox_ABS_system_choice.currentText() == " ": self.groupbox_measurement_information_no_ABS() elif self.combobox_ABS_system_choice.currentText() == "Aquascat 1000R": self.groupbox_measurement_information_Aquascat() # self.lineEdit_acoustic_file.clear() elif self.combobox_ABS_system_choice.currentText() == "UB-SediFlow": self.groupbox_measurement_information_UBSediFlow() # self.lineEdit_acoustic_file.clear() # self.label_date_groupbox_acoustic_file.clear() # self.label_date_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ": ") # self.label_hour_groupbox_acoustic_file.clear() # self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ": ") def groupbox_measurement_information_no_ABS(self): self.label_ABS_name.hide() self.label_date_acoustic_file.hide() self.label_hour_acoustic_file.hide() self.label_temperature.hide() self.spinbox_temperature.hide() self.label_speed_of_sound.hide() self.spinbox_speed_of_sound.hide() self.label_sound_attenuation.hide() self.spinbox_sound_attenuation.hide() self.label_freq.hide() self.combobox_frequency_information.hide() self.label_profiles.hide() self.label_profiles_per_sec.hide() self.label_cells.hide() self.label_cell_size.hide() self.label_pulse_length.hide() self.label_pings_per_sec.hide() self.label_pings_per_profile.hide() self.label_kt.hide() self.spinbox_kt.hide() self.checkbox_kt.hide() self.label_rx.hide() self.spinbox_rx.hide() self.checkbox_rx.hide() self.label_tx.hide() self.spinbox_tx.hide() self.checkbox_tx.hide() def groupbox_measurement_information_Aquascat(self): # --- Hide UBSediFlow information and remove widget from grid layout --- self.label_ABS_name.hide() self.label_date_acoustic_file.hide() self.label_hour_acoustic_file.hide() self.label_temperature.hide() self.spinbox_temperature.hide() self.label_speed_of_sound.hide() self.spinbox_speed_of_sound.hide() self.label_sound_attenuation.hide() self.spinbox_sound_attenuation.hide() self.label_freq.hide() self.combobox_frequency_information.hide() self.label_profiles.hide() self.label_profiles_per_sec.hide() self.label_cells.hide() self.label_cell_size.hide() self.label_pulse_length.hide() self.label_pings_per_sec.hide() self.label_pings_per_profile.hide() self.label_kt.hide() self.spinbox_kt.hide() self.checkbox_kt.hide() self.label_rx.hide() self.spinbox_rx.hide() self.checkbox_rx.hide() self.label_tx.hide() self.spinbox_tx.hide() self.checkbox_tx.hide() for i in reversed(range(self.gridLayout_goupbox_info.count())): widgetToRemove = self.gridLayout_goupbox_info.itemAt(i).widget() # remove it from the layout list self.gridLayout_goupbox_info.removeWidget(widgetToRemove) # remove it from the gui widgetToRemove.setParent(None) # --- Show Aquascat information --- self.label_ABS_name.show() self.label_ABS_name.setText("Acoustic Backscatter System: AQUAscat") self.gridLayout_goupbox_info.addWidget(self.label_ABS_name, 0, 0, 1, 2) self.label_date_acoustic_file.show() self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1) self.label_hour_acoustic_file.show() self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) self.label_temperature.show() self.gridLayout_goupbox_info.addWidget(self.label_temperature, 2, 0, 1, 1) self.spinbox_temperature.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_temperature, 2, 1, 1, 1) self.label_speed_of_sound.show() self.gridLayout_goupbox_info.addWidget(self.label_speed_of_sound, 3, 0, 1, 1) self.spinbox_speed_of_sound.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_speed_of_sound, 3, 1, 1, 1) self.label_sound_attenuation.show() self.gridLayout_goupbox_info.addWidget(self.label_sound_attenuation, 4, 0, 1, 1) self.spinbox_sound_attenuation.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_sound_attenuation, 4, 1, 1, 1) self.label_freq.show() self.gridLayout_goupbox_info.addWidget(self.label_freq, 5, 0, 1, 1) self.combobox_frequency_information.show() self.gridLayout_goupbox_info.addWidget(self.combobox_frequency_information, 5, 1, 1, 1) self.label_profiles.show() self.gridLayout_goupbox_info.addWidget(self.label_profiles, 6, 0, 1, 1) self.label_profiles_per_sec.show() self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 7, 0, 1, 1) self.label_cells.show() self.gridLayout_goupbox_info.addWidget(self.label_cells, 8, 0, 1, 1) self.label_cell_size.show() self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 9, 0, 1, 1) self.label_pulse_length.show() self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 10, 0, 1, 1) self.label_pings_per_sec.show() self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 11, 0, 1, 1) self.label_pings_per_profile.show() self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 12, 0, 1, 1) self.label_kt.show() self.gridLayout_goupbox_info.addWidget(self.label_kt, 13, 0, 1, 1) self.spinbox_kt.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_kt, 13, 1, 1, 1) self.checkbox_kt.show() self.gridLayout_goupbox_info.addWidget(self.checkbox_kt, 13, 2, 1, 1) self.label_rx.show() self.gridLayout_goupbox_info.addWidget(self.label_rx, 14, 0, 1, 1) self.spinbox_rx.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_rx, 14, 1, 1, 1) self.checkbox_rx.show() self.gridLayout_goupbox_info.addWidget(self.checkbox_rx, 14, 2, 1, 1) self.label_tx.show() self.gridLayout_goupbox_info.addWidget(self.label_tx, 15, 0, 1, 1) self.spinbox_tx.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_tx, 15, 1, 1, 1) self.checkbox_tx.show() self.gridLayout_goupbox_info.addWidget(self.checkbox_tx, 15, 2, 1, 1) def groupbox_measurement_information_UBSediFlow(self): # --- Hide Aquascat information --- self.label_ABS_name.hide() self.label_date_acoustic_file.hide() self.label_hour_acoustic_file.hide() self.label_temperature.hide() self.spinbox_temperature.hide() self.label_speed_of_sound.hide() self.spinbox_speed_of_sound.hide() self.label_sound_attenuation.hide() self.spinbox_sound_attenuation.hide() self.label_freq.hide() self.combobox_frequency_information.hide() self.label_profiles.hide() self.label_profiles_per_sec.hide() self.label_cells.hide() self.label_cell_size.hide() self.label_pulse_length.hide() self.label_pings_per_sec.hide() self.label_pings_per_profile.hide() self.label_kt.hide() self.spinbox_kt.hide() self.checkbox_kt.hide() self.label_rx.hide() self.spinbox_rx.hide() self.checkbox_rx.hide() self.label_tx.hide() self.spinbox_tx.hide() self.checkbox_tx.hide() for i in reversed(range(self.gridLayout_goupbox_info.count())): widgetToRemove = self.gridLayout_goupbox_info.itemAt(i).widget() # remove it from the layout list self.gridLayout_goupbox_info.removeWidget(widgetToRemove) # remove it from the gui widgetToRemove.setParent(None) # --- Show UBSediFlow information --- self.label_ABS_name.show() self.label_ABS_name.setText("Acoustic Backscatter System: UBSediFlow") self.gridLayout_goupbox_info.addWidget(self.label_ABS_name, 0, 0, 1, 2) self.label_date_acoustic_file.show() self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1) self.label_hour_acoustic_file.show() self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) self.label_temperature.show() self.gridLayout_goupbox_info.addWidget(self.label_temperature, 2, 0, 1, 1) self.spinbox_temperature.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_temperature, 2, 1, 1, 1) self.label_speed_of_sound.show() self.gridLayout_goupbox_info.addWidget(self.label_speed_of_sound, 3, 0, 1, 1) self.spinbox_speed_of_sound.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_speed_of_sound, 3, 1, 1, 1) self.label_sound_attenuation.show() self.gridLayout_goupbox_info.addWidget(self.label_sound_attenuation, 4, 0, 1, 1) self.spinbox_sound_attenuation.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_sound_attenuation, 4, 1, 1, 1) self.label_freq.show() self.gridLayout_goupbox_info.addWidget(self.label_freq, 5, 0, 1, 1) self.combobox_frequency_information.show() self.gridLayout_goupbox_info.addWidget(self.combobox_frequency_information, 5, 1, 1, 1) self.label_profiles.show() self.gridLayout_goupbox_info.addWidget(self.label_profiles, 6, 0, 1, 1) self.label_profiles_per_sec.show() self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 7, 0, 1, 1) self.label_cells.show() self.gridLayout_goupbox_info.addWidget(self.label_cells, 8, 0, 1, 1) self.label_cell_size.show() self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 9, 0, 1, 1) self.label_pulse_length.show() self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 10, 0, 1, 1) self.label_pings_per_sec.show() self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 11, 0, 1, 1) self.label_pings_per_profile.show() self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 12, 0, 1, 1) self.label_kt.show() self.gridLayout_goupbox_info.addWidget(self.label_kt, 13, 0, 1, 1) self.spinbox_kt.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_kt, 13, 1, 1, 1) self.checkbox_kt.show() self.gridLayout_goupbox_info.addWidget(self.checkbox_kt, 13, 2, 1, 1) self.label_rx.show() self.gridLayout_goupbox_info.addWidget(self.label_rx, 14, 0, 1, 1) self.spinbox_rx.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_rx, 14, 1, 1, 1) self.checkbox_rx.show() self.gridLayout_goupbox_info.addWidget(self.checkbox_rx, 14, 2, 1, 1) self.label_tx.show() self.gridLayout_goupbox_info.addWidget(self.label_tx, 15, 0, 1, 1) self.spinbox_tx.show() self.gridLayout_goupbox_info.addWidget(self.spinbox_tx, 15, 1, 1, 1) self.checkbox_tx.show() self.gridLayout_goupbox_info.addWidget(self.checkbox_tx, 15, 2, 1, 1) def temperature_value(self): if self.fileListWidget.count() > 0: stg.temperature[self.fileListWidget.currentRow()] = self.spinbox_temperature.value() print(f"stg.temperature : {stg.temperature}") self.water_velocity() self.water_attenuation() def water_velocity(self): """Computing sond speed from Bilaniuk and Wong 1993""" C = (1.40238744 * 1e3 + 5.03836171 * self.spinbox_temperature.value() - 5.81172916 * 1e-2 * self.spinbox_temperature.value() ** 2 + 3.34638117 * 1e-4 * self.spinbox_temperature.value() ** 3 - 1.48259672 * 1e-6 * self.spinbox_temperature.value() ** 4 + 3.16585020 * 1e-9 * self.spinbox_temperature.value() ** 5) stg.water_velocity[self.fileListWidget.currentRow()] = C self.spinbox_speed_of_sound.setValue(stg.water_velocity[self.fileListWidget.currentRow()]) print("water velocity ", stg.water_velocity) # -------- Computing water attenuation coefficient ----------- # def water_attenuation(self): """Computing attenuation from François and Garrison 1982""" stg.water_attenuation[self.fileListWidget.currentRow()].clear() for f in stg.freq[self.fileListWidget.currentRow()]: if self.spinbox_temperature.value() > 20: alpha = ((3.964 * 1e-4 - 1.146 * 1e-5 * self.spinbox_temperature.value() + 1.45 * 1e-7 * self.spinbox_temperature.value() ** 2 - 6.5 * 1e-10 * self.spinbox_temperature.value() ** 3) * 1e-3 * (np.log(10) / 20) * (f * 1e-3) ** 2) else: alpha = ((4.937 * 1e-4 - 2.59 * 1e-5 * self.spinbox_temperature.value() + 9.11 * 1e-7 * self.spinbox_temperature.value() ** 2 - 1.5 * 1e-8 * self.spinbox_temperature.value() ** 3) * 1e-3 * (np.log(10) / 20) * (f * 1e-3) ** 2) stg.water_attenuation[self.fileListWidget.currentRow()].append(alpha) self.spinbox_sound_attenuation.setValue(stg.water_attenuation[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) print("water attenuation ", stg.water_attenuation) def clicked_pushbutton_noise_level(self): self.WindowNoiseLevelTailAveragedProfile().show() def open_dialog_box(self): # print(self.combobox_ABS_system_choice.currentText()) # print(self.sender().objectName()) # --- Open dialog box + choice directory and select file --- if self.combobox_ABS_system_choice.currentIndex() == 0: msgBox = QMessageBox() msgBox.setWindowTitle("Download Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText("Choose ABS system before download acoustic files") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() elif self.combobox_ABS_system_choice.currentIndex() == 1: filename = QFileDialog.getOpenFileName(self, "Open file", [stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0], "Aquascat file (*.aqa)") dir_name = path.dirname(filename[0]) name = path.basename(filename[0]) print(f"dir name : {dir_name} & file name : {name}") # print(dir_name, name) elif self.combobox_ABS_system_choice.currentIndex() == 2: filename = QFileDialog.getOpenFileName(self, "Open file", [stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0], "UBSediFlow file (*.udt)") dir_name = path.dirname(filename[0]) name = path.basename(filename[0]) print(f"dir name : {dir_name} & file name : {name}") # --- Fill lineEdit with path and file names + load acoustic data --- # --- 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() try: # if self.fileListWidget.count() == 0: # stg.path_BS_raw_data = [dir_name] # stg.filename_BS_raw_data = [name] # print(f"0 dir name : {dir_name} & file name : {name}") # else: stg.path_BS_raw_data.append(dir_name) stg.filename_BS_raw_data.append(name) stg.data_preprocessed.append(name) print(f"1 dir name : {dir_name} & file name : {name}") self.load_BS_acoustic_raw_data() print("0 Lecture de la donnée BS") except ValueError as e: # print("error : ", e) # print("1 Je suis sur la donnée BS") msgBox = QMessageBox() msgBox.setWindowTitle("Download Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText("Please select a file") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() else: print("1 Fill widget and plot graphs") print(f"stg.path_BS_raw_data {stg.path_BS_raw_data}") print(f"stg.filename_BS_raw_data {stg.filename_BS_raw_data}") # self.lineEdit_acoustic_file.setText(stg.filename_BS_raw_data) # self.lineEdit_acoustic_file.setToolTip(stg.path_BS_raw_data) print("0. Number of filenames in fileListWidget : ", self.fileListWidget.count()) self.fileListWidget.addFilenames([stg.filename_BS_raw_data[-1]]) print("1. Number of filenames in fileListWidget : ", self.fileListWidget.count()) # self.btnToggled() self.fileListWidget.setToolTip(stg.path_BS_raw_data[-1]) # self.label_date_acoustic_file.clear() # self.label_date_acoustic_file.setText( # _translate("CONSTANT_STRING", cs.DATE) + ": " + str(stg.date[self.fileListWidget.currentRow()])) # self.label_hour_acoustic_file.clear() # self.label_hour_acoustic_file.setText( # _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour[self.fileListWidget.currentRow()])) self.fill_measurements_information_groupbox() self.fill_table() # self.set_range_for_doubleRangeSlider_time() # self.set_range_for_doubleRangeSlider_depth() # self.set_range_for_doubleRangeSlider_intg_area() self.plot_backscattered_acoustic_signal_recording() self.update_frequency_combobox() # self.combobox_frequency_bathymetry.clear() # self.combobox_frequency_bathymetry.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]]) # self.combobox_frequency_profile.clear() # self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]]) stg.acoustic_data = list(range(self.fileListWidget.count())) print("helloooooooo ", stg.acoustic_data) # 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 rename_file_in_ListWidget(self, event): print("souris cliqué !") print(f"event = {event}") if event == QEvent.MouseButtonPress: print("c'est bon") if event.button == Qt.RightButton: print("Right button clicked") elif event.button == Qt.LeftButton: print("Left button clicked") if event.type() == QEvent.ContextMenu: menu = QMenu() menu.addAction('Rename') # if menu.exec_(event.globalPos()): # item = self.fileListWidget.itemAt(event.pos()) # print(item.text()) # return True # return super().eventFilter(source, event) def remove_file_from_ListWidget(self): if self.fileListWidget.count() > 0: # --- Clear files included in list Widget --- current_row = self.fileListWidget.currentRow() if current_row >= 0: current_item = self.fileListWidget.takeItem(current_row) del current_item # --- Clear variables --- list_to_pop1 = ["stg.acoustic_data", "stg.date", "stg.hour", "stg.freq", "stg.freq_text", "stg.temperature", "stg.nb_profiles", "stg.nb_profiles_per_sec", "stg.nb_cells", "stg.cell_size", "stg.pulse_length", "stg.nb_pings_per_sec", "stg.nb_pings_averaged_per_profile", "stg.kt_read", "stg.kt_corrected", "stg.gain_rx", "stg.gain_tx", "stg.filename_BS_raw_data", "stg.path_BS_raw_data", "stg.BS_raw_data", "stg.time", "stg.depth", "stg.BS_raw_data_reshape", "stg.time_reshape", "stg.depth_reshape"] for p in list_to_pop1: print(p) exec(p + ".pop(current_row)") print("stg.freq after remove: ", stg.freq) if stg.BS_cross_section: list_to_pop2 = ["stg.rmin", "stg.rmax", "stg.tmin", "stg.tmax", "stg.time_cross_section", "stg.BS_cross_section"] for k in list_to_pop2: exec(k + ".pop(current_row)") if self.fileListWidget.count() == 0: # --- Clear measurements information --- self.label_date_acoustic_file.clear() self.label_date_acoustic_file.setText("Date: ") self.label_hour_acoustic_file.clear() self.label_hour_acoustic_file.setText("Hour: ") self.spinbox_temperature.clear() self.spinbox_speed_of_sound.clear() self.spinbox_sound_attenuation.clear() self.combobox_frequency_information.clear() self.label_profiles_value.clear() self.label_profiles_per_sec_value.clear() self.label_cells_value.clear() self.label_cell_size_value.clear() self.label_pulse_length_value.clear() self.label_pings_per_sec_value.clear() self.label_pings_per_profile_value.clear() self.spinbox_kt.clear() self.spinbox_rx.clear() self.spinbox_tx.clear() # --- Clear display options --- self.doubleRangeSlider_depth.setRange(min=0, max=50) self.doubleRangeSlider_depth.setValue(value=(5, 40)) self.doubleRangeSlider_recording_time.setRange(min=0, max=50) self.doubleRangeSlider_recording_time.setValue(value=(5, 40)) self.doubleRangeSlider_distance_from_bank.setRange(min=0, max=50) self.doubleRangeSlider_distance_from_bank.setValue(value=(5, 40)) self.combobox_frequency_bathymetry.clear() self.doubleRangeSlider_intg_area.setRange(min=0, max=50) self.doubleRangeSlider_intg_area.setValue(value=(5, 40)) self.spinbox_offset_next_cell.setValue(0.00) # --- Clear table of values --- self.tableView.reset() data = pd.DataFrame(np.zeros((10, 10))) self.tableModel = TableModel(data) self.tableView.setModel(self.tableModel) # --- Clear figures --- self.canvas_BS.figure.clear() self.fig_BS.clf() print("axis BS : ", self.axis_BS) self.axis_BS.tolist().clear() print("clear axis BS : ", self.axis_BS) self.canvas_plot_profile.figure.clear() self.fig_profile.clear() self.axis_profile.clear() self.slider.setValue(0) self.slider.setMaximum(10) def clear_files_from_ListWidget(self): # if self.fileListWidget.count() > 0: list_to_clear = ["stg.acoustic_data", "stg.date", "stg.hour", "stg.freq", "stg.freq_text", "stg.temperature", "stg.nb_profiles", "stg.nb_profiles_per_sec", "stg.nb_cells", "stg.cell_size", "stg.pulse_length", "stg.nb_pings_per_sec", "stg.nb_pings_averaged_per_profile", "stg.kt_read", "stg.kt_corrected", "stg.gain_rx", "stg.gain_tx", "stg.BS_raw_data", "stg.time", "stg.depth", "stg.BS_raw_data_reshape", "stg.time_reshape", "stg.depth_reshape", "stg.rmin", "stg.rmax", "stg.tmin", "stg.tmax", "stg.time_cross_section", "stg.depth_cross_section", "stg.BS_cross_section"] for k in list_to_clear: exec(k + ".clear()") self.fileListWidget.clear() if self.fileListWidget.count() == 0: # --- Clear measurmeents information --- self.label_date_acoustic_file.clear() self.label_date_acoustic_file.setText("Date: ") self.label_hour_acoustic_file.clear() self.label_hour_acoustic_file.setText("Hour: ") self.spinbox_temperature.clear() self.spinbox_speed_of_sound.clear() self.spinbox_sound_attenuation.clear() self.combobox_frequency_information.clear() self.label_profiles_value.clear() self.label_profiles_per_sec_value.clear() self.label_cells_value.clear() self.label_cell_size_value.clear() self.label_pulse_length_value.clear() self.label_pings_per_sec_value.clear() self.label_pings_per_profile_value.clear() self.spinbox_kt.clear() self.spinbox_rx.clear() self.spinbox_tx.clear() # --- Clear display options --- self.doubleRangeSlider_depth.setRange(min=0, max=50) self.doubleRangeSlider_depth.setValue(value=(5, 40)) self.doubleRangeSlider_recording_time.setRange(min=0, max=50) self.doubleRangeSlider_recording_time.setValue(value=(5, 40)) self.doubleRangeSlider_distance_from_bank.setRange(min=0, max=50) self.doubleRangeSlider_distance_from_bank.setValue(value=(5, 40)) self.combobox_frequency_bathymetry.clear() self.doubleRangeSlider_intg_area.setRange(min=0, max=50) self.doubleRangeSlider_intg_area.setValue(value=(5, 40)) self.spinbox_offset_next_cell.setValue(0.00) # --- Clear table of values --- self.tableView.reset() data = pd.DataFrame(np.zeros((10, 10))) self.tableModel = TableModel(data) self.tableView.setModel(self.tableModel) # --- Clear figure area for backscattered acoutsic signal recording --- # self.canvas_BS.figure.clear() # self.fig_BS.clf() # for ax in range(len(self.axis_BS)): # self.axis_BS[ax].cla() # print("axis BS : ", self.axis_BS) # # self.axis_BS.tolist().clear() # # print("clear axis BS : ", self.axis_BS) # # self.canvas_plot_profile.figure.clear() # print("0 fig profile : ", self.fig_profile) # self.fig_profile.delaxes(self.axis_profile) # print("1 fig profile : ", self.fig_profile) # # self.axis_profile.clear() self.combobox_frequency_profile.clear() # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) # self.canvas_BS = FigureCanvas() # self.scroll_BS.setWidget(self.canvas_BS) # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) # --- Clear figure area for profile --- # if self.fig_profile: # self.axis_profile.cla() # self.fig_profile.clf() # self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) # self.canvas_plot_profile = FigureCanvas() # self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) self.canvas_BS.figure.clear() self.fig_BS.clf() print("axis BS : ", self.axis_BS) self.axis_BS.tolist().clear() print("clear axis BS : ", self.axis_BS) self.canvas_BS = FigureCanvas() self.scroll_BS.setWidget(self.canvas_BS) self.canvas_plot_profile.figure.clear() self.fig_profile.clear() self.axis_profile.clear() self.canvas_plot_profile = FigureCanvas() self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) self.slider.setValue(0) self.slider.setMaximum(10) def load_BS_acoustic_raw_data(self): print("Je suis dans le load_BS_acoustic_raw_data") if self.combobox_ABS_system_choice.currentIndex() == 1: print("Je suis dans le load_BS_acoustic_raw_data - 1") acoustic_data = AcousticDataLoader(stg.path_BS_raw_data[-1] + "/" + stg.filename_BS_raw_data[-1]) # stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) # stg.BS_raw_data.append(acoustic_data._BS_raw_data) # stg.BS_raw_data_reshape.append(acoustic_data.reshape_BS_raw_data()) # stg.depth.append(acoustic_data._r) # stg.depth_2D.append(acoustic_data.compute_r_2D()) # stg.depth_reshape.append(acoustic_data.reshape_r()) # stg.time.append(acoustic_data._time) # stg.time_reshape.append(acoustic_data.reshape_time()) # stg.freq.append(acoustic_data._freq) # stg.freq_text.append(acoustic_data._freq_text) # stg.date.append(acoustic_data._date) # stg.hour.append(acoustic_data._hour) # stg.nb_profiles.append(acoustic_data._nb_profiles) # stg.nb_profiles_per_sec.append(acoustic_data._nb_profiles_per_sec) # stg.nb_cells.append(acoustic_data._nb_cells) # stg.cell_size.append(acoustic_data._cell_size) # stg.pulse_length.append(acoustic_data._cell_size) # stg.nb_pings_per_sec.append(acoustic_data._nb_pings_per_sec) # stg.nb_pings_averaged_per_profile.append(acoustic_data._nb_pings_averaged_per_profile) # stg.kt_read.append(acoustic_data._kt) # stg.kt_corrected.append(acoustic_data._kt) # stg.gain_rx.append(acoustic_data._gain_rx) # stg.gain_tx.append(acoustic_data._gain_tx) # stg.temperature.append(self.spinbox_temperature.value()) # if self.fileListWidget.count() == 0: # # stg.ABS_name = [self.combobox_ABS_system_choice.currentText()] # stg.BS_raw_data = [acoustic_data._BS_raw_data] # # print("len(stg.BS_raw_data) ", len(stg.BS_raw_data)) # # print("stg.BS_raw_data[0].shape ", stg.BS_raw_data[0].shape) # stg.BS_raw_data_reshape = [acoustic_data.reshape_BS_raw_data()] # stg.depth = [acoustic_data._r] # stg.depth_2D = [acoustic_data.compute_r_2D()] # stg.depth_reshape = [acoustic_data.reshape_r()] # stg.time = [acoustic_data._time] # stg.time_reshape = [acoustic_data.reshape_time()] # stg.freq = [acoustic_data._freq] # stg.freq_text = [acoustic_data._freq_text] # # print("freq text ", stg.freq_text) # stg.date = [acoustic_data._date] # stg.hour = [acoustic_data._hour] # stg.nb_profiles = [acoustic_data._nb_profiles] # stg.nb_profiles_per_sec = [acoustic_data._nb_profiles_per_sec] # stg.nb_cells = [acoustic_data._nb_cells] # stg.cell_size = [acoustic_data._cell_size] # stg.pulse_length = [acoustic_data._cell_size] # stg.nb_pings_per_sec = [acoustic_data._nb_pings_per_sec] # stg.nb_pings_averaged_per_profile = [acoustic_data._nb_pings_averaged_per_profile] # stg.kt = [acoustic_data._kt] # stg.gain_rx = [acoustic_data._gain_rx] # stg.gain_tx = [acoustic_data._gain_tx] # # else: # # stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) # stg.BS_raw_data.append(acoustic_data._BS_raw_data) # stg.BS_raw_data_reshape.append(acoustic_data.reshape_BS_raw_data()) # stg.depth.append(acoustic_data._r) # stg.depth_2D.append(acoustic_data.compute_r_2D()) # stg.depth_reshape.append(acoustic_data.reshape_r()) # stg.time.append(acoustic_data._time) # stg.time_reshape.append(acoustic_data.reshape_time()) # stg.freq.append(acoustic_data._freq) # stg.freq_text.append(acoustic_data._freq_text) # stg.date.append(acoustic_data._date) # stg.hour.append(acoustic_data._hour) # stg.nb_profiles.append(acoustic_data._nb_profiles) # stg.nb_profiles_per_sec.append(acoustic_data._nb_profiles_per_sec) # stg.nb_cells.append(acoustic_data._nb_cells) # stg.cell_size.append(acoustic_data._cell_size) # stg.pulse_length.append(acoustic_data._cell_size) # stg.nb_pings_per_sec.append(acoustic_data._nb_pings_per_sec) # stg.nb_pings_averaged_per_profile.append(acoustic_data._nb_pings_averaged_per_profile) # stg.kt.append(acoustic_data._kt) # stg.gain_rx.append(acoustic_data._gain_rx) # stg.gain_tx.append(acoustic_data._gain_tx) elif self.combobox_ABS_system_choice.currentIndex() == 2: acoustic_data = AcousticDataLoaderUBSediFlow(stg.path_BS_raw_data[-1] + "/" + stg.filename_BS_raw_data[-1]) # stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) # stg.BS_raw_data.append(acoustic_data._BS_raw_data) # stg.BS_raw_data_reshape.append(acoustic_data.reshape_BS_raw_data()) # stg.depth.append(acoustic_data._r) # stg.depth_2D.append(acoustic_data.compute_r_2D()) # stg.depth_reshape.append(acoustic_data.reshape_r()) # stg.time.append(acoustic_data._time) # stg.time_reshape.append(acoustic_data.reshape_t()) # stg.freq.append(acoustic_data._freq) # stg.freq_text.append(acoustic_data._freq_text) # stg.date.append(acoustic_data._date) # stg.hour.append(acoustic_data._hour) # stg.nb_profiles.append(acoustic_data._nb_profiles) # stg.nb_profiles_per_sec.append(acoustic_data._nb_profiles_per_sec) # stg.nb_cells.append(acoustic_data._nb_cells) # stg.cell_size.append(acoustic_data._cell_size) # stg.pulse_length.append(acoustic_data._cell_size) # stg.nb_pings_per_sec.append(acoustic_data._nb_pings_per_sec) # stg.nb_pings_averaged_per_profile.append(acoustic_data._nb_pings_averaged_per_profile) # stg.kt_read.append(acoustic_data._kt) # stg.kt_corrected.append(acoustic_data._kt) # stg.gain_rx.append(acoustic_data._gain_rx) # stg.gain_tx.append(acoustic_data._gain_tx) # stg.temperature.append(self.spinbox_temperature.value()) # --- The acoustic variables are field with loaded data --- stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) stg.BS_raw_data.append(acoustic_data._BS_raw_data) stg.BS_raw_data_reshape.append(acoustic_data.reshape_BS_raw_data()) stg.depth.append(acoustic_data._r) stg.depth_2D.append(acoustic_data.compute_r_2D()) stg.depth_reshape.append(acoustic_data.reshape_r()) stg.time.append(acoustic_data._time) stg.time_reshape.append(acoustic_data.reshape_t()) stg.freq.append(acoustic_data._freq) stg.freq_text.append(acoustic_data._freq_text) stg.date.append(acoustic_data._date) stg.hour.append(acoustic_data._hour) stg.nb_profiles.append(acoustic_data._nb_profiles) stg.nb_profiles_per_sec.append(acoustic_data._nb_profiles_per_sec) stg.nb_cells.append(acoustic_data._nb_cells) stg.cell_size.append(acoustic_data._cell_size) stg.pulse_length.append(acoustic_data._cell_size) stg.nb_pings_per_sec.append(acoustic_data._nb_pings_per_sec) stg.nb_pings_averaged_per_profile.append(acoustic_data._nb_pings_averaged_per_profile) stg.kt_read.append(acoustic_data._kt) # stg.kt_corrected.append(acoustic_data._kt) stg.gain_rx.append(acoustic_data._gain_rx) stg.gain_tx.append(acoustic_data._gain_tx) stg.temperature.append(0) stg.water_velocity.append(0) stg.water_attenuation.append([]) # --- The other acoustic variables lists are filled with empty object. --- # --- They will be used for pre- and post-processing --- stg.BS_cross_section.append(np.array([])) stg.depth_cross_section.append(np.array([])) stg.time_cross_section.append(np.array([])) stg.tmin.append("") stg.tmax.append("") stg.rmin.append("") stg.rmax.append("") stg.BS_stream_bed.append(np.array([])) stg.depth_bottom.append(np.array([])) stg.val_bottom.append([]) stg.ind_bottom.append([]) stg.freq_bottom_detection.append([]) stg.depth_bottom_detection_1st_int_area.append([]) stg.BS_noise_raw_data.append(np.array([])) stg.BS_noise_averaged_data.append(np.array([])) stg.SNR_raw_data.append(np.array([])) stg.SNR_cross_section.append(np.array([])) stg.SNR_stream_bed.append(np.array([])) stg.time_noise.append(np.array([])) stg.noise_method.append(0) stg.noise_value.append(0) stg.SNR_filter_value.append(0) stg.Nb_cells_to_average_BS_signal.append(0) stg.filename_BS_noise_data.append("") stg.path_BS_noise_data.append("") stg.BS_raw_data_pre_process_SNR.append(np.array([])) stg.BS_raw_data_pre_process_average.append(np.array([])) stg.BS_raw_data_pre_process_SNR_average.append(np.array([])) stg.BS_cross_section_pre_process_SNR.append(np.array([])) stg.BS_cross_section_pre_process_average.append(np.array([])) stg.BS_cross_section_pre_process_SNR_average.append(np.array([])) stg.BS_stream_bed_pre_process_SNR.append(np.array([])) stg.BS_stream_bed_pre_process_average.append(np.array([])) stg.BS_stream_bed_pre_process_SNR_average.append(np.array([])) # if self.fileListWidget.count() == 0: # # stg.ABS_name = [self.combobox_ABS_system_choice.currentText()] # stg.date = [acoustic_data._date] # stg.hour = [acoustic_data._hour] # stg.freq = [acoustic_data._freq] # stg.time = [acoustic_data._time] # stg.depth = [acoustic_data._r] # stg.depth_2D = [acoustic_data.compute_r_2D()] # stg.freq_text = [acoustic_data._freq_text] # stg.BS_raw_data = [acoustic_data._BS_raw_data] # stg.BS_raw_data_reshape = acoustic_data.reshape_BS_raw_data() # stg.depth_reshape = acoustic_data.reshape_r() # stg.time_reshape = acoustic_data.reshape_t() # # else: # # stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) # stg.date.append(acoustic_data._date) # stg.hour.append(acoustic_data._hour) # stg.freq.append(acoustic_data._freq) # stg.time.append(acoustic_data._time) # stg.depth.append(acoustic_data._r) # stg.depth_2D.append(acoustic_data.compute_r_2D()) # stg.freq_text.append(acoustic_data._freq_text) # stg.BS_raw_data.append(acoustic_data._BS_raw_data) # stg.SNR_data = acoustic_data._SNR_data # stg.snr_reshape = acoustic_data.reshape_SNR_data() # print(f"r = {stg.depth}") # 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.depth.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: # self.label_date_acoustic_file.setText( # _translate("CONSTANT_STRING", cs.DATE) + ": " + str(stg.date[self.fileListWidget.currentRow()])) # self.label_hour_acoustic_file.setText( # _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour[self.fileListWidget.currentRow()])) # self.label_profiles.setText( # _translate("CONSTANT_STRING", cs.NB_PROFILES) + ": " + str(stg.nb_profiles[self.fileListWidget.currentRow()])) # self.label_profiles_per_sec.setText( # _translate("CONSTANT_STRING", cs.NB_PROFILES_PER_SEC) + ": " + # str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()]) + " Hz") # print("OL ", self.fileListWidget.currentRow()) # self.label_freq.setText( # _translate("CONSTANT_STRING", cs.FREQUENCY) + ": " + ', '.join(stg.freq_text[self.fileListWidget.currentIndex().row()])) # self.label_cells.setText( # _translate("CONSTANT_STRING", cs.NB_CELLS) + ": " + str(stg.nb_cells[self.fileListWidget.currentRow()])) # self.label_cell_size.setText( # _translate("CONSTANT_STRING", cs.CELL_SIZE) + ": " + str(100*round(stg.cell_size[self.fileListWidget.currentRow()], 3)) + " cm") # self.label_pulse_length.setText( # _translate("CONSTANT_STRING", cs.PULSE_LENGHT) + ": " + str(round(stg.pulse_length[self.fileListWidget.currentRow()], 6)) + "sec") # self.label_pings_per_sec.setText( # _translate("CONSTANT_STRING", cs.NB_PINGS_PER_SEC) + ": " + str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()]) + " Hz") # self.label_pings_per_profile.setText( # _translate("CONSTANT_STRING", cs.NB_PINGS_PER_PROFILE) + ": " + # str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()])) # self.label_kt.setText( # _translate("CONSTANT_STRING", cs.KT) + ": " + ', '.join(map(str, stg.kt[self.fileListWidget.currentRow()]))) # self.label_rx.setText( # _translate("CONSTANT_STRING", cs.GAIN_RX) + ": " + ', '.join(map(str, stg.gain_rx[self.fileListWidget.currentRow()]))) # self.label_tx.setText( # _translate("CONSTANT_STRING", cs.GAIN_TX) + ": " + ', '.join(map(str, stg.gain_tx[self.fileListWidget.currentRow()]))) print("self.fileListWidget.currentItem() ", self.fileListWidget.currentItem()) print("self.fileListWidget.currentRow ", self.fileListWidget.currentRow()) print("self.fileListWidget.count() ", self.fileListWidget.count()) if self.fileListWidget.currentRow() != -1: self.label_date_acoustic_file.clear() self.label_date_acoustic_file.setText("Date: " + str(stg.date[self.fileListWidget.currentRow()])) self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1) self.label_hour_acoustic_file.clear() self.label_hour_acoustic_file.setText("Hour: " + str(stg.hour[self.fileListWidget.currentRow()])) self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) self.combobox_frequency_information.clear() self.combobox_frequency_information.addItems(stg.freq_text[self.fileListWidget.currentRow()]) self.combobox_frequency_information.currentIndexChanged.connect(self.combobox_frequency_information_update) self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 6, 1, 1, 1) self.label_profiles_per_sec_value.setText(str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) + " Hz") self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 7, 1, 1, 1) self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 8, 1, 1, 1) self.label_cell_size_value.setText(str(100*round(stg.cell_size[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()], 3)) + " cm") self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 9, 1, 1, 1) self.label_pulse_length_value.setText(str(round(stg.pulse_length[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()], 6)) + " sec") self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 10, 1, 1, 1) self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) + " Hz") self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 11, 1, 1, 1) self.label_pings_per_profile_value.setText(str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 12, 1, 1, 1) stg.kt_corrected = deepcopy(stg.kt_read) # if self.checkbox_kt.isChecked(): # self.spinbox_kt.setValue( # stg.kt_corrected[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) # else: self.spinbox_kt.setValue( stg.kt_read[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) self.spinbox_kt.setSuffix(f" V.m^{1.5}") self.spinbox_kt.setEnabled(False) self.checkbox_kt.stateChanged.connect(self.activate_unactivate_spinbox_kt) self.spinbox_kt.valueChanged.connect(self.kt_value) self.spinbox_rx.setValue(stg.gain_rx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) self.spinbox_rx.setEnabled(False) self.checkbox_rx.stateChanged.connect(self.activate_unactivate_spinbox_rx) self.spinbox_rx.valueChanged.connect(self.gain_rx_value) self.spinbox_tx.setValue(stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) self.spinbox_tx.setEnabled(False) self.checkbox_tx.stateChanged.connect(self.activate_unactivate_spinbox_tx) self.spinbox_kt.valueChanged.connect(self.gain_tx_value) # for find, fval in enumerate(stg.freq[self.fileListWidget.currentRow()]): # print(f"find {find} fval {fval}") # exec(f"self.spinbox_freq_" + str(int(fval)) + " = QDoubleSpinBox()") # exec(f"self.spinbox_freq_" + str(int(fval)) + ".setSuffix('Hz')") # exec(f"self.spinbox_freq_" + str(int(fval)) + ".setValue(" + str(fval) + ")") # exec(f"self.gridLayout_goupbox_info.addWidget(self.spinbox_freq_" + str(int(fval)) + ", 6, " + str(find+1) + ", 1, 1)") # self.gridLayout_goupbox_info.addWidget(stg.freq_text[self.fileListWidget.currentIndex().row()]) # self.gridLayout_goupbox_info.addWidget(', '.join(map(str, stg.kt[self.fileListWidget.currentRow()]))) # self.gridLayout_goupbox_info.addWidget(', '.join(map(str, stg.gain_rx[self.fileListWidget.currentRow()]))) # self.gridLayout_goupbox_info.addWidget(', '.join(map(str, stg.gain_tx[self.fileListWidget.currentRow()]))) # elif self.combobox_ABS_system_choice.currentIndex() == 2: # # # self.label_freq.setText( # # _translate("CONSTANT_STRING", cs.FREQUENCY) + ": " + ', '.join(stg.freq_text[self.fileListWidget.currentRow()])) # # self.label_freq = QLabel("Date: " + str(stg.date[self.fileListWidget.currentRow()])) # self.gridLayout_goupbox_info.addWidget(self.label_freq, 0, 0, 1, 1) # self.label_freq = QLabel("Hour: " + str(stg.hour[self.fileListWidget.currentRow()])) # self.gridLayout_goupbox_info.addWidget(self.label_freq, 0, 1, 1, 1) # # self.combobox_frequency_information.clear() # self.combobox_frequency_information.addItems(stg.freq_text[self.fileListWidget.currentRow()]) # self.combobox_frequency_information.currentIndexChanged.connect(self.combobox_frequency_information_update) # # self.label_profiles_value.clear() # self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] # [self.combobox_frequency_information.currentIndex()])) # self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 3, 1, 1, 1) # # self.label_profiles_per_sec_value.clear() # self.label_profiles_per_sec_value.setText(str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] # [self.combobox_frequency_information.currentIndex()]) + " Hz") # self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 4, 1, 1, 1) # # self.label_cells_value.clear() # self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] # [self.combobox_frequency_information.currentIndex()])) # self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 5, 1, 1, 1) # # self.label_cell_size_value.clear() # self.label_cell_size_value.setText(str(100 * round(stg.cell_size[self.fileListWidget.currentRow()] # [self.combobox_frequency_information.currentIndex()], # 3)) + " cm") # self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 6, 1, 1, 1) # # self.label_pulse_length_value.clear() # self.label_pulse_length_value.setText(str(round(stg.pulse_length[self.fileListWidget.currentRow()] # [self.combobox_frequency_information.currentIndex()], # 6)) + " sec") # self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 7, 1, 1, 1) # # self.label_pings_per_sec_value.clear() # self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] # [self.combobox_frequency_information.currentIndex()]) + " Hz") # self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 8, 1, 1, 1) # # self.label_pings_per_profile_value.clear() # self.label_pings_per_profile_value.setText( # str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] # [self.combobox_frequency_information.currentIndex()])) # self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 9, 1, 1, 1) # # self.spinbox_kt.setValue( # stg.kt[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) # self.spinbox_kt.setSuffix(f" V.m^{1.5}") # self.spinbox_kt.setEnabled(False) # self.checkbox_kt.stateChanged.connect(self.activate_unactivate_spinbox_kt) # self.spinbox_kt.valueChanged.connect(self.kt_value) # # self.spinbox_rx.setValue( # stg.gain_rx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) # self.spinbox_rx.setEnabled(False) # self.checkbox_rx.stateChanged.connect(self.activate_unactivate_spinbox_rx) # self.spinbox_rx.valueChanged.connect(self.gain_rx_value) # # self.spinbox_tx.setValue( # stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) # self.spinbox_tx.setEnabled(False) # self.checkbox_tx.stateChanged.connect(self.activate_unactivate_spinbox_tx) # self.spinbox_kt.valueChanged.connect(self.gain_tx_value) def combobox_frequency_information_update(self): if self.fileListWidget.count() > 0: print("stg.water_attenuation ", stg.water_attenuation) if stg.water_attenuation[self.fileListWidget.currentRow()]: self.spinbox_sound_attenuation.clear() self.spinbox_sound_attenuation.setValue(stg.water_attenuation[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) self.label_profiles_value.clear() self.gridLayout_goupbox_info.removeWidget(self.label_profiles_value) self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 6, 1, 1, 1) self.label_profiles_per_sec_value.clear() self.label_profiles_per_sec_value.setText( str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) + " Hz") self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 7, 1, 1, 1) self.label_cells_value.clear() self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 8, 1, 1, 1) self.label_cell_size_value.clear() self.gridLayout_goupbox_info.removeWidget(self.label_cell_size_value) self.label_cell_size_value.setText( str(100 * round(stg.cell_size[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()], 3)) + " cm") self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 9, 1, 1, 1) self.label_pulse_length_value.clear() self.label_pulse_length_value.setText( str(round(stg.pulse_length[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()], 6)) + " sec") self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 10, 1, 1, 1) self.label_pings_per_sec_value.clear() self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) + " Hz") self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 11, 1, 1, 1) self.label_pings_per_profile_value.clear() self.label_pings_per_profile_value.setText( str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()])) self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 12, 1, 1, 1) self.spinbox_kt.clear() if self.checkbox_kt.isChecked(): print("combobox information update : checkbox checked") self.spinbox_kt.setValue(stg.kt_corrected[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) else: print("combobox information update : checkbox unchecked") self.spinbox_kt.setValue(stg.kt_read[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) self.spinbox_kt.setSuffix(f" V.m^{1.5}") self.spinbox_rx.clear() self.spinbox_rx.setValue(stg.gain_rx[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) self.spinbox_tx.clear() self.spinbox_tx.setValue(stg.gain_tx[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) def activate_unactivate_spinbox_kt(self): if self.checkbox_kt.isChecked(): print(f"checkbox checked : kt corrected {stg.kt_corrected}") self.spinbox_kt.setValue(stg.kt_corrected[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) self.spinbox_kt.setEnabled(True) else: print(f"checkbox unchecked : kt read {stg.kt_read}") self.spinbox_kt.setValue(stg.kt_read[self.fileListWidget.currentRow()] [self.combobox_frequency_information.currentIndex()]) self.spinbox_kt.setDisabled(True) def activate_unactivate_spinbox_rx(self): if self.checkbox_rx.isChecked(): self.spinbox_rx.setEnabled(True) else: self.spinbox_rx.setDisabled(True) def activate_unactivate_spinbox_tx(self): if self.checkbox_tx.isChecked(): self.spinbox_tx.setEnabled(True) else: self.spinbox_tx.setDisabled(True) def kt_value(self): print(f"0 stg.kt_read : {stg.kt_read}") print(f"0 stg.kt_corrected {stg.kt_corrected}") if self.checkbox_kt.isChecked(): stg.kt_corrected[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] = ( self.spinbox_kt.value()) print(f"1 stg.kt_read : {stg.kt_read}") print(f"1 stg.kt_corrected {stg.kt_corrected}") def gain_rx_value(self): stg.gain_rx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] =\ self.spinbox_rx.value() # print(f"stg.rx : {stg.gain_rx}") def gain_tx_value(self): stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] =\ self.spinbox_tx.value() # print(f"stg.tx : {stg.gain_tx}") def fill_table(self): if self.fileListWidget.currentRow() != -1: # header_list = [] # for freq_ind, freq_value in enumerate(stg.freq_text[0]): # header_list.append("Time - " + freq_value) # header_list.append("Depth - " + freq_value) # header_list.append("BS - " + freq_value) # # if freq_ind == 0: # table_data = np.vstack((np.vstack((stg.time_reshape[0][:, freq_ind], # stg.depth_reshape[0][:, freq_ind])), # stg.BS_raw_data_reshape[0][:, freq_ind])) # else: # table_data = np.vstack((table_data, # np.vstack((np.vstack((stg.time_reshape[0][:, freq_ind], # stg.depth_reshape[0][:, freq_ind])), # stg.BS_raw_data_reshape[0][:, freq_ind])) # )) # # print("1 header_list ", header_list) # print("1 table_data.shape ", table_data.shape) # # stg.DataFrame_acoustic = pd.DataFrame(data=table_data.transpose(), columns=header_list) # # else: header_list = [] header_list.clear() table_data = np.array([[]]) for freq_ind, freq_value in enumerate(stg.freq_text[0]): header_list.append("Time - " + freq_value) header_list.append("Depth - " + freq_value) header_list.append("BS - " + freq_value) if freq_ind == 0: table_data = np.vstack((np.vstack((stg.time_reshape[self.fileListWidget.currentRow()][:, freq_ind], stg.depth_reshape[self.fileListWidget.currentRow()][:, freq_ind])), stg.BS_raw_data_reshape[self.fileListWidget.currentRow()][:, freq_ind])) else: table_data = np.vstack((table_data, np.vstack((np.vstack((stg.time_reshape[self.fileListWidget.currentRow()][:, freq_ind], stg.depth_reshape[self.fileListWidget.currentRow()][:, freq_ind])), stg.BS_raw_data_reshape[self.fileListWidget.currentRow()][:, freq_ind])) )) stg.DataFrame_acoustic = pd.DataFrame(None) stg.DataFrame_acoustic = pd.DataFrame(data=table_data.transpose(), columns=header_list) print("2 header_list ", header_list) print("2 table_data.shape", table_data.shape) # stg.DataFrame_acoustic = ( # pd.DataFrame(np.concatenate((stg.time_reshape[self.fileListWidget.currentRow()], # stg.BS_raw_data_reshape[self.fileListWidget.currentRow()]), axis=1), # columns=list(map(str, ["Time - " + f for f in stg.freq_text[self.fileListWidget.currentRow()]] + # ["BS - " + f for f in stg.freq_text[self.fileListWidget.currentRow()]]))) # ) self.tableModel = TableModel(stg.DataFrame_acoustic) self.tableView.setModel(self.tableModel) # self.tableView.setItemDelegate(FloatDelegate(3)) # if self.combobox_ABS_system_choice.currentIndex() == 2: # 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.snr_reshape), axis=1), # columns=list(map(str, ["Time"] + ["BS - " + 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(): # 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]))) # self.tableModel = TableModel(stg.DataFrame_acoustic) # self.tableView.setModel(self.tableModel) # else: # msgBox = QMessageBox() # msgBox.setWindowTitle("Fill table Error") # msgBox.setIcon(QMessageBox.Warning) # msgBox.setText("Download files before fill table") # msgBox.setStandardButtons(QMessageBox.Ok) # 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) # 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]))) # self.tableModel = TableModel(stg.DataFrame_acoustic) # self.tableView.setModel(self.tableModel) # else: # msgBox = QMessageBox() # msgBox.setWindowTitle("Fill table Error") # msgBox.setIcon(QMessageBox.Warning) # msgBox.setText("Download files before fill table") # msgBox.setStandardButtons(QMessageBox.Ok) # msgBox.exec() def export_table(self): if self.tableWidget.columnCount() == 10: msgBox = QMessageBox() msgBox.setWindowTitle("Export table Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText("Fill table before export table") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() else: print("export table") def transect_xaxis_choice(self): if self.groupbox_xaxis_time.isChecked() == True: # self.groupbox_xaxis_time.setDisabled(True) self.groupbox_xaxis_space.setChecked(False) # self.groupbox_xaxis_space.setDisabled(False) elif self.groupbox_xaxis_space.isChecked() == True: self.groupbox_xaxis_time.setChecked(False) # self.groupbox_xaxis_time.setDisabled(False) # self.groupbox_xaxis_space.setDisabled(True) def compute_time(self): ''' tmin and tmax are filled with min and max of time when data are uploaded and double slider of time are updated with these values ''' if self.fileListWidget.currentRow() != -1: print("self.fileListWidget.currentRow() ", self.fileListWidget.currentRow()) # if stg.time_cross_section[self.fileListWidget.currentRow()].shape == (0,): # --- tmim / tmax --- tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( stg.time[self.fileListWidget.currentRow()][0, :])) == np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) stg.tmin[self.fileListWidget.currentRow()] = (tmin_indice, tmin_value) print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( stg.time[self.fileListWidget.currentRow()][0, :])) == np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) stg.tmax[self.fileListWidget.currentRow()] = (tmax_indice + 1, tmax_value) # else: # # # --- tmim / tmax --- # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # stg.tmin[self.fileListWidget.currentRow()] = (tmin_indice, tmin_value) # # print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") # # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # stg.tmax[self.fileListWidget.currentRow()] = (tmax_indice + 1, tmax_value) # print(f" tmax_indice = {tmax_indice} , tmax_value = {tmax_value}") # # print("stg.time ", stg.time[self.fileListWidget.currentRow()][:, 0:4499]) # print("stg.tmin[self.fileListWidget.currentRow()][0] ", stg.tmin[self.fileListWidget.currentRow()][0]) # print("stg.tmax[self.fileListWidget.currentRow()][0] ", stg.tmax[self.fileListWidget.currentRow()][0]) # --- time_cross_section --- # stg.time_cross_section[self.fileListWidget.currentRow()] = \ # stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]: # stg.tmax[self.fileListWidget.currentRow()][0]] # print(f"time cross section = {stg.time_cross_section[0].shape}") self.set_range_for_doubleRangeSlider_time() # if ((self.fileListWidget.count() == 1) and (len(stg.tmax) == 0)): # # print("Config 1 : time") # # # --- tmim / tmax --- # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # stg.tmin = [(tmin_indice, tmin_value)] # # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # stg.tmax = [(tmax_indice+1, tmax_value)] # # print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") # # # --- time_cross_section --- # stg.time_cross_section = [stg.time[self.fileListWidget.currentRow()][:, # stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] # print(f"t = {stg.time_cross_section}") # # # --- spinbox tmin / tmax --- # # self.spinbox_tmin.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) # # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) # # # self.doubleRangeSlider_recording_time.update() # # self.doubleRangeSlider_recording_time.setValue((0, 500)) # # (stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) # # # print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) # # elif len(stg.tmax) < self.fileListWidget.count(): # # print("Config 2 : time") # # # --- tmim / tmax --- # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") # # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # print(f" tmax_indice = {tmax_indice} , tmax_value = {tmax_value}") # # print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") # stg.tmin.append((tmin_indice, tmin_value)) # stg.tmax.append((tmax_indice+1, tmax_value)) # print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") # # # --- time_cross_section --- # stg.time_cross_section = stg.time_cross_section + [stg.time[self.fileListWidget.currentRow()][:, # stg.tmin[self.fileListWidget.currentRow()][0]: # stg.tmax[self.fileListWidget.currentRow()][0]]] # # # --- spinbox tmin / tmax --- # # self.spinbox_tmin.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) # # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) # # # self.doubleRangeSlider_recording_time.setValue(value=( # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) # # print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) # # else: # print("-----------------") # print("Config 3 : time") # print("-----------------") # # self.set_range_for_doubleRangeSlider_time() # # # --- spinbox tmin / tmax --- # # self.spinbox_tmin.setValue( # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) # # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][ # # 0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) # # # print("tmin = ", stg.tmin) # # print("tmax = ", stg.tmax) # # print("list Widget : ", self.fileListWidget.currentRow()) # # print("stg.tmin[self.fileListWidget.currentRow()][0] ", stg.tmin[self.fileListWidget.currentRow()][0]) # # print("stg.tmax[self.fileListWidget.currentRow()][0] - 1 ", stg.tmax[self.fileListWidget.currentRow()][0]-1) # # # # print("time_cross_section min ", stg.time_cross_section[self.fileListWidget.currentRow()][ # # 0, stg.tmin[self.fileListWidget.currentRow()][0]]) # # print("time_cross_section max ", stg.time_cross_section[self.fileListWidget.currentRow()][ # # 0, stg.tmax[self.fileListWidget.currentRow()][0]]) # # # self.doubleRangeSlider_recording_time.setValue(value=(stg.tmin[self.fileListWidget.currentRow()][1], stg.tmax[self.fileListWidget.currentRow()][1])) # # # # self.doubleRangeSlider_recording_time.setValue(value=( # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1] # # )) # # # # print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) def set_range_for_doubleRangeSlider_time(self): self.doubleRangeSlider_recording_time.setRange(min=stg.time[self.fileListWidget.currentRow()][0, 0], max=stg.time[self.fileListWidget.currentRow()][0, -1]) if stg.time_cross_section[self.fileListWidget.currentRow()].shape == (0,): self.doubleRangeSlider_recording_time.setValue(value=(stg.time[self.fileListWidget.currentRow()][0, 0], stg.time[self.fileListWidget.currentRow()][0, -1])) else: self.doubleRangeSlider_recording_time.setValue(value=(stg.time_cross_section[self.fileListWidget.currentRow()][0, 0], stg.time_cross_section[self.fileListWidget.currentRow()][0, -1])) def set_tmin_tmax_for_doubleRangeSider_time(self): ''' tmin and tmax are updated with double slider of time ''' stg.tmin[self.fileListWidget.currentRow()] = (( np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], 2) - self.doubleRangeSlider_recording_time.value()[0]) == np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], 2) - self.doubleRangeSlider_recording_time.value()[0])))[0][0], self.doubleRangeSlider_recording_time.value()[0] )) print("tmax = ", stg.tmax) stg.tmax[self.fileListWidget.currentRow()] = (( np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], 2) - self.doubleRangeSlider_recording_time.value()[1]) == np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], 2) - self.doubleRangeSlider_recording_time.value()[1])))[0][0]+1, self.doubleRangeSlider_recording_time.value()[1] )) print("tmax = ", stg.tmax) # def time_spin_box_value(self): # # if Qt.Key_Return: # # stg.tmax[self.fileListWidget.currentRow()] = (( # np.where(np.abs(np.round(stg.time_cross_section[self.fileListWidget.currentRow()][0, :], 2) - self.spinbox_tmax.value()) == # np.nanmin(np.abs(np.round(stg.time_cross_section[self.fileListWidget.currentRow()][0, :], # 2) - self.spinbox_tmax.value())))[0][0], # self.spinbox_tmax.value() # )) # print("tmax = ", stg.tmax) # # stg.time_cross_section[self.fileListWidget.currentRow()] = ( # stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]] # ) def compute_depth(self): ''' rmin and rmax are filled with min and max of depth when data are uploaded and double slider of depth are updated with these values ''' # if self.fileListWidget.currentRow() != -1: # print("self.fileListWidget.currentRow() ", self.fileListWidget.currentRow()) # if stg.depth_cross_section[self.fileListWidget.currentRow()].shape == (0,): # # # --- tmim / tmax --- # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # stg.tmin[self.fileListWidget.currentRow()] = (tmin_indice, tmin_value) # # print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") # # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # stg.tmax[self.fileListWidget.currentRow()] = (tmax_indice + 1, tmax_value) # # else: # # # --- tmim / tmax --- # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # stg.tmin[self.fileListWidget.currentRow()] = (tmin_indice, tmin_value) # # print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") # # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) # stg.tmax[self.fileListWidget.currentRow()] = (tmax_indice + 1, tmax_value) if self.fileListWidget.currentRow() != -1: # --- rmim / rmax --- rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( stg.depth[self.fileListWidget.currentRow()][0, :])) == np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) stg.rmin[self.fileListWidget.currentRow()] = (rmin_indice, rmin_value) print(f" rmin_indice = {rmin_indice} , rmin_value = {rmin_value}") rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( stg.depth[self.fileListWidget.currentRow()][0, :])) == np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) stg.rmax[self.fileListWidget.currentRow()] = (rmax_indice + 1, rmax_value) print(f" rmax_indice = {rmax_indice} , rmax_value = {rmax_value}") # # --- depth_cross_section --- # # stg.depth_cross_section[self.fileListWidget.currentRow()] = \ # stg.depth[self.fileListWidget.currentRow()][:, stg.rmin[self.fileListWidget.currentRow()][0]: # stg.rmax[self.fileListWidget.currentRow()][0]] # print(f"depth cross section = {stg.depth_cross_section}") self.set_range_for_doubleRangeSlider_depth() # if ((self.fileListWidget.count() == 1) and (len(stg.rmax) == 0)): # # # --- rmim / rmax --- # rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.depth[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] # rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) # stg.rmin = [(rmin_indice, rmin_value)] # # rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.depth[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] # rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) # stg.rmax = [(rmax_indice+1, rmax_value)] # # # --- depth_cross_section --- # stg.depth_cross_section = [stg.depth[self.fileListWidget.currentRow()][:, # stg.rmin[self.fileListWidget.currentRow()][0]: # stg.rmax[self.fileListWidget.currentRow()][0]]] # print("Config 1 : depth") # print("rmin ", stg.rmin) # print("rmax ", stg.rmax) # # elif len(stg.rmax) < self.fileListWidget.count(): # # # --- rmim / rmax --- # rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.depth[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( # stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] # rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) # # rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.depth[self.fileListWidget.currentRow()][0, :])) == # np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( # stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] # rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) # # stg.rmin.append((rmin_indice, rmin_value)) # stg.rmax.append((rmax_indice+1, rmax_value)) # # # --- depth_cross_section --- # stg.depth_cross_section = stg.depth_cross_section + [stg.depth[self.fileListWidget.currentRow()][:, # stg.rmin[self.fileListWidget.currentRow()][0]: # stg.rmax[self.fileListWidget.currentRow()][0]]] # print("Config 2 : depth") # print("rmin ", stg.rmin) # print("rmax ", stg.rmax) # # else: # # self.set_range_for_doubleRangeSlider_depth() # print("Config 3 : depth") # print("rmin ", stg.rmin) # print("rmax ", stg.rmax) def set_range_for_doubleRangeSlider_depth(self): self.doubleRangeSlider_depth.setRange(min=-stg.depth[self.fileListWidget.currentRow()][0, -1], max=-stg.depth[self.fileListWidget.currentRow()][0, 0]) if stg.depth_cross_section[self.fileListWidget.currentRow()].shape == (0,): self.doubleRangeSlider_depth.setValue(value=(-stg.depth[self.fileListWidget.currentRow()][0, -1], -stg.depth[self.fileListWidget.currentRow()][0, 0])) else: self.doubleRangeSlider_depth.setValue( value=(-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], -stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0])) # print("self.doubleRangeSlider_depth.value() ", self.doubleRangeSlider_depth.value()) def set_rmin_rmax_for_doubleRangeSider_depth(self): ''' rmin and rmax are updated with double slider of depth ''' stg.rmin[self.fileListWidget.currentRow()] = (( np.where(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :], 2) - -self.doubleRangeSlider_depth.value()[1]) == np.nanmin(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :], 2) - (-self.doubleRangeSlider_depth.value()[1]))))[0][0], -self.doubleRangeSlider_depth.value()[1] )) print("rmax before ", stg.rmax) stg.rmax[self.fileListWidget.currentRow()] = (( np.where(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :], 2) - -self.doubleRangeSlider_depth.value()[0]) == np.nanmin(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :], 2) - (-self.doubleRangeSlider_depth.value()[0]))))[0][0]+1, -self.doubleRangeSlider_depth.value()[0] )) print("rmax afer ", stg.rmax) stg.depth_cross_section[self.fileListWidget.currentRow()] = ( stg.depth[self.fileListWidget.currentRow()][:, stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0]] ) def compute_BS_cross_section(self): if self.fileListWidget.currentRow() != -1: # print("tmax for compute BS cross section = ", stg.tmax) stg.time_cross_section[self.fileListWidget.currentRow()] = ( stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]: stg.tmax[self.fileListWidget.currentRow()][0]] ) stg.depth_cross_section[self.fileListWidget.currentRow()] = ( stg.depth[self.fileListWidget.currentRow()][:, stg.rmin[self.fileListWidget.currentRow()][0]: stg.rmax[self.fileListWidget.currentRow()][0]] ) stg.BS_cross_section[self.fileListWidget.currentRow()] = ( stg.BS_raw_data[self.fileListWidget.currentRow()] [:, stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]) # print(f"BS_cross_section : {len(stg.BS_cross_section)}") # print(f"BS_cross_section shape : {stg.BS_cross_section[self.fileListWidget.currentRow()].shape}") # if (self.fileListWidget.count() == 1) and (len(stg.BS_cross_section) == 0): # # print("Config 1 : BS_cross_section") # # stg.BS_cross_section = [stg.BS_raw_data[self.fileListWidget.currentRow()][:, # stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], # stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] # # elif len(stg.BS_cross_section) < self.fileListWidget.count(): # # print("Config 2 : BS_cross_section") # print("tmin for cross section ", stg.tmin) # stg.BS_cross_section = stg.BS_cross_section + [stg.BS_raw_data[self.fileListWidget.currentRow()][:, # stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], # stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] # # else: # # print("Config 3 : BS_cross_section") # # stg.BS_cross_section[self.fileListWidget.currentRow()] = ( # stg.BS_raw_data[self.fileListWidget.currentRow()] # [:, stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], # stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]) # # print(f"BS_cross_section : {len(stg.BS_cross_section)}") # print(f"BS_cross_section shape : {stg.BS_cross_section[self.fileListWidget.currentRow()].shape}") def update_frequency_combobox(self): if self.fileListWidget.currentRow() != -1: self.combobox_frequency_bathymetry.clear() self.combobox_frequency_bathymetry.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]]) self.combobox_frequency_profile.clear() self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]]) def set_range_for_doubleRangeSlider_intg_area(self): if self.fileListWidget.currentRow() != -1: if stg.depth_cross_section[self.fileListWidget.currentRow()].shape == (0,): self.doubleRangeSlider_intg_area.setRange( min=-stg.depth[self.fileListWidget.currentRow()][0, -1], max=-stg.depth[self.fileListWidget.currentRow()][0, 0]) self.doubleRangeSlider_intg_area.setValue( value=(-stg.depth[self.fileListWidget.currentRow()][0, -1], -stg.depth[self.fileListWidget.currentRow()][0, 0])) else: self.doubleRangeSlider_intg_area.setRange( min=-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], max=-stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0]) self.doubleRangeSlider_intg_area.setValue( value=(-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], -stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0])) def set_range_for_spinboxes_bathymetry(self): if self.fileListWidget.currentRow() != -1: if stg.depth_cross_section[self.fileListWidget.currentRow()].shape != (0,): self.spinbox_depth_min_bathy.setValue(stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0]) self.spinbox_depth_max_bathy.setValue(stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1]) else: self.spinbox_depth_min_bathy.setValue(stg.depth[self.fileListWidget.currentRow()][0, 0]) self.spinbox_depth_max_bathy.setValue(stg.depth[self.fileListWidget.currentRow()][0, -1]) def plot_backscattered_acoustic_signal_recording(self): # --- Condition if table is not filled --- # if not self.lineEdit_acoustic_file.text(): # if not stg.filename_BS_raw_data: # print(stg.filename_BS_raw_data.text()) # msgBox = QMessageBox() # msgBox.setWindowTitle("Plot transect Error") # msgBox.setIcon(QMessageBox.Warning) # msgBox.setText("Load data before plot transect 2D field") # msgBox.setStandardButtons(QMessageBox.Ok) # msgBox.exec() # elif self.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.canvas_BS == None: # else: # self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq.shape[0], ncols=1, sharex=True, sharey=False, # layout="constrained") # # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) # plt.close(self.fig_BS) if self.fileListWidget.currentRow() != -1: self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") self.canvas_BS = FigureCanvas(self.fig_BS) # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_BS) # self.scroll_BS = QScrollArea() self.scroll_BS.setWidget(self.canvas_BS) # self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) # self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) # # self.scroll_BS.setWidgetResizable(True) # self.scroll_BS.setAlignment(Qt.AlignCenter) self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) if val_min == 0: val_min = 1e-5 # print(f"freq = {f}") if self.combobox_ABS_system_choice.currentIndex() == 1: pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :], -stg.depth[self.fileListWidget.currentRow()][f, :], stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :], # stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])], 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[self.fileListWidget.currentRow()][f, :], -stg.depth[self.fileListWidget.currentRow()][f, :], np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]), # np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]), cmap='Blues') self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_BS[f].transAxes) # --- Plot red solid line on transect to visualize position of plotted profile --- # print("on the 2D field ", self.combobox_freq_choice.currentIndex()) self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]), -stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :], color='red', linestyle="solid", linewidth=2) self.fig_BS.supxlabel('Time (sec)', fontsize=10) self.fig_BS.supylabel('Depth (m)', fontsize=10) cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right') cbar.set_label(label='Acoustic backscatter signal (V)', rotation=270, labelpad=10) self.fig_BS.canvas.draw_idle() # plt.close(self.fig_BS) # self.plot_profile() def update_plot_backscattered_acoustic_signal_recording(self): # --- Condition if table is filled but transect is not plotted # --- => Error message if spin box values of tmin or tmax is change if self.canvas_BS == None: # if stg.BS_raw_data.size == 0: 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() else: # print("stg.BS_cross_section[self.fileListWidget.currentRow()].shape ", stg.BS_cross_section[self.fileListWidget.currentRow()].shape) if self.fileListWidget.currentRow() != -1: if len(self.axis_BS.tolist()) != stg.freq[self.fileListWidget.currentRow()].shape[0]: self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): self.axis_BS[f].cla() if stg.BS_cross_section[self.fileListWidget.currentRow()].shape != (0,): val_min = np.nanmin(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]) val_max = np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][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_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], stg.BS_cross_section[self.fileListWidget.currentRow()][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_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]), cmap='Blues') # --- Plot red solid line on transect to visualize position of plotted profile --- slider_value = \ [self.slider.value() - 1 if self.slider.value() - 1 <= stg.time_cross_section[self.fileListWidget.currentRow()].shape[ 1] - 1 else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0] self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( stg.time_cross_section[self.fileListWidget.currentRow()][ 0, # self.combobox_frequency_profile.currentIndex(), slider_value] * np.ones( stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1]), -stg.depth_cross_section[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :], color='red', linestyle="solid", linewidth=2) # --- Plot river bottom line --- # if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): # print("stg.depth_bottom ", stg.depth_bottom) # print("len(stg.depth_bottom) ", len(stg.depth_bottom)) self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][ self.combobox_frequency_bathymetry.currentIndex(), :], -stg.depth_bottom[self.fileListWidget.currentRow()], color='black', linewidth=1, linestyle="solid") else: val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][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[self.fileListWidget.currentRow()][f, :], -stg.depth[self.fileListWidget.currentRow()][f, :], stg.BS_raw_data[self.fileListWidget.currentRow()][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[self.fileListWidget.currentRow()][f, :], -stg.depth[self.fileListWidget.currentRow()][f, :], np.log( stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]), cmap='Blues') # --- Plot red solid line on transect to visualize position of plotted profile --- slider_value = \ [self.slider.value() - 1 if self.slider.value() - 1 <= stg.time[self.fileListWidget.currentRow()].shape[ 1] - 1 else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( stg.time[self.fileListWidget.currentRow()][0, slider_value] * np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]), -stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :], color='red', linestyle="solid", linewidth=2) # --- Plot river bottom line --- if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): self.axis_BS[f].plot(stg.time[self.fileListWidget.currentRow()][ self.combobox_frequency_bathymetry.currentIndex(), :], -stg.depth_bottom[self.fileListWidget.currentRow()], color='black', linewidth=1, linestyle="solid") self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][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() # self.fig_BS.canvas.flush_events() # plt.close(self.fig_BS) # # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) # # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) # # # --- Backscatter acoustic signal is recorded for next tab --- # # # stg.BS_cross_section = np.array([[[]]]) # # stg.t = np.array([[]]) # # # stg.tmin[self.fileListWidget.currentRow()] = ( # # np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], # # 2) - self.spinbox_tmin.value()) == # # np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], # # 2) - self.spinbox_tmin.value())))[0][ # # 0] # # ) # # # # stg.tmax[self.fileListWidget.currentRow()] = ( # # np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], # # 2) - self.spinbox_tmax.value()) == # # np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], # # 2) - self.spinbox_tmax.value())))[0][ # # 0] # # ) # # # # print(f"Update tmin {stg.tmin}") # # print(f"Update tmax {stg.tmax}") # # # # if (self.fileListWidget.count() == 1) and (len(stg.BS_cross_section) == 0): # # stg.BS_cross_section = [stg.BS_raw_data[self.fileListWidget.currentRow()][:, :, # # int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]] # # elif (self.fileListWidget.count() > 1) and (len(stg.BS_cross_section) < self.fileListWidget.count()): # # stg.BS_cross_section = ( # # np.append(stg.BS_cross_section, # # stg.BS_raw_data[self.fileListWidget.currentRow()][:, :, # # int(stg.tmin[self.fileListWidget.currentRow()]):int( # # stg.tmax[self.fileListWidget.currentRow()])]) # # ) # # else: # # stg.BS_cross_section[self.fileListWidget.currentRow()] = ( # # stg.BS_raw_data[self.fileListWidget.currentRow()] # # [:, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]) # # # # # # if (self.fileListWidget.count() == 1) and (len(stg.t) == 0): # # stg.t = [stg.time[self.fileListWidget.currentRow()][:, # # int(stg.tmin[self.fileListWidget.currentRow()]):int( # # stg.tmax[self.fileListWidget.currentRow()])]] # # elif self.fileListWidget.count() > 1: # # stg.t = np.append(stg.t, # # stg.time[self.fileListWidget.currentRow()][:, # # int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]) # # else: # # stg.t[self.fileListWidget.currentRow()] = stg.time[self.fileListWidget.currentRow()][:, # # int(stg.tmin[self.fileListWidget.currentRow()]):int( # # stg.tmax[self.fileListWidget.currentRow()])] # # # stg.t = np.append(stg.t, np.array([stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) # # # # # print("stg.t[self.fileListWidget.currentRow()].shape() ", stg.t[self.fileListWidget.currentRow()].shape()) # # print("0/ stg.freq before plot : ", stg.freq) # # print("2/ stg.freq after plot : ", stg.freq[self.fileListWidget.currentRow()]) # for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): # # # print(f"f = {f}") # # # stg.tmin[f] = np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][f, :], 2) - self.spinbox_tmin.value()) == # # np.nanmin(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmin.value())))[0][0] # # # # 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(self.fileListWidget.count()) # # print(stg.BS_cross_section[self.fileListWidget.currentRow()].shape) # # if stg.BS_cross_section[self.fileListWidget.currentRow()].shape[2] == 0: # # if self.fileListWidget.count() == 1: # # stg.BS_cross_section = np.array( # # [stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]) # # else: # # stg.BS_cross_section[self.fileListWidget.currentRow()] = ( # # np.append(stg.BS_cross_section[self.fileListWidget.currentRow()], # # np.array([stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]), 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) # # 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[self.fileListWidget.currentRow()].shape[1] == 0: # # if self.fileListWidget.count() == 1: # # stg.t = np.array([stg.time[self.fileListWidget.currentRow()][f, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]) # # else: # # stg.t[self.fileListWidget.currentRow()] = np.append(stg.t[self.fileListWidget.currentRow()], # # np.array([stg.time[self.fileListWidget.currentRow()][f, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]), 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[self.fileListWidget.currentRow()].shape) # # print(f"stg.t : {stg.t}") # # stg.depth_2D = stg.depth_2D[:, 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]] # # print("stg.depth shape ", stg.depth_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[self.fileListWidget.currentRow()].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]]) # # # print("self.axis_BS ", self.axis_BS) # # print(f"self.axis_BS[{f}] ", self.axis_BS[f]) # self.axis_BS[f].cla() # # if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): # # # print("stg.BS_cross_section[self.fileListWidget.currentRow()].shape ", # # stg.BS_cross_section[self.fileListWidget.currentRow()].shape) # # val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) # val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) # if val_min == 0: # val_min = 1e-5 # # # print("stg.t[f, :].shape ", stg.t[f]) # # print("stg.depth[f, :].shape ", stg.depth[f, :]) # # if self.combobox_ABS_system_choice.currentIndex() == 1: # pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :], # -stg.depth[self.fileListWidget.currentRow()][f, # :], # stg.BS_raw_data[self.fileListWidget.currentRow()][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[self.fileListWidget.currentRow()][f, :], # -stg.depth[self.fileListWidget.currentRow()][f, # :], # np.log( # stg.BS_raw_data[self.fileListWidget.currentRow()][f, # :, :]), # cmap='Blues') # # # --- Plot red solid line on transect to visualize position of plotted profile --- # slider_value = \ # [self.slider.value() - 1 if self.slider.value() - 1 <= # stg.time[self.fileListWidget.currentRow()].shape[ # 1] - 1 # else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] # # self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( # stg.time[self.fileListWidget.currentRow()][ # 0, # self.combobox_frequency_profile.currentIndex(), # slider_value] * np.ones( # stg.depth[self.fileListWidget.currentRow()].shape[1]), # -stg.depth[self.fileListWidget.currentRow()][ # self.combobox_frequency_profile.currentIndex(), :], # color='red', linestyle="solid", linewidth=2) # # else: # # # print("stg.BS_cross_section[self.fileListWidget.currentRow()].shape ", # # stg.BS_cross_section[self.fileListWidget.currentRow()].shape) # # val_min = np.nanmin(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]) # val_max = np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]) # if val_min == 0: # val_min = 1e-5 # # # print("stg.t[f, :].shape ", stg.t[f]) # # print("stg.depth[f, :].shape ", stg.depth[f, :]) # # if self.combobox_ABS_system_choice.currentIndex() == 1: # pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :], # -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], # stg.BS_cross_section[self.fileListWidget.currentRow()][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_cross_section[self.fileListWidget.currentRow()][f, :], # -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], # np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]), # cmap='Blues') # # # --- Plot red solid line on transect to visualize position of plotted profile --- # slider_value = \ # [self.slider.value() - 1 if self.slider.value() - 1 <= # stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1 # else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0] # # self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( # stg.time_cross_section[self.fileListWidget.currentRow()][ # 0, # self.combobox_frequency_profile.currentIndex(), # slider_value] * np.ones( # stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1]), # -stg.depth_cross_section[self.fileListWidget.currentRow()][ # self.combobox_frequency_profile.currentIndex(), :], # color='red', linestyle="solid", linewidth=2) # # # --- Plot river bottom line --- # # # if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): # if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0: # # # print("stg.depth_bottom ", stg.depth_bottom) # # print("len(stg.depth_bottom) ", len(stg.depth_bottom)) # self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :], # -stg.depth_bottom[self.fileListWidget.currentRow()], # color='black', linewidth=1, linestyle="solid") # # self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][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() # # self.fig_BS.canvas.flush_events() # # plt.close(self.fig_BS) def plot_profile(self): if self.fileListWidget.currentRow() != -1: self.combobox_frequency_profile.setCurrentIndex(0) self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_profile) self.combobox_frequency_profile.currentIndexChanged.connect( self.update_plot_backscattered_acoustic_signal_recording) # self.slider.setMaximum(stg.BS_raw_data[self.fileListWidget.currentRow()].shape[2]) self.slider.setMaximum(stg.time[self.fileListWidget.currentRow()].shape[1]) self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) # --- 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) # for f, _ in enumerate(stg.freq[0]): slider_value = [ self.slider.value() - 1 if self.slider.value() - 1 <= stg.time[self.fileListWidget.currentRow()].shape[ 1] - 1 else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] # --- Profile plot --- # self.axis_profile.cla() self.axis_profile.plot(stg.BS_raw_data[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], -stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) self.axis_profile.text(.95, .05, stg.freq_text[self.fileListWidget.currentRow()][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) # --- Plot bottom line --- # if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0: self.axis_profile.plot([0, np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :, slider_value])], -stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] * np.ones(2), linestyle='solid', color='r', linewidth=1) position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / np.nanmax( stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :])) self.axis_profile.text(.95, 1 - position_x + 0.05, "River bed", fontsize=10, fontweight='normal', fontname="Times New Roman", fontstyle="italic", c="red", alpha=0.2, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_profile.transAxes) self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.fig_profile.supylabel("Depth (m)") self.fig_profile.canvas.draw_idle() # plt.close(self.fig_profile) # self.plot_transect_with_BS_raw_data() # 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) def update_plot_profile(self): # print("len(stg.BS_cross_section) ", len(stg.BS_cross_section)) # if (len(stg.BS_cross_section) == 0) and (len(stg.BS_raw_data) != 0): if self.fileListWidget.currentRow() != -1: if stg.BS_cross_section[self.fileListWidget.currentRow()].shape != (0,): self.axis_profile.cla() # --- Set slider value --- self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) slider_value = [self.slider.value() - 1 if self.slider.value() - 1 <= stg.time_cross_section[ self.fileListWidget.currentRow()].shape[1] - 1 else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0] # --- Profile plot --- self.axis_profile.plot(stg.BS_cross_section[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :, slider_value], -stg.depth_cross_section[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) # --- Write frequency on graph --- self.axis_profile.text(.95, .90, stg.freq_text[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex()], fontsize=14, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_profile.transAxes) # --- Plot bottom line --- if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): self.axis_profile.plot([0, np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :, slider_value])], -stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][ slider_value]] * np.ones(2), linestyle='solid', color='r', linewidth=1) position_x = (stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / np.nanmax(stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :])) self.axis_profile.text(.95, 1 - position_x + 0.05, "River bed", fontsize=10, fontweight='normal', fontname="Ubuntu", fontstyle="italic", c="red", alpha=0.2, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_profile.transAxes) else: self.axis_profile.cla() # --- Set slider value --- self.slider.setMaximum(stg.time[self.fileListWidget.currentRow()].shape[1]) slider_value = [self.slider.value() - 1 if self.slider.value() - 1 <= stg.time[ self.fileListWidget.currentRow()].shape[1] - 1 else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] # --- Profile plot --- self.axis_profile.plot(stg.BS_raw_data[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], -stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) # --- Write frequency on graph --- self.axis_profile.text(.95, .05, stg.freq_text[self.fileListWidget.currentRow()][ 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) # --- Plot bottom line --- if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): self.axis_profile.plot([0, np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :, slider_value])], -stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][ slider_value]] * np.ones(2), linestyle='solid', color='r', linewidth=1) position_x = (stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / np.nanmax(stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :])) self.axis_profile.text(.95, 1 - position_x + 0.05, "River bed", fontsize=10, fontweight='normal', fontname="Ubuntu", fontstyle="italic", c="red", alpha=0.2, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_profile.transAxes) self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.fig_profile.supylabel("Depth (m)") self.fig_profile.canvas.draw_idle() # self.fig_profile.canvas.flush_events() # plt.close(self.fig_profile) def slide_profile_number_to_begin(self): self.slider.setValue(int(self.slider.minimum())) self.lineEdit_slider.setText(str(self.slider.value())) def slide_profile_number_to_right(self): self.slider.setValue(int(self.slider.value()) + 1) self.lineEdit_slider.setText(str(self.slider.value())) def slide_profile_number_to_left(self): self.slider.setValue(int(self.slider.value()) - 1) self.lineEdit_slider.setText(str(self.slider.value())) def slide_profile_number_to_end(self): self.slider.setValue(int(self.slider.maximum())) self.lineEdit_slider.setText(str(self.slider.value())) def profile_number_on_lineEdit(self): self.slider.setValue(int(self.lineEdit_slider.text())) def update_lineEdit_by_moving_slider(self): self.lineEdit_slider.setText(str(self.slider.value())) # 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.depth) # # # # 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.depth[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.depth[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() # 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.depth[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.depth[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.fileListWidget.count() == 0: msgBox = QMessageBox() msgBox.setWindowTitle("Detect bottom Error") msgBox.setIcon(QMessageBox.Warning) 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.canvas_BS == None: msgBox = QMessageBox() msgBox.setWindowTitle("Detect bottom Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText("Plot transect before compute bathymety algorithm") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() # elif self.canvas_SNR == None: # msgBox = QMessageBox() # msgBox.setWindowTitle("Detect bottom Error") # msgBox.setIcon(QMessageBox.Warning) # msgBox.setText("Plot transect before compute bathymety algorithm") # msgBox.setStandardButtons(QMessageBox.Ok) # msgBox.exec() elif self.canvas_BS != None: # --- Record frequency choose for bottom detection --- # if ((self.fileListWidget.count() == 1) and (len(stg.freq_bottom_detection) == 0)): # # stg.freq_bottom_detection = [self.combobox_frequency_bathymetry.currentIndex()] # # elif len(stg.rmax) < self.fileListWidget.count(): # # stg.freq_bottom_detection.append(self.combobox_frequency_bathymetry.currentIndex()) # if stg.depth_bottom == []: # stg.freq_bottom_detection = [np.array([])]*self.fileListWidget.count() # stg.depth_bottom = [np.array([])]*self.fileListWidget.count() # stg.val_bottom = [np.array([])]*self.fileListWidget.count() # stg.ind_bottom = [np.array([])]*self.fileListWidget.count() if stg.BS_cross_section[self.fileListWidget.currentRow()].shape != (0,): stg.freq_bottom_detection[self.fileListWidget.currentRow()] = self.combobox_frequency_bathymetry.currentIndex() # Selecting the range in which we look for the bottom reflection # rmin = np.float32(self.doubleRangeSlider_intg_area.value()[0].text().replace(",", ".")) # rmax = np.float32(self.doubleRangeSlider_intg_area.value()[1].text().replace(",", ".")) # rmin = -self.doubleRangeSlider_intg_area.value()[1] # rmax = -self.doubleRangeSlider_intg_area.value()[0] rmin = self.spinbox_depth_min_bathy.value() rmax = self.spinbox_depth_max_bathy.value() print("rmin ", rmin) print("rmax ", rmax) # empty result arrays # r_bottom = np.zeros(stg.nb_profiles) # val_bottom = np.zeros(stg.nb_profiles) r_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) val_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) r_bottom_ind = [] # print(f"r_bottom shape with zeros : {r_bottom.shape}") BS_smooth = deepcopy(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :, :]) # print(f"BS_smooth shape : {BS_smooth.shape}") for k in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]): BS_smooth[:, k] = savgol_filter(BS_smooth[:, k], 10, 2) # fig1, ax1 = plt.subplots(nrows=1, ncols=1, layout="constrained") # pcm1 = ax1.pcolormesh(stg.time_cross_section[0][0, :], -stg.depth_cross_section[0][0, :], (BS_smooth[:, :]), cmap='Blues') # fig1.colorbar(pcm1, ax=ax1, shrink=1, location='right') # plt.show() # ----------- Detecting the bottom ------------- # for d in range(stg.nb_profiles): for d in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]): # Index of the range where we look for the peak # print(f"self.combobox_freq_choice.currentIndex() : {self.combobox_freq_choice.currentIndex()}") # print(f"r = {stg.r}") # print(f"ind_min : {np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][int(self.combobox_frequency_bathymetry.currentIndex()), :] >= rmin)}") # print(f"ind_max : {np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][int(self.combobox_frequency_bathymetry.currentIndex()), :] <= rmax)}") ind_min = np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][int(self.combobox_frequency_bathymetry.currentIndex()), :] >= rmin)[0][0] ind_max = np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][int(self.combobox_frequency_bathymetry.currentIndex()), :] <= rmax)[0][-1] # Getting the peak try: # val_bottom[d] = np.nanmax((stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d])) val_bottom[d] = np.nanmax(BS_smooth[ind_min:ind_max, d]) # print('---------------------------------------------------') # print(f"d = {d}") # print("stg.BS_raw_data[ind_min:ind_max] : ", stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d]) except ValueError as e: msgBox = QMessageBox() msgBox.setWindowTitle("Detect bottom Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText(f"1/ {e} : maximum value of section bottom is not found. \n " f"Please change parameter of algorithm") msgBox.setStandardButtons(QMessageBox.Ok) msgBox_return = msgBox.exec() if msgBox_return == msgBox.Ok: break #msgBox.close() else: # Getting the range cell of the peak # ind_bottom = np.where((stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d]) # == val_bottom[d])[0][0] ind_bottom = np.where((BS_smooth[ind_min:ind_max, d]) == val_bottom[d])[0][0] np.append(stg.ind_bottom, ind_bottom) r_bottom[d] = stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), ind_bottom + ind_min] r_bottom_ind.append(ind_bottom + ind_min) # Updating the range where we will look for the peak (in the next cell) # rmin = r_bottom[d] - locale.atof(self.doublespinbox_next_cell.text()) # rmax = r_bottom[d] + locale.atof(self.doublespinbox_next_cell.text()) # rmin = r_bottom[d] - np.float32(self.spinbox_offset_next_cell.text().replace(",", ".")) # rmax = r_bottom[d] + np.float32(self.spinbox_offset_next_cell.text().replace(",", ".")) rmin = r_bottom[d] - self.doublespinbox_next_cell_bathy.value() rmax = r_bottom[d] + self.doublespinbox_next_cell_bathy.value() # --- Plot vertical profile for bottom detection --- # n = 60 # t0 = 200 # t1 = np.where(np.abs(stg.time[0, :] - t0) == np.nanmin(np.abs(stg.time[0, :] - t0)))[0][0] # # print(np.abs(self._time[0, :] - 200)) # # print(f"x0 = {x0}") # r1 = 98 # r2 = 150 # fig2, ax2 = plt.subplots(nrows=1, ncols=n, layout="constrained") # for i in range(n): # ax2[i].plot(stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), r1:r2, t1 + i], # -stg.r[0, r1:r2], 'b') # ax2[i].plot(BS_smooth[r1:r2, t1 + i], -stg.r[0, r1:r2], 'r') # ax2[i].scatter(val_bottom[i], -r_bottom[i], marker="o", fc="black", s=12) # ax2[i].set_xticks([]) # if i != 0: # ax2[i].set_yticks([]) # plt.show() # print(f"r_bootom shape : {r_bottom.shape}") BS_section_bottom = np.zeros((stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1], stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])) for i in range(BS_section_bottom.shape[0]): try: # print(f"r_bottom_ind : {r_bottom_ind}") BS_section_bottom[r_bottom_ind[i]][i] = 1 except IndexError as e: msgBox = QMessageBox() msgBox.setWindowTitle("Detect bottom Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText(f"2/ {e} : maximum value of section bottom is not found. \n " f"Please change parameter of algorithm") msgBox.setStandardButtons(QMessageBox.Ok) msgBox_return = msgBox.exec() if msgBox_return == msgBox.Ok: break # msgBox.close() if BS_section_bottom.sum() > 2: # --- Record r_bottom for other tabs --- # stg.r_bottom = 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]] # stg.val_bottom = val_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]] stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom print("stg.depth_bottom", stg.depth_bottom) stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom print("stg.val_bottom", stg.val_bottom) stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind print("stg.ind_bottom", stg.ind_bottom) # if ((self.fileListWidget.count() == 1) and (len(stg.depth_bottom) == 0)): # stg.depth_bottom = [r_bottom]#[int(stg.tmin[self.combobox_freq_choice.currentIndex()]): # # int(stg.tmax[self.combobox_freq_choice.currentIndex()])] # stg.val_bottom = [val_bottom]#[int(stg.tmin[self.combobox_freq_choice.currentIndex()]): # # int(stg.tmax[self.combobox_freq_choice.currentIndex()])] # stg.ind_bottom = [r_bottom_ind] # # elif len(stg.depth_bottom) < self.fileListWidget.count(): # # stg.depth_bottom.append(r_bottom) # # stg.val_bottom.append(val_bottom) # # stg.ind_bottom.append(r_bottom_ind) # # else: # # stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom # # stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom # # stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind BS_stream_bed_copy = deepcopy(stg.BS_cross_section[self.fileListWidget.currentRow()]) for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): for k, _ in enumerate(stg.depth_bottom[self.fileListWidget.currentRow()]): # print(k, np.where(stg.r >= stg.r_bottom[k])[0]) BS_stream_bed_copy[ f, np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :] >= stg.depth_bottom[self.fileListWidget.currentRow()][k])[ 0], k] = np.nan stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy # if ((self.fileListWidget.count() == 1) and (len(stg.BS_stream_bed) == 0)): # # stg.BS_stream_bed = [BS_stream_bed_copy] # # elif len(stg.BS_stream_bed) < self.fileListWidget.count(): # # stg.BS_stream_bed.append(BS_stream_bed_copy) # # else: # # stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy # --- Plot transect BS with bathymetry --- for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): self.axis_BS[f].cla() val_min = np.min(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) val_max = np.max(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) if val_min == 0: val_min = 1e-5 # pcm = self.axis_BS[f].pcolormesh( # 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, # (stg.BS_raw_data[:, 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]]), # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) if self.combobox_ABS_system_choice.currentIndex() == 1: pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], stg.BS_cross_section[self.fileListWidget.currentRow()][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_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]), cmap='Blues') # self.axis_BS[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]], # color='black', linewidth=1, linestyle="solid") # print("stg.t[self.combobox_freq_choice.currentIndex(), :] : ", stg.t[self.combobox_freq_choice.currentIndex(), :].shape) # print("-stg.r_bottom : ", stg.r_bottom.shape) self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :], -stg.depth_bottom[self.fileListWidget.currentRow()], color='black', linewidth=1, linestyle="solid") self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_BS[f].transAxes) # --- Update plot profile --- self.update_plot_profile() self.fig_BS.canvas.draw_idle() elif stg.BS_raw_data[self.fileListWidget.currentRow()].shape != (0,): print("I'm here for bottom detection") stg.freq_bottom_detection[ self.fileListWidget.currentRow()] = self.combobox_frequency_bathymetry.currentIndex() # Selecting the range in which we look for the bottom reflection # rmin = -self.doubleRangeSlider_intg_area.value()[1] # rmax = -self.doubleRangeSlider_intg_area.value()[0] rmin = self.spinbox_depth_min_bathy.value() rmax = self.spinbox_depth_max_bathy.value() # empty result arrays r_bottom = np.zeros(stg.time[self.fileListWidget.currentRow()].shape[1]) val_bottom = np.zeros(stg.time[self.fileListWidget.currentRow()].shape[1]) r_bottom_ind = [] BS_smooth = deepcopy(stg.BS_raw_data[self.fileListWidget.currentRow()][ self.combobox_frequency_bathymetry.currentIndex(), :, :]) # print(f"BS_smooth shape : {BS_smooth.shape}") for k in range(stg.time[self.fileListWidget.currentRow()].shape[1]): BS_smooth[:, k] = savgol_filter(BS_smooth[:, k], 10, 2) # ----------- Detecting the bottom ------------- for d in range(stg.time[self.fileListWidget.currentRow()].shape[1]): # Index of the range where we look for the peak ind_min = np.where(stg.depth[self.fileListWidget.currentRow()][ int(self.combobox_frequency_bathymetry.currentIndex()), :] >= rmin)[0][0] ind_max = np.where(stg.depth[self.fileListWidget.currentRow()][ int(self.combobox_frequency_bathymetry.currentIndex()), :] <= rmax)[0][-1] # Getting the peak try: val_bottom[d] = np.nanmax(BS_smooth[ind_min:ind_max, d]) except ValueError as e: msgBox = QMessageBox() msgBox.setWindowTitle("Detect bottom Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText(f"1/ {e} : maximum value of section bottom is not found. \n " f"Please change parameter of algorithm") msgBox.setStandardButtons(QMessageBox.Ok) msgBox_return = msgBox.exec() if msgBox_return == msgBox.Ok: break # msgBox.close() else: # Getting the range cell of the peak ind_bottom = np.where((BS_smooth[ind_min:ind_max, d]) == val_bottom[d])[0][0] np.append(stg.ind_bottom, ind_bottom) r_bottom[d] = stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_bathymetry.currentIndex(), ind_bottom + ind_min] r_bottom_ind.append(ind_bottom + ind_min) # Updating the range where we will look for the peak (in the next cell) # rmin = r_bottom[d] - np.float32(self.spinbox_offset_next_cell.text().replace(",", ".")) # rmax = r_bottom[d] + np.float32(self.spinbox_offset_next_cell.text().replace(",", ".")) rmin = r_bottom[d] - self.doublespinbox_next_cell_bathy.value() rmax = r_bottom[d] + self.doublespinbox_next_cell_bathy.value() BS_section_bottom = np.zeros((stg.depth[self.fileListWidget.currentRow()].shape[1], stg.time[self.fileListWidget.currentRow()].shape[1])) for i in range(BS_section_bottom.shape[0]): try: BS_section_bottom[r_bottom_ind[i]][i] = 1 except IndexError as e: msgBox = QMessageBox() msgBox.setWindowTitle("Detect bottom Error") msgBox.setIcon(QMessageBox.Warning) msgBox.setText(f"2/ {e} : maximum value of section bottom is not found. \n " f"Please change parameter of algorithm") msgBox.setStandardButtons(QMessageBox.Ok) msgBox_return = msgBox.exec() if msgBox_return == msgBox.Ok: break # msgBox.close() if BS_section_bottom.sum() > 2: # --- Record r_bottom for other tabs --- stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind BS_stream_bed_copy = deepcopy(stg.BS_raw_data[self.fileListWidget.currentRow()]) for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): for k, _ in enumerate(stg.depth_bottom[self.fileListWidget.currentRow()]): # print(k, np.where(stg.r >= stg.r_bottom[k])[0]) BS_stream_bed_copy[ f, np.where(stg.depth[self.fileListWidget.currentRow()][ self.combobox_frequency_bathymetry.currentIndex(), :] >= stg.depth_bottom[self.fileListWidget.currentRow()][k])[ 0], k] = np.nan stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy # --- Plot transect BS with bathymetry --- for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): self.axis_BS[f].cla() val_min = np.min(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) val_max = np.max(stg.BS_raw_data[self.fileListWidget.currentRow()][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[self.fileListWidget.currentRow()][f, :], -stg.depth[self.fileListWidget.currentRow()][f, :], stg.BS_raw_data[self.fileListWidget.currentRow()][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[self.fileListWidget.currentRow()][f, :], -stg.depth[self.fileListWidget.currentRow()][f, :], np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]), cmap='Blues') self.axis_BS[f].plot(stg.time[self.fileListWidget.currentRow()][ self.combobox_frequency_bathymetry.currentIndex(), :], -stg.depth_bottom[self.fileListWidget.currentRow()], color='black', linewidth=1, linestyle="solid") self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', transform=self.axis_BS[f].transAxes) # --- Update plot profile --- self.update_plot_profile() self.fig_BS.canvas.draw_idle() # print("stg.freq_bottom_detection : ", stg.freq_bottom_detection) # print("stg.depth_bottom : ", stg.depth_bottom) # print("stg.val_bottom : ", stg.val_bottom) # print("stg.ind_bottom : ", stg.ind_bottom) # # --- 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.depth) # # 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.depth[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.depth[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.depth_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: # # acoustic_data = self.load_BS_acoustic_raw_data() # # Selecting the range in which we look for the bottom reflection # rmin = np.int(self.spinbox_depth_min.text()) # 4 # rmax = np.int(self.spinbox_depth_max.text()) # 8 # # # empty result arrays # r_bottom = np.zeros(acoustic_data._nb_profiles) # val_bottom = np.zeros(acoustic_data._nb_profiles) # r_bottom_ind = [] # # ----------- Detecting the bottom ------------- # for d in range(acoustic_data._nb_profiles): # # Index of the range where we look for the peak # ind_min = np.where(acoustic_data._r >= rmin)[0][0] # ind_max = np.where(acoustic_data._r <= rmax)[0][-1] # # Getting the peak # val_bottom[d] = np.nanmax(acoustic_data._BS_raw_data[ind_min:ind_max, # self.combobox_freq_choice.currentIndex() - 1, d]) # # Getting the range cell of the peak # ind_bottom = np.where(acoustic_data._BS_raw_data[ind_min:ind_max, # self.combobox_freq_choice.currentIndex() - 1, d] == val_bottom[d])[0][0] # r_bottom[d] = acoustic_data._r[ind_bottom + ind_min] # r_bottom_ind.append(ind_bottom + ind_min) # # Updating the range where we will look for the peak (in the next cell) # rmin = r_bottom[d] - locale.atof(self.doublespinbox_next_cell.text()) # 0.75 # rmax = r_bottom[d] + locale.atof(self.doublespinbox_next_cell.text()) # 0.75 # # BS_section_bottom = np.zeros((acoustic_data._BS_raw_data.shape[0], acoustic_data._BS_raw_data.shape[2])) # # for i in range(BS_section_bottom.shape[0]): # # print(r_bottom_temp_ind[i]) # # print(i) # BS_section_bottom[r_bottom_ind[i]][i] = 1 # # print(BS_section_bottom[r_bottom_temp_ind[i]][i]) # # # --- Plot transect BS with bathymetry --- # for f in range(acoustic_data._freq.shape[0]): # self.axis_BS[f].cla() # # val_min = np.min(acoustic_data._BS_raw_data[:, f, :]) # val_max = np.max(acoustic_data._BS_raw_data[:, f, :]) # if val_min == 0: # val_min = 1e-5 # # pcm = self.axis_BS[f].pcolormesh( # acoustic_data._time[np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: # np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]], # -acoustic_data._r, # (acoustic_data._BS_raw_data[:, f, # np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: # np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]]), # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) # , shading='gouraud') # # self.axis_BS[f].plot( # acoustic_data._time[np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: # np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]], # # np.max(r_bottom[np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: # # np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]]), # - r_bottom[np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: # np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmax.value())[0][0]], # # + np.min(r_bottom[np.where(np.round(acoustic_data._time, 2) == self.spinbox_tmin.value())[0][0]: # # np.where(np.round(acoustic_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_BS[f].text(1, .70, acoustic_data._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('Distance from left bank (m)', fontsize=10) # self.fig_BS.supylabel('Depth (m)', fontsize=10) # # plt.subplots_adjust(bottom=0.125, top=0.98, right=1.03, left=0.08, hspace=0.1) # # self.fig.tight_layout() # cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right') # cbar.set_label(label='Backscatter acoustic signal (V)', rotation=270, labelpad=10) # self.fig_SNR.canvas.draw_idle() # return r_bottom, val_bottom, r_bottom_ind, BS_section_bottom