Averaged transect is computed before applying SNR filter + Computing water attenuation is added + transect is plotted without outliers below the section bottom

dev-brahim
brahim 2023-09-11 10:55:05 +02:00
parent ff019e5117
commit 45aa5ae2f5
3 changed files with 352 additions and 456 deletions

View File

@ -17,7 +17,7 @@ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as Navigatio
import Translation.constant_string as cs
from checkable_combobox import CheckableComboBox
from View.checkable_combobox import CheckableComboBox
import settings as stg

View File

@ -7,6 +7,7 @@ from PyQt5.QtCore import Qt, QCoreApplication
import numpy as np
from copy import deepcopy
from scipy.ndimage import convolve1d
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
@ -82,12 +83,13 @@ class SignalProcessingTab(QWidget):
self.pushbutton_load_data = QPushButton()
self.horizontalLayout_pushbutton_load_data_plot_bottom_line.addWidget(self.pushbutton_load_data)
self.pushbutton_load_data.clicked.connect(self.compute_BS_data_section)
self.pushbutton_load_data.clicked.connect(self.plot_profile_position_on_transect)
self.pushbutton_load_data.clicked.connect(self.plot_profile)
self.combobox_frequency = QComboBox()
self.horizontalLayout_pushbutton_load_data_plot_bottom_line.addWidget(self.combobox_frequency)
self.combobox_frequency.currentTextChanged.connect(self.update_plot_profile_position_on_transect)
# self.combobox_frequency.currentTextChanged.connect(self.update_plot_profile_position_on_transect)
# +++++++++++++++++++++++++++++++++++++++++++++++++
# +++ --- GroupBox Display Profile Position --- +++
@ -149,42 +151,35 @@ class SignalProcessingTab(QWidget):
self.verticalLayout_groupbox_post_processing = QVBoxLayout(self.groupbox_post_processing)
self.groupbox_acoustic_profile = QGroupBox()
self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_acoustic_profile)
self.groupbox_rayleigh_criterion = QGroupBox()
self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_rayleigh_criterion)
self.groupbox_window_size = QGroupBox()
self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_window_size)
self.groupbox_rayleigh_criterion = QGroupBox()
self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_rayleigh_criterion)
self.groupbox_acoustic_profile = QGroupBox()
self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_acoustic_profile)
# --- Groupbox acoustic profile ---
# --- Groupbox Rayleigh criterion ---
self.gridLayout_groupbox_acoustic_profile = QGridLayout(self.groupbox_acoustic_profile)
self.gridLayout_rayleigh_criterion = QGridLayout(self.groupbox_rayleigh_criterion)
# self.checkbox_SNR_criterion = QCheckBox()
self.label_SNR_criterion = QLabel()
self.gridLayout_groupbox_acoustic_profile.addWidget(self.label_SNR_criterion, 0, 0, 1, 1)
self.spinbox_SNR_criterion = QSpinBox()
self.spinbox_SNR_criterion.setRange(0, 9999)
self.spinbox_SNR_criterion.setValue(0)
# self.spinbox_SNR_criterion.setDisabled(True)
self.gridLayout_groupbox_acoustic_profile.addWidget(self.spinbox_SNR_criterion, 0, 1, 1, 1)
self.label_Rayleigh_criterion = QLabel()
self.label_Rayleigh_criterion.setText("<V²>/<V>² <=")
self.gridLayout_rayleigh_criterion.addWidget(self.label_Rayleigh_criterion, 0, 0, 1, 1)
# self.checkbox_SNR_criterion.clicked.connect(self.enable_disable_spinbox_snr_value)
self.spinbox_SNR_criterion.valueChanged.connect(self.remove_point_with_snr_filter)
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.pushbutton_snr_filter = QPushButton()
self.pushbutton_snr_filter.setText("Apply SNR")
# self.pushbutton_snr_filter.setDisabled(True)
self.gridLayout_groupbox_acoustic_profile.addWidget(self.pushbutton_snr_filter, 0, 2, 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.spinbox_SNR_criterion.valueChanged.connect(self.update_plot_profiles)
# self.spinbox_SNR_criterion.valueChanged.connect(self.update_plot_profile_position_on_transect)
self.pushbutton_snr_filter.clicked.connect(self.update_plot_profile)
# self.pushbutton_snr_filter.clicked.connect(self.remove_point_with_snr_filter)
# self.pushbutton_snr_filter.clicked.connect(self.update_plot_profile_position_on_transect)
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)
# --- Groupbox Window size ---
@ -207,56 +202,30 @@ class SignalProcessingTab(QWidget):
# self.pushbutton_snr_filter.setDisabled(True)
self.horizontalLayout_groupbox_window_size.addWidget(self.pushbutton_average)
self.pushbutton_average.clicked.connect(self.update_plot_profile_position_on_transect)
self.pushbutton_average.clicked.connect(self.plot_averaged_profile)
# --- Groupbox Rayleigh criterion ---
# --- Groupbox acoustic profile ---
# # self.groupbox_rayleigh_criterion.setTitle("Rayleigh criterion")
# # self.groupbox_despiking_signal = QGroupBox()
# # self.groupbox_despiking_signal.setTitle("Despiking the signal")
# # self.verticalLayout_despiking_signal = QVBoxLayout(self.groupbox_despiking_signal)
# # self.horizontalLayout_despiking_signal_label = QHBoxLayout()
#
# # self.gridLayout_rayleigh_criterion = QGridLayout(self.groupbox_rayleigh_criterion)
# self.horizontalLayout_rayleigh_criterion = QHBoxLayout(self.groupbox_rayleigh_criterion)
#
# self.label_Rayleigh_criterion = QLabel()
# self.label_Rayleigh_criterion.setText("<V²>/<V>² <=")
# # self.horizontalLayout_despiking_signal_label.addWidget(self.label_Rayleigh_criterion)
# # self.gridLayout_rayleigh_criterion.addWidget(self.label_Rayleigh_criterion, 0, 0, 1, 1)
# self.horizontalLayout_rayleigh_criterion.addWidget(self.label_Rayleigh_criterion)
# # self.lineEdit_despiking_signal_label = QLineEdit()
# # self.lineEdit_despiking_signal_label.setText("10")
# self.spinbox_rayleigh_criterion = QSpinBox()
# self.spinbox_rayleigh_criterion.setRange(0, 9999)
# self.spinbox_rayleigh_criterion.setValue(10)
# # self.horizontalLayout_despiking_signal_label.addWidget(self.lineEdit_despiking_signal_label)
# # self.gridLayout_rayleigh_criterion.addWidget(self.lineEdit_despiking_signal_label, 0, 1, 1, 1)
# self.horizontalLayout_rayleigh_criterion.addWidget(self.spinbox_rayleigh_criterion)
# self.label_4pi = QLabel()
# self.label_4pi.setText("% x 4/pi")
# # self.horizontalLayout_despiking_signal_label.addWidget(self.label_4pi)
# # self.gridLayout_rayleigh_criterion.addWidget(self.label_4pi, 0, 2, 1, 1)
# self.horizontalLayout_rayleigh_criterion.addWidget(self.label_4pi)
# # self.verticalLayout_despiking_signal.addLayout(self.horizontalLayout_despiking_signal_label)
# # self.pushbutton_despiking_signal = QPushButton()
# # self.pushbutton_despiking_signal.setText("Despiking the signal")
# # self.verticalLayout_despiking_signal.addWidget(self.pushbutton_despiking_signal)
# self.checkbox_despiked_acoustic_signal = QCheckBox()
# # self.checkbox_despiked_acoustic_signal.setText("Despiking")
# self.checkbox_despiked_acoustic_signal.setToolTip("Enable for further computation")
# # self.gridLayout_rayleigh_criterion.addWidget(self.checkbox_rayleigh_criterion_enable, 0, 3, 1, 1)
# self.horizontalLayout_rayleigh_criterion.addWidget(self.checkbox_despiked_acoustic_signal)
# # self.horizontalLayout_averaged_profile_despiking_signal.addWidget(self.groupbox_rayleigh_criterion)
#
# # self.verticalLayout_groupbox_averageprofile_despikingsignal.addWidget(self.groupbox_despiking_signal)
self.gridLayout_groupbox_acoustic_profile = QGridLayout(self.groupbox_acoustic_profile)
# # self.horizontalLayoutMid_signalProcessing.addWidget(self.groupbox_post_processing, 3)
# self.verticalLayout_left_SignalProcessingTab.addWidget(self.groupbox_post_processing)
#
# # self.horizontalLayoutBottom_signalProcessing = QHBoxLayout()
# # self.verticalLayout_signalProcessingTab.addLayout(self.horizontalLayoutBottom_signalProcessing, 3)
#
# self.checkbox_SNR_criterion = QCheckBox()
self.label_SNR_criterion = QLabel()
self.gridLayout_groupbox_acoustic_profile.addWidget(self.label_SNR_criterion, 0, 0, 1, 1)
self.spinbox_SNR_criterion = QSpinBox()
self.spinbox_SNR_criterion.setRange(0, 9999)
self.spinbox_SNR_criterion.setValue(0)
# self.spinbox_SNR_criterion.setDisabled(True)
self.gridLayout_groupbox_acoustic_profile.addWidget(self.spinbox_SNR_criterion, 0, 1, 1, 1)
self.spinbox_SNR_criterion.valueChanged.connect(self.remove_point_with_snr_filter)
self.pushbutton_snr_filter = QPushButton()
self.pushbutton_snr_filter.setText("Apply SNR")
self.gridLayout_groupbox_acoustic_profile.addWidget(self.pushbutton_snr_filter, 0, 2, 1, 1)
self.pushbutton_snr_filter.clicked.connect(self.update_plot_profile)
self.pushbutton_snr_filter.clicked.connect(self.update_plot_profile_position_on_transect)
# ++++++++++++++++++++++++++++++++++++
# +++ --- GroupBox FCB options --- +++
@ -264,103 +233,79 @@ class SignalProcessingTab(QWidget):
self.verticalLayout_groupbox_FCBoption = QVBoxLayout(self.groupbox_FCBoption)
# --- Groupbox water attenuation ---
self.groupbox_water_attenuation = QGroupBox()
self.verticalLayout_groupbox_FCBoption.addWidget(self.groupbox_water_attenuation)
# self.verticalLayout_groupbox_water_attenuation = QVBoxLayout(self.groupbox_water_attenuation)
# self.horizontalLayout_waterAttenuationModel_temperature = QHBoxLayout()
# self.verticalLayout_groupbox_water_attenuation.addLayout(
# self.horizontalLayout_waterAttenuationModel_temperature)
#
# self.combobox_water_attenuation_model = QComboBox()
# self.combobox_water_attenuation_model.addItem("François & Garrison 1982")
# self.combobox_water_attenuation_model.addItem("Other model")
# self.horizontalLayout_waterAttenuationModel_temperature.addWidget(self.combobox_water_attenuation_model)
#
# self.label_temperature_water_attenation = QLabel()
# # self.label_temperature_water_attenation.setText("Temperature:")
# self.horizontalLayout_waterAttenuationModel_temperature.addWidget(self.label_temperature_water_attenation)
#
# # self.lineEdit_temperature_water_attenuation = QLineEdit()
# self.spinbox_temperature_water_attenuation = QSpinBox()
# self.horizontalLayout_waterAttenuationModel_temperature.addWidget(self.spinbox_temperature_water_attenuation)
#
# self.label_degre_celsius = QLabel()
# self.label_degre_celsius.setText("°C")
# self.horizontalLayout_waterAttenuationModel_temperature.addWidget(self.label_degre_celsius)
#
# self.horizontalLayout_comboboxFrequencies_WaterAttenuationValue = QHBoxLayout()
# self.verticalLayout_groupbox_water_attenuation.addLayout(
# self.horizontalLayout_comboboxFrequencies_WaterAttenuationValue)
#
# self.combobox_water_attenuation = QComboBox()
# self.combobox_water_attenuation.addItem('0.3 MHz')
# self.combobox_water_attenuation.addItem('0.5 MHz')
# self.combobox_water_attenuation.addItem('1 MHz')
# self.combobox_water_attenuation.addItem('5 MHz')
# # self.combobox_water_attenuation.currentIndexChanged.connect(self.alpha_value_changed)
#
# self.horizontalLayout_comboboxFrequencies_WaterAttenuationValue.addWidget(self.combobox_water_attenuation)
#
# self.label_water_attenuation = QLabel()
# self.label_water_attenuation.setText("\u03B1w = 0.02 dB/m")
# self.label_water_attenuation.setFont(QFont("Ubuntu", 14, QFont.Normal))
# self.horizontalLayout_comboboxFrequencies_WaterAttenuationValue.addWidget(self.label_water_attenuation)
# --- Groupbox fit regression line ---
self.groupbox_fit_regression_line = QGroupBox()
self.verticalLayout_groupbox_FCBoption.addWidget(self.groupbox_fit_regression_line)
# self.verticalLayout_groupbox_fit_regression = QVBoxLayout(self.groupbox_fit_regression_line)
#
# self.label_alphaS_expression = QLabel()
# # self.label_alphaS_expression.setText("For homogeneous suspension: dFCB/dr = -2\u03B1<sub>s<\sub>")
# self.verticalLayout_groupbox_fit_regression.addWidget(self.label_alphaS_expression)
#
# self.horizontalLayout_alphaS_computation = QHBoxLayout()
# self.verticalLayout_groupbox_fit_regression.addLayout(self.horizontalLayout_alphaS_computation)
#
# self.combobox_frequency_compute_alphaS = QComboBox()
# self.combobox_frequency_compute_alphaS.addItem("0.3 MHz")
# self.combobox_frequency_compute_alphaS.addItem("0.5 MHz")
# self.combobox_frequency_compute_alphaS.addItem("1 MHz")
# self.combobox_frequency_compute_alphaS.addItem("5 MHz")
# self.combobox_frequency_compute_alphaS.addItem("All frequencies")
# self.horizontalLayout_alphaS_computation.addWidget(self.combobox_frequency_compute_alphaS)
#
# self.label_alphaS_computation_from = QLabel()
# # self.label_alphaS_computation_from.setText("From")
# self.horizontalLayout_alphaS_computation.addWidget(self.label_alphaS_computation_from)
#
# # self.lineEdit_alphaS_computation_from = QLineEdit()
# self.spinbox_alphaS_computation_from = QDoubleSpinBox()
# self.spinbox_alphaS_computation_from.setRange(0, 9999)
# self.horizontalLayout_alphaS_computation.addWidget(self.spinbox_alphaS_computation_from)
#
# self.label_alphaS_computation_to = QLabel()
# # self.label_alphaS_computation_to.setText("to")
# self.horizontalLayout_alphaS_computation.addWidget(self.label_alphaS_computation_to)
#
# # self.lineEdit_alphaS_computation_to = QLineEdit()
# self.spinbox_alphaS_computation_to = QDoubleSpinBox()
# self.horizontalLayout_alphaS_computation.addWidget(self.spinbox_alphaS_computation_to)
#
# self.horizontalLayout_fitButton_alphaWvalue = QHBoxLayout()
# self.verticalLayout_groupbox_fit_regression.addLayout(self.horizontalLayout_fitButton_alphaWvalue)
#
# self.pushbutton_fit_regression_line = QPushButton()
# self.pushbutton_fit_regression_line.setText("Fit && Compute \u03B1s")
# self.horizontalLayout_fitButton_alphaWvalue.addWidget(self.pushbutton_fit_regression_line)
#
# self.label_alphaS = QLabel()
# self.label_alphaS.setText("\u03B1s = " + "0.0" + "dB/m")
# self.label_alphaS.setFont(QFont("Ubuntu", 14, QFont.Normal))
# self.horizontalLayout_fitButton_alphaWvalue.addWidget(self.label_alphaS)
# --- Groupbox water attenuation ---
# # self.verticalLayout_groupbox_fit_regression
self.gridLayout_groupbox_water_attenuation = QGridLayout(self.groupbox_water_attenuation)
self.combobox_water_attenuation_model = QComboBox()
self.combobox_water_attenuation_model.addItem("François & Garrison 1982")
self.combobox_water_attenuation_model.addItem("Other model")
self.gridLayout_groupbox_water_attenuation.addWidget(self.combobox_water_attenuation_model, 0, 0, 1, 1)
self.label_temperature_water_attenation = QLabel()
self.gridLayout_groupbox_water_attenuation.addWidget(self.label_temperature_water_attenation, 0, 1, 1, 1)
self.spinbox_temperature_water_attenuation = QSpinBox()
self.gridLayout_groupbox_water_attenuation.addWidget(self.spinbox_temperature_water_attenuation, 0, 2, 1, 1)
self.label_degre_celsius = QLabel()
self.label_degre_celsius.setText("°C")
self.gridLayout_groupbox_water_attenuation.addWidget(self.label_degre_celsius, 0, 3, 1, 1)
self.combobox_freq_for_water_attenuation = QComboBox()
# self.combobox_water_attenuation.currentIndexChanged.connect(self.alpha_value_changed)
self.gridLayout_groupbox_water_attenuation.addWidget(self.combobox_freq_for_water_attenuation, 1, 0, 1, 1)
self.pushbutton_water_attenuation = QPushButton()
self.pushbutton_water_attenuation.setText("Compute \u03B1w")
self.gridLayout_groupbox_water_attenuation.addWidget(self.pushbutton_water_attenuation, 1, 1, 1, 1)
self.pushbutton_water_attenuation.clicked.connect(self.compute_water_attenuation)
self.label_water_attenuation = QLabel()
self.label_water_attenuation.setText("\u03B1w = 0.00 dB/m")
self.label_water_attenuation.setFont(QFont("Ubuntu", 14, QFont.Normal))
self.gridLayout_groupbox_water_attenuation.addWidget(self.label_water_attenuation, 1, 2, 1, 1)
# --- Groupbox fit regression line ---
self.gridLayout_groupbox_fit_regression = QGridLayout(self.groupbox_fit_regression_line)
self.label_alphaS_expression = QLabel()
# self.label_alphaS_expression.setText("For homogeneous suspension: dFCB/dr = -2\u03B1<sub>s<\sub>")
self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_expression, 0, 0, 1, 5)
self.combobox_frequency_compute_alphaS = QComboBox()
self.gridLayout_groupbox_fit_regression.addWidget(self.combobox_frequency_compute_alphaS, 1, 0, 1, 1)
self.label_alphaS_computation_from = QLabel()
self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_computation_from, 1, 1, 1, 1)
self.spinbox_alphaS_computation_from = QDoubleSpinBox()
self.spinbox_alphaS_computation_from.setRange(0, 9999)
self.gridLayout_groupbox_fit_regression.addWidget(self.spinbox_alphaS_computation_from, 1, 2, 1, 1)
self.label_alphaS_computation_to = QLabel()
self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS_computation_to, 1, 3, 1, 1)
self.spinbox_alphaS_computation_to = QDoubleSpinBox()
self.gridLayout_groupbox_fit_regression.addWidget(self.spinbox_alphaS_computation_to, 1, 4, 1, 1)
self.pushbutton_fit_regression_line = QPushButton()
self.pushbutton_fit_regression_line.setText("Fit && Compute \u03B1s")
self.gridLayout_groupbox_fit_regression.addWidget(self.pushbutton_fit_regression_line, 2, 0, 1, 1)
self.label_alphaS = QLabel()
self.label_alphaS.setText("\u03B1s = " + "0.0" + "dB/m")
self.label_alphaS.setFont(QFont("Ubuntu", 14, QFont.Normal))
self.gridLayout_groupbox_fit_regression.addWidget(self.label_alphaS, 2, 3, 1, 2)
# self.verticalLayout_groupbox_fit_regression
# --------------------------------------------------------------------------------------------------------------
### --- Layout of groupbox in the Right vertical layout box
@ -582,7 +527,7 @@ class SignalProcessingTab(QWidget):
self.retranslate_signal_processing_tab()
# # -------------------- Functions for Signal processing Tab --------------------
#
def retranslate_signal_processing_tab(self):
self.pushbutton_load_data.setText(_translate("CONSTANT_STRING", cs.LOAD_DATA_FROM_ACOUSTIC_DATA_TAB))
@ -595,29 +540,31 @@ class SignalProcessingTab(QWidget):
self.groupbox_acoustic_profile.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_PROFILE))
# self.checkbox_substract_noise.setText(_translate("CONSTANT_STRING", cs.SUBTRACT_THE_NOISE))
self.label_SNR_criterion.setText(_translate("CONSTANT_STRING", cs.SNR_CRITERION))
#
self.groupbox_window_size.setTitle(_translate("CONSTANT_STRING", cs.WINDOW_SIZE))
# self.label_averageH.setText(_translate("CONSTANT_STRING", cs.HORIZONTAL) + ": +/-")
self.label_cells.setText(_translate("CONSTANT_STRING", cs.CELLS) + " = +/- ? sec")
self.groupbox_rayleigh_criterion.setTitle(_translate("CONSTANT_STRING", cs.RAYLEIGH_CRITERION))
# self.checkbox_despiked_acoustic_signal.setText(_translate("CONSTANT_STRING", cs.DESPIKING))
#
self.groupbox_FCBoption.setTitle(_translate("CONSTANT_STRING", cs.FCB_OPTIONS))
#
self.groupbox_water_attenuation.setTitle(_translate("CONSTANT_STRING", cs.COMPUTING_WATER_ATTENUATION))
# self.label_temperature_water_attenation.setText(_translate("CONSTANT_STRING", cs.TEMPERATURE) + ":")
#
self.label_temperature_water_attenation.setText(_translate("CONSTANT_STRING", cs.TEMPERATURE) + ":")
self.groupbox_fit_regression_line.setTitle(_translate("CONSTANT_STRING", cs.FIT_REGRESSION_LINE))
# self.label_alphaS_expression.setText(
# _translate("CONSTANT_STRING", cs.FOR_HOMOGENEOUS_SUSPENSION) + ": dFCB/dr = -2\u03B1<sub>s<\sub>")
# self.label_alphaS_computation_from.setText(_translate("CONSTANT_STRING", cs.FROM))
# self.label_alphaS_computation_to.setText(_translate("CONSTANT_STRING", cs.TO))
#
self.label_alphaS_expression.setText(
_translate("CONSTANT_STRING", cs.FOR_HOMOGENEOUS_SUSPENSION) + ": dFCB/dr = -2\u03B1<sub>s<\sub>")
self.label_alphaS_computation_from.setText(_translate("CONSTANT_STRING", cs.FROM))
self.label_alphaS_computation_to.setText(_translate("CONSTANT_STRING", cs.TO))
self.groupbox_plot_profile.setTitle(_translate("CONSTANT_STRING", cs.PROFILE))
self.groupbox_plot_averaged_profile.setTitle(_translate("CONSTANT_STRING", cs.AVERAGED_PROFILE))
self.groupbox_FCB_profile.setTitle(_translate("CONSTANT_STRING", cs.FCB_PROFILE))
# ------------------------------------- Connect Push Button Load Data + Slider -------------------------------------
def slide_profile_number_to_right(self):
self.slider.setValue(int(self.slider.value()) + 1)
self.lineEdit_slider.setText(str(self.slider.value()))
@ -632,48 +579,120 @@ class SignalProcessingTab(QWidget):
def update_lineEdit_by_moving_slider(self):
self.lineEdit_slider.setText(str(self.slider.value()))
# def enable_disable_spinbox_snr_value(self):
# if self.checkbox_SNR_criterion.isChecked():
# self.spinbox_SNR_criterion.setEnabled(True)
# self.pushbutton_snr_filter.setEnabled(True)
# else:
# self.spinbox_SNR_criterion.setDisabled(True)
# self.pushbutton_snr_filter.setDisabled(True)
def compute_BS_data_section(self):
if stg.r_bottom.size == 0:
stg.BS_data_section = deepcopy(stg.BS_data)
elif stg.r_bottom.size != 0:
stg.BS_data_section = deepcopy(stg.BS_data)
for f in range(stg.freq.shape[0]):
for k in range(stg.r_bottom.shape[0]):
# print(k, np.where(stg.r >= stg.r_bottom[k])[0])
stg.BS_data_section[np.where(stg.r >= stg.r_bottom[k])[0], f, k] = np.nan
# ----------------------------------------- Connect Groupbox average data -----------------------------------------
def compute_averaged_profile(self):
filter_convolve = np.ones(self.spinbox_average.value())
stg.BS_data_section_averaged = np.zeros((stg.r.shape[0], stg.freq.shape[0], stg.t.shape[0]))
for f in range(stg.freq.shape[0]):
for i in range(stg.r.shape[0]):
stg.BS_data_section_averaged[i, f, :] \
= convolve1d(stg.BS_data_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0]
self.label_cells.clear()
self.label_cells.setText("cells = +/- " + str((self.spinbox_average.value() // 2)*(1/stg.nb_profiles_per_sec)) + " sec")
# ---------------------------------------- Connect Groupbox filter with SNR ----------------------------------------
def remove_point_with_snr_filter(self):
if stg.BS_data_section_averaged.size == 0:
stg.BS_data_section_SNR_filter = deepcopy(stg.BS_data_section)
stg.SNR_data_average = np.divide(
(stg.BS_data_section_SNR_filter - stg.Noise_data[:, :, :stg.t.shape[0]])**2,
stg.Noise_data[:, :, :stg.t.shape[0]]**2)
stg.BS_data_filter_snr = deepcopy(stg.BS_data)
print("Before : ", np.sum(np.isnan(stg.BS_data_filter_snr[:, 0, :])))
for f in range(stg.freq.shape[0]):
stg.BS_data_filter_snr[np.where(stg.SNR_data[:, 0, :] < self.spinbox_SNR_criterion.value())[0],
f,
np.where(stg.SNR_data[:, 0, :] < self.spinbox_SNR_criterion.value())[1]] \
= np.nan
print("After : ", np.sum(np.isnan(stg.BS_data_filter_snr[:, 0, :])))
for f in range(stg.freq.shape[0]):
stg.BS_data_section_SNR_filter[np.where(stg.SNR_data_average[:, 0, :] < self.spinbox_SNR_criterion.value())[0],
f,
np.where(stg.SNR_data_average[:, 0, :] < self.spinbox_SNR_criterion.value())[1]] \
= np.nan
elif stg.BS_data_section_averaged.size != 0:
stg.BS_data_section_SNR_filter = deepcopy(stg.BS_data_section_averaged)
stg.SNR_data_average = np.divide(
(stg.BS_data_section_SNR_filter - stg.Noise_data[:, :, :stg.t.shape[0]]) ** 2,
stg.Noise_data[:, :, :stg.t.shape[0]] ** 2)
for f in range(stg.freq.shape[0]):
stg.BS_data_section_SNR_filter[
np.where(stg.SNR_data_average[:, 0, :] < self.spinbox_SNR_criterion.value())[0],
f,
np.where(stg.SNR_data_average[:, 0, :] < self.spinbox_SNR_criterion.value())[1]] \
= np.nan
def compute_water_attenuation(self):
if self.combobox_water_attenuation_model.currentIndex() == 0:
self.Francois_and_Garrison_1982()
else:
pass
print(f"{stg.water_attenuation:.2f}")
self.label_water_attenuation.clear()
self.label_water_attenuation.setText("\u03B1w = " + f"{stg.water_attenuation:.4f}" + " dB/m")
def Francois_and_Garrison_1982(self):
if self.spinbox_temperature_water_attenuation.value() > 20:
stg.water_attenuation = ((3.964 * 1e-4 - 1.146 * 1e-5 * self.spinbox_temperature_water_attenuation.value() +
1.45 * 1e-7 * self.spinbox_temperature_water_attenuation.value() ** 2 -
6.5 * 1e-10 * self.spinbox_temperature_water_attenuation.value() ** 3) * 1e-3 *
(np.log(10) / 20) *
(stg.freq[self.combobox_freq_for_water_attenuation.currentIndex()] * 1e-3) ** 2)
else:
stg.water_attenuation = ((4.937 * 1e-4 - 2.59 * 1e-5 * self.spinbox_temperature_water_attenuation.value() +
9.11 * 1e-7 * self.spinbox_temperature_water_attenuation.value() ** 2 -
1.5 * 1e-8 * self.spinbox_temperature_water_attenuation.value() ** 3) * 1e-3 *
(np.log(10) / 20) *
(stg.freq[self.combobox_freq_for_water_attenuation.currentIndex()] * 1e-3) ** 2)
# ---------------------------------------- PLOT PROFILE POSITION ON TRANSECT ---------------------------------------
def plot_profile_position_on_transect(self):
# --- Choose frequency (Combo box) to plot transect with profile position ---
self.combobox_frequency.addItems(stg.freq_text)
self.combobox_frequency.currentTextChanged.connect(self.update_plot_profile_position_on_transect)
# --- Choose frequency (Combo box) to compute water attenuation ---
self.combobox_freq_for_water_attenuation.addItems(stg.freq_text)
# --- Choose frequency (Combo box) to compute sediment attenuation ---
self.combobox_frequency_compute_alphaS.addItems(stg.freq_text)
# --- Fix maximum value of slider + Edit Label Profile number ---
self.slider.setMaximum(stg.t.shape[0])
self.label_profile_number.clear()
self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum()))
self.label_profile_number.setText(
"Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum()))
# --- Create Matplotlib canvas (with figure and axis) to plot transect ---
self.canvas_plot_profile_position_on_transect = FigureCanvas()
self.figure_plot_profile_position_on_transect, self.axis_plot_profile_position_on_transect = \
plt.subplots(nrows=1, ncols=1, layout="constrained")
plt.subplots(nrows=1, ncols=1, layout="constrained")
self.canvas_plot_profile_position_on_transect = FigureCanvas(self.figure_plot_profile_position_on_transect)
self.verticalLayout_groupbox_display_profile_position.addWidget(self.canvas_plot_profile_position_on_transect)
# if stg.r_bottom.size == 0:
val_min = np.min(stg.BS_data[:, stg.freq_bottom_detection, :])
val_max = np.max(stg.BS_data[:, stg.freq_bottom_detection, :])
# --- Plot transect with profile position ---
val_min = np.nanmin(stg.BS_data_section[:, stg.freq_bottom_detection, :])
val_max = np.nanmax(stg.BS_data_section[:, stg.freq_bottom_detection, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_plot_profile_position_on_transect.pcolormesh(
stg.t, -stg.r, stg.BS_data[:, stg.freq_bottom_detection, :],
self.axis_plot_profile_position_on_transect.pcolormesh(
stg.t, -stg.r, stg.BS_data_section[:, stg.freq_bottom_detection, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
if stg.r_bottom.size != 0:
@ -684,38 +703,11 @@ class SignalProcessingTab(QWidget):
stg.t[self.slider.value() - 1] * np.ones(stg.r.shape[0]), -stg.r,
color='red', linestyle="solid", linewidth=2)
self.axis_plot_profile_position_on_transect.set_xticks([])
self.axis_plot_profile_position_on_transect.set_yticks([])
self.figure_plot_profile_position_on_transect.canvas.draw_idle()
# else:
# stg.BS_data_section = deepcopy(stg.BS_data)
# for f in range(stg.freq.shape[0]):
# for k in range(stg.r_bottom.shape[0]):
# # print(k, np.where(stg.r >= stg.r_bottom[k])[0])
# stg.BS_data_section[np.where(stg.r >= stg.r_bottom[k])[0], f, k] \
# = np.nan
# # print("----------------------------------------------------------")
# val_min = np.min(stg.BS_data_section[:, stg.freq_bottom_detection, :])
# val_max = np.max(stg.BS_data_section[:, stg.freq_bottom_detection, :])
# if val_min == 0:
# val_min = 1e-5
#
# pcm = self.axis_plot_profile_position_on_transect.pcolormesh(
# stg.t, -stg.r, stg.BS_data_section[:, stg.freq_bottom_detection, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# if stg.r_bottom.size != 0:
# self.axis_plot_profile_position_on_transect.plot(
# stg.t, -stg.r_bottom, color='black', linewidth=1, linestyle="solid")
#
# self.axis_plot_profile_position_on_transect.plot(
# stg.t[self.slider.value() - 1] * np.ones(stg.r.shape[0]), -stg.r,
# color='red', linestyle="solid", linewidth=2)
#
# self.figure_plot_profile_position_on_transect.canvas.draw_idle()
def update_plot_profile_position_on_transect(self):
# --- Update label "Profile N / max(N)" ---
@ -723,55 +715,96 @@ class SignalProcessingTab(QWidget):
self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum()))
# --- Update transect plot ---
if self.canvas_plot_profile_position_on_transect != None:
# if stg.r_bottom.size != 0:
if self.canvas_plot_profile_position_on_transect is None:
msgBox = QMessageBox()
msgBox.setWindowTitle("Plot transect Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText("Load and Plot transect before post process")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
self.axis_plot_profile_position_on_transect.cla()
elif self.canvas_plot_profile_position_on_transect != None:
val_min = np.min(stg.BS_data[:, self.combobox_frequency.currentIndex(), :])
val_max = np.max(stg.BS_data[:, self.combobox_frequency.currentIndex(), :])
if val_min == 0:
val_min = 1e-5
if (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0):
self.axis_plot_profile_position_on_transect.pcolormesh(
stg.t, -stg.r, stg.BS_data[:, self.combobox_frequency.currentIndex(), :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
self.axis_plot_profile_position_on_transect.cla()
val_min = np.nanmin(stg.BS_data_section[:, self.combobox_frequency.currentIndex(), :])
val_max = np.nanmax(stg.BS_data_section[:, self.combobox_frequency.currentIndex(), :])
if val_min == 0:
val_min = 1e-5
self.axis_plot_profile_position_on_transect.pcolormesh(
stg.t, -stg.r, stg.BS_data_section[:, self.combobox_frequency.currentIndex(), :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
if stg.r_bottom.size != 0:
self.axis_plot_profile_position_on_transect.plot(stg.t, -stg.r_bottom,
color='black', linewidth=1, linestyle="solid")
if stg.r_bottom.size != 0:
self.axis_plot_profile_position_on_transect.plot(
stg.t, -stg.r_bottom,
color='black', linewidth=1, linestyle="solid")
stg.t[self.slider.value()-1] * np.ones(stg.r.shape[0]), -stg.r,
color='red', linestyle="solid", linewidth=2)
self.axis_plot_profile_position_on_transect.plot(
stg.t[self.slider.value() - 1] * np.ones(stg.r.shape[0]), -stg.r,
color='red', linestyle="solid", linewidth=2)
self.axis_plot_profile_position_on_transect.set_xticks([])
self.axis_plot_profile_position_on_transect.set_yticks([])
self.figure_plot_profile_position_on_transect.canvas.draw_idle()
self.figure_plot_profile_position_on_transect.canvas.draw_idle()
# else:
#
# self.axis_plot_profile_position_on_transect.cla()
#
# val_min = np.min(stg.BS_data[:, self.combobox_frequency.currentIndex(), :])
# val_max = np.max(stg.BS_data[:, self.combobox_frequency.currentIndex(), :])
# if val_min == 0:
# val_min = 1e-5
#
# pcm = self.axis_plot_profile_position_on_transect.pcolormesh(
# stg.t, -stg.r, stg.BS_data[:, self.combobox_frequency.currentIndex(), :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# if stg.r_bottom.size != 0:
# self.axis_plot_profile_position_on_transect.plot(
# stg.t, -stg.r_bottom,
# color='black', linewidth=1, linestyle="solid")
#
# self.axis_plot_profile_position_on_transect.plot(
# stg.t[self.slider.value()-1] * np.ones(stg.r.shape[0]), -stg.r,
# color='red', linestyle="solid", linewidth=2)
#
# self.figure_plot_profile_position_on_transect.canvas.draw_idle()
elif (stg.BS_data_section_averaged.size != 0) and (stg.BS_data_section_SNR_filter.size == 0):
self.axis_plot_profile_position_on_transect.cla()
val_min = np.nanmin(stg.BS_data_section_averaged[:, self.combobox_frequency.currentIndex(), :])
val_max = np.nanmax(stg.BS_data_section_averaged[:, self.combobox_frequency.currentIndex(), :])
if val_min == 0:
val_min = 1e-5
self.axis_plot_profile_position_on_transect.pcolormesh(
stg.t, -stg.r, stg.BS_data_section_averaged[:, self.combobox_frequency.currentIndex(), :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
if stg.r_bottom.size != 0:
self.axis_plot_profile_position_on_transect.plot(stg.t, -stg.r_bottom,
color='black', linewidth=1, linestyle="solid")
self.axis_plot_profile_position_on_transect.plot(
stg.t[self.slider.value() - 1] * np.ones(stg.r.shape[0]), -stg.r,
color='red', linestyle="solid", linewidth=2)
self.axis_plot_profile_position_on_transect.set_xticks([])
self.axis_plot_profile_position_on_transect.set_yticks([])
self.figure_plot_profile_position_on_transect.canvas.draw_idle()
elif stg.BS_data_section_SNR_filter.size != 0:
self.axis_plot_profile_position_on_transect.cla()
val_min = np.nanmin(stg.BS_data_section_SNR_filter[:, self.combobox_frequency.currentIndex(), :])
val_max = np.nanmax(stg.BS_data_section_SNR_filter[:, self.combobox_frequency.currentIndex(), :])
if val_min == 0:
val_min = 1e-5
self.axis_plot_profile_position_on_transect.pcolormesh(
stg.t, -stg.r, stg.BS_data_section_SNR_filter[:, self.combobox_frequency.currentIndex(), :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
if stg.r_bottom.size != 0:
self.axis_plot_profile_position_on_transect.plot(stg.t, -stg.r_bottom,
color='black', linewidth=1, linestyle="solid")
self.axis_plot_profile_position_on_transect.plot(
stg.t[self.slider.value() - 1] * np.ones(stg.r.shape[0]), -stg.r,
color='red', linestyle="solid", linewidth=2)
self.axis_plot_profile_position_on_transect.set_xticks([])
self.axis_plot_profile_position_on_transect.set_yticks([])
self.figure_plot_profile_position_on_transect.canvas.draw_idle()
# -------------------------------------------------- PLOT PROFILE -------------------------------------------------
def plot_profile(self):
@ -784,185 +817,65 @@ class SignalProcessingTab(QWidget):
for f in range(stg.freq.shape[0]):
self.axis_profile[f].cla()
self.axis_profile[f].plot(stg.BS_data[:, f, self.slider.value() - 1], -stg.r,
self.axis_profile[f].plot(stg.BS_data_section[:, f, self.slider.value() - 1], -stg.r,
linestyle='solid', color='k', linewidth=1)
if stg.r_bottom.size != 0:
self.axis_profile[f].plot(
np.array([0, np.nanmax(stg.BS_data[:, stg.freq_bottom_detection, self.slider.value() - 1])]),
-stg.r_bottom[self.slider.value() - 1]*np.ones(2),
linestyle='solid', color='red', linewidth=1)
self.axis_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
self.figure_profile.canvas.draw_idle()
# # --- Raw averaged profile ---
#
# self.figure_averaged_profile, self.axis_averaged_profile \
# = plt.subplots(nrows=1, ncols=stg.freq.shape[0], layout='constrained')
# self.canvas_averaged_profile = FigureCanvas(self.figure_averaged_profile)
# self.verticalLayout_groupbox_plot_averaged_profile.addWidget(self.canvas_averaged_profile)
#
# for f in range(stg.freq.shape[0]):
# self.axis_averaged_profile[f].cla()
# self.axis_averaged_profile[f].plot(stg.BS_data[:, f, self.slider.value() - 1], -stg.r,
# linestyle='solid', color='k', linewidth=1)
# self.axis_averaged_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
# # --- Raw FCB profile ---
#
# self.figure_FCB_profile, self.axis_FCB_profile \
# = plt.subplots(nrows=1, ncols=stg.freq.shape[0], layout='constrained')
# self.canvas_FCB_profile = FigureCanvas(self.figure_FCB_profile)
# self.verticalLayout_groupbox_plot_FCB_profile.addWidget(self.canvas_FCB_profile)
def update_plot_profile(self):
# if self.checkbox_SNR_criterion.isChecked():
# self.remove_point_with_snr_filter()
if stg.BS_data_filter_snr.size == 0:
for f in range(stg.freq.shape[0]):
self.axis_profile[f].cla()
self.axis_profile[f].plot(stg.BS_data[:, f, self.slider.value()-1], -stg.r,
linestyle='solid', color='k', linewidth=1)
self.axis_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
else:
for f in range(stg.freq.shape[0]):
self.axis_profile[f].cla()
self.axis_profile[f].plot(stg.BS_data_filter_snr[:, f, self.slider.value()-1], -stg.r,
linestyle='solid', color='k', linewidth=1)
# if stg.r_bottom.size != 0:
# self.axis_profile[f].plot(
# np.array([0, np.nanmax(stg.BS_data[:, stg.freq_bottom_detection, self.slider.value() - 1])]),
# -stg.r_bottom[self.slider.value() - 1] * np.ones(2),
# linestyle='dashed', color='red', linewidth=1)
self.axis_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
# else:
#
# for f in range(stg.freq.shape[0]):
# self.axis_profile[f].cla()
# self.axis_profile[f].plot(stg.BS_data[:, f, self.slider.value()-1], -stg.r,
# linestyle='solid', color='k', linewidth=1)
# if stg.r_bottom.size != 0:
# self.axis_profile[f].plot(
# np.array([0, np.nanmax(stg.BS_data[:, stg.freq_bottom_detection, self.slider.value() - 1])]),
# -stg.r_bottom[self.slider.value() - 1] * np.ones(2),
# linestyle='dashed', color='red', linewidth=1)
# self.axis_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
self.figure_profile.canvas.draw_idle()
def compute_averaged_profile(self):
filter_convolve = np.ones(self.spinbox_average.value())
if stg.BS_data_filter_snr.size == 0:
stg.BS_data_averaged = np.zeros((stg.r.shape[0], stg.freq.shape[0], stg.t.shape[0]-self.spinbox_average.value()+1))
for f in range(stg.freq.shape[0]):
for i in range(stg.r.shape[0]):
stg.BS_data_averaged[i, f, :] = np.convolve(stg.BS_data[i, f, :], filter_convolve, mode='valid')
# stg.BS_data_averaged = np.concatenate((stg.BS_data[:, :, :np.int(self.spinbox_average.value()/2)],
# stg.BS_data_averaged,
# stg.BS_data[:, :, -np.int(self.spinbox_average.value()/2):]),
# axis=2)
# print(stg.BS_data_averaged.shape)
else:
stg.BS_data_averaged = np.zeros((stg.r.shape[0], stg.freq.shape[0], stg.t.shape[0]-self.spinbox_average.value()+1))
for f in range(stg.freq.shape[0]):
for i in range(stg.r.shape[0]):
stg.BS_data_averaged[i, f, :] = np.convolve(stg.BS_data_filter_snr[i, f, :], filter_convolve,
mode='valid')
self.label_cells.clear()
self.label_cells.setText("cells = +/- " + str((self.spinbox_average.value() // 2)*(1/stg.nb_profiles_per_sec)) + " sec")
def plot_averaged_profile(self):
# fig, ax = plt.subplots(nrows=1, ncols=1)
# ax.pcolormesh(stg.t[8:2232], -stg.r, stg.BS_data_averaged[:, 0, :],
# cmap='viridis',
# norm=LogNorm(vmin=1e-5, vmax=np.max(stg.BS_data_averaged[:, 0, :])))
# plt.show()
if self.canvas_averaged_profile != None:
for f in range(stg.freq.shape[0]):
self.axis_averaged_profile[f].cla()
# --- Raw averaged profile ---
self.figure_averaged_profile, self.axis_averaged_profile \
= plt.subplots(nrows=1, ncols=stg.freq.shape[0], layout='constrained')
= plt.subplots(nrows=1, ncols=stg.freq.shape[0], layout='constrained')
self.canvas_averaged_profile = FigureCanvas(self.figure_averaged_profile)
self.verticalLayout_groupbox_plot_averaged_profile.addWidget(self.canvas_averaged_profile)
if stg.BS_data_filter_snr.size == 0:
# --- Raw FCB profile ---
BS_concatenate = stg.BS_data_averaged = np.concatenate((stg.BS_data[:, :, :np.int(self.spinbox_average.value()/2)],
stg.BS_data_averaged,
stg.BS_data[:, :, -np.int(self.spinbox_average.value()/2):]),
axis=2)
for f in range(stg.freq.shape[0]):
self.axis_averaged_profile[f].cla()
self.axis_averaged_profile[f].plot(BS_concatenate[:, f, self.slider.value()-1], -stg.r,
self.figure_FCB_profile, self.axis_FCB_profile \
= plt.subplots(nrows=1, ncols=stg.freq.shape[0], layout='constrained')
self.canvas_FCB_profile = FigureCanvas(self.figure_FCB_profile)
self.verticalLayout_groupbox_plot_FCB_profile.addWidget(self.canvas_FCB_profile)
def update_plot_profile(self):
for f in range(stg.freq.shape[0]):
self.axis_profile[f].cla()
self.axis_profile[f].plot(stg.BS_data_section[:, f, self.slider.value() - 1], -stg.r,
linestyle='solid', color='k', linewidth=1)
self.figure_profile.canvas.draw_idle()
# --------------------------------- PLOT AVERAGED PROFILE FILTERED OR NOT WITH SNR ---------------------------------
def plot_averaged_profile(self):
for f in range(stg.freq.shape[0]):
self.axis_averaged_profile[f].cla()
self.axis_averaged_profile[f].plot(stg.BS_data_section_averaged[:, f, self.slider.value()-1], -stg.r,
linestyle='solid', color='k', linewidth=1)
self.axis_averaged_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
else:
BS_concatenate = stg.BS_data_averaged = np.concatenate((stg.BS_data_filter_snr[:, :, :np.int(self.spinbox_average.value() / 2)],
stg.BS_data_averaged,
stg.BS_data_filter_snr[:, :, -np.int(self.spinbox_average.value() / 2):]),
axis=2)
for f in range(stg.freq.shape[0]):
self.axis_averaged_profile[f].cla()
self.axis_averaged_profile[f].plot(BS_concatenate[:, f, self.slider.value() - 1], -stg.r,
linestyle='solid', color='k', linewidth=1)
self.axis_averaged_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
self.axis_averaged_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
self.figure_averaged_profile.canvas.draw_idle()
def update_plot_averaged_profile(self):
if self.canvas_averaged_profile == None:
msgBox = QMessageBox()
msgBox.setWindowTitle("Plot averaged profile Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText("Compute acoustic backscatter averaged data")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
if stg.BS_data_section_SNR_filter.size == 0:
else:
for f in range(stg.freq.shape[0]):
self.axis_averaged_profile[f].cla()
self.axis_averaged_profile[f].plot(stg.BS_data_section_averaged[:, f, self.slider.value() - 1], -stg.r,
linestyle='solid', color='k', linewidth=1)
self.axis_averaged_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
if stg.BS_data_filter_snr.size == 0:
self.figure_averaged_profile.canvas.draw_idle()
BS_concatenate = stg.BS_data_averaged = np.concatenate(
(stg.BS_data[:, :, :np.int(self.spinbox_average.value() / 2)],
stg.BS_data_averaged,
stg.BS_data[:, :, -np.int(self.spinbox_average.value() / 2):]),
axis=2)
for f in range(stg.freq.shape[0]):
self.axis_averaged_profile[f].cla()
self.axis_averaged_profile[f].plot(BS_concatenate[:, f, self.slider.value() - 1], -stg.r,
linestyle='solid', color='k', linewidth=1)
self.axis_averaged_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
else:
BS_concatenate = stg.BS_data_averaged = np.concatenate(
(stg.BS_data_filter_snr[:, :, :np.int(self.spinbox_average.value() / 2)],
stg.BS_data_averaged,
stg.BS_data_filter_snr[:, :, -np.int(self.spinbox_average.value() / 2):]),
axis=2)
for f in range(stg.freq.shape[0]):
self.axis_averaged_profile[f].cla()
self.axis_averaged_profile[f].plot(BS_concatenate[:, f, self.slider.value() - 1], -stg.r,
linestyle='solid', color='k', linewidth=1)
self.axis_averaged_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
elif stg.BS_data_section_SNR_filter.size != 0:
self.figure_averaged_profile.canvas.draw_idle()
for f in range(stg.freq.shape[0]):
self.axis_averaged_profile[f].cla()
self.axis_averaged_profile[f].plot(stg.BS_data_section_SNR_filter[:, f, self.slider.value() - 1], -stg.r,
linestyle='solid', color='k', linewidth=1)
self.axis_averaged_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
self.figure_averaged_profile.canvas.draw_idle()
# def plot_transect_bottom_with_profile_position(self, profile_position):
# frequency = self.model.Freq[0]
@ -1029,28 +942,6 @@ class SignalProcessingTab(QWidget):
# self.figure_FCBoptions.canvas.draw_idle()
# # self.figure_FCBoptions.canvas.flush_events()
# def linear(self, figure, axis, i):
# # for i in range(4):
# # axis[i].plot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], '*-')
# # figure.tight_layout()
# for i in range(4):
# axis[i].plot(self.model.BS_raw_cross_section.V[:, i, 800], self.model.r, c='k')
#
# def polynome(self, figure, axis):
# # for i in range(4):
# # axis[i].plot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100], '*-')
# # figure.tight_layout()
# for i in range(4):
# axis[i].plot(self.model.BS_averaged_cross_section.V[:, i, 800], self.model.r, c='b')
#
# def cubique(self, figure, axis):
# # for i in range(4):
# # axis[i].plot([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000], '*-')
# # figure.tight_layout()
# for i in range(4):
# axis[i].plot(self.model.FCB[:, i, 800], self.model.r, c='r')
#
#

View File

@ -7,7 +7,7 @@ import datetime
# --- load raw data ---
path_BS_raw_data = ""
filename_BS_raw_data = ""
BS_raw_data = np.array([])
BS_raw_data = np.array([]) # BS raw data : all measurement (go and back)
r = np.array([])
r_2D = np.array([])
freq = np.array([])
@ -47,7 +47,7 @@ DataFrame_acoustic = pd.DataFrame()
# --- Processed data in Acoustic Data Tab and used in Acoustic processing tab ---
BS_data = np.array([]) # BS data limited with tmin and tmax values of spin box
BS_data_section = np.array([])
BS_data_section = np.array([]) # BS data in the section. Values NaN outside the bottom of the section are deleted
Noise_data = np.array([])
SNR_data = np.array([])
t = np.array([])
@ -56,9 +56,14 @@ val_bottom = np.array([])
ind_bottom = np.array([])
freq_bottom_detection = 0
BS_data_subtract_noise = np.array([])
BS_data_filter_snr = np.array([])
BS_data_averaged = np.array([])
# --- Processed data in Signal Processing Tab ---
BS_data_section_SNR_filter = np.array([]) # BS data filtered with SNR values (remove point if SNR < value)
BS_data_section_averaged = np.array([]) # BS data averaged
time_average = np.array([])
SNR_data_average = np.array([])
water_attenuation = 0
sediment_attenuation = 0
# --- Sample Data ---