Signal processing: Remove noise file loading (from fs) at '.acd' opening.
parent
1fe6b6a1e1
commit
84fe5738a3
|
|
@ -113,7 +113,6 @@ class ReadTableForOpen:
|
||||||
WHERE (acoustic_data = {k})
|
WHERE (acoustic_data = {k})
|
||||||
'''
|
'''
|
||||||
data = self.execute(query)[0]
|
data = self.execute(query)[0]
|
||||||
print("data acoustic file", data)
|
|
||||||
|
|
||||||
stg.filename_BS_raw_data.append(
|
stg.filename_BS_raw_data.append(
|
||||||
str(data[1]) + '.aqa'
|
str(data[1]) + '.aqa'
|
||||||
|
|
|
||||||
|
|
@ -548,9 +548,8 @@ class SignalProcessingTab(QWidget):
|
||||||
)
|
)
|
||||||
|
|
||||||
def update_SignalPreprocessingTab(self):
|
def update_SignalPreprocessingTab(self):
|
||||||
|
|
||||||
""" The tab is updated in two cases :
|
""" The tab is updated in two cases :
|
||||||
- the user remove a file (in the list widget) in the first tab (Acoustic data), so that the combobox
|
- the user remove a file (in the list widget) in the first tab (Acoustic data), so that the combobox
|
||||||
of data to be processed is updated,
|
of data to be processed is updated,
|
||||||
- the user change the limits of one or all the records in the first tab (Acoustic data) """
|
- the user change the limits of one or all the records in the first tab (Acoustic data) """
|
||||||
if len(stg.filename_BS_raw_data) == 0:
|
if len(stg.filename_BS_raw_data) == 0:
|
||||||
|
|
@ -627,13 +626,68 @@ class SignalProcessingTab(QWidget):
|
||||||
|
|
||||||
if stg.noise_method[data_id] == 0:
|
if stg.noise_method[data_id] == 0:
|
||||||
if stg.filename_BS_noise_data[data_id] != "":
|
if stg.filename_BS_noise_data[data_id] != "":
|
||||||
self.load_noise_data_and_compute_SNR()
|
if len(stg.BS_noise_raw_data) == 0:
|
||||||
|
self.load_noise_data_and_compute_SNR()
|
||||||
|
else:
|
||||||
|
self.compute_noise()
|
||||||
elif stg.noise_method[data_id] == 1:
|
elif stg.noise_method[data_id] == 1:
|
||||||
self.compute_noise_from_profile_tail_value()
|
self.compute_noise_from_profile_tail_value()
|
||||||
|
|
||||||
self.remove_point_with_snr_filter()
|
self.remove_point_with_snr_filter()
|
||||||
self.compute_averaged_BS_data()
|
self.compute_averaged_BS_data()
|
||||||
|
|
||||||
|
def compute_noise(self):
|
||||||
|
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||||
|
|
||||||
|
if stg.time_cross_section[data_id].shape != (0,):
|
||||||
|
stg.time_noise[data_id] = (
|
||||||
|
stg.time_cross_section[data_id]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
stg.time_noise[data_id] = (
|
||||||
|
stg.time[data_id]
|
||||||
|
)
|
||||||
|
if stg.depth_cross_section[data_id].shape != (0,):
|
||||||
|
stg.depth_noise[data_id] = (
|
||||||
|
stg.depth_cross_section[data_id]
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
stg.depth_noise[data_id] = (
|
||||||
|
stg.depth[data_id]
|
||||||
|
)
|
||||||
|
|
||||||
|
if self._is_correct_shape(stg.BS_stream_bed):
|
||||||
|
BS_data = stg.BS_stream_bed
|
||||||
|
SNR_data = stg.SNR_stream_bed
|
||||||
|
elif self._is_correct_shape(stg.BS_cross_section):
|
||||||
|
BS_data = stg.BS_cross_section
|
||||||
|
SNR_data = stg.SNR_cross_section
|
||||||
|
else:
|
||||||
|
BS_data = stg.BS_raw_data
|
||||||
|
SNR_data = stg.SNR_raw_data
|
||||||
|
|
||||||
|
noise = np.zeros(BS_data[data_id].shape)
|
||||||
|
for f, _ in enumerate(BS_data[data_id]):
|
||||||
|
noise[f, :, :] = np.mean(
|
||||||
|
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1)
|
||||||
|
)
|
||||||
|
|
||||||
|
stg.BS_noise_averaged_data[data_id] = noise
|
||||||
|
|
||||||
|
SNR_data[data_id] = (
|
||||||
|
np.divide(
|
||||||
|
(
|
||||||
|
BS_data[data_id] - stg.BS_noise_averaged_data[data_id]
|
||||||
|
) ** 2,
|
||||||
|
stg.BS_noise_averaged_data[data_id] ** 2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.combobox_frequency_profile.clear()
|
||||||
|
self.combobox_frequency_profile.addItems(
|
||||||
|
[f for f in stg.freq_text[data_id]]
|
||||||
|
)
|
||||||
|
|
||||||
def replot(self):
|
def replot(self):
|
||||||
self.plot_averaged_profile_tail()
|
self.plot_averaged_profile_tail()
|
||||||
self.plot_transect_with_SNR_data()
|
self.plot_transect_with_SNR_data()
|
||||||
|
|
@ -1034,50 +1088,42 @@ class SignalProcessingTab(QWidget):
|
||||||
|
|
||||||
stg.noise_method[data_id] = 0
|
stg.noise_method[data_id] = 0
|
||||||
|
|
||||||
noise_data = AcousticDataLoader(stg.path_BS_noise_data[data_id] +
|
noise_data = AcousticDataLoader(
|
||||||
"/" +
|
os.path.join(
|
||||||
stg.filename_BS_noise_data[data_id])
|
stg.path_BS_noise_data[data_id],
|
||||||
|
stg.filename_BS_noise_data[data_id]
|
||||||
|
)
|
||||||
|
)
|
||||||
stg.BS_noise_raw_data[data_id] = noise_data._BS_raw_data
|
stg.BS_noise_raw_data[data_id] = noise_data._BS_raw_data
|
||||||
|
|
||||||
stg.time_noise[data_id] = noise_data._time
|
stg.time_noise[data_id] = noise_data._time
|
||||||
stg.depth_noise[data_id] = noise_data._r
|
stg.depth_noise[data_id] = noise_data._r
|
||||||
|
|
||||||
if stg.BS_stream_bed[data_id].shape != (0,):
|
if stg.BS_stream_bed[data_id].shape != (0,):
|
||||||
|
BS_data = stg.BS_stream_bed
|
||||||
noise = np.zeros(stg.BS_stream_bed[data_id].shape)
|
SNR_data = stg.SNR_stream_bed
|
||||||
for f, _ in enumerate(noise_data._freq):
|
|
||||||
noise[f, :, :] = np.mean(
|
|
||||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1))
|
|
||||||
stg.BS_noise_averaged_data[data_id] = noise
|
|
||||||
stg.SNR_stream_bed[data_id] = (
|
|
||||||
np.divide((stg.BS_stream_bed[data_id] -
|
|
||||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
|
||||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
|
||||||
|
|
||||||
elif stg.BS_cross_section[data_id].shape != (0,):
|
elif stg.BS_cross_section[data_id].shape != (0,):
|
||||||
|
BS_data = stg.BS_cross_section
|
||||||
noise = np.zeros(stg.BS_cross_section[data_id].shape)
|
SNR_data = stg.SNR_cross_section
|
||||||
for f, _ in enumerate(noise_data._freq):
|
|
||||||
noise[f, :, :] = np.mean(
|
|
||||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1))
|
|
||||||
stg.BS_noise_averaged_data[data_id] = noise
|
|
||||||
stg.SNR_cross_section[data_id] = (
|
|
||||||
np.divide((stg.BS_cross_section[data_id] -
|
|
||||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
|
||||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
|
||||||
# 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:
|
||||||
|
BS_data = stg.BS_raw_data
|
||||||
|
SNR_data = stg.SNR_raw_data
|
||||||
|
|
||||||
noise = np.zeros(stg.BS_raw_data[data_id].shape)
|
noise = np.zeros(BS_data[data_id].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[data_id][f, :, :], axis=(0, 1))
|
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1)
|
||||||
stg.BS_noise_averaged_data[data_id] = noise
|
)
|
||||||
stg.SNR_raw_data[data_id] = (
|
|
||||||
np.divide((stg.BS_raw_data[data_id] -
|
stg.BS_noise_averaged_data[data_id] = noise
|
||||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
SNR_data[data_id] = (
|
||||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
np.divide(
|
||||||
|
(
|
||||||
|
BS_data[data_id] - stg.BS_noise_averaged_data[data_id]
|
||||||
|
) ** 2,
|
||||||
|
stg.BS_noise_averaged_data[data_id] ** 2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def open_plot_noise_window(self):
|
def open_plot_noise_window(self):
|
||||||
pnw = PlotNoiseWindow()
|
pnw = PlotNoiseWindow()
|
||||||
|
|
@ -1091,6 +1137,11 @@ class SignalProcessingTab(QWidget):
|
||||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))
|
float(self.lineEdit_profile_tail_value.text().replace(",", "."))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.compute_noise_from_profile_tail_value_compute()
|
||||||
|
|
||||||
|
def compute_noise_from_profile_tail_value_compute(self):
|
||||||
|
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||||
|
|
||||||
if stg.time_cross_section[data_id].shape != (0,):
|
if stg.time_cross_section[data_id].shape != (0,):
|
||||||
stg.time_noise[data_id] = (
|
stg.time_noise[data_id] = (
|
||||||
stg.time_cross_section[data_id]
|
stg.time_cross_section[data_id]
|
||||||
|
|
@ -1110,47 +1161,38 @@ class SignalProcessingTab(QWidget):
|
||||||
|
|
||||||
# --- Compute noise from value and compute SNR ---
|
# --- Compute noise from value and compute SNR ---
|
||||||
if self._is_correct_shape(stg.BS_stream_bed):
|
if self._is_correct_shape(stg.BS_stream_bed):
|
||||||
stg.BS_noise_raw_data[data_id] = np.array([])
|
BS_data = stg.BS_stream_bed
|
||||||
stg.BS_noise_raw_data[data_id] = (
|
SNR_data = stg.SNR_stream_bed
|
||||||
np.full(stg.BS_stream_bed[data_id].shape,
|
|
||||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
|
||||||
|
|
||||||
stg.BS_noise_averaged_data[data_id] = (
|
|
||||||
stg.BS_noise_raw_data[data_id][:, :,
|
|
||||||
:stg.BS_stream_bed[data_id].shape[2]])
|
|
||||||
stg.SNR_stream_bed[data_id] = (
|
|
||||||
np.divide((stg.BS_stream_bed[data_id]
|
|
||||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
|
||||||
stg.BS_noise_raw_data[data_id] ** 2))
|
|
||||||
|
|
||||||
elif self._is_correct_shape(stg.BS_cross_section):
|
elif self._is_correct_shape(stg.BS_cross_section):
|
||||||
stg.BS_noise_raw_data[data_id] = (
|
BS_data = stg.BS_cross_section
|
||||||
np.full(stg.BS_cross_section[data_id].shape,
|
SNR_data = stg.SNR_cross_section
|
||||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
|
||||||
|
|
||||||
stg.BS_noise_averaged_data[data_id] = (
|
|
||||||
stg.BS_noise_raw_data[data_id][:, :,
|
|
||||||
:stg.BS_cross_section[data_id].shape[2]])
|
|
||||||
stg.SNR_cross_section[data_id] = (
|
|
||||||
np.divide((stg.BS_cross_section[data_id]
|
|
||||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
|
||||||
stg.BS_noise_raw_data[data_id] ** 2)) #
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
stg.BS_noise_raw_data[data_id] = (
|
BS_data = stg.BS_raw_data
|
||||||
np.full(stg.BS_raw_data[data_id].shape,
|
SNR_data = stg.SNR_raw_data
|
||||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
|
||||||
|
|
||||||
stg.BS_noise_averaged_data[data_id] = (
|
stg.BS_noise_raw_data[data_id] = (
|
||||||
stg.BS_noise_raw_data[data_id])
|
np.full(
|
||||||
stg.SNR_raw_data[data_id] = (
|
BS_data[data_id].shape,
|
||||||
np.divide((stg.BS_raw_data[data_id]
|
float(self.lineEdit_profile_tail_value.text().replace(",", "."))
|
||||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
)
|
||||||
stg.BS_noise_raw_data[data_id] ** 2))
|
)
|
||||||
|
|
||||||
|
stg.BS_noise_averaged_data[data_id] = (
|
||||||
|
stg.BS_noise_raw_data[data_id]
|
||||||
|
)
|
||||||
|
SNR_data[data_id] = (
|
||||||
|
np.divide(
|
||||||
|
(
|
||||||
|
BS_data[data_id] - stg.BS_noise_raw_data[data_id]
|
||||||
|
) ** 2,
|
||||||
|
stg.BS_noise_raw_data[data_id] ** 2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.combobox_frequency_profile.clear()
|
self.combobox_frequency_profile.clear()
|
||||||
self.combobox_frequency_profile.addItems(
|
self.combobox_frequency_profile.addItems(
|
||||||
[f for f in stg.freq_text[data_id]])
|
[f for f in stg.freq_text[data_id]]
|
||||||
|
)
|
||||||
|
|
||||||
# --- Trigger graphic widgets ---
|
# --- Trigger graphic widgets ---
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue