From 8340c547d537ed0b41705ca4049805022c769b66 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 29 Apr 2025 15:06:03 +0200 Subject: [PATCH] Signal processing: Fix noise_method type, noise_value update and refacto. --- Model/create_table_for_save_as.py | 2 +- View/sediment_calibration_tab.py | 1 - View/signal_processing_tab.py | 63 +++++++++++++++++++------------ 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/Model/create_table_for_save_as.py b/Model/create_table_for_save_as.py index bfcb2c0..f8377ee 100644 --- a/Model/create_table_for_save_as.py +++ b/Model/create_table_for_save_as.py @@ -45,7 +45,7 @@ class CreateTableForSaveAs: ABS_name STRING, path_BS_noise_data STRING, filename_BS_noise_data STRING, - noise_method FLOAT, + noise_method INTERGER, noise_value FLOAT, data_preprocessed STRING ) diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index 93175eb..759982e 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -1996,7 +1996,6 @@ class SedimentCalibrationTab(QWidget): ] for i in range(self.combobox_acoustic_data_choice.count()): - J_cross_section_freq1 = np.array([]) J_cross_section_freq2 = np.array([]) diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index 51a9cca..4f313c0 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -922,6 +922,10 @@ class SignalProcessingTab(QWidget): logger.debug(f"stg.SNR_filter_value: {stg.SNR_filter_value}") + self.lineEdit_profile_tail_value.setText( + str(stg.noise_value[data_id]) + ) + self.lineEdit_SNR_criterion.setText( str(stg.SNR_filter_value[data_id]) ) @@ -1029,22 +1033,30 @@ class SignalProcessingTab(QWidget): self.slider.setMaximum(10) def open_dialog_box(self): + data_id = self.combobox_acoustic_data_choice.currentIndex() if self.combobox_acoustic_data_choice.count() > 0: - filename = QFileDialog.getOpenFileNames(self, "AQUAscat Noise file", - [stg.path_BS_raw_data[-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0], - "Aquascat file (*.aqa)", - options=QFileDialog.DontUseNativeDialog) - if filename[0]: - dir_name = path.dirname(filename[0][0]) - name = path.basename(filename[0][0]) - stg.path_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()] = dir_name - stg.filename_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()] = name + directory = "" + if self.combobox_acoustic_data_choice.count() > 0: + directory = stg.path_BS_raw_data[-1] + + filename, _ = QFileDialog.getOpenFileName( + self, "AQUAscat Noise file", + directory, + "Aquascat file (*.aqa)", + options=QFileDialog.DontUseNativeDialog + ) + + if filename == "": + return + + dir_name = path.dirname(filename) + name = path.basename(filename) + stg.path_BS_noise_data[data_id] = dir_name + stg.filename_BS_noise_data[data_id] = name try: - self.load_noise_data_and_compute_SNR() - except ValueError as e: msgBox = QMessageBox() msgBox.setWindowTitle("Download Error") @@ -1052,34 +1064,35 @@ class SignalProcessingTab(QWidget): msgBox.setText("Please select a file") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() - else: - self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()]) - self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data[self.combobox_acoustic_data_choice.currentIndex()]) + self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[data_id]) + self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data[data_id]) self.plot_transect_with_SNR_data() self.combobox_frequency_profile.clear() - self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]]) - self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_pre_processed_BS_signal) - self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_pre_processed_profile) + self.combobox_frequency_profile.addItems( + [f for f in stg.freq_text[data_id]] + ) - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - - self.slider.setMaximum(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) + self.combobox_frequency_profile\ + .currentIndexChanged\ + .connect(self.plot_pre_processed_BS_signal) + self.combobox_frequency_profile\ + .currentIndexChanged\ + .connect(self.update_plot_pre_processed_profile) + if stg.time_cross_section[data_id].shape != (0,): + self.slider.setMaximum(stg.time_cross_section[data_id].shape[1]) else: - - self.slider.setMaximum(stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) + self.slider.setMaximum(stg.time[data_id].shape[1]) self.plot_pre_processed_BS_signal() self.plot_pre_processed_profile() - stg.noise_method[self.combobox_acoustic_data_choice.currentIndex()] = 0 + stg.noise_method[data_id] = 0 self.activate_list_of_pre_processed_data() - else: - msgBox = QMessageBox() msgBox.setWindowTitle("Download Error") msgBox.setIcon(QMessageBox.Warning)