Acoustic data tab is simplified for time, depth and BS cross section computation. The button clear all works. The signal processing is updated.

dev-brahim
brahim 2024-06-18 17:43:36 +02:00
parent 8320a9a0e1
commit 44b87378b8
3 changed files with 379 additions and 347 deletions

View File

@ -1727,9 +1727,14 @@ class AcousticDataTab(QWidget):
print("axis BS : ", self.axis_BS) print("axis BS : ", self.axis_BS)
self.axis_BS.tolist().clear() self.axis_BS.tolist().clear()
print("clear axis BS : ", self.axis_BS) print("clear axis BS : ", self.axis_BS)
self.canvas_BS = FigureCanvas()
self.scroll_BS.setWidget(self.canvas_BS)
self.canvas_plot_profile.figure.clear() self.canvas_plot_profile.figure.clear()
self.fig_profile.clear() self.fig_profile.clear()
self.axis_profile.clear() self.axis_profile.clear()
self.canvas_plot_profile = FigureCanvas()
self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile)
self.slider.setValue(0) self.slider.setValue(0)
self.slider.setMaximum(10) self.slider.setMaximum(10)
@ -1893,6 +1898,17 @@ class AcousticDataTab(QWidget):
stg.freq_bottom_detection.append([]) stg.freq_bottom_detection.append([])
stg.depth_bottom_detection_1st_int_area.append([]) stg.depth_bottom_detection_1st_int_area.append([])
stg.BS_noise_raw_data.append(np.array([]))
stg.BS_noise_averaged_data.append(np.array([]))
stg.SNR_raw_data.append(np.array([]))
stg.SNR_cross_section.append(np.array([]))
stg.SNR_stream_bed.append(np.array([]))
stg.time_noise.append(np.array([]))
stg.noise_method.append(0)
stg.SNR_filter_value.append(0)
stg.filename_BS_noise_data.append("")
stg.path_BS_noise_data.append("")
stg.BS_raw_data_pre_process_SNR.append(np.array([])) stg.BS_raw_data_pre_process_SNR.append(np.array([]))
stg.BS_raw_data_pre_process_average.append(np.array([])) stg.BS_raw_data_pre_process_average.append(np.array([]))
stg.BS_raw_data_pre_process_SNR_average.append(np.array([])) stg.BS_raw_data_pre_process_SNR_average.append(np.array([]))
@ -2984,112 +3000,112 @@ class AcousticDataTab(QWidget):
else: else:
# print("stg.BS_cross_section[self.fileListWidget.currentRow()].shape ", stg.BS_cross_section[self.fileListWidget.currentRow()].shape) # print("stg.BS_cross_section[self.fileListWidget.currentRow()].shape ", stg.BS_cross_section[self.fileListWidget.currentRow()].shape)
if self.fileListWidget.currentRow() != -1:
if len(self.axis_BS.tolist()) != stg.freq[self.fileListWidget.currentRow()].shape[0]:
self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0],
ncols=1,
sharex=True, sharey=False, layout="constrained")
if len(self.axis_BS.tolist()) != stg.freq[self.fileListWidget.currentRow()].shape[0]: for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]):
self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0], self.axis_BS[f].cla()
ncols=1,
sharex=True, sharey=False, layout="constrained")
for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,):
self.axis_BS[f].cla()
if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
if val_min == 0:
val_min = 1e-5
val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) if self.combobox_ABS_system_choice.currentIndex() == 1:
val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :],
if val_min == 0: -stg.depth[self.fileListWidget.currentRow()][f,
val_min = 1e-5 :],
stg.BS_raw_data[self.fileListWidget.currentRow()][f, :,
:],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
if self.combobox_ABS_system_choice.currentIndex() == 1: elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :], pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :],
-stg.depth[self.fileListWidget.currentRow()][f, -stg.depth[self.fileListWidget.currentRow()][f,
:], :],
stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, np.log(
:], stg.BS_raw_data[self.fileListWidget.currentRow()][f,
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) :, :]),
cmap='Blues')
elif self.combobox_ABS_system_choice.currentIndex() == 2: # --- Plot red solid line on transect to visualize position of plotted profile ---
pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :], slider_value = \
-stg.depth[self.fileListWidget.currentRow()][f, [self.slider.value() - 1 if self.slider.value() - 1 <=
:], stg.time[self.fileListWidget.currentRow()].shape[
np.log( 1] - 1
stg.BS_raw_data[self.fileListWidget.currentRow()][f, else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0]
:, :]),
cmap='Blues')
# --- Plot red solid line on transect to visualize position of plotted profile --- self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
slider_value = \ stg.time[self.fileListWidget.currentRow()][0, slider_value] *
[self.slider.value() - 1 if self.slider.value() - 1 <= np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]),
stg.time[self.fileListWidget.currentRow()].shape[ -stg.depth[self.fileListWidget.currentRow()][
1] - 1 self.combobox_frequency_profile.currentIndex(), :],
else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] color='red', linestyle="solid", linewidth=2)
self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( # --- Plot river bottom line ---
stg.time[self.fileListWidget.currentRow()][0, slider_value] * if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0:
np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]), self.axis_BS[f].plot(stg.time[self.fileListWidget.currentRow()][
-stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :],
color='red', linestyle="solid", linewidth=2)
# --- Plot river bottom line ---
if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0:
self.axis_BS[f].plot(stg.time[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :],
-stg.depth[self.fileListWidget.currentRow()],
color='black', linewidth=1, linestyle="solid")
else:
val_min = np.nanmin(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :])
val_max = np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :])
if val_min == 0:
val_min = 1e-5
if self.combobox_ABS_system_choice.currentIndex() == 1:
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :,
:]),
cmap='Blues')
# --- Plot red solid line on transect to visualize position of plotted profile ---
slider_value = \
[self.slider.value() - 1 if self.slider.value() - 1 <=
stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1
else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0]
self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
stg.time_cross_section[self.fileListWidget.currentRow()][
0, # self.combobox_frequency_profile.currentIndex(),
slider_value] * np.ones(
stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1]),
-stg.depth_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :],
color='red', linestyle="solid", linewidth=2)
# --- Plot river bottom line ---
# if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()):
if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0:
# print("stg.depth_bottom ", stg.depth_bottom)
# print("len(stg.depth_bottom) ", len(stg.depth_bottom))
self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :], self.combobox_frequency_bathymetry.currentIndex(), :],
-stg.depth_bottom[self.fileListWidget.currentRow()], -stg.depth[self.fileListWidget.currentRow()],
color='black', linewidth=1, linestyle="solid") color='black', linewidth=1, linestyle="solid")
self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f], else:
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_BS[f].transAxes)
self.fig_BS.supxlabel('Time (sec)', fontsize=10) val_min = np.nanmin(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :])
self.fig_BS.supylabel('Depth (m)', fontsize=10) val_max = np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :])
self.fig_BS.canvas.draw_idle() if val_min == 0:
val_min = 1e-5
if self.combobox_ABS_system_choice.currentIndex() == 1:
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :,
:]),
cmap='Blues')
# --- Plot red solid line on transect to visualize position of plotted profile ---
slider_value = \
[self.slider.value() - 1 if self.slider.value() - 1 <=
stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1
else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0]
self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
stg.time_cross_section[self.fileListWidget.currentRow()][
0, # self.combobox_frequency_profile.currentIndex(),
slider_value] * np.ones(
stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1]),
-stg.depth_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :],
color='red', linestyle="solid", linewidth=2)
# --- Plot river bottom line ---
# if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()):
if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0:
# print("stg.depth_bottom ", stg.depth_bottom)
# print("len(stg.depth_bottom) ", len(stg.depth_bottom))
self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :],
-stg.depth_bottom[self.fileListWidget.currentRow()],
color='black', linewidth=1, linestyle="solid")
self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_BS[f].transAxes)
self.fig_BS.supxlabel('Time (sec)', fontsize=10)
self.fig_BS.supylabel('Depth (m)', fontsize=10)
self.fig_BS.canvas.draw_idle()
# self.fig_BS.canvas.flush_events() # self.fig_BS.canvas.flush_events()
# plt.close(self.fig_BS) # plt.close(self.fig_BS)
@ -3400,88 +3416,90 @@ class AcousticDataTab(QWidget):
def update_plot_profile(self): def update_plot_profile(self):
# print("len(stg.BS_cross_section) ", len(stg.BS_cross_section)) # print("len(stg.BS_cross_section) ", len(stg.BS_cross_section))
# if (len(stg.BS_cross_section) == 0) and (len(stg.BS_raw_data) != 0): # if (len(stg.BS_cross_section) == 0) and (len(stg.BS_raw_data) != 0):
if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): if self.fileListWidget.currentRow() != -1:
self.axis_profile.cla() if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,):
self.axis_profile.plot(stg.BS_raw_data[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
self.axis_profile.text(.95, .05, stg.freq_text[self.fileListWidget.currentRow()][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.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.axis_profile.cla()
self.fig_profile.supylabel("Depth (m)") self.axis_profile.plot(stg.BS_raw_data[self.fileListWidget.currentRow()][
# self.fig_profile.canvas.draw() self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
self.fig_profile.canvas.draw_idle() -stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :],
# self.fig_profile.canvas.flush_events() linestyle='solid', color='k', linewidth=1)
# plt.close(self.fig_profile) self.axis_profile.text(.95, .05, stg.freq_text[self.fileListWidget.currentRow()][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)
else: self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)")
self.fig_profile.supylabel("Depth (m)")
# self.fig_profile.canvas.draw()
self.fig_profile.canvas.draw_idle()
# self.fig_profile.canvas.flush_events()
# plt.close(self.fig_profile)
self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) else:
slider_value = [self.slider.value() - 1 if self.slider.value() -1 <= stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1 self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])
else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1)][0]
self.axis_profile.cla() slider_value = [self.slider.value() - 1 if self.slider.value() -1 <= stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1
else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1)][0]
# --- Profile plot --- self.axis_profile.cla()
self.axis_profile.plot(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :, slider_value],
-stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
# --- Plot upper limit line --- # --- Profile plot ---
self.axis_profile.plot(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :, slider_value],
-stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
# self.axis_profile.plot([0, # --- Plot upper limit line ---
# stg.BS_cross_section[self.combobox_frequency_profile.currentIndex(),
# stg.ind_bottom[slider_value],
# slider_value]],
# -stg.
# )
# --- Plot lower limit line --- # self.axis_profile.plot([0,
# stg.BS_cross_section[self.combobox_frequency_profile.currentIndex(),
# stg.ind_bottom[slider_value],
# slider_value]],
# -stg.
# )
# --- Write frequency on graph --- # --- Plot lower limit line ---
self.axis_profile.text(.95, .90, stg.freq_text[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()], # --- Write frequency on graph ---
fontsize=14, fontweight='bold', fontname="Ubuntu",
fontstyle="normal", c="black", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes)
# --- Plot bottom line --- self.axis_profile.text(.95, .90, stg.freq_text[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()],
fontsize=14, fontweight='bold', fontname="Ubuntu",
fontstyle="normal", c="black", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes)
# print("len(stg.depth_bottom) ", len(stg.depth_bottom)) # --- Plot bottom line ---
# print("self.fileListWidget.currentRow() ", self.fileListWidget.count())
# if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()):
if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0: # print("len(stg.depth_bottom) ", len(stg.depth_bottom))
# print("self.fileListWidget.currentRow() ", self.fileListWidget.count())
# if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()):
self.axis_profile.plot([0, if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0:
np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(),
:, slider_value])],
-stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]]*np.ones(2),
linestyle='solid', color='r', linewidth=1)
position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / self.axis_profile.plot([0,
np.nanmax(stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :])) np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(),
:, slider_value])],
-stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]]*np.ones(2),
linestyle='solid', color='r', linewidth=1)
self.axis_profile.text(.95, 1-position_x + 0.05, "River bed", position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] /
fontsize=10, fontweight='normal', fontname="Ubuntu", np.nanmax(stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :]))
fontstyle="italic", c="red", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes)
self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.axis_profile.text(.95, 1-position_x + 0.05, "River bed",
self.fig_profile.supylabel("Depth (m)") fontsize=10, fontweight='normal', fontname="Ubuntu",
# self.fig_profile.canvas.draw() fontstyle="italic", c="red", alpha=0.2,
self.fig_profile.canvas.draw_idle() horizontalalignment='right', verticalalignment='bottom',
# self.fig_profile.canvas.flush_events() transform=self.axis_profile.transAxes)
# plt.close(self.fig_profile)
self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)")
self.fig_profile.supylabel("Depth (m)")
# self.fig_profile.canvas.draw()
self.fig_profile.canvas.draw_idle()
# self.fig_profile.canvas.flush_events()
# plt.close(self.fig_profile)
def slide_profile_number_to_begin(self): def slide_profile_number_to_begin(self):
self.slider.setValue(int(self.slider.minimum())) self.slider.setValue(int(self.slider.minimum()))

