# ============================================================================== #
# mainwindow.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see . #
from cProfile import label
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox, QLabel, QCheckBox,
QSpinBox, QDoubleSpinBox, QComboBox, QLineEdit, QSlider, QGridLayout, QMessageBox,
QScrollArea, QRadioButton, QFileDialog, QSpacerItem, QSizePolicy, QTextEdit, QPlainTextEdit)
from PyQt5.QtGui import QFont, QIcon, QPixmap, QSyntaxHighlighter, QTextCharFormat
from PyQt5.QtCore import Qt, QCoreApplication, QEvent, pyqtSignal, QPropertyAnimation, QSize
import numpy as np
from copy import deepcopy
from scipy.ndimage import convolve1d
from astropy.convolution import convolve, Gaussian2DKernel
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar
from matplotlib.colors import LogNorm, BoundaryNorm
from scipy import stats
from os import path
from View.show_popup_combobox import ComboBoxShowPopUpWindow
from View.plot_noise_window import PlotNoiseWindow
import Translation.constant_string as cs
from Model.acoustic_data_loader import AcousticDataLoader
import settings as stg
from settings import depth_cross_section
_translate = QCoreApplication.translate
class SyntaxHighlighter(QSyntaxHighlighter):
def __init__(self, parent):
super(SyntaxHighlighter, self).__init__(parent)
self._highlight_lines = dict()
def highlight_line(self, line, fmt):
if isinstance(line, int) and line >= 0 and isinstance(fmt, QTextCharFormat):
self._highlight_lines[line] = fmt
tb = self.document().findBlockByLineNumber(line)
self.rehighlightBlock(tb)
print("self._highlight_lines ", self._highlight_lines[line])
print("tb", tb)
print("self.rehighlightBlock(tb) ", self.rehighlightBlock(tb))
def clear_highlight(self):
self._highlight_lines = dict()
self.rehighlight()
print("self._highlight_lines ", self._highlight_lines)
def highlightBlock(self, text):
line = self.currentBlock().blockNumber()
fmt = self._highlight_lines.get(line)
if fmt is not None:
self.setFormat(0, len(text), fmt)
class SignalProcessingTab(QWidget):
''' This class generates the Signal Processing Tab '''
FillCombobox = pyqtSignal()
def __init__(self, widget_tab):
super().__init__()
self.path_icon = "./icons/"
self.icon_folder = QIcon(self.path_icon + "folder.png")
self.icon_triangle_left = QIcon(self.path_icon + "triangle_left.png")
self.icon_triangle_right = QIcon(self.path_icon + "triangle_right.png")
self.icon_triangle_left_to_begin = QIcon(self.path_icon + "triangle_left_to_begin.png")
self.icon_triangle_right_to_end = QIcon(self.path_icon + "triangle_right_to_end.png")
self.icon_update = QIcon(self.path_icon + "update.png")
self.icon_clear = QIcon(self.path_icon + "clear.png")
self.icon_apply = QIcon(self.path_icon + "circle_green_arrow_right.png")
### --- General layout of widgets ---
# |-----------------| |------------| |-----------------|
# | Data to be | | Plot SNR | | Pre-processing |
# | pre-processed | |------------| | options |
# |-----------------| |-----------------|
# |------------------------------------------------------------------------|
# |-----------------------| |-----------------------| |------------------|
# | Plot pre-processed | | Plot pre-processed | | Pre-processed |
# | data 2D field | | data profile | | data list |
# |-----------------------| |-----------------------| |------------------|
# |------------------------------------------------------------------------|
self.verticalLayoutMain = QVBoxLayout(widget_tab)
self.horizontalLayout_Top = QHBoxLayout()
self.verticalLayoutMain.addLayout(self.horizontalLayout_Top, 5)
self.horizontalLayout_Bottom = QHBoxLayout()
self.verticalLayoutMain.addLayout(self.horizontalLayout_Bottom, 5)
# --------------------------------------------------------------------------------------------------------------
### --- Layout of groupbox in the top layout box
self.groupbox_study_data = QGroupBox()
self.horizontalLayout_Top.addWidget(self.groupbox_study_data, 3)
self.groupbox_plot_SNR = QGroupBox()
self.horizontalLayout_Top.addWidget(self.groupbox_plot_SNR, 5)
self.groupbox_pre_processing_option = QGroupBox()
self.horizontalLayout_Top.addWidget(self.groupbox_pre_processing_option, 2)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++ --- Download data to be processed + Download noise file + compute noise data from profile tail + --- +++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
self.groupbox_study_data.setTitle("Study data")
### --- Groupbox download data to be processed ---
self.verticalLayout_groupbox_study_data = QVBoxLayout(self.groupbox_study_data)
self.horizontalLayout_groupbox_data_to_be_processed_Pushbutton_plot_clear_noise = QHBoxLayout()
self.verticalLayout_groupbox_study_data.addLayout(self.horizontalLayout_groupbox_data_to_be_processed_Pushbutton_plot_clear_noise)
self.groupbox_data_to_be_processed = QGroupBox()
self.gridLayout_groupbox_data_to_be_processed = QGridLayout(self.groupbox_data_to_be_processed)
self.groupbox_data_to_be_processed.setTitle("Data to be processed")
self.combobox_acoustic_data_choice = QComboBox()
self.combobox_acoustic_data_choice.setMinimumWidth(200)
self.gridLayout_groupbox_data_to_be_processed.addWidget(self.combobox_acoustic_data_choice, 0, 0, 1, 1, Qt.AlignCenter)
self.pushbutton_update = QPushButton()
self.pushbutton_update.setIcon(self.icon_update)
# self.pushbutton_update.setMaximumWidth(50)
self.gridLayout_groupbox_data_to_be_processed.addWidget(self.pushbutton_update, 0, 1, 1, 1, Qt.AlignCenter)
self.horizontalLayout_groupbox_data_to_be_processed_Pushbutton_plot_clear_noise.addWidget(
self.groupbox_data_to_be_processed)
self.pushbutton_plot_noise_data = QPushButton()
self.pushbutton_plot_noise_data.setText("Plot noise field")
self.horizontalLayout_groupbox_data_to_be_processed_Pushbutton_plot_clear_noise.addWidget(
self.pushbutton_plot_noise_data)
self.pushbutton_clear_noise_data = QPushButton()
self.pushbutton_clear_noise_data.setIcon(self.icon_clear)
self.horizontalLayout_groupbox_data_to_be_processed_Pushbutton_plot_clear_noise.addWidget(
self.pushbutton_clear_noise_data)
### --- Groupbox download noise file ---
self.groupbox_download_noise_file = QGroupBox()
self.groupbox_download_noise_file.setTitle("Noise file")
self.groupbox_download_noise_file.setCheckable(True)
self.groupbox_download_noise_file.setChecked(True)
self.gridLayout_groupbox_noise_file = QGridLayout(self.groupbox_download_noise_file)
self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_download_noise_file)
self.pushbutton_noise_file = QPushButton()
self.pushbutton_noise_file.setIcon(self.icon_folder)
self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_file, 0, 0, 1, 1, Qt.AlignCenter)
self.lineEdit_noise_file = QLineEdit()
# self.lineEdit_noise_file.setMaximumWidth(1000)
self.gridLayout_groupbox_noise_file.addWidget(self.lineEdit_noise_file, 0, 1, 1, 2, Qt.AlignLeft)
### --- Groupbox compute noise from profile tail ---
self.groupbox_compute_noise_from_profile_tail = QGroupBox()
self.groupbox_compute_noise_from_profile_tail.setTitle("Profile tail")
self.groupbox_compute_noise_from_profile_tail.setCheckable(True)
self.groupbox_compute_noise_from_profile_tail.setChecked(False)
self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_profile_tail)
self.horizontalLayout_groupbox_compute_noise_from_profile_tail = QHBoxLayout(self.groupbox_compute_noise_from_profile_tail)
self.groupbox_plot_profile_tail = QGroupBox()
self.horizontalLayout_groupbox_compute_noise_from_profile_tail.addWidget(self.groupbox_plot_profile_tail)
self.verticalLayout_groupbox_plot_profile_tail = QVBoxLayout(self.groupbox_plot_profile_tail)
self.canvas_profile_tail = FigureCanvas()
self.verticalLayout_groupbox_plot_profile_tail.addWidget(self.canvas_profile_tail)
self.horizontalLayout_groupbox_compute_noise_from_profile_tail.addWidget(self.groupbox_plot_profile_tail)
self.groupbox_option_profile_tail = QGroupBox()
# self.groupbox_option_profile_tail.setCheckable(True)
# self.groupbox_option_profile_tail.setChecked(False)
self.horizontalLayout_groupbox_compute_noise_from_profile_tail.addWidget(self.groupbox_option_profile_tail)
self.gridLayout_groupbox_option_profile_tail = QGridLayout(self.groupbox_option_profile_tail)
self.combobox_freq_noise_from_profile_tail = QComboBox()
self.gridLayout_groupbox_option_profile_tail.addWidget(self.combobox_freq_noise_from_profile_tail, 0, 0, 1, 2, Qt.AlignCenter)
self.lineEdit_val1 = QLineEdit()
self.lineEdit_val1.setText("0.00")
self.gridLayout_groupbox_option_profile_tail.addWidget(self.lineEdit_val1, 1, 0, 1, 1, Qt.AlignCenter)
self.lineEdit_val2 = QLineEdit()
self.lineEdit_val2.setText("0.00")
self.gridLayout_groupbox_option_profile_tail.addWidget(self.lineEdit_val2, 1, 1, 1, 1, Qt.AlignCenter)
self.pushbutton_plot_profile_tail = QPushButton()
# self.pushbutton_plot_profile_tail.setText("Profile tail")
self.pushbutton_plot_profile_tail.setIcon(self.icon_apply)
self.gridLayout_groupbox_option_profile_tail.addWidget(self.pushbutton_plot_profile_tail, 1, 2, 1, 1, Qt.AlignCenter)
self.lineEdit_profile_tail_value = QLineEdit()
self.lineEdit_profile_tail_value.setText("0.0000")
self.gridLayout_groupbox_option_profile_tail.addWidget(self.lineEdit_profile_tail_value, 2, 0, 1, 1, Qt.AlignCenter)
self.label_Volts = QLabel()
self.label_Volts.setText("Volts")
self.gridLayout_groupbox_option_profile_tail.addWidget(self.label_Volts, 2, 1, 1, 1, Qt.AlignLeft)
self.pushbutton_apply_noise_from_profile_tail = QPushButton()
self.pushbutton_apply_noise_from_profile_tail.setIcon(self.icon_apply)
self.gridLayout_groupbox_option_profile_tail.addWidget(self.pushbutton_apply_noise_from_profile_tail, 2, 2, 1, 1, Qt.AlignCenter)
# --- Push button Plot/Clear noise data ---
# self.gridLayout_pushbutton_noise_data = QGridLayout()
# self.verticalLayout_groupbox_study_data.addLayout(self.gridLayout_pushbutton_noise_data)
#
# self.pushbutton_plot_noise_data = QPushButton()
# self.pushbutton_plot_noise_data.setText("Plot noise field")
# self.gridLayout_pushbutton_noise_data.addWidget(self.pushbutton_plot_noise_data, 0, 0, 1, 1, Qt.AlignCenter)
#
# self.pushbutton_clear_noise_data = QPushButton()
# self.pushbutton_clear_noise_data.setIcon(self.icon_clear)
# # self.pushbutton_clear_noise_data.setMaximumWidth(50)
# self.gridLayout_pushbutton_noise_data.addWidget(self.pushbutton_clear_noise_data, 0, 1, 1, 1, Qt.AlignCenter)
# self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_value)
### --- Push button plot noise ---
# self.pushbutton_plot_noise = QPushButton()
# self.pushbutton_plot_noise.setText("Plot noise")
# self.verticalLayout_groupbox_study_data.addWidget(self.pushbutton_plot_noise)
# ++++++++++++++++++++++++
# +++ --- Plot SNR --- +++
# ++++++++++++++++++++++++
self.groupbox_plot_SNR.setTitle("Plot SNR")
self.verticalLayout_groupbox_plot_SNR = QVBoxLayout(self.groupbox_plot_SNR)
self.canvas_SNR = FigureCanvas()
self.toolbar_SNR = NavigationToolBar(self.canvas_SNR, self)
self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR)
self.scroll_SNR = QScrollArea()
self.scroll_SNR.setWidget(self.canvas_SNR)
self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scroll_SNR.setAlignment(Qt.AlignCenter)
self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR)
# +++++++++++++++++++++++++++++++++++++
# +++ --- Pre-processing option --- +++
# +++++++++++++++++++++++++++++++++++++
self.groupbox_pre_processing_option.setTitle("Pre-processing options")
self.verticalLayout_groupbox_pre_processing_option = QVBoxLayout(self.groupbox_pre_processing_option)
### --- Groupbox SNR criterion ---
self.groupbox_SNR_criterion = QGroupBox()
self.groupbox_SNR_criterion.setTitle("SNR filter")
self.gridLayout_SNR_criterion = QGridLayout(self.groupbox_SNR_criterion)
self.label_SNR_criterion = QLabel("SNR < ")
self.gridLayout_SNR_criterion.addWidget(self.label_SNR_criterion, 0, 0, 1, 1, Qt.AlignCenter)
self.lineEdit_SNR_criterion = QLineEdit()
self.lineEdit_SNR_criterion.setMaximumWidth(60)
self.gridLayout_SNR_criterion.addWidget(self.lineEdit_SNR_criterion, 0, 1, 1, 1, Qt.AlignCenter)
self.pushbutton_Apply_SNR_filter = QPushButton()
# self.pushbutton_Apply_SNR_filter.setText("Apply SNR")
self.pushbutton_Apply_SNR_filter.setIcon(self.icon_apply)
self.gridLayout_SNR_criterion.addWidget(self.pushbutton_Apply_SNR_filter, 0, 2, 1, 1, Qt.AlignCenter)
self.verticalLayout_groupbox_pre_processing_option.addWidget(self.groupbox_SNR_criterion)
# --- Rayleigh criterion groupbox ---
self.groupbox_Rayleigh_criterion = QGroupBox()
self.groupbox_Rayleigh_criterion.setTitle("Despiking the signal")
self.groupbox_Rayleigh_criterion.setDisabled(True)
self.gridLayout_Rayleigh_criterion = QGridLayout(self.groupbox_Rayleigh_criterion)
self.label_Rayleigh_criterion = QLabel()
self.label_Rayleigh_criterion.setText("/² <=")
self.gridLayout_Rayleigh_criterion.addWidget(self.label_Rayleigh_criterion, 0, 0, 1, 1)
self.spinbox_Rayleigh_criterion = QSpinBox()
self.spinbox_Rayleigh_criterion.setRange(0, 9999)
self.spinbox_Rayleigh_criterion.setValue(10)
self.gridLayout_Rayleigh_criterion.addWidget(self.spinbox_Rayleigh_criterion, 0, 1, 1, 1)
self.label_4pi = QLabel()
self.label_4pi.setText("% x 4/pi")
self.gridLayout_Rayleigh_criterion.addWidget(self.label_4pi, 0, 2, 1, 1)
self.pushbutton_despiking_signal = QPushButton()
self.pushbutton_despiking_signal.setText("Despiking the signal")
self.gridLayout_Rayleigh_criterion.addWidget(self.pushbutton_despiking_signal, 0, 3, 1, 1)
self.verticalLayout_groupbox_pre_processing_option.addWidget(self.groupbox_Rayleigh_criterion)
# --- Average signal groupbox ---
self.groupbox_window_size = QGroupBox()
self.groupbox_window_size.setTitle("Horizontal averaging")
self.gridLayout_groupbox_window_size = QGridLayout(self.groupbox_window_size)
self.label_signal_averaging_horizontal = QLabel()
self.label_signal_averaging_horizontal.setText("Horizontal +/- ")
# self.horizontalLayout_groupbox_window_size.addWidget(self.label_signal_averaging_over)
self.gridLayout_groupbox_window_size.addWidget(self.label_signal_averaging_horizontal, 0, 0, 1, 1, Qt.AlignCenter)
# self.spinbox_average_horizontal = QSpinBox()
# self.spinbox_average_horizontal.setRange(0, 9999)
# self.spinbox_average_horizontal.setValue(0)
self.lineEdit_horizontal_average = QLineEdit()
self.lineEdit_horizontal_average.setText("0.00")
self.lineEdit_horizontal_average.setMaximumWidth(60)
# self.horizontalLayout_groupbox_window_size.addWidget(self.spinbox_average)
self.gridLayout_groupbox_window_size.addWidget(self.lineEdit_horizontal_average, 0, 1, 1, 1, Qt.AlignCenter)
# self.lineEdit_horizontal_average = QLineEdit()
# self.lineEdit_horizontal_average.setMaximumWidth(60)
# self.gridLayout_groupbox_window_size.addWidget(self.lineEdit_horizontal_average, 0, 1, 1, 1, Qt.AlignCenter)
self.label_cells_horizontal = QLabel()
self.label_cells_horizontal.setText("cells = +/- ? sec")
# self.horizontalLayout_groupbox_window_size.addWidget(self.label_cells)
self.gridLayout_groupbox_window_size.addWidget(self.label_cells_horizontal, 0, 2, 1, 1, Qt.AlignCenter)
self.pushbutton_average = QPushButton()
# self.pushbutton_average.setText("Apply averaging")
self.pushbutton_average.setIcon(self.icon_apply)
self.gridLayout_groupbox_window_size.addWidget(self.pushbutton_average, 0, 3, 1, 1, Qt.AlignCenter)
self.verticalLayout_groupbox_pre_processing_option.addWidget(self.groupbox_window_size)
# # ++++++++++++++++++++++++++++++++++++++++++++++
# # +++ --- Plot BS data filtered with SNR --- +++
# # ++++++++++++++++++++++++++++++++++++++++++++++
# --------------------------------------------------------------------------------------------------------------
### --- Layout of groupbox in the bottom layout box
# self.groupbox_pre_processing = QGroupBox()
# self.horizontalLayout_Bottom.addWidget(self.groupbox_pre_processing, 4)
self.groupbox_plot_pre_processed_data_2D_field = QGroupBox()
self.horizontalLayout_Bottom.addWidget(self.groupbox_plot_pre_processed_data_2D_field, 5)
self.groupbox_plot_pre_processed_data_profile = QGroupBox()
self.horizontalLayout_Bottom.addWidget(self.groupbox_plot_pre_processed_data_profile, 3)
self.groupbox_list_pre_processed_data = QGroupBox()
self.horizontalLayout_Bottom.addWidget(self.groupbox_list_pre_processed_data, 2)
# ++++++++++++++++++++++++++++++++++++++++++++++++
# +++ --- Plot pre-processed data 2D field --- +++
# ++++++++++++++++++++++++++++++++++++++++++++++++
self.groupbox_plot_pre_processed_data_2D_field.setTitle("Display pre-processed data 2D fields")
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field = QVBoxLayout(
self.groupbox_plot_pre_processed_data_2D_field)
self.canvas_BS = FigureCanvas()
self.toolbar_BS = NavigationToolBar(self.canvas_BS, self)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.toolbar_BS)
self.scroll_BS = QScrollArea()
self.scroll_BS.setWidget(self.canvas_BS)
self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
# self.scroll_BS.setWidgetResizable(True)
self.scroll_BS.setAlignment(Qt.AlignCenter)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.scroll_BS)
# +++++++++++++++++++++++++++++++++++++++++++++++
# +++ --- Plot pre-processed data profile --- +++
# +++++++++++++++++++++++++++++++++++++++++++++++
self.groupbox_plot_pre_processed_data_profile.setTitle("Display pre-processed data profile")
self.verticalLayout_groupbox_plot_pre_processed_data_2D_profile = QVBoxLayout(
self.groupbox_plot_pre_processed_data_profile)
self.horizontalLayout_profile_frequency = QHBoxLayout()
self.verticalLayout_groupbox_plot_pre_processed_data_2D_profile.addLayout(
self.horizontalLayout_profile_frequency)
self.spacerItem_frequency_profile = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout_profile_frequency.addSpacerItem(self.spacerItem_frequency_profile)
self.combobox_frequency_profile = QComboBox()
self.horizontalLayout_profile_frequency.addWidget(self.combobox_frequency_profile)
self.groupbox_plot_profile = QGroupBox()
self.verticalLayout_groupbox_plot_profile = QVBoxLayout(self.groupbox_plot_profile)
self.canvas_profile = FigureCanvas()
self.toolbar_profile = NavigationToolBar(self.canvas_profile, self)
self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile)
self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_profile.addWidget(self.groupbox_plot_profile)
# --- Slider for moving the profile ---
self.horizontalLayout_slider = QHBoxLayout()
self.verticalLayout_groupbox_plot_pre_processed_data_2D_profile.addLayout(self.horizontalLayout_slider)
self.pushbutton_slider_left_to_begin = QPushButton()
self.pushbutton_slider_left_to_begin.setIcon(self.icon_triangle_left_to_begin)
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)
# ++++++++++++++++++++++++++++++++++++++++++
# +++ --- List of pre-processed data --- +++
# ++++++++++++++++++++++++++++++++++++++++++
self.groupbox_list_pre_processed_data.setTitle("List pre-processed data: user label")
self.verticalLayout_groupbox_list_pre_processed_data = QVBoxLayout(self.groupbox_list_pre_processed_data)
# Create a scroll area
self.scrollArea_list_preprocessed_data = QScrollArea()
self.verticalLayout_groupbox_list_pre_processed_data.addWidget(self.scrollArea_list_preprocessed_data)
# Set scrollbar policies
self.scrollArea_list_preprocessed_data.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.scrollArea_list_preprocessed_data.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scroll_BS.setAlignment(Qt.AlignLeft)
# Create a widget to be scrolled
self.widget_scrollArea_list_preprocessed_data = QWidget()
self.verticalLayout_scrollArea_list_pre_processed_data = QVBoxLayout()
self.widget_scrollArea_list_preprocessed_data.setLayout(self.verticalLayout_scrollArea_list_pre_processed_data)
# Add content to the widget (labels in this example)
# QPlainTextEdit().setMaximumSize(maxw=10, maxh=)
for i in range(20):
exec("self.lineEdit_list_pre_processed_data_" + str(i) + "= QLineEdit()")
# eval("self.plaintextedit_" + str(i) + ".setMaximumSize(maxw=" + str(50)+ ", maxh=" + str(10) + ")")
eval("self.verticalLayout_scrollArea_list_pre_processed_data.addWidget("
"self.lineEdit_list_pre_processed_data_" + str(i) + ")")
eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
# self.plaintextedit_list_pre_processed_data = QPlainTextEdit()
# self.verticalLayout_list_pre_processed_data.addWidget(self.plaintextedit_list_pre_processed_data)
# Set the widget as the scroll area's widget
self.scrollArea_list_preprocessed_data.setWidget(self.widget_scrollArea_list_preprocessed_data)
self.scrollArea_list_preprocessed_data.setWidgetResizable(True)
# self.plaintextedit_list_pre_processed_data.appendPlainText("blablabla \nblobloblo")
# --------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------
# +++++++++ CONNECT SIGNAL OF WIDGET TO SLOT FUNCTION +++++++++
# --------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------
self.pushbutton_update.clicked.connect(self.update_SignalPreprocessingTab)
self.pushbutton_update.clicked.connect(self.compute_average_profile_tail)
self.pushbutton_update.clicked.connect(self.plot_averaged_profile_tail)
self.combobox_acoustic_data_choice.currentIndexChanged.connect(self.combobox_acoustic_data_choice_change_index)
self.groupbox_download_noise_file.toggled.connect(self.groupbox_download_noise_file_toggle)
# self.groupbox_download_noise_file.toggled.connect(self.groupbox_download_noise_file_size_change)
self.groupbox_compute_noise_from_profile_tail.toggled.connect(self.groupbox_option_profile_tail_toggle)
# self.groupbox_compute_noise_from_profile_tail.toggled.connect(self.groupbox_option_profile_tail_size_change)
self.pushbutton_noise_file.clicked.connect(self.open_dialog_box)
self.pushbutton_plot_noise_data.clicked.connect(self.open_plot_noise_window)
self.pushbutton_clear_noise_data.clicked.connect(self.clear_noise_data)
self.pushbutton_plot_profile_tail.clicked.connect(self.compute_average_profile_tail)
self.pushbutton_plot_profile_tail.clicked.connect(self.plot_averaged_profile_tail)
self.pushbutton_apply_noise_from_profile_tail.clicked.connect(self.plot_averaged_profile_tail)
self.pushbutton_apply_noise_from_profile_tail.clicked.connect(self.compute_noise_from_profile_tail_value)
self.combobox_freq_noise_from_profile_tail.currentIndexChanged.connect(self.compute_average_profile_tail)
self.combobox_freq_noise_from_profile_tail.currentIndexChanged.connect(self.plot_averaged_profile_tail)
self.pushbutton_Apply_SNR_filter.clicked.connect(self.remove_point_with_snr_filter)
# self.pushbutton_Apply_SNR_filter.clicked.connect(self.plot_pre_processed_BS_signal)
# self.pushbutton_Apply_SNR_filter.clicked.connect(self.update_plot_pre_processed_profile)
# self.spinbox_average_horizontal.valueChanged.connect(self.update_label_cells_sec)
self.lineEdit_horizontal_average.returnPressed.connect(self.update_label_cells_sec)
self.pushbutton_average.clicked.connect(self.compute_averaged_BS_data)
# self.pushbutton_average.clicked.connect(self.plot_pre_processed_BS_signal)
# self.pushbutton_average.clicked.connect(self.update_plot_pre_processed_profile)
self.pushbutton_slider_left_to_begin.clicked.connect(self.slide_profile_number_to_begin)
self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left)
self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit)
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.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider)
self.slider.valueChanged.connect(self.update_plot_pre_processed_profile)
# --------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------
# +++++++++ FUNCTION +++++++++
# --------------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------------
def update_SignalPreprocessingTab(self):
""" The tab is updated in two cases :
- the user remove a file (in the list widget) in the first tab (Acoustic data), so that the combobox
of data to be processed is updated,
- the user change the limits of one or all the records in the first tab (Acoustic data) """
print("filename BS_raw_data before clear ", stg.filename_BS_raw_data)
self.combobox_acoustic_data_choice.clear()
print("filename BS_raw_data after clear ", stg.filename_BS_raw_data)
self.combobox_acoustic_data_choice.addItems(stg.filename_BS_raw_data)
print("stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] ",
stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()])
if stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] == 0:
self.groupbox_download_noise_file.setChecked(True)
self.groupbox_compute_noise_from_profile_tail.setChecked(False)
self.groupbox_download_noise_file_toggle()
elif stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] == 1:
self.groupbox_download_noise_file.setChecked(False)
self.groupbox_compute_noise_from_profile_tail.setChecked(True)
self.groupbox_option_profile_tail_toggle()
self.combobox_freq_noise_from_profile_tail.clear()
self.combobox_freq_noise_from_profile_tail.addItems(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()])
self.combobox_acoustic_data_choice.currentIndexChanged.connect(self.combobox_acoustic_data_choice_change_index)
def activate_list_of_pre_processed_data(self):
for i in range(self.combobox_acoustic_data_choice.count()):
eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
eval("self.lineEdit_list_pre_processed_data_" + str(
self.combobox_acoustic_data_choice.currentIndex()) + ".setEnabled(True)")
eval("self.lineEdit_list_pre_processed_data_" + str(
self.combobox_acoustic_data_choice.currentIndex()) + ".returnPressed.connect(self.rename_preprocessed_data)")
# for t in range(self.combobox_acoustic_data_choice.count()):
# eval("self.lineEdit_list_pre_processed_data_" + str(t) + ".clear()")
eval("self.lineEdit_list_pre_processed_data_" + str(self.combobox_acoustic_data_choice.currentIndex()) +
".setText(stg.filename_BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()])")
def rename_preprocessed_data(self):
print("Before : stg.data_preprocessed ", stg.data_preprocessed)
exec("stg.data_preprocessed[self.combobox_acoustic_data_choice.currentIndex()] = "
"self.lineEdit_list_pre_processed_data_" + str(self.combobox_acoustic_data_choice.currentIndex()) + ".text()")
print("After : stg.data_preprocessed ", stg.data_preprocessed)
# print("QPlainTextEdit.textCursor().blockNumber() ", QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber())
# line_number = int(QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()/2)
# stg.data_preprocessed[line_number] = (
# QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()/2)
# print("stg.data_preprocessed ", stg.data_preprocessed)
# line = QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data).blockNumber()
# print(self.plaintextedit_list_pre_processed_data.setTextCursor(QPlainTextEdit.textCursor(self.plaintextedit_list_pre_processed_data)))
# # textCursor().currentList().itemText(line)
# stg.data_preprocessed
# ------------------------------------------------------
def groupbox_download_noise_file_toggle(self):
if self.groupbox_download_noise_file.isChecked() == True:
self.groupbox_compute_noise_from_profile_tail.setChecked(False)
elif self.groupbox_download_noise_file.isChecked() == False:
self.groupbox_compute_noise_from_profile_tail.setChecked(True)
def groupbox_download_noise_file_size_change(self):
duration = 500
self.animation_groupbox_download_noise_file = QPropertyAnimation(self.groupbox_download_noise_file, b"size")
self.animation_groupbox_download_noise_file.setDuration(duration)
self.animation_groupbox_download_noise_file.setStartValue(QSize(self.groupbox_download_noise_file.width(),
self.groupbox_download_noise_file.height()))
if self.groupbox_download_noise_file.isChecked():
self.animation_groupbox_download_noise_file.setEndValue(
QSize(self.groupbox_download_noise_file.width(),
self.groupbox_download_noise_file.sizeHint().height()))
else:
self.animation_groupbox_download_noise_file.setEndValue(QSize(self.groupbox_download_noise_file.width(), 25))
self.animation_groupbox_download_noise_file.start()
def groupbox_option_profile_tail_toggle(self):
if self.groupbox_compute_noise_from_profile_tail.isChecked() == True:
self.groupbox_download_noise_file.setChecked(False)
elif self.groupbox_compute_noise_from_profile_tail.isChecked() == False:
self.groupbox_download_noise_file.setChecked(True)
def groupbox_option_profile_tail_size_change(self):
duration = 500
self.animation_groupbox_option_profile_tail = QPropertyAnimation(self.groupbox_option_profile_tail, b"size")
self.animation_groupbox_option_profile_tail.setDuration(duration)
self.animation_groupbox_option_profile_tail.setStartValue(QSize(self.groupbox_option_profile_tail.width(),
self.groupbox_option_profile_tail.height()))
if self.groupbox_option_profile_tail.isChecked():
self.animation_groupbox_option_profile_tail.setEndValue(
QSize(self.groupbox_option_profile_tail.width(),
self.groupbox_option_profile_tail.sizeHint().height()))
else:
self.animation_groupbox_option_profile_tail.setEndValue(QSize(self.groupbox_option_profile_tail.width(), 25))
self.animation_groupbox_option_profile_tail.start()
# ------------------------------------------------------
def compute_average_profile_tail(self):
if (float(self.lineEdit_val1.text()) == 0) and (float(self.lineEdit_val2.text()) == 0):
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.lineEdit_val1.setText(str(
'%.3f' % np.nanmin(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()])))
self.lineEdit_val2.setText(str(
'%.3f' % np.nanmax(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()])))
elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.lineEdit_val1.setText(str(
'%.3f' % np.nanmin(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()])))
self.lineEdit_val2.setText(str(
'%.3f' % np.nanmax(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()])))
# --- Find index of line edit value ---
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val1 = np.where(np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()] -
float(self.lineEdit_val1.text().replace(",", ".")))
==
np.nanmin(np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()] -
float(self.lineEdit_val1.text().replace(",", "."))))
)[0][0]
val2 = np.where(np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()] -
float(self.lineEdit_val2.text().replace(",", ".")))
==
np.nanmin(np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()] -
float(self.lineEdit_val2.text().replace(",", "."))))
)[0][0]
elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val1 = np.where(np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()] -
float(self.lineEdit_val1.text().replace(",", ".")))
==
np.nanmin(np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()] -
float(self.lineEdit_val1.text().replace(",", "."))))
)[0][0]
val2 = np.where(np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()] -
float(self.lineEdit_val2.text().replace(",", ".")))
==
np.nanmin(np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()] -
float(self.lineEdit_val2.text().replace(",", "."))))
)[0][0]
print("val1 ", val1)
print("val2 ", val2)
# --- Compute averaged signal ---
# if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
# stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
# np.nanmean(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
# elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
# stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
# np.nanmean(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
# elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
print("self.combobox_acoustic_data_choice.currentIndex() ", self.combobox_acoustic_data_choice.currentIndex(),
self.combobox_acoustic_data_choice.currentText(), val1, val2,
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape)
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
np.nanmean(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
# for i in range(self.combobox_freq_noise_from_profile_tail.count()):
# print("BS_mean shape ", stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][i].shape)
# print("BS_mean ", stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][i])
def plot_averaged_profile_tail(self):
# --- Plot averaged signal ---
if stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.verticalLayout_groupbox_plot_profile_tail.removeWidget(self.canvas_profile_tail)
self.fig_profile_tail, self.axis_profile_tail = plt.subplots(nrows=1, ncols=1, layout='constrained')
self.canvas_profile_tail = FigureCanvas(self.fig_profile_tail)
self.verticalLayout_groupbox_plot_profile_tail.addWidget(self.canvas_profile_tail)
# if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# self.axis_profile_tail.plot(
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
# stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
# color="blue", linewidth=1)
# self.axis_profile_tail.plot(
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_freq_noise_from_profile_tail.currentIndex()],
# float(self.lineEdit_profile_tail_value.text().replace(",", ".")) *
# np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_freq_noise_from_profile_tail.currentIndex()].shape[0]),
# linestyle='dashed', linewidth=2, color='red')
#
# elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# print(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_freq_noise_from_profile_tail.currentIndex()].shape)
self.axis_profile_tail.plot(
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
color="blue", linewidth=1)
self.axis_profile_tail.plot(
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()],
float(self.lineEdit_profile_tail_value.text().replace(",", ".")) *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()].shape[0]),
linestyle='dashed', linewidth=2, color='red')
self.axis_profile_tail.set_yscale('log')
self.axis_profile_tail.tick_params(axis='both', labelsize=8)
# self.axis_profile_tail.set_yticklabels(fontsize=8)
self.axis_profile_tail.text(.98, .03, "Depth (m)",
fontsize=8, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.9,
horizontalalignment='right', verticalalignment='bottom', rotation='horizontal',
transform=self.axis_profile_tail.transAxes)
self.axis_profile_tail.text(.1, .45, "BS signal (v)",
fontsize=8, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.9,
horizontalalignment='right', verticalalignment='bottom', rotation='vertical',
transform=self.axis_profile_tail.transAxes)
self.axis_profile_tail.text(.98, .85,
stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()],
fontsize=10, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile_tail.transAxes)
self.fig_profile_tail.canvas.draw_idle()
# ------------------------------------------------------
def combobox_acoustic_data_choice_change_index(self):
# self.combobox_freq_noise_from_profile_tail.currentIndexChanged.connect(self.compute_average_profile_tail)
# self.combobox_freq_noise_from_profile_tail.currentIndexChanged.connect(self.plot_averaged_profile_tail)
self.compute_average_profile_tail()
self.plot_averaged_profile_tail()
self.lineEdit_SNR_criterion.setText(str(stg.SNR_filter_value[self.combobox_acoustic_data_choice.currentIndex()]))
self.plot_transect_with_SNR_data()
# self.plot_BS_signal_filtered_with_SNR()
self.plot_pre_processed_BS_signal()
# self.spinbox_average_horizontal.setValue(stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()])
self.lineEdit_horizontal_average.setText(str(stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()]))
# self.plot_profile_and_position_on_transect_with_slider()
self.combobox_frequency_profile.clear()
self.combobox_frequency_profile.addItems(
[f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]])
self.plot_pre_processed_profile()
if self.combobox_acoustic_data_choice.count() > 0:
for i in range(self.combobox_acoustic_data_choice.count()):
eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
#
eval("self.lineEdit_list_pre_processed_data_" + str(
self.combobox_acoustic_data_choice.currentIndex()) + ".setEnabled(True)")
def clear_noise_data(self):
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] = 0
stg.SNR_filter_value[self.combobox_acoustic_data_choice.currentIndex()] = 0
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
# stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
# stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
# stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
print("All is clear")
if stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] == 0:
self.lineEdit_noise_file.clear()
elif stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] == 1:
self.lineEdit_val1.clear()
self.lineEdit_val1.setText("0.00")
self.lineEdit_val2.clear()
self.lineEdit_val2.setText("0.00")
self.lineEdit_profile_tail_value.clear()
self.lineEdit_profile_tail_value.setText("0.0000")
self.verticalLayout_groupbox_plot_profile_tail.removeWidget(self.canvas_profile_tail)
self.canvas_profile_tail = FigureCanvas()
self.verticalLayout_groupbox_plot_profile_tail.addWidget(self.canvas_profile_tail)
self.lineEdit_SNR_criterion.setText("0.00")
self.lineEdit_horizontal_average.setText("0.00")
# self.label_profile_number.clear()
# self.label_profile_number.setText("Profile ")
# --- Clear SNR plot ---
self.verticalLayout_groupbox_plot_SNR.removeWidget(self.toolbar_SNR)
self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR)
self.canvas_SNR = FigureCanvas()
self.toolbar_SNR = NavigationToolBar(self.canvas_SNR, self)
self.scroll_SNR.setWidget(self.canvas_SNR)
self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR)
self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR)
print("SNR plot is clear")
# --- Clear BS plot ---
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.toolbar_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.scroll_BS)
self.canvas_BS = FigureCanvas()
self.toolbar_BS = NavigationToolBar(self.canvas_BS, self)
self.scroll_BS.setWidget(self.canvas_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.toolbar_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.scroll_BS)
print("BS plot is clear")
self.combobox_frequency_profile.clear()
self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile)
self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile)
self.canvas_profile = FigureCanvas()
self.toolbar_profile = NavigationToolBar(self.canvas_profile, self)
self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile)
self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile)
self.slider.setValue(1)
self.slider.setMaximum(10)
print("Profile plot is clear")
self.slider.setValue(0)
self.slider.setMaximum(10)
def open_dialog_box(self):
if self.combobox_acoustic_data_choice.count() > 0:
filename = QFileDialog.getOpenFileNames(self, "AQUAscat Noise file",
[stg.path_BS_raw_data[-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0],
"Aquascat file (*.aqa)",
options=QFileDialog.DontUseNativeDialog)
print("filename noise ", filename)
if filename[0]:
dir_name = path.dirname(filename[0][0])
name = path.basename(filename[0][0])
stg.path_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()] = dir_name
stg.filename_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()] = name
try:
print("stg.path_BS_noise_data : ", stg.path_BS_noise_data)
print("stg.filename_BS_noise_data : ", stg.filename_BS_noise_data)
self.load_noise_data_and_compute_SNR()
except ValueError as e:
print("error = ", e)
msgBox = QMessageBox()
msgBox.setWindowTitle("Download Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText("Please select a file")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
else:
self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()])
self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()])
# self.plot_noise()
self.plot_transect_with_SNR_data()
# self.combobox_freq_noise.addItems([f for f in stg.freq_text])
# self.combobox_freq_noise.currentIndexChanged.connect(self.plot_noise)
# self.spinbox_SNR_criterion.setValue(2)
# !!!!! A DECOCHER !!!!!!!!
# self.remove_point_with_snr_filter()
self.combobox_frequency_profile.clear()
self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]])
self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_pre_processed_BS_signal)
self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_pre_processed_profile)
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.slider.setMaximum(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
else:
self.slider.setMaximum(stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
# if len(stg.BS_stream_bed) and stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape:
#
# self.slider.setMaximum(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
#
# elif (stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[2]
# < stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape[2]):
#
# self.slider.setMaximum(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
#
# else:
#
# self.slider.setMaximum(stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
# !!!!! A DECOCHER !!!!!!!!
# self.compute_averaged_BS_data()
# !!!!! A DECOCHER !!!!!!!!
# self.plot_profile_and_position_on_transect_with_slider()
self.plot_pre_processed_BS_signal()
self.plot_pre_processed_profile()
stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] = 0
self.activate_list_of_pre_processed_data()
else:
msgBox = QMessageBox()
msgBox.setWindowTitle("Download Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText("Please upload acoustic data")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
def load_noise_data_and_compute_SNR(self):
stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] = 0
noise_data = AcousticDataLoader(stg.path_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()] +
"/" +
stg.filename_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()])
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = noise_data._BS_raw_data
# stg.date_noise = noise_data._date
# stg.hour_noise = noise_data._hour
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = noise_data._time
stg.depth_noise[self.combobox_acoustic_data_choice.currentIndex()] = noise_data._r
# stg.time_snr_reshape = stg.time_reshape
# print("len(stg.BS_cross_section) : ", len(stg.BS_cross_section))
# print("stg.BS_cross_section[0] : ", stg.BS_cross_section[0].shape)
# print("len(stg.BS_stream_bed) : ", len(stg.BS_stream_bed))
if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
print("Je suis dans stream bed")
noise = np.zeros(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape)
for f, _ in enumerate(noise_data._freq):
noise[f, :, :] = np.mean(
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :], axis=(0, 1))
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] = noise
stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()] = (
np.divide((stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()] -
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
print("Je suis dans cross section")
noise = np.zeros(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)
for f, _ in enumerate(noise_data._freq):
noise[f, :, :] = np.mean(
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :], axis=(0, 1))
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] = noise
stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = (
np.divide((stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()] -
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
# stg.SNR_reshape = np.reshape(stg.SNR_cross_section, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), order="F")
else:
print("Je suis dans raw")
noise = np.zeros(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape)
for f, _ in enumerate(noise_data._freq):
noise[f, :, :] = np.mean(
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :], axis=(0, 1))
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] = noise
stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
np.divide((stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()] -
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
# print("stg.SNR_raw_data[0].shape ", stg.SNR_raw_data)
print("C'est fait")
def open_plot_noise_window(self):
pnw = PlotNoiseWindow()
pnw.exec()
# def compute_noise_from_value(self):
#
# # --- Compute noise from value and compute SNR ---
#
# if stg.BS_stream_bed.size == 0:
#
# stg.time_snr = stg.t
#
# if self.spinbox_compute_noise_from_value.value() == 0:
#
# stg.BS_noise_raw_data = np.full(stg.BS_cross_section.shape,
# self.spinbox_compute_noise_from_value.value())
# print(f"stg.BS_noise_raw_data.shape : {stg.BS_noise_raw_data.shape}")
# stg.SNR_cross_section = np.full(stg.BS_cross_section.shape, 1e3)
#
# else:
#
# stg.BS_noise_raw_data = np.full(stg.BS_cross_section.shape, self.spinbox_compute_noise_from_value.value())
# stg.SNR_cross_section = np.divide((stg.BS_cross_section - stg.BS_noise_raw_data) ** 2,
# stg.BS_noise_raw_data ** 2)
#
# else:
#
# stg.time_snr = stg.t
#
# if self.spinbox_compute_noise_from_value.value() == 0:
#
# stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape,
# self.spinbox_compute_noise_from_value.value())
# stg.SNR_stream_bed = np.full(stg.BS_stream_bed.shape, 1e3)
#
# else:
#
# stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape,
# self.spinbox_compute_noise_from_value.value())
# stg.SNR_stream_bed = np.divide((stg.BS_stream_bed - stg.BS_noise_raw_data) ** 2,
# stg.BS_noise_raw_data ** 2)
#
#
#
# # --- Trigger graphic widgets ---
#
# self.combobox_freq_noise.addItems([f for f in stg.freq_text])
# self.plot_noise()
# self.plot_transect_with_SNR_data()
# self.combobox_freq_noise.currentIndexChanged.connect(self.plot_noise)
# self.spinbox_SNR_criterion.setValue(0)
# self.remove_point_with_snr_filter()
#
# self.combobox_frequency_profile.addItems([f for f in stg.freq_text])
# self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_profile_and_position_on_transect_with_slider)
# self.slider.setMaximum(stg.t.shape[1])
# self.compute_averaged_BS_data()
# self.plot_profile_and_position_on_transect_with_slider()
def compute_noise_from_profile_tail_value(self):
stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] = 1
stg.noise_value[self.combobox_acoustic_data_choice.currentIndex()] = (
float(self.lineEdit_profile_tail_value.text().replace(",", ".")))
# stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
# np.full(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape,
# self.spinbox_compute_noise_from_value.value()))
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()])
else:
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.time[self.combobox_acoustic_data_choice.currentIndex()])
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.depth_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()])
else:
stg.depth_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.depth[self.combobox_acoustic_data_choice.currentIndex()])
# --- Compute noise from value and compute SNR ---
if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
np.full(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape,
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:, :,
:stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape[2]])
stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()] = (
np.divide((stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()]
- stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
np.full(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape,
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:, :,
:stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[2]])
stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = (
np.divide((stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
- stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
else:
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
np.full(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape,
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
stg.BS_noise_averaged_data[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()])
stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
np.divide((stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()]
- stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
# print("stg.BS_noise_averaged_data ", stg.BS_noise_averaged_data)
# if len(stg.BS_stream_bed) == 0:
#
# if self.spinbox_compute_noise_from_value.value() == 0:
#
# stg.BS_noise_raw_data = np.full(stg.BS_cross_section[0].shape,
# self.spinbox_compute_noise_from_value.value())
# print(f"stg.BS_noise_raw_data.shape : {stg.BS_noise_raw_data.shape}")
# stg.SNR_cross_section = np.full(stg.BS_cross_section[0].shape, 1e3)
#
# else:
#
# stg.BS_noise_raw_data = np.full(stg.BS_cross_section[0].shape,
# self.spinbox_compute_noise_from_value.value())
# stg.SNR_cross_section = np.divide((stg.BS_cross_section[0] - stg.BS_noise_raw_data) ** 2,
# stg.BS_noise_raw_data ** 2)
#
# else:
#
# if self.spinbox_compute_noise_from_value.value() == 0:
#
# stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape,
# self.spinbox_compute_noise_from_value.value())
# stg.SNR_stream_bed = np.full(stg.BS_stream_bed.shape, 1e3)
#
# else:
#
# stg.BS_noise_raw_data = np.full(stg.BS_stream_bed.shape,
# self.spinbox_compute_noise_from_value.value())
# stg.SNR_stream_bed = np.divide((stg.BS_stream_bed - stg.BS_noise_raw_data) ** 2,
# stg.BS_noise_raw_data ** 2)
self.combobox_frequency_profile.clear()
self.combobox_frequency_profile.addItems(
[f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]])
# --- Trigger graphic widgets ---
if stg.SNR_filter_value[self.combobox_acoustic_data_choice.currentIndex()] == 0:
self.lineEdit_SNR_criterion.setText("0.00")
else:
self.lineEdit_SNR_criterion.setText(str(stg.SNR_filter_value[self.combobox_acoustic_data_choice.currentIndex()]))
# self.remove_point_with_snr_filter()
# self.combobox_frequency_profile.addItems(
# [f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]])
# self.combobox_frequency_profile.currentIndexChanged.connect(
# self.update_plot_pre_processed_profile)
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.slider.setMaximum(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
else:
self.slider.setMaximum(stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
self.plot_transect_with_SNR_data()
# self.compute_averaged_BS_data()
self.plot_pre_processed_BS_signal()
self.plot_pre_processed_profile()
self.activate_list_of_pre_processed_data()
def plot_noise(self):
self.horizontalLayout_groupbox_plot_noise_data.removeWidget(self.canvas_noise)
self.fig_noise, self.axis_noise = plt.subplots(nrows=1, ncols=1, layout="constrained")
self.canvas_noise = FigureCanvas(self.fig_noise)
self.horizontalLayout_groupbox_plot_noise_data.addWidget(self.canvas_noise)
val_min = np.nanmin(stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :])
val_max = np.nanmax(stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :])
print(f"0/ val_min for plot noise = {val_min}")
print(f"0/ val_max for plot noise = {val_max}")
if val_min == val_max:
pcm = self.axis_noise.pcolormesh(stg.time_snr[0, :],
-stg.depth[self.combobox_freq_noise.currentIndex(), :],
stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :],
cmap='viridis')
else:
if val_min == 0:
val_min = 1e-5
pcm = self.axis_noise.pcolormesh(stg.time_snr[0, :],
-stg.r[self.combobox_freq_noise.currentIndex(), :],
stg.BS_noise_raw_data[self.combobox_freq_noise.currentIndex(), :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
self.axis_noise.tick_params(axis='both', which='minor', labelsize=10)
# cbar = self.fig_noise.colorbar(pcm, ax=self.axis_noise, shrink=1, location='top')
# cbar.set_label(label='Noise signal (V)', rotation=0, labelpad=8)
# self.axis_noise.text(1, .70, stg.freq_text[self.combobox_freq_noise.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_noise.transAxes)
def plot_transect_with_SNR_data(self):
# --- Condition if table is not filled ---
# if not self.lineEdit_noise_file.text():
if len(stg.BS_noise_raw_data) == 0:
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.canvas_SNR == None:
else:
if ((self.combobox_acoustic_data_choice.currentIndex() != -1)
and (stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
self.verticalLayout_groupbox_plot_SNR.removeWidget(self.toolbar_SNR)
self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR)
self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], ncols=1, sharex=True, sharey=False, layout='constrained')
self.canvas_SNR = FigureCanvas(self.fig_SNR)
# self.verticalLayout_groupbox_plot_Noise_SNR.addWidget(self.canvas_SNR)
self.toolbar_SNR = NavigationToolBar(self.canvas_SNR, self)
# self.verticalLayout_groupbox_plot_SNR
# self.verticalLayout_groupbox_plot_Noise_SNR.removeWidget(self.scroll_SNR)
# self.scroll_SNR = QScrollArea()
self.scroll_SNR.setWidget(self.canvas_SNR)
# self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
# self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
# self.scroll_SNR.setAlignment(Qt.AlignCenter)
# self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR)
self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR)
self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR)
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
if stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x, y = np.meshgrid(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :],
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :])
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x, y = np.meshgrid(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :],
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :])
else:
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x, y = np.meshgrid(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][f, :],
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :])
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x, y = np.meshgrid(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][f, :],
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :])
print("0 plot SNR with SNR_stream_bed")
val_min = np.nanmin(stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
print(f"val min = {val_min}, val max = {val_max}")
if val_min == val_max:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
print("levels 0 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
else:
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
print("levels 1 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
print("bounds 1 = ", bounds)
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
print("levels 2 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max * 1000]
print("bounds 2 = ", bounds)
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
cf = (self.axis_SNR[f].contourf(x, -y,
stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
levels, cmap='gist_rainbow',
norm=norm))
elif stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x, y = np.meshgrid(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :],
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :])
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x, y = np.meshgrid(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :],
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :])
else:
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x, y = np.meshgrid(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][f, :],
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :])
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x, y = np.meshgrid(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][f, :],
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :])
print("1 plot SNR with SNR_cross_section")
val_min = np.nanmin(stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
print(f"val min = {val_min}, val max = {val_max}")
if val_min == val_max:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
print("levels 0 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
else:
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
print("levels 1 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
print("bounds 1 = ", bounds)
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
print("levels 2 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max * 1000]
print("bounds 2 = ", bounds)
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
cf = (self.axis_SNR[f].contourf(x, -y,
stg.SNR_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
levels, cmap='gist_rainbow', norm=norm))
else:
x, y = np.meshgrid(stg.time[self.combobox_acoustic_data_choice.currentIndex()][0, :],
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][0, :])
print("0 plot SNR with SNR_raw_data")
val_min = np.nanmin(stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
print(f"val min = {val_min}, val max = {val_max}")
if val_min == val_max:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
print("levels 0 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
else:
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
print("levels 1 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
print("bounds 1 = ", bounds)
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
print("levels 2 = ", levels)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max * 1000]
print("bounds 2 = ", bounds)
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
print("self.combobox_acoustic_data_choice.currentIndex() ", self.combobox_acoustic_data_choice.currentIndex())
print("x ", x.shape)
print("y ", y.shape)
print("stg.SNR_raw_data", stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape)
print("levels before cf ", levels)
cf = (self.axis_SNR[f].contourf(x, -y,
stg.SNR_raw_data[
self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
levels, cmap='gist_rainbow', norm=norm))
self.axis_SNR[f].text(1, .70, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][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()
# # --- Plot red solid line on transect to visualize position of plotted profile ---
# self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
# stg.time[self.combobox_frequency_profile.currentIndex(), 0] * np.ones(
# stg.r.shape[1]),
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# color='red', linestyle="solid", linewidth=2)
else:
self.verticalLayout_groupbox_plot_SNR.removeWidget(self.toolbar_SNR)
self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR)
self.canvas_SNR = FigureCanvas()
self.toolbar_SNR = NavigationToolBar(self.canvas_SNR, self)
self.scroll_SNR.setWidget(self.canvas_SNR)
self.verticalLayout_groupbox_plot_SNR.addWidget(self.toolbar_SNR)
self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR)
def remove_point_with_snr_filter(self):
if len(stg.BS_noise_raw_data) == 0:
msgBox = QMessageBox()
msgBox.setWindowTitle("SNR filter Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText("Load Noise data from acoustic data tab before using SNR filter")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
else:
stg.SNR_filter_value[self.combobox_acoustic_data_choice.currentIndex()] = (
float(self.lineEdit_SNR_criterion.text().replace(",", ".")))
if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_stream_bed_pre_process_SNR = deepcopy(stg.BS_stream_bed)
# stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]])
# stg.SNR_data_average = np.divide(
# (stg.BS_stream_bed_pre_process_SNR - stg.Noise_data) ** 2, stg.Noise_data ** 2)
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
f,
np.where(stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :] <
float(self.lineEdit_SNR_criterion.text().replace(",", ".")))[0],
np.where(stg.SNR_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :] <
float(self.lineEdit_SNR_criterion.text().replace(",", ".")))[1]] \
= np.nan
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_cross_section_pre_process_SNR = deepcopy(stg.BS_cross_section)
# stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]])
# stg.SNR_data_average = np.divide(
# (stg.BS_stream_bed_pre_process_SNR - stg.Noise_data) ** 2, stg.Noise_data ** 2)
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
f,
np.where(stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :,
:] < float(self.lineEdit_SNR_criterion.text().replace(",", ".")))[0],
np.where(stg.SNR_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :,
:] < float(self.lineEdit_SNR_criterion.text().replace(",", ".")))[1]] \
= np.nan
else:
stg.BS_raw_data_pre_process_SNR = deepcopy(stg.BS_raw_data)
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
f,
np.where(stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :,
:] < float(self.lineEdit_SNR_criterion.text().replace(",", ".")))[0],
np.where(stg.SNR_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :,
:] < float(self.lineEdit_SNR_criterion.text().replace(",", ".")))[1]] \
= np.nan
# elif stg.BS_stream_bed_pre_process_average.size != 0:
# stg.BS_stream_bed_pre_process_SNR = deepcopy(stg.BS_stream_bed_pre_process_average)
# BS_noise_cross_section = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]])
# print("BS_noise_cross_section.shape ", BS_noise_cross_section.shape)
# stg.SNR_data_average = np.divide(
# (stg.BS_stream_bed_pre_process_SNR - BS_noise_cross_section) ** 2, BS_noise_cross_section ** 2)
#
# print(stg.SNR_data_average[0, :, :])
# fig, ax = plt.subplots(nrows=1, ncols=1)
# x, y = np.meshgrid(list(range(stg.SNR_data_average.shape[2])),
# list(range(stg.SNR_data_average.shape[1])))
# levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
# bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2]
# norm = BoundaryNorm(boundaries=bounds, ncolors=300)
# cf = ax.contourf(x, -y, stg.SNR_data_average[0, :, :], cmap='gist_rainbow') # , levels, norm=norm)
# cbar = fig.colorbar(cf, ax=ax, shrink=1, location='right')
# plt.show()
#
# for f, _ in enumerate(stg.freq):
# print("----------------------------------------------")
# print(np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[0])
# print(np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1])
# stg.BS_stream_bed_pre_process_SNR[
# f,
# np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[0],
# np.where(stg.SNR_data_average[f, :, :] < self.spinbox_SNR_criterion.value())[1]] \
# = np.nan
# self.plot_pre_processed_BS_signal()
# self.update_plot_profile_position_on_transect()
# self.update_plot_averaged_profile()
# !!! A DECOCHER !!!
self.compute_averaged_BS_data()
self.update_plot_pre_processed_profile()
def plot_pre_processed_BS_signal(self):
# self.spinbox_average_horizontal.setValue(
# stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()])
self.lineEdit_horizontal_average.setText(str(stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()]))
if ((self.combobox_acoustic_data_choice.currentIndex() != -1)
and (stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.toolbar_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.scroll_BS)
self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0], ncols=1, sharex=True, sharey=False, layout="constrained")
self.canvas_BS = FigureCanvas(self.fig_BS)
self.toolbar_BS = NavigationToolBar(self.canvas_BS, self)
# self.verticalLayout_groupbox_plot_SNR.addWidget(self.canvas_SNR)
# self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR)
# self.scroll_BS = QScrollArea()
self.scroll_BS.setWidget(self.canvas_BS)
# self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
# self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
# self.scroll_BS.setAlignment(Qt.AlignCenter)
# self.verticalLayout_groupbox_BS_SNR_filter.addWidget(self.scroll_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.toolbar_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.scroll_BS)
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x_time = stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
y_depth = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x_time = stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
y_depth = stg.depth[self.combobox_acoustic_data_choice.currentIndex()]
else:
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x_time = stg.time[self.combobox_acoustic_data_choice.currentIndex()]
y_depth = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x_time = stg.time[self.combobox_acoustic_data_choice.currentIndex()]
y_depth = stg.depth[self.combobox_acoustic_data_choice.currentIndex()]
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
if stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(x_time[f, :], -y_depth[f, :],
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
self.axis_BS[f].plot(x_time[f, :], -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
color='black', linewidth=1, linestyle="solid")
elif stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(
x_time[f, :], -y_depth[f, :],
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(x_time[f, :], -y_depth[f, :],
stg.BS_raw_data_pre_process_average[
self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(x_time[f, :], -y_depth[f, :],
stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
self.axis_BS[f].plot(x_time[f, :],
-stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
color='black', linewidth=1, linestyle="solid")
elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(
x_time[f, :], -y_depth[f, :],
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(x_time[f, :], -y_depth[f, :],
stg.BS_raw_data_pre_process_SNR[
self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(
stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(
stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(x_time[f, :], -y_depth[f, :],
stg.BS_stream_bed[
self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(
stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(
stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(x_time[f, :], -y_depth[f, :],
stg.BS_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
val_min = np.nanmin(
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
val_max = np.nanmax(
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(x_time[f, :], -y_depth[f, :],
stg.BS_raw_data[
self.combobox_acoustic_data_choice.currentIndex()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
self.axis_BS[f].text(1, .70, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_BS[f].transAxes)
# --- Display red line on acoustic recording for profile position ---
self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
x_time[self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
np.ones(y_depth.shape[1]),
-y_depth[self.combobox_frequency_profile.currentIndex(), :],
linestyle="solid", linewidth=2, color="red")
# # print("current freq profile ", self.combobox_frequency_profile.currentIndex())
# if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
# stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
# np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle="solid", linewidth=2, color="red")
#
# elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
# stg.time[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
# np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle="solid", linewidth=2, color="red")
#
# elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
# stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
# np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
# -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle="solid", linewidth=2, color="red")
#
# elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# self.red_line_return, = self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
# stg.time[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
# np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
# -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle="solid", linewidth=2, color="red")
self.fig_BS.supxlabel('Time (sec)', fontsize=10)
self.fig_BS.supylabel('Depth (m)', fontsize=10)
cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right')
cbar.set_label(label='Acoustic backscatter signal (V)', rotation=270, labelpad=10)
self.fig_BS.canvas.draw_idle()
else:
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.toolbar_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.removeWidget(self.scroll_BS)
self.canvas_BS = FigureCanvas()
self.toolbar_BS = NavigationToolBar(self.canvas_BS, self)
self.scroll_BS.setWidget(self.canvas_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.toolbar_BS)
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field.addWidget(self.scroll_BS)
def update_label_cells_sec(self):
print("Je change la valeur du moyennage")
print(stg.nb_profiles_per_sec)
print(stg.nb_profiles_per_sec[self.combobox_acoustic_data_choice.currentIndex()][0])
print(self.combobox_acoustic_data_choice.currentIndex())
self.label_cells_horizontal.clear()
self.label_cells_horizontal.setText(
"cells = +/- " +
str((float(self.lineEdit_horizontal_average.text().replace(",", ".")) // 2) *
(1 / stg.nb_profiles_per_sec[self.combobox_acoustic_data_choice.currentIndex()][0])) +
" sec")
def compute_averaged_BS_data(self):
kernel_avg = np.ones(2 * int(float(self.lineEdit_horizontal_average.text().replace(",", "."))) + 1)
print(kernel_avg)
stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()] = (
float(self.lineEdit_horizontal_average.text().replace(",", ".")))
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x_time = stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
y_depth = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x_time = stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
y_depth = stg.depth[self.combobox_acoustic_data_choice.currentIndex()]
else:
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x_time = stg.time[self.combobox_acoustic_data_choice.currentIndex()]
y_depth = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()]
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
x_time = stg.time[self.combobox_acoustic_data_choice.currentIndex()]
y_depth = stg.depth[self.combobox_acoustic_data_choice.currentIndex()]
if stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy(
stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]))
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
for i in range(y_depth.shape[1]):
# stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i,:] = (
# convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
# f, i, :], weights=kernel_avg) / len(kernel_avg))
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
convolve(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :],
kernel_avg))
print("1 - Je suis dans stg.BS_stream_bed_pre_process_SNR")
elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy(
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]))
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
for i in range(y_depth.shape[1]):
# stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
# convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
# f, i, :], weights=kernel_avg) / len(kernel_avg))
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
convolve(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :],
kernel_avg))
print("2 - Je suis dans stg.BS_cross_section_pre_process_SNR")
elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy(
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]))
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
for i in range(y_depth.shape[1]):
# stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
# convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
# f, i, :], weights=kernel_avg) / len(kernel_avg))
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
convolve(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :],
kernel_avg))
print("3 - Je suis dans stg.BS_raw_data_pre_process_SNR")
elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy(
stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()]))
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
for i in range(y_depth.shape[1]):
# stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
# convolve1d(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][
# f, i, :], weights=kernel_avg) / len(kernel_avg))
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
convolve(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg))
print("4 - Je suis dans stg.BS_stream_bed")
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy(
stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()]))
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
for i in range(y_depth.shape[1]):
# stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
# convolve1d(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# f, i, :], weights=kernel_avg) / len(kernel_avg))
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
convolve(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, i, :],
kernel_avg))
print("5 - Je suis dans stg.BS_cross_section")
elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy(
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()]))
for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
for i in range(y_depth.shape[1]):
# stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
# convolve1d(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][
# f, i, :], weights=kernel_avg) / len(kernel_avg))
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = (
convolve(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg))
print("6 - Je suis dans stg.BS_raw_data")
self.plot_pre_processed_BS_signal()
self.update_plot_pre_processed_profile()
# if len(stg.BS_noise_raw_data) == 0:
# msgBox = QMessageBox()
# msgBox.setWindowTitle("Average Backscatter signal Error")
# msgBox.setIcon(QMessageBox.Warning)
# msgBox.setText("Load data from acoustic data tab before averaging backscatter signal")
# msgBox.setStandardButtons(QMessageBox.Ok)
# msgBox.exec()
#
# else:
#
# kernel = np.ones(2*self.spinbox_average_horizontal.value()+1)
# print(kernel)
#
# if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# # --- Données pré-traitées avec SNR : BS stream bed pre process SNR -> BS stream bed pre process SNR average ---
#
# if stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
# # ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()].shape) or
# # (stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape))):
#
# stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR)
#
# for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
# for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]):
# stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()][f, i,:] \
# = convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], weights=kernel) / len(kernel)
# print("1 - Je suis dans stg.BS_stream_bed_pre_process_SNR_average")
#
# # --- Données BS stream bed : BS stream bed -> BS stream bed pre process average ---
#
# else:
# # elif ((stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape) or
# # (stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape)):
#
# stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed)
#
# for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
# for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]):
# stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \
# = convolve1d(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], weights=kernel) / len(kernel)
# print("2 - Je suis dans stg.BS_stream_bed_pre_process_average")
#
# elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# # --- Données pré-traitées avec SNR : BS cross section pre process SNR -> BS cross section pre process SNR average ---
#
# if stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
# # if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()].shape) or
# # (stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape)):
#
# stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR)
#
# for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
# for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]):
# stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \
# = convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], weights=kernel) / len(kernel)
# print("3 - Je suis dans stg.BS_cross_section_pre_process_SNR_average")
#
# # --- Données BS section : BS cross section -> BS cross section pre process average ---
#
# else:
# # elif ((stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape) or
# # (stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)):
#
# stg.BS_cross_section_pre_process_average = deepcopy(stg.BS_cross_section)
#
# for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
# for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]):
# stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \
# = convolve1d(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], weights=kernel) / len(kernel)
# print("4 - Je suis dans stg.BS_cross_section_pre_process_average")
#
# else:
#
# # --- Données pré-traitées avec SNR : BS raw data pre process SNR -> BS raw data pre process SNR average ---
#
# if stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
# # if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()].shape) or
# # (stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape)):
#
# stg.BS_raw_data_pre_process_SNR_average = deepcopy(stg.BS_raw_data_pre_process_SNR)
#
# for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
# for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]):
# stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \
# = convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], weights=kernel) / len(kernel)
# print("5 - Je suis dans stg.BS_raw_data_pre_process_SNR_average")
#
# # --- Données BS brutes : BS raw data -> BS raw data pre process average ---
#
# else:
#
# stg.BS_raw_data_pre_process_average = deepcopy(stg.BS_raw_data)
#
# for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
# for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]):
# stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i,:] \
# = convolve1d(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], weights=kernel) / len(kernel)
# print("6 - Je suis dans stg.BS_raw_data_pre_process_average")
# if (stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape ==
# stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape):
#
# stg.BS_raw_data_pre_process_average = deepcopy(stg.BS_raw_data)
#
# for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]):
# for i in range(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]):
# stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] \
# = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=kernel) / len(kernel)
#
# stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR)
# # print(f"1/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_SNR_average}")
# for f, _ in enumerate(stg.freq):
# for i in range(stg.r.shape[1]):
# stg.BS_stream_bed_pre_process_SNR_average[f, i, :] \
# = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=kernel) / len(kernel)
# # stg.BS_stream_bed_pre_process_average[i, f, :] \
# # = convolve1d(stg.BS_cross_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0]
#
# return stg.BS_stream_bed_pre_process_SNR_average
#
# elif stg.BS_cross_section_pre_process_SNR.size != 0:
#
# stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR)
# print(f"2/ stg.BS_cross_section_averaged : {stg.BS_cross_section_pre_process_SNR_average}")
# for f, _ in enumerate(stg.freq):
# for i in range(stg.r.shape[1]):
# stg.BS_cross_section_pre_process_SNR_average[f, i, :] \
# = convolve1d(stg.BS_cross_section_pre_process_SNR[f, i, :],
# weights=kernel) / len(kernel)
#
# return stg.BS_cross_section_pre_process_SNR_average
#
# elif stg.BS_stream_bed.size != 0:
#
# stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed)
# # print(f"3/ stg.BS_stream_bed_pre_process_average : {stg.BS_stream_bed_pre_process_average.shape}")
# print(stg.BS_stream_bed_pre_process_average[0, 10, :50])
# for f, _ in enumerate(stg.freq):
# for i in range(stg.r.shape[1]):
# stg.BS_stream_bed_pre_process_average[f, i, :] \
# = convolve1d(stg.BS_stream_bed[f, i, :],
# weights=kernel) / len(kernel)
# print(stg.BS_stream_bed_pre_process_average[0, 10, :50])
#
# return stg.BS_stream_bed_pre_process_average
#
# elif stg.BS_cross_section.size != 0:
#
# stg.BS_cross_section_averaged = deepcopy(stg.BS_cross_section)
# # print(f"4/ stg.BS_cross_section_averaged : {stg.BS_cross_section_averaged.shape}")
# for f, _ in enumerate(stg.freq):
# for i in range(stg.r.shape[1]):
# stg.BS_cross_section_averaged[f, i, :] \
# = convolve1d(stg.BS_cross_section[f, i, :],
# weights=kernel) / len(kernel)
#
# return stg.BS_cross_section_averaged
#
# if stg.ABS_name == "Aquascat 1000R":
# self.label_cells_horizontal.clear()
# self.label_cells_horizontal.setText(
# "cells = +/- " + str((self.spinbox_average_horizontal.value() // 2)*(1/stg.nb_profiles_per_sec)) + " sec")
# !!!!!!!!! A DECOCHER !!!!!!!!!!!
# self.plot_profile_and_position_on_transect_with_slider()
def plot_pre_processed_profile(self):
if ((self.combobox_acoustic_data_choice.currentIndex() != -1) and
(stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile)
self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile)
self.figure_profile, self.axis_profile = plt.subplots(nrows=1, ncols=1, layout="constrained")
self.canvas_profile = FigureCanvas(self.figure_profile)
# self.scroll_profile.setWidget(self.canvas_profile)
self.toolbar_profile = NavigationToolBar(self.canvas_profile, self)
self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile)
self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile)
# --- PLot profile ---
if stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_cross_section_pre_process_average[self.combobox_frequency_profile.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
self.axis_profile.text(
.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex()],
fontsize=10, fontweight='bold', fontname="Ubuntu",
fontstyle="normal", c="black", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes)
self.axis_profile.set_xlabel("Acoustic Backscatter Signal (V)")
self.axis_profile.set_ylabel("Depth (m)")
self.figure_profile.canvas.draw_idle()
else:
self.combobox_frequency_profile.clear()
self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile)
self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile)
self.canvas_profile = FigureCanvas()
self.toolbar_profile = NavigationToolBar(self.canvas_profile, self)
self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile)
self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile)
self.slider.setValue(1)
self.slider.setMaximum(10)
def update_plot_pre_processed_profile(self):
if ((self.combobox_acoustic_data_choice.currentIndex() != -1) and
(stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
self.axis_profile.cla()
# --- PLot profile ---
if stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile.plot(
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
self.axis_profile.text(
.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex()],
fontsize=10, fontweight='bold', fontname="Ubuntu",
fontstyle="normal", c="black", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes)
self.axis_profile.set_xlabel("Acoustic Backscatter Signal (V)")
self.axis_profile.set_ylabel("Depth (m)")
self.figure_profile.canvas.draw_idle()
# --- Update red line position on transect ---
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.red_line_return.set_data(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), self.slider.value()-1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :])
elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.red_line_return.set_data(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :])
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.red_line_return.set_data(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :])
elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.red_line_return.set_data(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), :])
self.fig_BS.canvas.draw_idle()
# def plot_pre_processed_profile(self):
#
# # --- Update label "Profile N / max(N)" ---
# # self.label_profile_number.clear()
# # self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum()))
#
# if ((self.combobox_acoustic_data_choice.currentIndex() != -1) and
# (stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
#
# self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile)
# self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile)
#
# self.figure_profile, self.axis_profile = plt.subplots(nrows=2, ncols=1, layout="constrained")
# self.canvas_profile = FigureCanvas(self.figure_profile)
# # self.scroll_profile.setWidget(self.canvas_profile)
# self.toolbar_profile = NavigationToolBar(self.canvas_profile, self)
#
# self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile)
# self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile)
#
# if stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# # --- Plot profile ---
# self.axis_profile.plot(
# stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(
# stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(
# stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_stream_bed_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# elif stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(
# stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(
# stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_stream_bed_pre_process_average[
# self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# elif stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(
# stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(
# stg.BS_cross_section_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_cross_section_pre_process_SNR_average[
# self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# elif stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(
# stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(
# stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_cross_section_pre_process_average[
# self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# elif stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(
# stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(
# stg.BS_raw_data_pre_process_SNR_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_raw_data_pre_process_SNR_average[
# self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
# -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(
# stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(
# stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_raw_data_pre_process_average[
# self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
#
# self.axis_profile[1].plot(
# stg.time[self.combobox_acoustic_data_choice.currentIndex()]
# [self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] *
# np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
# -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :],
# color='red', linestyle="solid", linewidth=2)
#
# self.axis_profile[0].set_xlabel("Acoustic Backscatter Signal (V)")
# self.axis_profile[0].set_ylabel("Depth (m)")
#
# if len(stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()]) != 0:
# if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
# self.axis_profile[1].plot(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex(), :],
# -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
# color='black', linewidth=1, linestyle="solid")
# else:
# self.axis_profile[1].plot(stg.time[self.combobox_acoustic_data_choice - 1][
# self.combobox_frequency_profile.currentIndex(), :],
# -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
# color='black', linewidth=1, linestyle="solid")
#
# self.axis_profile[1].set_xticks([])
# self.axis_profile[1].set_yticks([])
#
# self.figure_profile.canvas.draw_idle()
#
# else:
#
# # self.canvas_profile.figure.clear()
# # self.figure_profile.clf()
# # self.axis_profile.tolist().clear()
# self.canvas_profile = FigureCanvas()
# self.scroll_profile.setWidget(self.canvas_profile)
# if stg.BS_stream_bed_pre_process_SNR_average.size != 0:
#
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :],
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_stream_bed_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# elif stg.BS_cross_section_pre_process_SNR_average.size != 0:
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_cross_section_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :,
# self.slider.value() - 1],
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR_average[self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :],
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_cross_section_pre_process_SNR_average[
# self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# elif stg.BS_stream_bed_pre_process_SNR.size != 0:
#
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :],
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_stream_bed_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# elif stg.BS_cross_section_pre_process_SNR.size != 0:
# # --- Plot profile ---
# self.axis_profile[0].plot(
# stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :,
# self.slider.value() - 1],
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# linestyle='solid', color='k', linewidth=1)
# self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_frequency_profile.currentIndex()],
# fontsize=10, fontweight='bold', fontname="Ubuntu",
# fontstyle="normal", c="black", alpha=0.2,
# horizontalalignment='right', verticalalignment='bottom',
# transform=self.axis_profile[0].transAxes)
#
# # --- Plot transect with profile position ---
# self.axis_profile[1].cla()
# val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :])
# val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR[self.combobox_frequency_profile.currentIndex(), :, :])
# if val_min == 0:
# val_min = 1e-5
# self.axis_profile[1].pcolormesh(stg.t[self.combobox_frequency_profile.currentIndex(), :],
# -stg.r[self.combobox_frequency_profile.currentIndex(), :],
# stg.BS_cross_section_pre_process_SNR[
# self.combobox_frequency_profile.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
# ------------------------------------- Connect Push Button Load Data + Slider -------------------------------------
def slide_profile_number_to_begin(self):
self.slider.setValue(int(self.slider.minimum()))
self.update_lineEdit_by_moving_slider()
def slide_profile_number_to_right(self):
self.slider.setValue(int(self.slider.value()) + 1)
self.update_lineEdit_by_moving_slider()
def slide_profile_number_to_left(self):
self.slider.setValue(int(self.slider.value()) - 1)
self.update_lineEdit_by_moving_slider()
def slide_profile_number_to_end(self):
self.slider.setValue(int(self.slider.maximum()))
self.update_lineEdit_by_moving_slider()
def profile_number_on_lineEdit(self):
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.slider.setValue(
int(np.where(
np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()] -
float(self.lineEdit_slider.text().replace(",", "."))) ==
np.nanmin(
np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()] -
float(self.lineEdit_slider.text().replace(",", ".")))))[0][0]))
else:
self.slider.setValue(
int(np.where(
np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()] -
float(self.lineEdit_slider.text().replace(",", "."))) ==
np.nanmin(
np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()] -
float(self.lineEdit_slider.text().replace(",", ".")))))[0][0]))
def update_lineEdit_by_moving_slider(self):
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.lineEdit_slider.setText(
str(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), self.slider.value()-1]))
else:
self.lineEdit_slider.setText(
str(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_profile.currentIndex(), self.slider.value()-1]))