Acoustic data: refactoring plot and fix #17.
parent
5f0fb9ad53
commit
571ac20d37
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import locale
|
import locale
|
||||||
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
@ -63,6 +64,7 @@ locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class AcousticDataTab(QWidget):
|
class AcousticDataTab(QWidget):
|
||||||
COMPTEUR = 1
|
COMPTEUR = 1
|
||||||
|
|
@ -630,7 +632,7 @@ class AcousticDataTab(QWidget):
|
||||||
self.fileListWidget.itemSelectionChanged.connect(self.compute_tmin_tmax)
|
self.fileListWidget.itemSelectionChanged.connect(self.compute_tmin_tmax)
|
||||||
self.fileListWidget.itemSelectionChanged.connect(self.compute_rmin_rmax)
|
self.fileListWidget.itemSelectionChanged.connect(self.compute_rmin_rmax)
|
||||||
self.fileListWidget.itemSelectionChanged.connect(self.update_frequency_combobox)
|
self.fileListWidget.itemSelectionChanged.connect(self.update_frequency_combobox)
|
||||||
self.fileListWidget.itemSelectionChanged.connect(self.plot_backscattered_acoustic_signal_recording)
|
# self.fileListWidget.itemSelectionChanged.connect(self.plot_backscattered_acoustic_signal_recording)
|
||||||
self.fileListWidget.itemSelectionChanged.connect(self.plot_profile)
|
self.fileListWidget.itemSelectionChanged.connect(self.plot_profile)
|
||||||
self.fileListWidget.itemSelectionChanged.connect(self.update_plot_backscattered_acoustic_signal_recording)
|
self.fileListWidget.itemSelectionChanged.connect(self.update_plot_backscattered_acoustic_signal_recording)
|
||||||
self.fileListWidget.itemSelectionChanged.connect(self.update_plot_profile)
|
self.fileListWidget.itemSelectionChanged.connect(self.update_plot_profile)
|
||||||
|
|
@ -1304,6 +1306,8 @@ class AcousticDataTab(QWidget):
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
else:
|
else:
|
||||||
|
self.fileListWidget.blockSignals(True)
|
||||||
|
|
||||||
if self.fileListWidget.count() == 0:
|
if self.fileListWidget.count() == 0:
|
||||||
for p, f in zip(stg.path_BS_raw_data,
|
for p, f in zip(stg.path_BS_raw_data,
|
||||||
stg.filename_BS_raw_data):
|
stg.filename_BS_raw_data):
|
||||||
|
|
@ -1332,6 +1336,8 @@ class AcousticDataTab(QWidget):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.fileListWidget.blockSignals(False)
|
||||||
|
|
||||||
def rename_file_in_ListWidget(self, event):
|
def rename_file_in_ListWidget(self, event):
|
||||||
|
|
||||||
if event == QEvent.MouseButtonPress:
|
if event == QEvent.MouseButtonPress:
|
||||||
|
|
@ -2282,58 +2288,82 @@ class AcousticDataTab(QWidget):
|
||||||
"-" + str("%.5s" % stg.depth[self.fileListWidget.currentRow()][0, 0]))
|
"-" + str("%.5s" % stg.depth[self.fileListWidget.currentRow()][0, 0]))
|
||||||
|
|
||||||
def plot_backscattered_acoustic_signal_recording(self):
|
def plot_backscattered_acoustic_signal_recording(self):
|
||||||
|
if self.fileListWidget.count() <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
if self.fileListWidget.count() > 0:
|
layout = self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data
|
||||||
|
file_id = self.fileListWidget.currentRow()
|
||||||
|
freq_id = self.combobox_frequency_profile.currentIndex()
|
||||||
|
|
||||||
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.toolbar_BS)
|
layout.removeWidget(self.toolbar_BS)
|
||||||
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS)
|
layout.removeWidget(self.scroll_BS)
|
||||||
|
|
||||||
self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0], ncols=1,
|
self.fig_BS, self.axis_BS = plt.subplots(
|
||||||
sharex=False, sharey=False, layout="constrained")
|
nrows=stg.freq[file_id].shape[0],
|
||||||
|
ncols=1, sharex=False, sharey=False,
|
||||||
|
layout="constrained"
|
||||||
|
)
|
||||||
self.canvas_BS = FigureCanvas(self.fig_BS)
|
self.canvas_BS = FigureCanvas(self.fig_BS)
|
||||||
self.toolbar_BS = NavigationToolBar(self.canvas_BS, self)
|
self.toolbar_BS = NavigationToolBar(self.canvas_BS, self)
|
||||||
|
|
||||||
self.scroll_BS.setWidget(self.canvas_BS)
|
self.scroll_BS.setWidget(self.canvas_BS)
|
||||||
|
|
||||||
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.toolbar_BS)
|
layout.addWidget(self.toolbar_BS)
|
||||||
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS)
|
layout.addWidget(self.scroll_BS)
|
||||||
|
|
||||||
for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]):
|
for f, _ in enumerate(stg.freq[file_id]):
|
||||||
|
val_min = np.nanmin(stg.BS_raw_data[file_id][f, :, :])
|
||||||
val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
|
val_max = np.nanmax(stg.BS_raw_data[file_id][f, :, :])
|
||||||
val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
|
|
||||||
if val_min == 0:
|
if val_min == 0:
|
||||||
val_min = 1e-5
|
val_min = 1e-5
|
||||||
|
|
||||||
if self.combobox_ABS_system_choice.currentIndex() == 1:
|
if self.combobox_ABS_system_choice.currentIndex() == 1:
|
||||||
|
pcm = self.axis_BS[f].pcolormesh(
|
||||||
pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :],
|
stg.time[file_id][f, :],
|
||||||
-stg.depth[self.fileListWidget.currentRow()][f, :],
|
-stg.depth[file_id][f, :],
|
||||||
stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :],
|
stg.BS_raw_data[file_id][f, :, :],
|
||||||
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
|
cmap='viridis',
|
||||||
|
norm=LogNorm(vmin=val_min, vmax=val_max)
|
||||||
|
)
|
||||||
elif self.combobox_ABS_system_choice.currentIndex() == 2:
|
elif self.combobox_ABS_system_choice.currentIndex() == 2:
|
||||||
pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :],
|
pcm = self.axis_BS[f].pcolormesh(
|
||||||
-stg.depth[self.fileListWidget.currentRow()][f, :],
|
stg.time[file_id][f, :],
|
||||||
np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]),
|
-stg.depth[file_id][f, :],
|
||||||
cmap='Blues')
|
np.log(stg.BS_raw_data[file_id][f, :, :]),
|
||||||
|
cmap='Blues'
|
||||||
|
)
|
||||||
|
|
||||||
self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f],
|
self.axis_BS[f].text(
|
||||||
fontsize=14, fontweight='bold', fontname="DejaVu Sans", c="black", alpha=0.5,
|
1, .70, stg.freq_text[file_id][f],
|
||||||
|
fontsize=14, fontweight='bold', fontname="DejaVu Sans",
|
||||||
|
c="black", alpha=0.5,
|
||||||
horizontalalignment='right', verticalalignment='bottom',
|
horizontalalignment='right', verticalalignment='bottom',
|
||||||
transform=self.axis_BS[f].transAxes)
|
transform=self.axis_BS[f].transAxes
|
||||||
|
)
|
||||||
|
|
||||||
# --- Plot red solid line on transect to visualize position of plotted profile ---
|
# --- Plot red solid line on transect to visualize position of
|
||||||
self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
|
# --- plotted profile ---
|
||||||
stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(),
|
self.axis_BS[freq_id].plot(
|
||||||
self.slider.value() - 1] * np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]),
|
stg.time[file_id][
|
||||||
-stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :],
|
freq_id, self.slider.value() - 1
|
||||||
color='red', linestyle="solid", linewidth=2)
|
]
|
||||||
|
* np.ones(stg.depth[file_id].shape[1]),
|
||||||
|
-stg.depth[file_id][freq_id, :],
|
||||||
|
color='red', linestyle="solid", linewidth=2
|
||||||
|
)
|
||||||
|
|
||||||
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[:], shrink=1, location='right')
|
|
||||||
cbar.set_label(label='Acoustic backscatter signal (V)', rotation=270, labelpad=10)
|
cbar = self.fig_BS.colorbar(
|
||||||
|
pcm, ax=self.axis_BS[:],
|
||||||
|
shrink=1, location='right'
|
||||||
|
)
|
||||||
|
|
||||||
|
cbar.set_label(
|
||||||
|
label='Acoustic backscatter signal (V)',
|
||||||
|
rotation=270, labelpad=10
|
||||||
|
)
|
||||||
self.fig_BS.canvas.draw_idle()
|
self.fig_BS.canvas.draw_idle()
|
||||||
|
|
||||||
def update_plot_backscattered_acoustic_signal_recording(self):
|
def update_plot_backscattered_acoustic_signal_recording(self):
|
||||||
|
|
@ -2465,7 +2495,8 @@ class AcousticDataTab(QWidget):
|
||||||
|
|
||||||
self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_profile)
|
self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_profile)
|
||||||
self.combobox_frequency_profile.currentIndexChanged.connect(
|
self.combobox_frequency_profile.currentIndexChanged.connect(
|
||||||
self.update_plot_backscattered_acoustic_signal_recording)
|
self.update_plot_backscattered_acoustic_signal_recording
|
||||||
|
)
|
||||||
|
|
||||||
self.slider.setMaximum(stg.time[self.fileListWidget.currentRow()].shape[1])
|
self.slider.setMaximum(stg.time[self.fileListWidget.currentRow()].shape[1])
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue