diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index 707f82e..7abee98 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -1551,105 +1551,123 @@ class SignalProcessingTab(QWidget): def compute_averaged_BS_data(self): - kernel_avg = np.ones(2 * int(float(self.lineEdit_horizontal_average.text().replace(",", "."))) + 1) - print(kernel_avg) + if len(stg.filename_BS_raw_data) == 0: + msgBox = QMessageBox() + msgBox.setWindowTitle("Compute noise from profile tail error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Download acoustic data in previous tab before applying SNR filter") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() - stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()] = ( - float(self.lineEdit_horizontal_average.text().replace(",", "."))) - - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - - x_time = stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()] - y_depth = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()] - - elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - - x_time = stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()] - y_depth = stg.depth[self.combobox_acoustic_data_choice.currentIndex()] + elif len(stg.BS_noise_raw_data) == 0: + msgBox = QMessageBox() + msgBox.setWindowTitle("SNR filter Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Define noise data (file or profile tail) before using SNR filter") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() else: - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + kernel_avg = np.ones(2 * int(float(self.lineEdit_horizontal_average.text().replace(",", "."))) + 1) + print(kernel_avg) - x_time = stg.time[self.combobox_acoustic_data_choice.currentIndex()] - y_depth = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()] + stg.Nb_cells_to_average_BS_signal[self.combobox_acoustic_data_choice.currentIndex()] = ( + float(self.lineEdit_horizontal_average.text().replace(",", "."))) - elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - x_time = stg.time[self.combobox_acoustic_data_choice.currentIndex()] - y_depth = stg.depth[self.combobox_acoustic_data_choice.currentIndex()] + if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - if stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + x_time = stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()] + y_depth = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()] - stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( - stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()])) + elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - for i in range(y_depth.shape[1]): + x_time = stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()] + y_depth = stg.depth[self.combobox_acoustic_data_choice.currentIndex()] - stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - convolve(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], - kernel_avg)) + else: - elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( - stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()])) + x_time = stg.time[self.combobox_acoustic_data_choice.currentIndex()] + y_depth = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()] - for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - for i in range(y_depth.shape[1]): + elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - convolve(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], - kernel_avg)) + x_time = stg.time[self.combobox_acoustic_data_choice.currentIndex()] + y_depth = stg.depth[self.combobox_acoustic_data_choice.currentIndex()] - elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( - stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()])) + stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( + stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()])) - for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - for i in range(y_depth.shape[1]): + for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): + for i in range(y_depth.shape[1]): - stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - convolve(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], - kernel_avg)) + stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( + convolve(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], + kernel_avg)) - elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( - stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()])) + stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( + stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()])) - for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - for i in range(y_depth.shape[1]): - stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - convolve(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) + for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): + for i in range(y_depth.shape[1]): - elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( + convolve(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], + kernel_avg)) - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( - stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()])) + elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - for i in range(y_depth.shape[1]): - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - convolve(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], - kernel_avg)) + stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( + stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()])) - elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): + for i in range(y_depth.shape[1]): - stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( - stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()])) + stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( + convolve(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], + kernel_avg)) - for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): - for i in range(y_depth.shape[1]): - stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( - convolve(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) + elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - self.plot_pre_processed_BS_signal() - self.update_plot_pre_processed_profile() + stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( + stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()])) + + for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): + for i in range(y_depth.shape[1]): + stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( + convolve(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) + + elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( + stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()])) + + for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): + for i in range(y_depth.shape[1]): + stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( + convolve(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], + kernel_avg)) + + elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + + stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()] = (deepcopy( + stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()])) + + for f, _ in enumerate(stg.freq[self.combobox_acoustic_data_choice.currentIndex()]): + for i in range(y_depth.shape[1]): + stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][f, i, :] = ( + convolve(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][f, i, :], kernel_avg)) + + self.plot_pre_processed_BS_signal() + self.update_plot_pre_processed_profile() def plot_pre_processed_profile(self):