The user can display the noise fields for each frequency by clicking on button PLot_noise in the pre-processing tab.
parent
dfbc91c9ec
commit
bba389ae9d
|
|
@ -2101,6 +2101,7 @@ class AcousticDataTab(QWidget):
|
|||
stg.SNR_cross_section.append(np.array([]))
|
||||
stg.SNR_stream_bed.append(np.array([]))
|
||||
stg.time_noise.append(np.array([]))
|
||||
stg.depth_noise.append(np.array([]))
|
||||
stg.noise_method.append(0)
|
||||
stg.noise_value.append(0)
|
||||
stg.SNR_filter_value.append(0)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,178 @@
|
|||
import sys
|
||||
|
||||
from PyQt5.QtGui import QIcon, QPixmap
|
||||
from PyQt5.QtWidgets import (QWidget, QLabel, QHBoxLayout, QVBoxLayout, QApplication, QMainWindow, QGridLayout,
|
||||
QDialog, QDialogButtonBox, QPushButton, QTextEdit, QFrame, QTabWidget, QScrollArea)
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
import numpy as np
|
||||
|
||||
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
|
||||
|
||||
import datetime
|
||||
|
||||
import settings as stg
|
||||
|
||||
from Translation.constant_string import HORIZONTAL
|
||||
from settings import depth_cross_section
|
||||
|
||||
|
||||
class PlotNoiseWindow(QDialog):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
|
||||
super(PlotNoiseWindow, self).__init__(parent)
|
||||
|
||||
self.setGeometry(400, 200, 700, 500)
|
||||
|
||||
self.setWindowTitle("Noise field")
|
||||
|
||||
self.verticalLayout_Main = QVBoxLayout()
|
||||
self.setLayout(self.verticalLayout_Main)
|
||||
|
||||
self.tab = QTabWidget()
|
||||
self.verticalLayout_Main.addWidget(self.tab)
|
||||
|
||||
for i in range(len(stg.filename_BS_raw_data)):
|
||||
|
||||
exec("self.tab" + str(i) + "= QWidget()")
|
||||
exec("self.tab.addTab(self.tab" + str(i) + ", stg.filename_BS_raw_data[" + str(i) + "])")
|
||||
|
||||
exec("self.verticalLayout_tab" + str(i) + "= QVBoxLayout()")
|
||||
exec("self.tab" + str(i) + ".setLayout(self.verticalLayout_tab" + str(i) + ")")
|
||||
|
||||
exec("self.fig" + str(i) + ", self.ax" + str(i) +
|
||||
"= plt.subplots(nrows=stg.freq[" + str(i) + "].shape[0], ncols=1, layout='constrained')")
|
||||
|
||||
if stg.BS_noise_raw_data[i].shape != (0,):
|
||||
|
||||
for freq_ind, freq_val in enumerate(stg.freq[i]):
|
||||
|
||||
val_min = np.nanmin(stg.BS_noise_raw_data[i][freq_ind, :, :])
|
||||
val_max = np.nanmax(stg.BS_noise_raw_data[i][freq_ind, :, :])
|
||||
|
||||
print("val_min = ", val_min, "val_max = ", val_max)
|
||||
|
||||
if val_min == val_max:
|
||||
exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
"stg.time[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
"-stg.depth[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
"stg.BS_noise_raw_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
"cmap='hsv')")
|
||||
else:
|
||||
val_min = 0
|
||||
val_max = 1e-5
|
||||
exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
"stg.time_noise[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
"-stg.depth_noise[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
"stg.BS_noise_raw_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
"cmap='hsv')")
|
||||
# , norm = LogNorm(vmin=val_min, vmax=val_max)
|
||||
|
||||
# if stg.time_cross_section[i].shape != (0,):
|
||||
#
|
||||
# if depth_cross_section[i].shape != (0,):
|
||||
# if val_min == val_max:
|
||||
# exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
# "stg.time_cross_section[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "-stg.depth_cross_section[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "stg.BS_noise_raw_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
# "cmap='viridis')" )
|
||||
# else:
|
||||
# val_min = 0
|
||||
# val_max = 1e-5
|
||||
# exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
# "stg.time_cross_section[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "-stg.depth_cross_section[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "stg.BS_noise_raw_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
# "cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))")
|
||||
# else:
|
||||
# if val_min == val_max:
|
||||
# exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
# "stg.time_cross_section[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "-stg.depth[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "stg.BS_noise_raw_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
# "cmap='viridis')" )
|
||||
# else:
|
||||
# val_min = 0
|
||||
# val_max = 1e-5
|
||||
# exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
# "stg.time_cross_section[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "-stg.depth[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "stg.BS_noise_averaged_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
# "cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))")
|
||||
#
|
||||
# else:
|
||||
#
|
||||
# if depth_cross_section[i].shape != (0,):
|
||||
# if val_min == val_max:
|
||||
# exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
# "stg.time[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "-stg.depth_cross_section[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "stg.BS_noise_averaged_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
# "cmap='viridis')" )
|
||||
# else:
|
||||
# val_min = 0
|
||||
# val_max = 1e-5
|
||||
# exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
# "stg.time[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "-stg.depth_cross_section[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "stg.BS_noise_averaged_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
# "cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))")
|
||||
# else:
|
||||
# if val_min == val_max:
|
||||
# exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
# "stg.time[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "-stg.depth[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "stg.BS_noise_averaged_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
# "cmap='viridis')" )
|
||||
# else:
|
||||
# val_min = 0
|
||||
# val_max = 1e-5
|
||||
# exec("pcm = self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".pcolormesh(" +
|
||||
# "stg.time[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "-stg.depth[" + str(i) + "][" + str(freq_ind) + ", :]," +
|
||||
# "stg.BS_noise_averaged_data[" + str(i) + "][" + str(freq_ind) + ", :, :]," +
|
||||
# "cmap='viridis')")
|
||||
# # , norm = LogNorm(vmin=val_min, vmax=val_max)
|
||||
|
||||
eval("self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".text(1, .70, stg.freq_text[" + str(i) +
|
||||
"][" + str(freq_ind) + "]," +
|
||||
"fontsize=10, fontweight='bold', fontname='Ubuntu', c='black', alpha=0.5," +
|
||||
"horizontalalignment='right', verticalalignment='bottom'," +
|
||||
"transform=self.ax" + str(i) + "[" + str(freq_ind) + "].transAxes)")
|
||||
|
||||
exec("self.fig" + str(i) + ".supxlabel('Time (sec)', fontsize=10)")
|
||||
exec("self.fig" + str(i) + ".supylabel('Depth (m)', fontsize=10)")
|
||||
|
||||
exec("cbar = self.fig" + str(i) + ".colorbar(pcm, ax=self.ax" + str(i) + "[:] ," +
|
||||
"shrink=1, location='right')")
|
||||
eval("cbar.set_label(label='Noise signal (V)', rotation=270, labelpad=8)")
|
||||
|
||||
exec("self.fig" + str(i) + ".canvas.draw_idle()")
|
||||
|
||||
else:
|
||||
|
||||
pass
|
||||
|
||||
# self.axis_noise.tick_params(axis='both', which='minor', labelsize=10)
|
||||
|
||||
exec("self.canvas" + str(i) + "= FigureCanvas(self.fig" + str(i) + ")")
|
||||
exec("self.toolbar" + str(i) + "= NavigationToolBar(self.canvas" + str(i) + ", self)")
|
||||
|
||||
exec("self.scroll" + str(i) + "= QScrollArea()")
|
||||
exec("self.scroll" + str(i) + ".setWidget(self.canvas" + str(i) + ")")
|
||||
|
||||
exec("self.verticalLayout_tab" + str(i) + ".addWidget(self.toolbar" + str(i) + ")")
|
||||
exec("self.verticalLayout_tab" + str(i) + ".addWidget(self.scroll" + str(i) + ")")
|
||||
|
||||
|
||||
# self.tab1 = QWidget()
|
||||
# self.tab.addTab(self.tab1, "Tab 1")
|
||||
|
||||
|
||||
|
||||
# ----------------------------------------------------------
|
||||
|
|
@ -19,6 +19,7 @@ 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
|
||||
|
||||
|
|
@ -151,9 +152,13 @@ class SignalProcessingTab(QWidget):
|
|||
self.pushbutton_noise_file = QPushButton()
|
||||
self.pushbutton_noise_file.setObjectName("pushbutton_noise_file")
|
||||
self.pushbutton_noise_file.setIcon(self.icon_folder)
|
||||
self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_file, 0, 1, 1, 1)
|
||||
self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_noise_file, 0, 0, 1, 1)
|
||||
self.lineEdit_noise_file = QLineEdit()
|
||||
self.gridLayout_groupbox_noise_file.addWidget(self.lineEdit_noise_file, 0, 2, 1, 1)
|
||||
self.gridLayout_groupbox_noise_file.addWidget(self.lineEdit_noise_file, 0, 1, 1, 1)
|
||||
|
||||
self.pushbutton_plot_noise_file = QPushButton()
|
||||
self.pushbutton_plot_noise_file.setText("Plot noise field")
|
||||
self.gridLayout_groupbox_noise_file.addWidget(self.pushbutton_plot_noise_file, 1, 0, 1, 2)
|
||||
|
||||
# self.label_date_groupbox_noise_file = QLabel()
|
||||
# self.gridLayout_groupbox_noise_file.addWidget(self.label_date_groupbox_noise_file, 1, 0, 1, 2)
|
||||
|
|
@ -189,6 +194,10 @@ class SignalProcessingTab(QWidget):
|
|||
self.pushbutton_compute_noise_from_value.setText("Apply noise")
|
||||
self.gridLayout_compute_noise_from_value.addWidget(self.pushbutton_compute_noise_from_value, 0, 3, 1, 1)
|
||||
|
||||
self.pushbutton_plot_noise_value = QPushButton()
|
||||
self.pushbutton_plot_noise_value.setText("Plot noise field")
|
||||
self.gridLayout_compute_noise_from_value.addWidget(self.pushbutton_plot_noise_value, 1, 0, 1, 4)
|
||||
|
||||
self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_value)
|
||||
|
||||
### --- Push button plot noise ---
|
||||
|
|
@ -515,8 +524,10 @@ class SignalProcessingTab(QWidget):
|
|||
self.pushbutton_clear_noise.clicked.connect(self.clear_noise_data)
|
||||
|
||||
self.pushbutton_noise_file.clicked.connect(self.open_dialog_box)
|
||||
self.pushbutton_plot_noise_file.clicked.connect(self.open_plot_noise_window)
|
||||
|
||||
self.pushbutton_compute_noise_from_value.clicked.connect(self.compute_noise_from_value)
|
||||
self.pushbutton_plot_noise_value.clicked.connect(self.open_plot_noise_window)
|
||||
|
||||
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)
|
||||
|
|
@ -1552,6 +1563,7 @@ class SignalProcessingTab(QWidget):
|
|||
# stg.date_noise = noise_data._date
|
||||
# stg.hour_noise = noise_data._hour
|
||||
stg.time_noise[self.combobox_fileListWidget.currentIndex()] = noise_data._time
|
||||
stg.depth_noise[self.combobox_fileListWidget.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)
|
||||
|
|
@ -1603,6 +1615,9 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
print("C'est fait")
|
||||
|
||||
def open_plot_noise_window(self):
|
||||
pnw = PlotNoiseWindow()
|
||||
pnw.exec()
|
||||
|
||||
# def compute_noise_from_value(self):
|
||||
#
|
||||
|
|
@ -1709,6 +1724,8 @@ class SignalProcessingTab(QWidget):
|
|||
stg.time_noise[self.combobox_fileListWidget.currentIndex()] = (
|
||||
stg.time[self.combobox_fileListWidget.currentIndex()])
|
||||
|
||||
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:
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ gain_tx = []
|
|||
|
||||
SNR_raw_data = [] # SNR is computed with BS_noise_averaged_data
|
||||
time_noise = []
|
||||
depth_noise = []
|
||||
|
||||
# --- reshape raw data for table of values in Acoustic Data tab ---
|
||||
time_reshape = []
|
||||
|
|
|
|||
Loading…
Reference in New Issue