Signal processing: Fix noise_method type, noise_value update and refacto.

dev
Pierre-Antoine 2025-04-29 15:06:03 +02:00
parent 0b10926978
commit 8340c547d5
3 changed files with 39 additions and 27 deletions

View File

@ -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
)

View File

@ -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([])

View File

@ -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)