diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index f879ac7..f07bb6e 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -1727,9 +1727,14 @@ class AcousticDataTab(QWidget): print("axis BS : ", self.axis_BS) self.axis_BS.tolist().clear() 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.fig_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.setMaximum(10) @@ -1893,6 +1898,17 @@ class AcousticDataTab(QWidget): stg.freq_bottom_detection.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_average.append(np.array([])) stg.BS_raw_data_pre_process_SNR_average.append(np.array([])) @@ -2984,112 +3000,112 @@ class AcousticDataTab(QWidget): else: # 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]: - self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0], - ncols=1, - sharex=True, sharey=False, layout="constrained") + for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): + self.axis_BS[f].cla() - for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): - self.axis_BS[f].cla() + if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): - 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, :, :]) - val_max = np.nanmax(stg.BS_raw_data[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[self.fileListWidget.currentRow()][f, :], + -stg.depth[self.fileListWidget.currentRow()][f, + :], + 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: - pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :], - -stg.depth[self.fileListWidget.currentRow()][f, - :], - stg.BS_raw_data[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[self.fileListWidget.currentRow()][f, :], + -stg.depth[self.fileListWidget.currentRow()][f, + :], + np.log( + stg.BS_raw_data[self.fileListWidget.currentRow()][f, + :, :]), + cmap='Blues') - elif self.combobox_ABS_system_choice.currentIndex() == 2: - pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :], - -stg.depth[self.fileListWidget.currentRow()][f, - :], - np.log( - stg.BS_raw_data[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[self.fileListWidget.currentRow()].shape[ + 1] - 1 + else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] - # --- 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[self.fileListWidget.currentRow()].shape[ - 1] - 1 - else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] + self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + stg.time[self.fileListWidget.currentRow()][0, slider_value] * + np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]), + -stg.depth[self.fileListWidget.currentRow()][ + self.combobox_frequency_profile.currentIndex(), :], + color='red', linestyle="solid", linewidth=2) - self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - stg.time[self.fileListWidget.currentRow()][0, slider_value] * - np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]), - -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()][ + # --- 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_bottom[self.fileListWidget.currentRow()], + -stg.depth[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) + else: - self.fig_BS.supxlabel('Time (sec)', fontsize=10) - self.fig_BS.supylabel('Depth (m)', fontsize=10) - self.fig_BS.canvas.draw_idle() + 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(), :], + -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() # plt.close(self.fig_BS) @@ -3400,88 +3416,90 @@ class AcousticDataTab(QWidget): def update_plot_profile(self): # 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 stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): + if self.fileListWidget.currentRow() != -1: - self.axis_profile.cla() - 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) + if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): - 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.axis_profile.cla() + 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) - 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 - else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1)][0] + self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) - 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.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.cla() - # --- 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, - # stg.BS_cross_section[self.combobox_frequency_profile.currentIndex(), - # stg.ind_bottom[slider_value], - # slider_value]], - # -stg. - # ) + # --- Plot upper limit line --- - # --- 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()], - fontsize=14, fontweight='bold', fontname="Ubuntu", - fontstyle="normal", c="black", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_profile.transAxes) + # --- Write frequency on graph --- - # --- 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)) - # print("self.fileListWidget.currentRow() ", self.fileListWidget.count()) - # if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): + # --- Plot bottom line --- - 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, - 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) + if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0: - position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / - np.nanmax(stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :])) + self.axis_profile.plot([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) - self.axis_profile.text(.95, 1-position_x + 0.05, "River bed", - fontsize=10, fontweight='normal', fontname="Ubuntu", - fontstyle="italic", c="red", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_profile.transAxes) + position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / + np.nanmax(stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :])) - 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.axis_profile.text(.95, 1-position_x + 0.05, "River bed", + fontsize=10, fontweight='normal', fontname="Ubuntu", + 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.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): self.slider.setValue(int(self.slider.minimum())) diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index a0e518e..1bb9ae0 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -100,16 +100,13 @@ class SignalProcessingTab(QWidget): self.radiobutton_file = QRadioButton("File") 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.radiobutton_profile_tail = QRadioButton("Profile tail") # 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.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) ### --- 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) # 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) @@ -158,7 +154,6 @@ class SignalProcessingTab(QWidget): self.pushbutton_compute_noise_from_value = QPushButton() 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_compute_noise_from_value.clicked.connect(self.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.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) # +++++++++++++++++++++++++++++ @@ -408,6 +401,19 @@ class SignalProcessingTab(QWidget): # --- 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.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)): self.combobox_fileListWidget.addItem(stg.filename_BS_raw_data[i]) - print("len stg.BS_noise_raw_data : ", len(stg.BS_noise_raw_data)) - if len(stg.BS_noise_raw_data) == 0: - 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("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.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_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.noise_method = [0]*(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_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) + # print("len stg.BS_noise_raw_data : ", len(stg.BS_noise_raw_data)) + # if len(stg.BS_noise_raw_data) == 0: + # 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("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.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_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.noise_method = [0]*(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_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) if (stg.noise_method == 1) or (stg.noise_method == 0): 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_value.setChecked(False) elif stg.noise_method == 2: @@ -1101,8 +1109,8 @@ class SignalProcessingTab(QWidget): name = path.basename(filename[0]) try: - stg.path_BS_noise_data = dir_name - stg.filename_BS_noise_data = name + stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1] = dir_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.filename_BS_noise_data : ", stg.filename_BS_noise_data) self.load_noise_data_and_compute_SNR() @@ -1117,8 +1125,8 @@ class SignalProcessingTab(QWidget): msgBox.exec() else: - self.lineEdit_noise_file.setText(stg.filename_BS_noise_data) - self.lineEdit_noise_file.setToolTip(stg.path_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.combobox_fileListWidget.currentIndex() - 1]) # self.plot_noise() self.plot_transect_with_SNR_data() # 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.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: - - 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]): + 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]) @@ -1142,6 +1145,19 @@ class SignalProcessingTab(QWidget): 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.plot_profile_and_position_on_transect_with_slider() @@ -1158,25 +1174,24 @@ class SignalProcessingTab(QWidget): # stg.hour_noise = noise_data._hour stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = noise_data._time # stg.time_snr_reshape = stg.time_reshape - print("len(stg.BS_cross_section) : ", len(stg.BS_cross_section)) - print("stg.BS_cross_section[0] : ", stg.BS_cross_section[0].shape) - print("len(stg.BS_stream_bed) : ", len(stg.BS_stream_bed)) + # print("len(stg.BS_cross_section) : ", len(stg.BS_cross_section)) + # print("stg.BS_cross_section[0] : ", stg.BS_cross_section[0].shape) + # print("len(stg.BS_stream_bed) : ", len(stg.BS_stream_bed)) - if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == - stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape): - print("Je suis dans raw") + if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + print("Je suis dans stream bed") - 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): noise[f, :, :] = np.mean( 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.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.divide((stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1] - + stg.SNR_stream_bed[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)) - 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") 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") 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): noise[f, :, :] = np.mean( 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.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.divide((stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] - + stg.SNR_raw_data[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.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) @@ -1391,60 +1406,7 @@ class SignalProcessingTab(QWidget): for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == - 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: + if stg.SNR_stream_bed[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, :]) @@ -1471,6 +1433,59 @@ class SignalProcessingTab(QWidget): levels, cmap='gist_rainbow', 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], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', @@ -1502,33 +1517,7 @@ class SignalProcessingTab(QWidget): else: - if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == - 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: + if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): stg.BS_stream_bed_pre_process_SNR = deepcopy(stg.BS_stream_bed) # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) @@ -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.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: # 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_averaged_profile() - # self.compute_averaged_BS_data() - # self.plot_profile_and_position_on_transect_with_slider() + self.compute_averaged_BS_data() + self.plot_profile_and_position_on_transect_with_slider() 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]): - if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == - 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: + if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): 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, :, :]) @@ -1644,6 +1633,38 @@ class SignalProcessingTab(QWidget): -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], 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], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', @@ -1670,11 +1691,11 @@ class SignalProcessingTab(QWidget): kernel = np.ones(2*self.spinbox_average_horizontal.value()+1) 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 --- - 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[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) print("2 - Je suis dans stg.BS_stream_bed_pre_process_average") - elif (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[2] - < stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape[2]): + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): # --- 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 # (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) print("4 - Je suis dans stg.BS_cross_section_pre_process_average") - - else: # --- Données pré-traitées avec SNR : BS raw data pre process SNR -> BS raw data pre process SNR average --- - if 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 # (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[1].cla() - if ((len(stg.BS_stream_bed_pre_process_SNR_average)) and - (len(stg.BS_stream_bed_pre_process_SNR_average) == (self.combobox_fileListWidget.count() -1))): + if stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( @@ -1871,8 +1888,7 @@ class SignalProcessingTab(QWidget): [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif (len(stg.BS_stream_bed_pre_process_average) - and (len(stg.BS_stream_bed_pre_process_average) == (self.combobox_fileListWidget.count() -1))): + elif stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( @@ -1907,8 +1923,7 @@ class SignalProcessingTab(QWidget): [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif (len(stg.BS_cross_section_pre_process_SNR_average) and - (len(stg.BS_cross_section_pre_process_SNR_average) == (self.combobox_fileListWidget.count() -1))): + elif stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( @@ -1943,8 +1958,7 @@ class SignalProcessingTab(QWidget): [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif (len(stg.BS_cross_section_pre_process_average) - and (len(stg.BS_cross_section_pre_process_average) == (self.combobox_fileListWidget.count() - 1))): + elif stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( @@ -1979,8 +1993,7 @@ class SignalProcessingTab(QWidget): [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif (len(stg.BS_raw_data_pre_process_SNR_average) - and (len(stg.BS_raw_data_pre_process_SNR_average) == (self.combobox_fileListWidget.count() - 1))): + elif stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( @@ -2021,7 +2034,7 @@ class SignalProcessingTab(QWidget): self.axis_profile[0].plot( stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 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(), :], linestyle='solid', color='k', linewidth=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(), :, :]) if val_min == 0: 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(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][ self.combobox_frequency_profile.currentIndex(), :], stg.BS_raw_data_pre_process_average[ self.combobox_fileListWidget.currentIndex() - 1] @@ -2060,8 +2073,8 @@ class SignalProcessingTab(QWidget): -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], color='red', linestyle="solid", linewidth=2) - if len(stg.depth_bottom): - if len(stg.time_cross_section): + if len(stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1]) != 0: + 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(), :], -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], color='black', linewidth=1, linestyle="solid") diff --git a/settings.py b/settings.py index b3f2d9b..7772c6f 100644 --- a/settings.py +++ b/settings.py @@ -17,12 +17,13 @@ freq = [] freq_text = [] time = [] -path_BS_noise_data = "" -filename_BS_noise_data = "" +path_BS_noise_data = [] +filename_BS_noise_data = [] 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) noise_method = [] +SNR_filter_value = [] date = [] date_noise = []