update for the BS signal averaging #43
parent
26bd476772
commit
72dff5a26c
|
|
@ -14,7 +14,7 @@
|
||||||
# #
|
# #
|
||||||
# You should have received a copy of the GNU General Public License #
|
# You should have received a copy of the GNU General Public License #
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
|
import math
|
||||||
# by Brahim MOUDJED #
|
# by Brahim MOUDJED #
|
||||||
# ============================================================================== #
|
# ============================================================================== #
|
||||||
|
|
||||||
|
|
@ -47,6 +47,8 @@ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as Navigatio
|
||||||
from matplotlib.colors import LogNorm, BoundaryNorm
|
from matplotlib.colors import LogNorm, BoundaryNorm
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
from numba.np.arraymath import np_average
|
||||||
|
|
||||||
from View.show_popup_combobox import ComboBoxShowPopUpWindow
|
from View.show_popup_combobox import ComboBoxShowPopUpWindow
|
||||||
from View.plot_noise_window import PlotNoiseWindow
|
from View.plot_noise_window import PlotNoiseWindow
|
||||||
|
|
||||||
|
|
@ -1441,8 +1443,7 @@ class SignalProcessingTab(QWidget):
|
||||||
val_max = np.nanmax(
|
val_max = np.nanmax(
|
||||||
BS_data[data_id][f, :, :]
|
BS_data[data_id][f, :, :]
|
||||||
)
|
)
|
||||||
|
if val_min == 0 or math.isinf(val_min):
|
||||||
if val_min == 0:
|
|
||||||
val_min = 1e-5
|
val_min = 1e-5
|
||||||
|
|
||||||
pcm = self.axis_BS[f].pcolormesh(
|
pcm = self.axis_BS[f].pcolormesh(
|
||||||
|
|
@ -1478,10 +1479,10 @@ class SignalProcessingTab(QWidget):
|
||||||
|
|
||||||
self.fig_BS.supxlabel('Time (sec)', fontsize=10)
|
self.fig_BS.supxlabel('Time (sec)', fontsize=10)
|
||||||
self.fig_BS.supylabel('Depth (m)', fontsize=10)
|
self.fig_BS.supylabel('Depth (m)', fontsize=10)
|
||||||
cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:],
|
# cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:],
|
||||||
shrink=1, location='right')
|
# shrink=1, location='right')
|
||||||
cbar.set_label(label='Acoustic backscatter signal (V)',
|
# cbar.set_label(label='Acoustic backscatter signal (V)',
|
||||||
rotation=270, labelpad=10)
|
# rotation=270, labelpad=10)
|
||||||
self.fig_BS.canvas.draw_idle()
|
self.fig_BS.canvas.draw_idle()
|
||||||
else:
|
else:
|
||||||
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field\
|
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field\
|
||||||
|
|
@ -1527,15 +1528,8 @@ class SignalProcessingTab(QWidget):
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
else:
|
else:
|
||||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||||
kernel_avg = np.ones(
|
n_average = 2 * int(float(self.lineEdit_horizontal_average.text().replace(",", "."))) + 1
|
||||||
2 * int(
|
kernel_avg = np.ones(n_average)
|
||||||
float(
|
|
||||||
self.lineEdit_horizontal_average\
|
|
||||||
.text()\
|
|
||||||
.replace(",", ".")
|
|
||||||
)
|
|
||||||
) + 1
|
|
||||||
)
|
|
||||||
logger.debug(f"kernel_avg: {kernel_avg}")
|
logger.debug(f"kernel_avg: {kernel_avg}")
|
||||||
|
|
||||||
stg.Nb_cells_to_average_BS_signal[data_id] = (
|
stg.Nb_cells_to_average_BS_signal[data_id] = (
|
||||||
|
|
@ -1599,16 +1593,34 @@ class SignalProcessingTab(QWidget):
|
||||||
|
|
||||||
logger.debug(f"BS_data: {BS_data[data_id].shape}")
|
logger.debug(f"BS_data: {BS_data[data_id].shape}")
|
||||||
|
|
||||||
BS_data_ppa[data_id] = deepcopy(BS_data[data_id])
|
# BS_data_ppa[data_id] = deepcopy(BS_data[data_id])
|
||||||
|
#
|
||||||
|
# for f, _ in enumerate(stg.freq[data_id]):
|
||||||
|
# for i in range(y_depth.shape[1]):
|
||||||
|
# BS_data_ppa[data_id][f, i, :] = (
|
||||||
|
# convolve(
|
||||||
|
# BS_data[data_id][f, i, :],
|
||||||
|
# kernel_avg
|
||||||
|
# )
|
||||||
|
# )
|
||||||
|
|
||||||
|
temp_list = []
|
||||||
for f, _ in enumerate(stg.freq[data_id]):
|
for f, _ in enumerate(stg.freq[data_id]):
|
||||||
|
temp0 = np.array([])
|
||||||
for i in range(y_depth.shape[1]):
|
for i in range(y_depth.shape[1]):
|
||||||
BS_data_ppa[data_id][f, i, :] = (
|
# temp = convolve(BS_data[data_id][f, i, :], kernel_avg, "same") / n_average
|
||||||
convolve(
|
temp = convolve(array=BS_data[data_id][f, i, :],
|
||||||
BS_data[data_id][f, i, :],
|
kernel=kernel_avg,
|
||||||
kernel_avg
|
nan_treatment='interpolate')
|
||||||
)
|
if temp0.shape == (0,):
|
||||||
)
|
temp0 = np.array([temp])
|
||||||
|
else:
|
||||||
|
temp0 = np.append(temp0, np.array([temp]), axis=0)
|
||||||
|
temp_list.append(temp0)
|
||||||
|
|
||||||
|
BS_data_ppa[data_id] = np.array([temp_list[0]])
|
||||||
|
for j in range(stg.freq[data_id].shape[0]-1):
|
||||||
|
BS_data_ppa[data_id] = np.append(BS_data_ppa[data_id], np.array([temp_list[j+1]]), axis=0)
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"BS_data_ppa: {BS_data_ppa[data_id].shape}"
|
f"BS_data_ppa: {BS_data_ppa[data_id].shape}"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue