1329 lines
70 KiB
Python
1329 lines
70 KiB
Python
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)
|
|
from PyQt5.QtGui import QPixmap, QIcon
|
|
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, '')
|
|
|
|
# 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 View.window_noise_level_averaged_profile import WindowNoiseLevelTailAveragedProfile
|
|
|
|
from View.sample_data_tab import SampleDataTab
|
|
|
|
import settings as stg
|
|
|
|
_translate = QCoreApplication.translate
|
|
|
|
|
|
class AcousticDataTab(QWidget):
|
|
|
|
''' This class generates the Acoustic Data Tab '''
|
|
|
|
def __init__(self, tab_widget):
|
|
super().__init__()
|
|
|
|
path_icon = "./icons/"
|
|
icon_folder = QIcon(path_icon + "folder.png")
|
|
|
|
### --- General layout of widgets ---
|
|
|
|
self.verticalLayoutMain = QVBoxLayout(tab_widget)
|
|
|
|
self.horizontalLayoutTop = QHBoxLayout()
|
|
self.verticalLayoutMain.addLayout(self.horizontalLayoutTop, 4) # 1O units is 100% , 1 units is 10%
|
|
|
|
self.horizontalLayoutBottom = QHBoxLayout()
|
|
self.verticalLayoutMain.addLayout(self.horizontalLayoutBottom, 6)
|
|
|
|
### --- Layout of groupbox in the Top horizontal layout box
|
|
|
|
# Download | Measurement information | Table of values | Display options
|
|
|
|
self.groupbox_download = QGroupBox()
|
|
self.horizontalLayoutTop.addWidget(self.groupbox_download, 3)
|
|
|
|
self.groupbox_info = QGroupBox()
|
|
self.horizontalLayoutTop.addWidget(self.groupbox_info, 3)
|
|
|
|
self.groupbox_table = QGroupBox()
|
|
self.horizontalLayoutTop.addWidget(self.groupbox_table, 4)
|
|
|
|
self.groupbox_display_option = QGroupBox()
|
|
self.horizontalLayoutTop.addWidget(self.groupbox_display_option, 3)
|
|
|
|
### --- Layout of groupbox in the Bottom horizontal layout box
|
|
|
|
# 2D field of raw acoustic backscatter data | 2D field of Signal to Noise ratio
|
|
|
|
self.groupbox_transect_2Dplot_raw_BS_data = QGroupBox()
|
|
self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_raw_BS_data)
|
|
|
|
self.groupbox_transect_2Dplot_snr_data = QGroupBox()
|
|
self.horizontalLayoutBottom.addWidget(self.groupbox_transect_2Dplot_snr_data)
|
|
|
|
# =====================================================
|
|
# TOP HORIZONTAL BOX LAYOUT
|
|
# =====================================================
|
|
|
|
# +++++++++++++++++++++++++++
|
|
# | Group box Download file |
|
|
# +++++++++++++++++++++++++++
|
|
|
|
self.verticalLayout_groupbox_download = QVBoxLayout(self.groupbox_download)
|
|
|
|
# --- Group box acoustic file ---
|
|
|
|
self.groupbox_acoustic_file = QGroupBox()
|
|
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.pushbutton_acoustic_file = QPushButton()
|
|
self.pushbutton_acoustic_file.setObjectName("pushbutton_acoustic_file")
|
|
self.pushbutton_acoustic_file.setIcon(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)
|
|
|
|
self.label_date_groupbox_acoustic_file = QLabel()
|
|
self.gridLayout_groupbox_acoustic_file.addWidget(self.label_date_groupbox_acoustic_file, 1, 0, 1, 2)
|
|
self.label_hour_groupbox_acoustic_file = QLabel()
|
|
self.gridLayout_groupbox_acoustic_file.addWidget(self.label_hour_groupbox_acoustic_file, 1, 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)
|
|
|
|
self.verticalLayout_groupbox_download.addWidget(self.groupbox_acoustic_file)
|
|
|
|
# --- Group box noise file ---
|
|
|
|
self.groupbox_noise_file = QGroupBox()
|
|
self.gridLayout_groupbox_noise_file = QGridLayout(self.groupbox_noise_file)
|
|
|
|
self.pushbutton_noise_level_with_tail_of_mean_profile = QPushButton()
|
|
self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_level_with_tail_of_mean_profile, 0, 0, 1, 1)
|
|
self.pushbutton_noise_file = QPushButton()
|
|
self.pushbutton_noise_file.setObjectName("pushbutton_noise_file")
|
|
self.pushbutton_noise_file.setIcon(icon_folder)
|
|
self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_file, 0, 1, 1, 1)
|
|
self.lineEdit_noise_file = QLineEdit()
|
|
self.gridLayout_groupbox_noise_file.addWidget(self.lineEdit_noise_file, 0, 2, 1, 1)
|
|
|
|
self.label_date_groupbox_noise_file = QLabel()
|
|
self.gridLayout_groupbox_noise_file.addWidget(self.label_date_groupbox_noise_file, 1, 0, 1, 2)
|
|
self.label_hour_groupbox_noise_file = QLabel()
|
|
self.gridLayout_groupbox_noise_file.addWidget(self.label_hour_groupbox_noise_file, 1, 2, 1, 1)
|
|
|
|
# Download Push Button event : connect button clicked signal to open file slot
|
|
self.pushbutton_noise_file.clicked.connect(self.open_dialog_box)
|
|
|
|
self.verticalLayout_groupbox_download.addWidget(self.groupbox_noise_file)
|
|
|
|
# --- Group box GPS file ---
|
|
|
|
self.groupbox_gps_file = QGroupBox()
|
|
self.gridLayout_groupbox_gps_file = QGridLayout(self.groupbox_gps_file)
|
|
|
|
self.combobox_gps_system_choice = QComboBox()
|
|
self.combobox_gps_system_choice.addItems([" ", "GPS1", "GPS2", "no GPS"])
|
|
self.gridLayout_groupbox_gps_file.addWidget(self.combobox_gps_system_choice, 0, 0, 1, 1)
|
|
self.pushbutton_gps_file = QPushButton()
|
|
self.pushbutton_gps_file.setIcon(icon_folder)
|
|
self.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, 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, 1)
|
|
|
|
# Download Push Button event : connect button clicked signal to open file slot
|
|
# self.pushButton_gpsfile.clicked.connect(self.open_dialog_box)
|
|
|
|
self.verticalLayout_groupbox_download.addWidget(self.groupbox_gps_file)
|
|
|
|
# --- 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.label_acoustic_gps_time = QLabel()
|
|
self.label_acoustic_gps_time.setText(
|
|
"T<span style= vertical-align:sub>acoustic</span> =" + " T<span style= vertical-align:sub>gps</span>")
|
|
self.gridLayout_time_offset.addWidget(self.label_acoustic_gps_time, 0, 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.spinbox_time_offset_value = QSpinBox()
|
|
self.gridLayout_time_offset.addWidget(self.spinbox_time_offset_value, 0, 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.verticalLayout_groupbox_download.addLayout(self.gridLayout_time_offset)
|
|
|
|
# ++++++++++++++++++++++++++++++++++++++
|
|
# | Group Box Measurements information |
|
|
# ++++++++++++++++++++++++++++++++++++++
|
|
|
|
self.gridLayout_goupbox_info = QGridLayout(self.groupbox_info)
|
|
|
|
self.label_profiles = QLabel()
|
|
self.label_profiles_per_sec = QLabel()
|
|
self.label_cells = QLabel()
|
|
self.label_cell_size = QLabel()
|
|
self.label_pulse_length = QLabel()
|
|
self.label_pings_per_sec = QLabel()
|
|
self.label_pings_per_profile = QLabel()
|
|
self.label_freq = QLabel()
|
|
self.label_kt = QLabel()
|
|
self.label_rx = QLabel()
|
|
self.label_tx = QLabel()
|
|
|
|
self.label_to_do = QLabel()
|
|
self.label_to_do.setText("UBSediFlow data : to do for Oct. 20th")
|
|
|
|
# self.groupbox_measurement_information_Aquascat()
|
|
self.combobox_ABS_system_choice.currentTextChanged.connect(self.ABS_system_choice)
|
|
|
|
# +++++++++++++++++++++++++++++
|
|
# | Group Box Table of values |
|
|
# +++++++++++++++++++++++++++++
|
|
|
|
self.verticalLayout_groupbox_table = QVBoxLayout(self.groupbox_table)
|
|
|
|
self.horizontalLayout_pushbutton_fill_export_table = QHBoxLayout()
|
|
self.pushbutton_fill_table = QPushButton()
|
|
self.horizontalLayout_pushbutton_fill_export_table.addWidget(self.pushbutton_fill_table)
|
|
|
|
self.pushbutton_fill_table.clicked.connect(self.fill_table)
|
|
|
|
self.horizontalSpacerItem_between_pushbutton_fill_export_table = QSpacerItem(50, 10,
|
|
QSizePolicy.Expanding, QSizePolicy.Minimum)
|
|
self.horizontalLayout_pushbutton_fill_export_table.addItem(
|
|
self.horizontalSpacerItem_between_pushbutton_fill_export_table)
|
|
|
|
self.pushbutton_export_table = QPushButton()
|
|
self.horizontalLayout_pushbutton_fill_export_table.addWidget(self.pushbutton_export_table)
|
|
|
|
self.pushbutton_export_table.clicked.connect(self.export_table)
|
|
|
|
self.verticalLayout_groupbox_table.addLayout(self.horizontalLayout_pushbutton_fill_export_table)
|
|
|
|
# self.tableWidget = QTableWidget()
|
|
# self.tableWidget.setRowCount(10)
|
|
# self.tableWidget.setColumnCount(10)
|
|
|
|
self.tableView = QTableView()
|
|
data = pd.DataFrame(np.zeros((10, 10)))
|
|
self.tableModel = TableModel(data)
|
|
self.tableView.setModel(self.tableModel)
|
|
self.verticalLayout_groupbox_table.addWidget(self.tableView)
|
|
|
|
# #------------------------------------
|
|
# # self.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_display_option = QVBoxLayout(self.groupbox_display_option)
|
|
|
|
# --- Push buttons to trigger plot of transect with Backscatter acoustic raw data and SNR ---
|
|
|
|
self.horizontalLayout_pushbutton_plot_BS_SNR_data = QHBoxLayout()
|
|
self.verticalLayout_display_option.addLayout(self.horizontalLayout_pushbutton_plot_BS_SNR_data)
|
|
|
|
self.pushbutton_plot_transect_with_BS_raw_data = QPushButton()
|
|
self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_BS_raw_data)
|
|
|
|
self.pushbutton_plot_transect_with_BS_raw_data.clicked.connect(self.plot_transect_with_BS_raw_data)
|
|
|
|
self.pushbutton_plot_transect_with_SNR_data = QPushButton()
|
|
self.horizontalLayout_pushbutton_plot_BS_SNR_data.addWidget(self.pushbutton_plot_transect_with_SNR_data)
|
|
|
|
self.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.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("t<span style= vertical-align:sub>min</span> = ")
|
|
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("t<span style= vertical-align:sub>max</span> = ")
|
|
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.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)
|
|
self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.update_xaxis_transect_with_BS_raw_data)
|
|
self.pushbutton_apply_transect_boundaries_in_time.clicked.connect(self.update_xaxis_transect_with_SNR_data)
|
|
|
|
# --- 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("x<span style= vertical-align:sub>min</span> = ")
|
|
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("x<span style= vertical-align:sub>max</span> = ")
|
|
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.setRange(0, 9999)
|
|
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.setRange(0, 99999)
|
|
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)
|
|
|
|
self.pushbutton_compute_bathymetry_algorithm.clicked.connect(self.detect_bottom)
|
|
|
|
# =====================================================
|
|
# 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.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)
|
|
|
|
self.retranslate_acoustic_data_tab()
|
|
|
|
# -------------------- Functions for Acoustic dataTab --------------------
|
|
|
|
def retranslate_acoustic_data_tab(self):
|
|
|
|
self.groupbox_download.setTitle(_translate("CONSTANT_STRING", cs.DOWNLOAD))
|
|
|
|
self.groupbox_acoustic_file.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_FILE))
|
|
self.label_date_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":")
|
|
self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":")
|
|
|
|
self.groupbox_noise_file.setTitle(_translate("CONSTANT_STRING", cs.NOISE_FILE))
|
|
self.pushbutton_noise_level_with_tail_of_mean_profile.setText(_translate("CONSTANT_STRING", cs.NOISE_LEVEL))
|
|
self.label_date_groupbox_noise_file.setText(_translate("CONSTANT_STRING", cs.DATE) + ":")
|
|
self.label_hour_groupbox_noise_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ":")
|
|
|
|
self.groupbox_gps_file.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_info.setTitle(_translate("CONSTANT_STRING", cs.MEASUREMENTS_INFORMATION))
|
|
|
|
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_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) + " t<span style= vertical-align:sub>min</span> = ")
|
|
# self.label_tmax.setText(_translate("CONSTANT_STRING", cs.TO) + " t<span style= vertical-align:sub>max</span> = ")
|
|
# 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) + " z<span style= vertical-align:sub>min</span> = ")
|
|
# self.label_zmax.setText(_translate("CONSTANT_STRING", cs.TO) + " z<span style= vertical-align:sub>max</span> = ")
|
|
# 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 ABS_system_choice(self):
|
|
if self.combobox_ABS_system_choice.currentText() == "Aquascat 1000R":
|
|
self.groupbox_measurement_information_Aquascat()
|
|
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.setText(_translate("CONSTANT_STRING", cs.HOUR) + ": ")
|
|
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.setText(_translate("CONSTANT_STRING", cs.DATE) + ": ")
|
|
self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ": ")
|
|
|
|
def groupbox_measurement_information_Aquascat(self):
|
|
# self.gridLayout_goupbox_info.itemAt(0).widget().deleteLater()
|
|
self.label_to_do.hide()
|
|
|
|
self.label_profiles.show()
|
|
self.label_profiles_per_sec.show()
|
|
self.label_cells.show()
|
|
self.label_cell_size.show()
|
|
self.label_pulse_length.show()
|
|
self.label_pings_per_sec.show()
|
|
self.label_pings_per_profile.show()
|
|
self.label_freq.show()
|
|
self.label_kt.show()
|
|
self.label_rx.show()
|
|
self.label_tx.show()
|
|
|
|
self.gridLayout_goupbox_info.addWidget(self.label_profiles, 0, 0, 1, 1)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 0, 1, 1, 1)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_cells, 1, 0, 1, 1)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 1, 1, 1, 1)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 2, 0, 1, 1)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 3, 0, 1, 1)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 3, 1, 1, 1)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_freq, 4, 0, 1, 2)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_kt, 5, 0, 1, 2)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_rx, 6, 0, 1, 2)
|
|
self.gridLayout_goupbox_info.addWidget(self.label_tx, 7, 0, 1, 2)
|
|
|
|
def groupbox_measurement_information_UBSediFlow(self):
|
|
# self.gridLayout_goupbox_info.itemAt(0).widget().deleteLater()
|
|
|
|
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_freq.hide()
|
|
self.label_kt.hide()
|
|
self.label_rx.hide()
|
|
self.label_tx.hide()
|
|
|
|
self.label_to_do.show()
|
|
|
|
self.gridLayout_goupbox_info.addWidget(self.label_to_do, 0, 0, 1, 1)
|
|
|
|
def clicked_pushbutton_noise_level(self):
|
|
self.WindowNoiseLevelTailAveragedProfile().show()
|
|
|
|
def open_dialog_box(self):
|
|
# --- 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",
|
|
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data",
|
|
"Aquascat file (*.aqa)")
|
|
dir_name = path.dirname(filename[0])
|
|
name = path.basename(filename[0])
|
|
elif self.combobox_ABS_system_choice.currentIndex() == 2:
|
|
filename = QFileDialog.getOpenFileName(self, "Open file", "", "UBSediFlow file (*.udt)")
|
|
dir_name = path.dirname(filename[0])
|
|
name = path.basename(filename[0])
|
|
|
|
# --- 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":
|
|
stg.path_BS_raw_data = dir_name
|
|
stg.filename_BS_raw_data = name
|
|
self.load_BS_acoustic_raw_data()
|
|
self.lineEdit_acoustic_file.setText(stg.filename_BS_raw_data)
|
|
self.lineEdit_acoustic_file.setToolTip(stg.path_BS_raw_data)
|
|
self.label_date_groupbox_acoustic_file.setText(
|
|
_translate("CONSTANT_STRING", cs.DATE) + ": " + str(stg.date))
|
|
self.label_hour_groupbox_acoustic_file.setText(
|
|
_translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour))
|
|
self.fill_measurements_information_groupbox()
|
|
self.combobox_freq_choice.addItems([f for f in stg.freq_text])
|
|
if self.sender().objectName() == "pushbutton_noise_file":
|
|
stg.path_BS_noise_data = dir_name
|
|
stg.filename_BS_noise_data = name
|
|
self.load_noise_data_and_compute_SNR()
|
|
self.lineEdit_noise_file.setText(stg.filename_BS_noise_data)
|
|
self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data)
|
|
self.label_date_groupbox_noise_file.setText(
|
|
_translate("CONSTANT_STRING", cs.DATE) + ": " + str(stg.date_noise))
|
|
self.label_hour_groupbox_noise_file.setText(
|
|
_translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour_noise))
|
|
|
|
def load_BS_acoustic_raw_data(self):
|
|
acoustic_data = AcousticDataLoader(stg.path_BS_raw_data + "/" + stg.filename_BS_raw_data)
|
|
stg.BS_raw_data = acoustic_data._BS_raw_data
|
|
stg.BS_raw_data_reshape = acoustic_data.reshape_BS_raw_cross_section()
|
|
stg.r = acoustic_data._r
|
|
stg.r_2D = acoustic_data.compute_r_2D()
|
|
stg.r_reshape = acoustic_data.reshape_r()
|
|
stg.time = acoustic_data._time
|
|
stg.time_reshape = acoustic_data.reshape_t()
|
|
stg.freq = acoustic_data._freq
|
|
stg.freq_text = acoustic_data._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
|
|
|
|
def load_noise_data_and_compute_SNR(self):
|
|
noise_data = AcousticDataLoader(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data)
|
|
# stg.BS_noise_data = noise_data._BS_raw_data
|
|
stg.date_noise = noise_data._date
|
|
stg.hour_noise = noise_data._hour
|
|
stg.time_snr = noise_data._time
|
|
noise = np.zeros(stg.BS_raw_data.shape)
|
|
for f in range(noise_data._freq.shape[0]):
|
|
noise[:, f, :] = np.mean(noise_data._BS_raw_data[:, f, :], axis=(0, 1))
|
|
stg.BS_noise_data = noise
|
|
stg.snr = np.divide((stg.BS_raw_data - stg.BS_noise_data) ** 2, stg.BS_noise_data ** 2)
|
|
stg.snr_reshape = np.reshape(stg.snr, (stg.r.shape[0] * stg.time.shape[0], stg.freq.shape[0]), order="F")
|
|
|
|
def fill_measurements_information_groupbox(self):
|
|
# acoustic_data = self.load_BS_acoustic_raw_data()
|
|
|
|
self.label_profiles.setText(
|
|
_translate("CONSTANT_STRING", cs.NB_PROFILES) + ": " + str(stg.nb_profiles))
|
|
self.label_profiles_per_sec.setText(
|
|
_translate("CONSTANT_STRING", cs.NB_PROFILES_PER_SEC) + ": " +
|
|
str(stg.nb_profiles_per_sec) + " Hz")
|
|
self.label_freq.setText(
|
|
_translate("CONSTANT_STRING", cs.FREQUENCY) + ": " + ', '.join(stg.freq_text))
|
|
self.label_cells.setText(
|
|
_translate("CONSTANT_STRING", cs.NB_CELLS) + ": " + str(stg.nb_cells))
|
|
self.label_cell_size.setText(
|
|
_translate("CONSTANT_STRING", cs.CELL_SIZE) + ": " + str(100*round(stg.cell_size, 3)) + " cm")
|
|
self.label_pulse_length.setText(
|
|
_translate("CONSTANT_STRING", cs.PULSE_LENGHT) + ": " + str(round(stg.pulse_length,6)) + "sec")
|
|
self.label_pings_per_sec.setText(
|
|
_translate("CONSTANT_STRING", cs.NB_PINGS_PER_SEC) + ": " + str(stg.nb_pings_per_sec) + " Hz")
|
|
self.label_pings_per_profile.setText(
|
|
_translate("CONSTANT_STRING", cs.NB_PINGS_PER_PROFILE) + ": " +
|
|
str(stg.nb_pings_averaged_per_profile))
|
|
self.label_kt.setText(
|
|
_translate("CONSTANT_STRING", cs.KT) + ": " + ', '.join(map(str, stg.kt)))
|
|
self.label_rx.setText(
|
|
_translate("CONSTANT_STRING", cs.GAIN_RX) + ": " + ', '.join(map(str, stg.gain_rx)))
|
|
self.label_tx.setText(
|
|
_translate("CONSTANT_STRING", cs.GAIN_TX) + ": " + ', '.join(map(str, stg.gain_tx)))
|
|
|
|
def fill_table(self):
|
|
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()
|
|
|
|
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 plot_transect_with_BS_raw_data(self):
|
|
# --- Condition if table is not filled ---
|
|
if not self.lineEdit_acoustic_file.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):
|
|
|
|
self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq.shape[0], ncols=1, sharex=True, sharey=False, layout="constrained")
|
|
self.canvas_BS = FigureCanvas(self.fig_BS)
|
|
# self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_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.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)
|
|
|
|
self.spinbox_tmin.setValue(np.min(stg.time))
|
|
self.spinbox_tmax.setValue(np.round(np.max(stg.time), 2))
|
|
|
|
for f in range(stg.freq.shape[0]):
|
|
|
|
val_min = np.nanmin(stg.BS_raw_data[:, f, :])
|
|
val_max = np.nanmax(stg.BS_raw_data[:, f, :])
|
|
if val_min == 0:
|
|
val_min = 1e-5
|
|
|
|
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))
|
|
|
|
self.axis_BS[f].text(1, .70, stg.freq_text[f],
|
|
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
|
horizontalalignment='right', verticalalignment='bottom',
|
|
transform=self.axis_BS[f].transAxes)
|
|
|
|
self.fig_BS.supxlabel('Time (sec)', fontsize=10)
|
|
self.fig_BS.supylabel('Depth (m)', fontsize=10)
|
|
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_BS.canvas.draw_idle()
|
|
|
|
def update_xaxis_transect_with_BS_raw_data(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:
|
|
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:
|
|
# --- Backscatter acoustic signal is recorded for next tab ---
|
|
stg.BS_data = stg.BS_raw_data[:, :, 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.t = 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_2D = stg.r_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]]
|
|
|
|
for f in range(stg.freq.shape[0]):
|
|
self.axis_BS[f].cla()
|
|
|
|
val_min = np.min(stg.BS_raw_data[:, f, :])
|
|
val_max = np.max(stg.BS_raw_data[:, 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))
|
|
|
|
self.axis_BS[f].text(1, .70, stg.freq_text[f],
|
|
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
|
horizontalalignment='right', verticalalignment='bottom',
|
|
transform=self.axis_BS[f].transAxes)
|
|
|
|
self.fig_BS.supxlabel('Time (sec)', fontsize=10)
|
|
self.fig_BS.supylabel('Depth (m)', fontsize=10)
|
|
self.fig_BS.canvas.draw_idle()
|
|
|
|
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))
|
|
|
|
x, y = np.meshgrid(
|
|
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
|
stg.r)
|
|
|
|
for f in range(stg.freq.shape[0]):
|
|
|
|
val_min = np.min(stg.snr[:, f, :])
|
|
val_max = np.max(stg.snr[:, f, :])
|
|
if val_min == 0:
|
|
val_min = 1e-5
|
|
if val_max > 1000:
|
|
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
|
else:
|
|
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
|
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
|
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
|
|
|
cf = (self.axis_SNR[f].
|
|
contourf(x, -y,
|
|
stg.snr[:, f,
|
|
np.where(np.round(stg.snr, 2) == self.spinbox_tmin.value())[0][0]:
|
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
|
levels, cmap='gist_rainbow', norm=norm))
|
|
|
|
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
|
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
|
horizontalalignment='right', verticalalignment='bottom',
|
|
transform=self.axis_SNR[f].transAxes)
|
|
|
|
self.fig_SNR.supxlabel('Time (sec)', fontsize=10)
|
|
self.fig_SNR.supylabel('Depth (m)', fontsize=10)
|
|
cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right')
|
|
cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10)
|
|
cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$'])
|
|
self.fig_SNR.canvas.draw_idle()
|
|
|
|
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.Noise_data = stg.BS_noise_data[:, :, 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.SNR_data = stg.snr[:, :, 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]]
|
|
|
|
x, y = np.meshgrid(
|
|
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
|
stg.r)
|
|
|
|
for f in range(stg.freq.shape[0]):
|
|
self.axis_SNR[f].cla()
|
|
|
|
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.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)
|
|
|
|
self.fig_SNR.supxlabel('Distance from left bank (m)', fontsize=10)
|
|
self.fig_SNR.supylabel('Depth (m)', fontsize=10)
|
|
self.fig_SNR.canvas.draw_idle()
|
|
|
|
def detect_bottom(self):
|
|
if self.lineEdit_acoustic_file.text() == "":
|
|
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:
|
|
# else:
|
|
# --- Record frequency choose for bottom detection ---
|
|
stg.freq_bottom_detection = self.combobox_freq_choice.currentIndex()
|
|
|
|
# Selecting the range in which we look for the bottom reflection
|
|
rmin = np.int(self.spinbox_depth_min.text())
|
|
rmax = np.int(self.spinbox_depth_max.text())
|
|
|
|
# empty result arrays
|
|
r_bottom = np.zeros(stg.nb_profiles)
|
|
val_bottom = np.zeros(stg.nb_profiles)
|
|
r_bottom_ind = []
|
|
# ----------- Detecting the bottom -------------
|
|
for d in range(stg.nb_profiles):
|
|
# Index of the range where we look for the peak
|
|
ind_min = np.where(stg.r >= rmin)[0][0]
|
|
ind_max = np.where(stg.r <= rmax)[0][-1]
|
|
# Getting the peak
|
|
try:
|
|
val_bottom[d] = np.nanmax(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d])
|
|
except ValueError as e:
|
|
msgBox = QMessageBox()
|
|
msgBox.setWindowTitle("Detect bottom Error")
|
|
msgBox.setIcon(QMessageBox.Warning)
|
|
msgBox.setText(f"{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[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d]
|
|
== val_bottom[d])[0][0]
|
|
np.append(stg.ind_bottom, ind_bottom)
|
|
|
|
r_bottom[d] = stg.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())
|
|
rmax = r_bottom[d] + locale.atof(self.doublespinbox_next_cell.text())
|
|
|
|
BS_section_bottom = np.zeros((stg.r.shape[0], stg.time.shape[0]))
|
|
|
|
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"{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]]
|
|
|
|
# --- Plot transect BS with bathymetry ---
|
|
for f in range(stg.freq.shape[0]):
|
|
self.axis_BS[f].cla()
|
|
|
|
val_min = np.min(stg.BS_raw_data[:, f, :])
|
|
val_max = np.max(stg.BS_raw_data[:, 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))
|
|
|
|
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")
|
|
|
|
self.axis_BS[f].text(1, .70, stg.freq_text[f],
|
|
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
|
horizontalalignment='right', verticalalignment='bottom',
|
|
transform=self.axis_BS[f].transAxes)
|
|
|
|
self.fig_BS.canvas.draw_idle()
|
|
|
|
# --- Plot transect SNR with bathymetry ---
|
|
if self.canvas_SNR != None:
|
|
x, y = np.meshgrid(
|
|
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
|
stg.r)
|
|
|
|
for f in range(stg.freq.shape[0]):
|
|
self.axis_SNR[f].cla()
|
|
|
|
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.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')
|
|
|
|
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.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_BS[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
|