Transect with profile position is added to signal processing tab

dev-brahim
brahim 2023-08-09 22:40:36 +02:00
parent 89fc888797
commit 6bcd0caa35
3 changed files with 277 additions and 208 deletions

View File

@ -704,14 +704,15 @@ class AcousticDataTab(QWidget):
def load_noise_data_and_compute_SNR(self):
noise_data = AcousticDataLoader(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data)
stg.BS_noise_data = noise_data._BS_raw_data
# stg.BS_noise_data = noise_data._BS_raw_data
stg.date_noise = noise_data._date
stg.hour_noise = noise_data._hour
stg.time_snr = noise_data._time
noise = np.zeros(stg.BS_raw_data.shape)
for f in range(noise_data._freq.shape[0]):
noise[:, f, :] = np.mean(stg.BS_noise_data[:, f, :], axis=(0, 1))
stg.snr = np.divide((stg.BS_raw_data - noise) ** 2, noise ** 2)
noise[:, f, :] = np.mean(noise_data._BS_raw_data[:, f, :], axis=(0, 1))
stg.BS_noise_data = noise
stg.snr = np.divide((stg.BS_raw_data - stg.BS_noise_data) ** 2, stg.BS_noise_data ** 2)
stg.snr_reshape = np.reshape(stg.snr, (stg.r.shape[0] * stg.time.shape[0], stg.freq.shape[0]), order="F")
def fill_measurements_information_groupbox(self):
@ -855,6 +856,11 @@ class AcousticDataTab(QWidget):
msgBox.exec()
else:
# --- Backscatter acoustic signal is recorded for next tab ---
stg.BS_data = stg.BS_raw_data[:, :, np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
stg.t = stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
for f in range(stg.freq.shape[0]):
self.axis_BS[f].cla()
@ -962,35 +968,43 @@ class AcousticDataTab(QWidget):
if ((self.canvas_BS != None) and (self.canvas_SNR != None)):
x, y = np.meshgrid(
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
# --- Backscatter noise signal is recorded for next tab ---
stg.Noise_data = stg.BS_noise_data[:, :, np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
stg.SNR_data = stg.snr[:, :, np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
x, y = np.meshgrid(
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
stg.r)
for f in range(stg.freq.shape[0]):
self.axis_SNR[f].cla()
for f in range(stg.freq.shape[0]):
self.axis_SNR[f].cla()
val_min = np.min(stg.snr[:, f, :])
val_max = np.max(stg.snr[:, f, :])
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
val_min = np.min(stg.snr[:, f, :])
val_max = np.max(stg.snr[:, f, :])
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
cf = self.axis_SNR[f].contourf(x, -y,
stg.snr[:, f,
np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
levels, cmap='gist_rainbow', norm=norm)
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_SNR[f].transAxes)
cf = self.axis_SNR[f].contourf(x, -y,
stg.snr[:, f,
np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
levels, cmap='gist_rainbow', norm=norm)
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_SNR[f].transAxes)
self.fig_SNR.supxlabel('Distance from left bank (m)', fontsize=10)
self.fig_SNR.supylabel('Depth (m)', fontsize=10)
@ -1027,6 +1041,9 @@ class AcousticDataTab(QWidget):
# msgBox.exec()
# elif (self.canvas_BS) and (self.canvas_SNR == None):
else:
# --- Record frequency choose for bottom detection ---
stg.freq_bottom_detection = self.combobox_freq_choice.currentIndex()
# Selecting the range in which we look for the bottom reflection
rmin = np.int(self.spinbox_depth_min.text())
rmax = np.int(self.spinbox_depth_max.text())
@ -1045,6 +1062,8 @@ class AcousticDataTab(QWidget):
# Getting the range cell of the peak
ind_bottom = np.where(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d]
== val_bottom[d])[0][0]
np.append(stg.ind_bottom, ind_bottom)
r_bottom[d] = stg.r[ind_bottom + ind_min]
r_bottom_ind.append(ind_bottom + ind_min)
# Updating the range where we will look for the peak (in the next cell)
@ -1059,6 +1078,12 @@ class AcousticDataTab(QWidget):
BS_section_bottom[r_bottom_ind[i]][i] = 1
# print(BS_section_bottom[r_bottom_temp_ind[i]][i])
# --- Record r_bottom for other tabs ---
stg.r_bottom = r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
stg.val_bottom = val_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
# --- Plot transect BS with bathymetry ---
for f in range(stg.freq.shape[0]):
self.axis_BS[f].cla()

View File

@ -16,12 +16,9 @@ import Translation.constant_string as cs
from Model.acoustic_data_loader import AcousticDataLoader
_translate = QCoreApplication.translate
import settings as stg
acoustic_data = AcousticDataLoader("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/"
"Data/Acoustic_data/20180107123500.aqa")
noise_data = AcousticDataLoader("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/"
"Data/AcousticNoise_data/20180107121600.aqa")
_translate = QCoreApplication.translate
class SignalProcessingTab(QWidget):
@ -58,12 +55,17 @@ class SignalProcessingTab(QWidget):
# --------------------------------------------------------------------------------------------------------------
### --- Layout of groupbox in the Left vertical layout box
# Push button Load data
# ---------------------
# Profile position
# --------------------
# ---------------------
# Post processing
# --------------------
# ---------------------
# FCB options
self.horizontalLayout_pushbutton_load_data_plot_bottom_line = QHBoxLayout()
self.verticalLayout_Left.addLayout(self.horizontalLayout_pushbutton_load_data_plot_bottom_line)
self.groupbox_display_profile_position = QGroupBox()
self.verticalLayout_Left.addWidget(self.groupbox_display_profile_position)
@ -73,6 +75,19 @@ class SignalProcessingTab(QWidget):
self.groupbox_FCBoption = QGroupBox()
self.verticalLayout_Left.addWidget(self.groupbox_FCBoption)
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# +++ --- Push button Load data + Push button plot bottom --- +++
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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.plot_profile_position_on_transect)
self.pushbutton_load_data.clicked.connect(self.plot_profiles)
self.pushbutton_plot_bottom_line = QPushButton()
self.pushbutton_plot_bottom_line.setText("Plot bottom line")
self.horizontalLayout_pushbutton_load_data_plot_bottom_line.addWidget(self.pushbutton_plot_bottom_line)
# +++++++++++++++++++++++++++++++++++++++++++++++++
# +++ --- GroupBox Display Profile Position --- +++
# +++++++++++++++++++++++++++++++++++++++++++++++++
@ -82,7 +97,7 @@ class SignalProcessingTab(QWidget):
self.label_profile_number = QLabel()
self.label_profile_number.setFont(QFont("Ubuntu", 16, QFont.Bold))
self.label_profile_number.setAlignment(Qt.AlignCenter)
self.label_profile_number.setText("Profile 1 / " + str(acoustic_data._time.shape[0]))
# self.label_profile_number.setText("Profile 1 / " + str(stg.nb_profiles))
self.verticalLayout_groupbox_display_profile_position.addWidget(self.label_profile_number)
self.canvas_profile_position_on_transect = None
@ -133,105 +148,36 @@ class SignalProcessingTab(QWidget):
self.verticalLayout_groupbox_post_processing = QVBoxLayout(self.groupbox_post_processing)
# # self.checkbox_substract_noise = QCheckBox()
# # self.checkbox_substract_noise.setText("Substract the noise")
# # self.verticalLayout_averaged_profile = QVBoxLayout(self.checkbox_substract_noise)
# # self.pushbutton_averaged_profile = QPushButton()
# # self.pushbutton_averaged_profile.setText("Plot averaged profile")
#
# # self.verticalLayout_groupbox_plotacousticprofile.addWidget(self.checkbox_substract_noise)
#
# # self.groupbox_SNR_criterion = QGroupBox()
# # self.groupbox_SNR_criterion.setTitle("SNR criterion")
# # self.verticalLayout_SNR_criterion = QVBoxLayout(self.groupbox_SNR_criterion)
# # self.horizontalLayout_SNR_criterion = QHBoxLayout()
# # self.label_SNR_crterion = QLabel()
# # self.label_SNR_crterion.setText("Remove point if SNR <")
# # self.horizontalLayout_SNR_criterion.addWidget(self.label_SNR_crterion)
# # self.lineEdit_SNR_criterion = QLineEdit()
# # self.horizontalLayout_SNR_criterion.addWidget(self.lineEdit_SNR_criterion)
# # self.verticalLayout_SNR_criterion.addLayout(self.horizontalLayout_SNR_criterion)
# # self.pushbutton_SNR_criterion = QPushButton()
# # self.pushbutton_SNR_criterion.setText("Remove points on profile")
# # self.verticalLayout_SNR_criterion.addWidget(self.pushbutton_SNR_criterion)
# # self.verticalLayout_groupbox_plotacousticprofile.addWidget(self.groupbox_SNR_criterion)
#
# # self.horizontalLayoutTop_signalProcessing.addWidget(self.groupbox_profile, 3)
#
# # self.horizontalLayoutMid_signalProcessing = QHBoxLayout()
# # self.verticalLayout_signalProcessingTab.addLayout(self.horizontalLayoutMid_signalProcessing, 3)
#
#
# self.verticalLayout_groupbox_post_processing = QVBoxLayout(self.groupbox_post_processing)
# --- Groupbox acoustic profile ---
self.groupbox_acoustic_profile = QGroupBox()
self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_acoustic_profile)
# self.gridLayout_groupbox_acoustic_profile = QGridLayout(self.groupbox_acoustic_profile)
# self.horizontalLayout_acoustic_profile = QHBoxLayout(self.groupbox_acoustic_profile)
# # self.label_subtract_noise = QLabel()
# # self.label_subtract_noise.setText("Subtract the noise")
# self.checkbox_substract_noise = QCheckBox()
# self.checkbox_substract_noise.setChecked(False)
# # self.checkbox_substract_noise.setText("Subtract the noise")
# self.checkbox_substract_noise.setToolTip("Enable for further computation")
# self.horizontalLayout_acoustic_profile.addWidget(self.checkbox_substract_noise)
# # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_substract_noise, 0, 0, 1, 1)
# # self.checkbox_subtract_noise_enable = QCheckBox()
# # self.checkbox_subtract_noise_enable.setChecked(False)
# # self.checkbox_subtract_noise_enable.setText("Enable")
# # self.horizontalLayout_label_subtract_noise.addWidget(self.checkbox_subtract_noise_enable)
# # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_subtract_noise_enable, 0, 1, 1, 1)
# # self.checkbox_subtract_noise_disable = QCheckBox()
# # self.checkbox_subtract_noise_disable.setChecked(True)
# # self.checkbox_subtract_noise_disable.setText("Disable")
# # self.checkbox_subtract_noise_add_noisy_profile = QCheckBox()
# # self.checkbox_subtract_noise_add_noisy_profile.setText("Add noisy profile")
# # self.horizontalLayout_label_subtract_noise.addWidget(self.checkbox_subtract_noise_disable)
# # self.verticalLayout_post_processing.addLayout(self.horizontalLayout_label_subtract_noise)
# # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_subtract_noise_add_noisy_profile, 0, 2, 1, 1)
# # self.horizontalLayout_SNR_criterion = QHBoxLayout()
# # self.formLayout_SNR_criterion = QFormLayout()
# # self.formLayout_SNR_criterion.set
# # self.label_SNR_criterion = QLabel()
# # self.label_SNR_criterion.setText("SNR criterion")
# self.checkbox_SNR_criterion = QCheckBox()
# self.checkbox_SNR_criterion.setChecked(False)
# # self.checkbox_SNR_criterion.setText("SNR criterion")
# self.checkbox_SNR_criterion.setToolTip("Enable for further computation")
# self.horizontalLayout_acoustic_profile.addWidget(self.checkbox_SNR_criterion)
# # self.gridLayout_groupbox_acoustic_profile.addWidget(self.label_SNR_criterion, 1, 0, 1, 1)
# # self.lineEdit_SNR_criterion = QLineEdit()
# # self.lineEdit_SNR_criterion.setEnabled(True)
# # self.lineEdit_SNR_criterion.setText("10")
# self.spinbox_SNR_criterion = QSpinBox()
# self.spinbox_SNR_criterion.setRange(0, 9999)
# self.spinbox_SNR_criterion.setValue(10)
# # self.lineEdit_SNR_criterion.setFixedWidth(5)
# self.horizontalLayout_acoustic_profile.addWidget(self.spinbox_SNR_criterion)
# # self.gridLayout_groupbox_acoustic_profile.addWidget(self.lineEdit_SNR_criterion, 1, 1, 1, 1)
# # self.checkbox_SNR_criterion_enable = QCheckBox()
# # self.checkbox_SNR_criterion_enable.setChecked(False)
# # self.checkbox_SNR_criterion_enable.setText("Enable")
# # self.horizontalLayout_SNR_criterion.addWidget(self.checkbox_SNR_criterion_enable)
# # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_SNR_criterion_enable, 1, 2, 1, 1)
# # self.checkbox_SNR_criterion_disable = QCheckBox()
# # self.checkbox_SNR_criterion_disable.setChecked(True)
# # self.checkbox_SNR_criterion_disable.setText("Disable")
# # self.horizontalLayout_SNR_criterion.addWidget(self.checkbox_SNR_criterion_disable)
# # self.verticalLayout_post_processing.addLayout(self.horizontalLayout_SNR_criterion)
# # self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_SNR_criterion_disable, 1, 3, 1, 1)
# # self.horizontalLayout_averaged_profile_despiking_signal = QHBoxLayout()
# # self.verticalLayout_groupbox_post_processing.addLayout(self.horizontalLayout_averaged_profile_despiking_signal)
# --- Groupbox Window size ---
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)
# --- Groupbox acoustic profile ---
self.gridLayout_groupbox_acoustic_profile = QGridLayout(self.groupbox_acoustic_profile)
self.checkbox_substract_noise = QCheckBox()
self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_substract_noise, 0, 0, 1, 1)
self.checkbox_substract_noise.clicked.connect(self.update_plot_profiles)
self.checkbox_SNR_criterion = QCheckBox()
self.gridLayout_groupbox_acoustic_profile.addWidget(self.checkbox_SNR_criterion, 1, 0, 1, 1)
self.spinbox_SNR_criterion = QSpinBox()
self.spinbox_SNR_criterion.setRange(0, 9999)
self.spinbox_SNR_criterion.setValue(0)
self.gridLayout_groupbox_acoustic_profile.addWidget(self.spinbox_SNR_criterion, 1, 1, 1, 1)
self.checkbox_SNR_criterion.clicked.connect(self.update_plot_profiles)
self.spinbox_SNR_criterion.valueChanged.connect(self.update_plot_profiles)
# --- Groupbox Window size ---
self.horizontalLayout_groupbox_window_size = QHBoxLayout(self.groupbox_window_size)
self.label_signal_averaging_over = QLabel()
@ -244,73 +190,8 @@ class SignalProcessingTab(QWidget):
self.label_cells = QLabel()
self.horizontalLayout_groupbox_window_size.addWidget(self.label_cells)
# # self.groupbox_averageprofile_despikingsignal = QGroupBox()
# # self.groupbox_averageprofile_despikingsignal.setTitle("Averaged profiles && Despiking the signal")
# # self.verticalLayout_groupbox_averageprofile_despikingsignal = QVBoxLayout(self.groupbox_averageprofile_despikingsignal)
#
# # self.groupbox_plot_averaged_profile = QGroupBox()
# # self.verticalLayout_plot_averaged_profile = QVBoxLayout(self.groupbox_plot_averaged_profile)
#
# # self.gridLayout_groupbox_window_size.addWidget(self.label_nb_horizontal_cells, 0, 0, 1, 1)
# # self.gridLayout_groupbox_window_size.addWidget(self.lineEdit_nb_horizontal_cells, 0, 1, 1, 1)
#
# # self.label_nb_horizontal_cells_cm.setText("cells = +/- ? cm")
#
# # self.verticalLayout_plot_averaged_profile.addLayout(self.horizontalLayout_horizontal_average)
# # self.gridLayout_groupbox_window_size.addWidget(self.label_nb_horizontal_cells_cm, 0, 2, 1, 1)
# # self.checkbox_nb_horizontal_cell_enable = QCheckBox()
# # self.checkbox_nb_horizontal_cell_enable.setText("Enable")
# # self.gridLayout_groupbox_window_size.addWidget(self.checkbox_nb_horizontal_cell_enable, 0, 3, 1, 1)
# # self.checkbox_nb_horizontal_cell_add_raw_profile = QCheckBox()
# # self.checkbox_nb_horizontal_cell_add_raw_profile.setText("Add raw profile")
# # self.gridLayout_groupbox_window_size.addWidget(self.checkbox_nb_horizontal_cell_add_raw_profile, 0, 4, 1, 1)
#
# self.horizontalLayout_vertical_average = QHBoxLayout()
# self.verticalLayout_windowsize.addLayout(self.horizontalLayout_vertical_average)
# # self.label_nb_vertical_cells = QLabel()
# # self.label_nb_vertical_cells.setText("Vertical: +/-")
# self.checkbox_nb_vertical_cells = QCheckBox()
# self.checkbox_nb_vertical_cells.setChecked(False)
# # self.checkbox_nb_vertical_cells.setText("Vertical: +/-")
# self.checkbox_nb_vertical_cells.setToolTip("Enable for further computation")
# self.horizontalLayout_vertical_average.addWidget(self.checkbox_nb_vertical_cells)
# # self.horizontalLayout_vertical_average.addWidget(self.label_nb_vertical_cells)
# # self.gridLayout_groupbox_window_size.addWidget(self.label_nb_vertical_cells, 1, 0, 1, 1)
# # self.lineEdit_nb_vertical_cells = QLineEdit()
# # self.lineEdit_nb_vertical_cells.setText("1")
# self.spinbox_nb_vertical_cells = QSpinBox()
# self.spinbox_nb_vertical_cells.setRange(0, 9999)
# self.spinbox_nb_vertical_cells.setValue(0)
# self.horizontalLayout_vertical_average.addWidget(self.spinbox_nb_vertical_cells)
# # self.horizontalLayout_vertical_average.addWidget(self.lineEdit_nb_vertical_cells)
# # self.gridLayout_groupbox_window_size.addWidget(self.lineEdit_nb_vertical_cells, 1, 1, 1, 1)
# self.label_nb_vertical_cells_cm = QLabel()
# # self.label_nb_vertical_cells_cm.setText("cells = +/- ? cm")
# self.horizontalLayout_vertical_average.addWidget(self.label_nb_vertical_cells_cm)
# # self.verticalLayout_plot_averaged_profile.addLayout(self.horizontalLayout_vertical_average)
# # self.gridLayout_groupbox_window_size.addWidget(self.label_nb_vertical_cells_cm, 1, 2, 1, 1)
# # self.checkbox_nb_vertical_cells_enable = QCheckBox()
# # self.checkbox_nb_vertical_cells_enable.setText("Enable")
# # self.gridLayout_groupbox_window_size.addWidget(self.checkbox_nb_vertical_cells_enable, 1, 3, 1, 1)
# # self.checkbox_nb_vertical_cells_add_raw_profile = QCheckBox()
# # self.checkbox_nb_vertical_cells_add_raw_profile.setText("Add raw profile")
# # self.gridLayout_groupbox_window_size.addWidget(self.checkbox_nb_vertical_cells_add_raw_profile, 1, 4, 1, 1)
#
# # self.pushbutton_plot_averaged_profile = QPushButton()
# # self.pushbutton_plot_averaged_profile.setText("Plot averaged profiles")
# # self.verticalLayout_plot_averaged_profile.addWidget(self.pushbutton_plot_averaged_profile)
# #
# # self.verticalLayout_groupbox_averageprofile_despikingsignal.addWidget(self.groupbox_plot_averaged_profile)
#
# # self.horizontalLayout_averaged_profile_despiking_signal.addWidget(self.groupbox_window_size)
# --- Groupbox Rayleigh criterion ---
self.groupbox_rayleigh_criterion = QGroupBox()
self.verticalLayout_groupbox_post_processing.addWidget(self.groupbox_rayleigh_criterion)
# # self.groupbox_rayleigh_criterion.setTitle("Rayleigh criterion")
# # self.groupbox_despiking_signal = QGroupBox()
# # self.groupbox_despiking_signal.setTitle("Despiking the signal")
@ -529,6 +410,8 @@ class SignalProcessingTab(QWidget):
self.verticalLayout_groupbox_plot_averaged_profile = QVBoxLayout(self.groupbox_plot_averaged_profile)
self.canvas_averaged_profile = None
# self.verticalLayout_averagedprofile = QVBoxLayout(self.groupbox_plot_averaged_profile)
# self.figure_averagedprofile, self.axis_averagedprofile = plt.subplots(nrows=1, ncols=4, layout='constrained')
# self.canvas_averagedprofile = FigureCanvas(self.figure_averagedprofile)
@ -580,7 +463,9 @@ class SignalProcessingTab(QWidget):
# +++ --- GroupBox Plot FCB profile --- +++
# ++++++++++++++++++++++++++++++++++++++++++++++
self.verticalLayout_groupbox_FCB_profile = QVBoxLayout(self.groupbox_FCB_profile)
self.verticalLayout_groupbox_plot_FCB_profile = QVBoxLayout(self.groupbox_FCB_profile)
self.canvas_FCB_profile = None
# self.verticalLayout_FCBoptions = QVBoxLayout(self.groupbox_FCB_profile)
# self.figure_FCBoptions, self.axis_FCBoptions = plt.subplots(nrows=1, ncols=4, layout="constrained")
@ -666,21 +551,20 @@ class SignalProcessingTab(QWidget):
# # self.slider_plotprofile.setTickPosition(QSlider.TicksBelow)
self.slider.setCursor(Qt.OpenHandCursor)
self.slider.setMinimum(1)
self.slider.setMaximum(acoustic_data._time.shape[0])#self.model.BS_averaged_cross_section_corr.V.shape[2])
# self.slider.setMaximum(stg.nb_profiles)#self.model.BS_averaged_cross_section_corr.V.shape[2])
self.slider.setTickInterval(1)
self.slider.setValue(1)
self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider)
self.slider.valueChanged.connect(self.plot_profile_position_on_transect)
self.slider.valueChanged.connect(self.plot_profile)
self.slider.valueChanged.connect(self.update_plot_profile_position_on_transect)
self.slider.valueChanged.connect(self.update_plot_profiles)
self.retranslate_signal_processing_tab()
# # -------------------- Functions for Signal processing Tab --------------------
#
def retranslate_signal_processing_tab(self):
# self.pushbutton_Load_data_from_acoustic_data_tab.setText(
# _translate("CONSTANT_STRING", cs.LOAD_DATA_FROM_ACOUSTIC_DATA_TAB))
self.pushbutton_load_data.setText(_translate("CONSTANT_STRING", cs.LOAD_DATA_FROM_ACOUSTIC_DATA_TAB))
self.groupbox_display_profile_position.setTitle(_translate("CONSTANT_STRING", cs.DISPLAY_PROFILE_POSITION))
# self.label_profile_number.setText(_translate("CONSTANT_STRING", cs.PROFILE_NUMBER) + " " +
@ -689,8 +573,8 @@ class SignalProcessingTab(QWidget):
self.groupbox_post_processing.setTitle(_translate("CONSTANT_STRING", cs.POST_PROCESSING))
self.groupbox_acoustic_profile.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_PROFILE))
# self.checkbox_substract_noise.setText(_translate("CONSTANT_STRING", cs.SUBTRACT_THE_NOISE))
# self.checkbox_SNR_criterion.setText(_translate("CONSTANT_STRING", cs.SNR_CRITERION))
self.checkbox_substract_noise.setText(_translate("CONSTANT_STRING", cs.SUBTRACT_THE_NOISE))
self.checkbox_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) + ": +/-")
@ -729,22 +613,170 @@ class SignalProcessingTab(QWidget):
self.lineEdit_slider.setText(str(self.slider.value()))
def plot_profile_position_on_transect(self):
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()))
def plot_profile(self):
if self.canvas_profile == None:
self.figure_profile, self.axis_profile = plt.subplots(nrows=1, ncols=acoustic_data._freq.shape[0], layout='constrained')
self.canvas_profile = FigureCanvas(self.figure_profile)
self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile)
self.canvas_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")
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)
for f in range(acoustic_data._freq.shape[0]):
val_min = np.min(stg.BS_data[:, stg.freq_bottom_detection, :])
val_max = np.max(stg.BS_data[:, 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, :],
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.canvas_plot_profile_position_on_transect.draw()
# def BS_signal_filtered(self):
# noise = np.zeros(acoustic_data._BS_raw_data.shape)
# for f in range(noise_data._freq.shape[0]):
# noise[:, f, :] = np.mean(noise_data._BS_raw_data[:, f, :], axis=(0, 1))
# noise_data._time_snr = acoustic_data._time
# noise_data._snr = np.divide((acoustic_data._BS_raw_data - noise)**2, noise**2)
# noise_data._snr_reshape = np.reshape(noise_data._snr,
# (acoustic_data._r.shape[0] * acoustic_data._time.shape[0],
# noise_data._freq.shape[0]),
# order="F")
# BS_denoise = np.sqrt(acoustic_data._BS_raw_data**2 - noise**2)
# BS_snr_filter = BS_denoise[np.where(noise_data._snr < self.spinbox_SNR_criterion.value())] = np.nan
# return noise_data, BS_denoise, BS_snr_filter
def update_plot_profile_position_on_transect(self):
self.label_profile_number.clear()
self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum()))
self.axis_plot_profile_position_on_transect.cla()
val_min = np.min(stg.BS_data[:, stg.freq_bottom_detection, :])
val_max = np.max(stg.BS_data[:, 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, :],
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.canvas_plot_profile_position_on_transect.draw()
def plot_profiles(self):
# --- Raw profile ---
self.figure_profile, self.axis_profile \
= plt.subplots(nrows=1, ncols=stg.freq.shape[0], layout='constrained')
self.canvas_profile = FigureCanvas(self.figure_profile)
self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_profile)
for f in range(stg.freq.shape[0]):
self.axis_profile[f].cla()
self.axis_profile[f].plot(acoustic_data._BS_raw_data[:, f, self.slider.value()-1],
acoustic_data._r)
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='solid', color='red', linewidth=1)
self.axis_profile[f].set_ylim(-np.max(stg.r), np.min(stg.r))
# --- 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_profiles(self):
BS_denoise = np.sqrt(stg.BS_data ** 2 - stg.Noise_data ** 2)
BS_snr_filter = np.zeros((stg.r.shape[0], stg.freq.shape[0], stg.t.shape[0]))
if (self.checkbox_substract_noise.isChecked() is True) and (self.checkbox_SNR_criterion.isChecked() is False):
print("Checkbox noise selected")
print("Checkbox SNR not selected")
for f in range(stg.freq.shape[0]):
self.axis_profile[f].cla()
self.axis_profile[f].plot(BS_denoise[:, 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))
elif (self.checkbox_substract_noise.isChecked() is False) and (self.checkbox_SNR_criterion.isChecked() is True):
BS_snr_filter = stg.BS_data
BS_snr_filter[np.where(stg.SNR_data < self.spinbox_SNR_criterion.value())] = np.nan
for f in range(stg.freq.shape[0]):
self.axis_profile[f].cla()
self.axis_profile[f].plot(BS_snr_filter[:, 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))
elif (self.checkbox_substract_noise.isChecked() is True) and (self.checkbox_SNR_criterion.isChecked() is True):
BS_snr_filter = BS_denoise
BS_snr_filter[np.where(stg.SNR_data < self.spinbox_SNR_criterion.value())] = np.nan
for f in range(stg.freq.shape[0]):
self.axis_profile[f].cla()
self.axis_profile[f].plot(BS_snr_filter[:, 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[:, 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.canvas_profile.draw()
# def remove_point_from_snr(self):
# noise_data, BS_denoise = self.remove_noise_from_signal()
# BS_snr_filter = BS_denoise[np.where(noise_data._snr < self.spinbox_SNR_criterion.value())] = np.nan
# return BS_snr_filter
def compute_averaged_profile(self):
pass

View File

@ -4,6 +4,7 @@ import numpy as np
import pandas as pd
import datetime
# --- load raw data ---
path_BS_raw_data = ""
filename_BS_raw_data = ""
BS_raw_data = np.array([])
@ -36,10 +37,21 @@ snr = np.array([])
snr_reshape = np.array([])
time_snr = np.array([])
# --- reshape raw data for table of values in Acoustic Data tab ---
time_reshape = np.array([])
r_reshape = np.array([])
BS_raw_data_reshape = np.array([])
snr_reshape = np.array([])
DataFrame_acoustic = pd.DataFrame()
# --- Processed data in Acoustic Data Tab and used in Acoustic processing tab ---
BS_data = np.array([])
Noise_data = np.array([])
SNR_data = np.array([])
t = np.array([])
r_bottom = np.array([])
val_bottom = np.array([])
ind_bottom = np.array([])
freq_bottom_detection = 0