View File

@ -100,16 +100,13 @@ class SignalProcessingTab(QWidget):
self.radiobutton_file = QRadioButton("File") self.radiobutton_file = QRadioButton("File")
self.radiobutton_file.setChecked(True) self.radiobutton_file.setChecked(True)
self.radiobutton_file.toggled.connect(self.onClicked_radiobutton_noise_data)
self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_file, 0, 0, 1, 1) self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_file, 0, 0, 1, 1)
self.radiobutton_profile_tail = QRadioButton("Profile tail") self.radiobutton_profile_tail = QRadioButton("Profile tail")
# self.radiobutton_file.setChecked(False) # self.radiobutton_file.setChecked(False)
self.radiobutton_profile_tail.toggled.connect(self.onClicked_radiobutton_noise_data)
self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_profile_tail, 0, 1, 1, 1) self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_profile_tail, 0, 1, 1, 1)
self.radiobutton_value = QRadioButton("Value") self.radiobutton_value = QRadioButton("Value")
self.radiobutton_value.toggled.connect(self.onClicked_radiobutton_noise_data)
self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_value, 0, 2, 1, 1) self.gridLayout_radiobutton_noise_data.addWidget(self.radiobutton_value, 0, 2, 1, 1)
### --- Groupbox download noise file --- ### --- Groupbox download noise file ---
@ -131,7 +128,6 @@ class SignalProcessingTab(QWidget):
# self.gridLayout_groupbox_noise_file.addWidget(self.label_hour_groupbox_noise_file, 1, 2, 1, 1) # self.gridLayout_groupbox_noise_file.addWidget(self.label_hour_groupbox_noise_file, 1, 2, 1, 1)
# Download Push Button event : connect button clicked signal to open file slot # Download Push Button event : connect button clicked signal to open file slot
self.pushbutton_noise_file.clicked.connect(self.open_dialog_box)
self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_download_noise_file) self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_download_noise_file)
@ -158,7 +154,6 @@ class SignalProcessingTab(QWidget):
self.pushbutton_compute_noise_from_value = QPushButton() self.pushbutton_compute_noise_from_value = QPushButton()
self.pushbutton_compute_noise_from_value.setText("Apply noise") 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.gridLayout_compute_noise_from_value.addWidget(self.pushbutton_compute_noise_from_value, 0, 3, 1, 1)
self.pushbutton_compute_noise_from_value.clicked.connect(self.compute_noise_from_value)
self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_value) self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_compute_noise_from_value)
@ -180,8 +175,6 @@ class SignalProcessingTab(QWidget):
self.pushbutton_Apply_SNR_filter = QPushButton() self.pushbutton_Apply_SNR_filter = QPushButton()
self.gridLayout_SNR_criterion.addWidget(self.pushbutton_Apply_SNR_filter, 0, 2, 1, 1) self.gridLayout_SNR_criterion.addWidget(self.pushbutton_Apply_SNR_filter, 0, 2, 1, 1)
self.pushbutton_Apply_SNR_filter.clicked.connect(self.remove_point_with_snr_filter)
self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_SNR_criterion) self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_SNR_criterion)
# +++++++++++++++++++++++++++++ # +++++++++++++++++++++++++++++
@ -408,6 +401,19 @@ class SignalProcessingTab(QWidget):
# --- Connect signal of widget --- # --- Connect signal of widget ---
self.pushbutton_update.clicked.connect(self.event_combobobx_fileListWidget)
self.pushbutton_update.clicked.connect(self.remove_point_with_snr_filter)
self.radiobutton_file.toggled.connect(self.onClicked_radiobutton_noise_data)
self.radiobutton_profile_tail.toggled.connect(self.onClicked_radiobutton_noise_data)
self.radiobutton_value.toggled.connect(self.onClicked_radiobutton_noise_data)
self.pushbutton_noise_file.clicked.connect(self.open_dialog_box)
self.pushbutton_compute_noise_from_value.clicked.connect(self.compute_noise_from_value)
self.pushbutton_Apply_SNR_filter.clicked.connect(self.remove_point_with_snr_filter)
self.pushbutton_average.clicked.connect(self.compute_averaged_BS_data) self.pushbutton_average.clicked.connect(self.compute_averaged_BS_data)
self.pushbutton_average.clicked.connect(self.plot_profile_and_position_on_transect_with_slider) self.pushbutton_average.clicked.connect(self.plot_profile_and_position_on_transect_with_slider)
@ -1037,28 +1043,30 @@ class SignalProcessingTab(QWidget):
for i in range(len(stg.filename_BS_raw_data)): for i in range(len(stg.filename_BS_raw_data)):
self.combobox_fileListWidget.addItem(stg.filename_BS_raw_data[i]) self.combobox_fileListWidget.addItem(stg.filename_BS_raw_data[i])
print("len stg.BS_noise_raw_data : ", len(stg.BS_noise_raw_data)) # print("len stg.BS_noise_raw_data : ", len(stg.BS_noise_raw_data))
if len(stg.BS_noise_raw_data) == 0: # if len(stg.BS_noise_raw_data) == 0:
stg.BS_noise_raw_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] # stg.BS_noise_raw_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)]
print("stg.BS_noise_raw_data : ", stg.BS_noise_raw_data) # print("stg.BS_noise_raw_data : ", stg.BS_noise_raw_data)
print("len stg.BS_noise_raw_data : ", len(stg.BS_noise_raw_data)) # print("len stg.BS_noise_raw_data : ", len(stg.BS_noise_raw_data))
stg.BS_noise_averaged_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] # stg.BS_noise_averaged_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)]
stg.SNR_raw_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] # stg.SNR_raw_data = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)]
stg.SNR_cross_section = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] # stg.SNR_cross_section = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)]
stg.SNR_stream_bed = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] # stg.SNR_stream_bed = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)]
stg.time_noise = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)] # stg.time_noise = [np.array([]) for _ in range(self.combobox_fileListWidget.count() - 1)]
stg.noise_method = [0]*(self.combobox_fileListWidget.count() - 1) # stg.noise_method = [0]*(self.combobox_fileListWidget.count() - 1)
elif len(stg.BS_noise_raw_data) < (self.combobox_fileListWidget.count() - 1): # elif len(stg.BS_noise_raw_data) < (self.combobox_fileListWidget.count() - 1):
stg.BS_noise_raw_data.append(np.array([])) # stg.BS_noise_raw_data.append(np.array([]))
stg.BS_noise_averaged_data.append(np.array([])) # stg.BS_noise_averaged_data.append(np.array([]))
stg.SNR_raw_data.append(np.array([])) # stg.SNR_raw_data.append(np.array([]))
stg.SNR_cross_section.append(np.array([])) # stg.SNR_cross_section.append(np.array([]))
stg.SNR_stream_bed.append(np.array([])) # stg.SNR_stream_bed.append(np.array([]))
stg.time_noise.append(np.array([])) # stg.time_noise.append(np.array([]))
stg.noise_method.append(0) # stg.noise_method.append(0)
if (stg.noise_method == 1) or (stg.noise_method == 0): if (stg.noise_method == 1) or (stg.noise_method == 0):
self.radiobutton_file.setChecked(True) self.radiobutton_file.setChecked(True)
if stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1] != "":
self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1])
self.radiobutton_profile_tail.setChecked(False) self.radiobutton_profile_tail.setChecked(False)
self.radiobutton_value.setChecked(False) self.radiobutton_value.setChecked(False)
elif stg.noise_method == 2: elif stg.noise_method == 2:
@ -1101,8 +1109,8 @@ class SignalProcessingTab(QWidget):
name = path.basename(filename[0]) name = path.basename(filename[0])
try: try:
stg.path_BS_noise_data = dir_name stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1] = dir_name
stg.filename_BS_noise_data = name stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1] = name
print("stg.path_BS_noise_data : ", stg.path_BS_noise_data) print("stg.path_BS_noise_data : ", stg.path_BS_noise_data)
print("stg.filename_BS_noise_data : ", stg.filename_BS_noise_data) print("stg.filename_BS_noise_data : ", stg.filename_BS_noise_data)
self.load_noise_data_and_compute_SNR() self.load_noise_data_and_compute_SNR()
@ -1117,8 +1125,8 @@ class SignalProcessingTab(QWidget):
msgBox.exec() msgBox.exec()
else: else:
self.lineEdit_noise_file.setText(stg.filename_BS_noise_data) self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1])
self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data) self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1])
# self.plot_noise() # self.plot_noise()
self.plot_transect_with_SNR_data() self.plot_transect_with_SNR_data()
# self.combobox_freq_noise.addItems([f for f in stg.freq_text]) # self.combobox_freq_noise.addItems([f for f in stg.freq_text])
@ -1129,12 +1137,7 @@ class SignalProcessingTab(QWidget):
self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1]]) self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1]])
self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_profile_and_position_on_transect_with_slider) self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_profile_and_position_on_transect_with_slider)
if len(stg.BS_stream_bed) and stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape: if stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1])
elif (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[2]
< stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape[2]):
self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1])
@ -1142,6 +1145,19 @@ class SignalProcessingTab(QWidget):
self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex() - 1].shape[1])
# if len(stg.BS_stream_bed) and stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape:
#
# self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1])
#
# elif (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[2]
# < stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape[2]):
#
# self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1])
#
# else:
#
# self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex() - 1].shape[1])
self.compute_averaged_BS_data() self.compute_averaged_BS_data()
self.plot_profile_and_position_on_transect_with_slider() self.plot_profile_and_position_on_transect_with_slider()
@ -1158,25 +1174,24 @@ class SignalProcessingTab(QWidget):
# stg.hour_noise = noise_data._hour # stg.hour_noise = noise_data._hour
stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = noise_data._time stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = noise_data._time
# stg.time_snr_reshape = stg.time_reshape # stg.time_snr_reshape = stg.time_reshape
print("len(stg.BS_cross_section) : ", len(stg.BS_cross_section)) # print("len(stg.BS_cross_section) : ", len(stg.BS_cross_section))
print("stg.BS_cross_section[0] : ", stg.BS_cross_section[0].shape) # print("stg.BS_cross_section[0] : ", stg.BS_cross_section[0].shape)
print("len(stg.BS_stream_bed) : ", len(stg.BS_stream_bed)) # print("len(stg.BS_stream_bed) : ", len(stg.BS_stream_bed))
if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape): print("Je suis dans stream bed")
print("Je suis dans raw")
noise = np.zeros(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape) noise = np.zeros(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape)
for f, _ in enumerate(noise_data._freq): for f, _ in enumerate(noise_data._freq):
noise[f, :, :] = np.mean( noise[f, :, :] = np.mean(
stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1)) stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1))
stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise
stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = ( stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] = (
np.divide((stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1] - np.divide((stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] -
stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2,
stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2))
elif len(stg.BS_stream_bed) < len(stg.BS_cross_section): elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
print("Je suis dans cross section") print("Je suis dans cross section")
noise = np.zeros(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape) noise = np.zeros(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape)
@ -1191,19 +1206,19 @@ class SignalProcessingTab(QWidget):
# stg.SNR_reshape = np.reshape(stg.SNR_cross_section, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), order="F") # stg.SNR_reshape = np.reshape(stg.SNR_cross_section, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), order="F")
else: else:
print("Je suis dans stream bed") print("Je suis dans raw")
noise = np.zeros(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape) noise = np.zeros(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape)
for f, _ in enumerate(noise_data._freq): for f, _ in enumerate(noise_data._freq):
noise[f, :, :] = np.mean( noise[f, :, :] = np.mean(
stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1)) stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1))
stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise
stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] = ( stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = (
np.divide((stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] - np.divide((stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1] -
stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2,
stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2))
# stg.SNR_reshape = np.reshape(stg.SNR_stream_bed, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]),
# order="F")
# print("stg.SNR_raw_data[0].shape ", stg.SNR_raw_data) # print("stg.SNR_raw_data[0].shape ", stg.SNR_raw_data)
@ -1391,60 +1406,7 @@ class SignalProcessingTab(QWidget):
for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]):
if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == if stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape):
x, y = np.meshgrid(stg.time[self.combobox_fileListWidget.currentIndex() - 1][0, :],
stg.depth[self.combobox_fileListWidget.currentIndex() - 1][0, :])
print("0 plot SNR with SNR_raw_data")
val_min = np.nanmin(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
if val_min == val_max:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
cf = (self.axis_SNR[f].contourf(x, -y,
stg.SNR_raw_data[
self.combobox_fileListWidget.currentIndex() - 1][f, :, :],
levels, cmap='gist_rainbow', norm=norm))
elif len(stg.BS_stream_bed) < len(stg.BS_cross_section):
x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :],
stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :])
print("1 plot SNR with SNR_cross_section")
val_min = np.nanmin(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
if val_min == val_max:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
cf = (self.axis_SNR[f].contourf(x, -y,
stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :],
levels, cmap='gist_rainbow', norm=norm))
else:
x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :], x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :],
stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :]) stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :])
@ -1471,6 +1433,59 @@ class SignalProcessingTab(QWidget):
levels, cmap='gist_rainbow', levels, cmap='gist_rainbow',
norm=norm)) norm=norm))
elif stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :],
stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :])
print("1 plot SNR with SNR_cross_section")
val_min = np.nanmin(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
if val_min == val_max:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
cf = (self.axis_SNR[f].contourf(x, -y,
stg.SNR_cross_section[
self.combobox_fileListWidget.currentIndex() - 1][f, :, :],
levels, cmap='gist_rainbow', norm=norm))
else:
x, y = np.meshgrid(stg.time[self.combobox_fileListWidget.currentIndex() - 1][0, :],
stg.depth[self.combobox_fileListWidget.currentIndex() - 1][0, :])
print("0 plot SNR with SNR_raw_data")
val_min = np.nanmin(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
if val_min == val_max:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
else:
levels = np.array([00.1, 1, 2, 10, 100, val_max])
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
cf = (self.axis_SNR[f].contourf(x, -y,
stg.SNR_raw_data[
self.combobox_fileListWidget.currentIndex() - 1][f, :, :],
levels, cmap='gist_rainbow', norm=norm))
self.axis_SNR[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][f], self.axis_SNR[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom', horizontalalignment='right', verticalalignment='bottom',
@ -1502,33 +1517,7 @@ class SignalProcessingTab(QWidget):
else: else:
if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape):
stg.BS_raw_data_pre_process_SNR = deepcopy(stg.BS_raw_data)
for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]):
stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][
f,
np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[0],
np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \
= np.nan
elif len(stg.BS_stream_bed) < len(stg.BS_cross_section):
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_fileListWidget.currentIndex() - 1]):
stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][
f,
np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[0],
np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \
= np.nan
else:
stg.BS_stream_bed_pre_process_SNR = deepcopy(stg.BS_stream_bed) 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.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]])
@ -1542,6 +1531,35 @@ class SignalProcessingTab(QWidget):
np.where(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ np.where(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \
= np.nan = np.nan
elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].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_fileListWidget.currentIndex() - 1]):
stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][
f,
np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :,
:] < self.spinbox_SNR_criterion.value())[0],
np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :,
:] < self.spinbox_SNR_criterion.value())[1]] \
= np.nan
else:
stg.BS_raw_data_pre_process_SNR = deepcopy(stg.BS_raw_data)
for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]):
stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][
f,
np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :,
:] < self.spinbox_SNR_criterion.value())[0],
np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :,
:] < self.spinbox_SNR_criterion.value())[1]] \
= np.nan
# elif stg.BS_stream_bed_pre_process_average.size != 0: # 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) # stg.BS_stream_bed_pre_process_SNR = deepcopy(stg.BS_stream_bed_pre_process_average)
@ -1576,8 +1594,8 @@ class SignalProcessingTab(QWidget):
# self.update_plot_profile_position_on_transect() # self.update_plot_profile_position_on_transect()
# self.update_plot_averaged_profile() # self.update_plot_averaged_profile()
# self.compute_averaged_BS_data() self.compute_averaged_BS_data()
# self.plot_profile_and_position_on_transect_with_slider() self.plot_profile_and_position_on_transect_with_slider()
def plot_BS_signal_filtered_with_SNR(self): def plot_BS_signal_filtered_with_SNR(self):
@ -1598,36 +1616,7 @@ class SignalProcessingTab(QWidget):
for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]):
if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape):
val_min = np.nanmin(
stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(
stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex() - 1][f, :],
-stg.depth[self.combobox_fileListWidget.currentIndex() - 1][f, :],
stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif len(stg.BS_stream_bed) < len(stg.BS_cross_section):
val_min = np.nanmin(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :],
-stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :],
stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
@ -1644,6 +1633,38 @@ class SignalProcessingTab(QWidget):
-stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1],
color='black', linewidth=1, linestyle="solid") color='black', linewidth=1, linestyle="solid")
elif stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
val_min = np.nanmin(
stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(
stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(
stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :],
-stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :],
stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
val_min = np.nanmin(
stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
val_max = np.nanmax(
stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex() - 1][f, :],
-stg.depth[self.combobox_fileListWidget.currentIndex() - 1][f, :],
stg.BS_raw_data_pre_process_SNR[
self.combobox_fileListWidget.currentIndex() - 1][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
self.axis_BS[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][f], self.axis_BS[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom', horizontalalignment='right', verticalalignment='bottom',
@ -1670,11 +1691,11 @@ class SignalProcessingTab(QWidget):
kernel = np.ones(2*self.spinbox_average_horizontal.value()+1) kernel = np.ones(2*self.spinbox_average_horizontal.value()+1)
print(kernel) print(kernel)
if len(stg.BS_stream_bed): if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
# --- Données pré-traitées avec SNR : BS stream bed pre process SNR -> BS stream bed pre process SNR average --- # --- Données pré-traitées avec SNR : BS stream bed pre process SNR -> BS stream bed pre process SNR average ---
if len(stg.BS_stream_bed_pre_process_SNR): if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
# ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or # ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or
# (stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape))): # (stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape))):
@ -1700,12 +1721,11 @@ class SignalProcessingTab(QWidget):
= convolve1d(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) = convolve1d(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel)
print("2 - Je suis dans stg.BS_stream_bed_pre_process_average") print("2 - Je suis dans stg.BS_stream_bed_pre_process_average")
elif (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[2] elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
< stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape[2]):
# --- Données pré-traitées avec SNR : BS cross section pre process SNR -> BS cross section pre process SNR average --- # --- Données pré-traitées avec SNR : BS cross section pre process SNR -> BS cross section pre process SNR average ---
if len(stg.BS_cross_section_pre_process_SNR): if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
# if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or # if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or
# (stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape)): # (stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape)):
@ -1731,13 +1751,11 @@ class SignalProcessingTab(QWidget):
= convolve1d(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) = convolve1d(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel)
print("4 - Je suis dans stg.BS_cross_section_pre_process_average") print("4 - Je suis dans stg.BS_cross_section_pre_process_average")
else: else:
# --- Données pré-traitées avec SNR : BS raw data pre process SNR -> BS raw data pre process SNR average --- # --- Données pré-traitées avec SNR : BS raw data pre process SNR -> BS raw data pre process SNR average ---
if len(stg.BS_cross_section_pre_process_SNR): if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
# if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or # if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or
# (stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape)): # (stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape)):
@ -1840,8 +1858,7 @@ class SignalProcessingTab(QWidget):
self.axis_profile[0].cla() self.axis_profile[0].cla()
self.axis_profile[1].cla() self.axis_profile[1].cla()
if ((len(stg.BS_stream_bed_pre_process_SNR_average)) and if stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
(len(stg.BS_stream_bed_pre_process_SNR_average) == (self.combobox_fileListWidget.count() -1))):
# --- Plot profile --- # --- Plot profile ---
self.axis_profile[0].plot( self.axis_profile[0].plot(
@ -1871,8 +1888,7 @@ class SignalProcessingTab(QWidget):
[self.combobox_frequency_profile.currentIndex(), :, :], [self.combobox_frequency_profile.currentIndex(), :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif (len(stg.BS_stream_bed_pre_process_average) elif stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
and (len(stg.BS_stream_bed_pre_process_average) == (self.combobox_fileListWidget.count() -1))):
# --- Plot profile --- # --- Plot profile ---
self.axis_profile[0].plot( self.axis_profile[0].plot(
@ -1907,8 +1923,7 @@ class SignalProcessingTab(QWidget):
[self.combobox_frequency_profile.currentIndex(), :, :], [self.combobox_frequency_profile.currentIndex(), :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif (len(stg.BS_cross_section_pre_process_SNR_average) and elif stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
(len(stg.BS_cross_section_pre_process_SNR_average) == (self.combobox_fileListWidget.count() -1))):
# --- Plot profile --- # --- Plot profile ---
self.axis_profile[0].plot( self.axis_profile[0].plot(
@ -1943,8 +1958,7 @@ class SignalProcessingTab(QWidget):
[self.combobox_frequency_profile.currentIndex(), :, :], [self.combobox_frequency_profile.currentIndex(), :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif (len(stg.BS_cross_section_pre_process_average) elif stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
and (len(stg.BS_cross_section_pre_process_average) == (self.combobox_fileListWidget.count() - 1))):
# --- Plot profile --- # --- Plot profile ---
self.axis_profile[0].plot( self.axis_profile[0].plot(
@ -1979,8 +1993,7 @@ class SignalProcessingTab(QWidget):
[self.combobox_frequency_profile.currentIndex(), :, :], [self.combobox_frequency_profile.currentIndex(), :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif (len(stg.BS_raw_data_pre_process_SNR_average) elif stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
and (len(stg.BS_raw_data_pre_process_SNR_average) == (self.combobox_fileListWidget.count() - 1))):
# --- Plot profile --- # --- Plot profile ---
self.axis_profile[0].plot( self.axis_profile[0].plot(
@ -2021,7 +2034,7 @@ class SignalProcessingTab(QWidget):
self.axis_profile[0].plot( self.axis_profile[0].plot(
stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1]
[self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][
self.combobox_frequency_profile.currentIndex(), :], self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1) linestyle='solid', color='k', linewidth=1)
self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][
@ -2041,9 +2054,9 @@ class SignalProcessingTab(QWidget):
[self.combobox_frequency_profile.currentIndex(), :, :]) [self.combobox_frequency_profile.currentIndex(), :, :])
if val_min == 0: if val_min == 0:
val_min = 1e-5 val_min = 1e-5
self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ self.axis_profile[1].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex() - 1][
self.combobox_frequency_profile.currentIndex(), :], self.combobox_frequency_profile.currentIndex(), :],
-stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][
self.combobox_frequency_profile.currentIndex(), :], self.combobox_frequency_profile.currentIndex(), :],
stg.BS_raw_data_pre_process_average[ stg.BS_raw_data_pre_process_average[
self.combobox_fileListWidget.currentIndex() - 1] self.combobox_fileListWidget.currentIndex() - 1]
@ -2060,8 +2073,8 @@ class SignalProcessingTab(QWidget):
-stg.depth[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :],
color='red', linestyle="solid", linewidth=2) color='red', linestyle="solid", linewidth=2)
if len(stg.depth_bottom): if len(stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1]) != 0:
if len(stg.time_cross_section): if stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,):
self.axis_profile[1].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], self.axis_profile[1].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :],
-stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1],
color='black', linewidth=1, linestyle="solid") color='black', linewidth=1, linestyle="solid")

View File

@ -17,12 +17,13 @@ freq = []
freq_text = [] freq_text = []
time = [] time = []
path_BS_noise_data = "" path_BS_noise_data = []
filename_BS_noise_data = "" filename_BS_noise_data = []
BS_noise_raw_data = [] # BS noise raw data : BS signal listen BS_noise_raw_data = [] # BS noise raw data : BS signal listen
BS_noise_averaged_data = [] # BS noise raw data averaged (array has the same shape than BS_raw_data shape) BS_noise_averaged_data = [] # BS noise raw data averaged (array has the same shape than BS_raw_data shape)
noise_method = [] noise_method = []
SNR_filter_value = []
date = [] date = []
date_noise = [] date_noise = []