Compare commits

...

12 Commits

7 changed files with 357 additions and 431 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
)
@ -104,7 +104,7 @@ class CreateTableForSaveAs:
tmax_index INTEGER, tmax_value FLOAT,
rmin_index INTEGER, rmin_value FLOAT,
rmax_index INTEGER, rmax_value FLOAT,
freq_bottom_detection_index FLOAT,
freq_bottom_detection_index INTEGER,
freq_bottom_detection_value STRING,
depth_bottom_detection_min FLOAT,
depth_bottom_detection_max FLOAT,
@ -455,9 +455,9 @@ class CreateTableForSaveAs:
int(stg.rmax[i][0]), stg.rmax[i][1],
stg.freq_bottom_detection[i][0],
stg.freq_bottom_detection[i][1],
stg.depth_bottom_detection_min,
stg.depth_bottom_detection_max,
stg.depth_bottom_detection_interval,
stg.depth_bottom_detection_min[i],
stg.depth_bottom_detection_max[i],
stg.depth_bottom_detection_interval[i],
stg.SNR_filter_value[i],
stg.Nb_cells_to_average_BS_signal[i]
)

View File

@ -528,9 +528,9 @@ class ReadTableForOpen:
stg.rmin.append((next(it), next(it)))
stg.rmax.append((next(it), next(it)))
stg.freq_bottom_detection.append((next(it), next(it)))
stg.depth_bottom_detection_min = next(it)
stg.depth_bottom_detection_max = next(it)
stg.depth_bottom_detection_interval = next(it)
stg.depth_bottom_detection_min.append(next(it))
stg.depth_bottom_detection_max.append(next(it))
stg.depth_bottom_detection_interval.append(next(it))
stg.SNR_filter_value.append(next(it))
stg.Nb_cells_to_average_BS_signal.append(next(it))

View File

@ -41,7 +41,7 @@ from PyQt5.QtWidgets import (
QPushButton, QComboBox, QLineEdit, QLabel,
QGridLayout, QTableView, QSpacerItem, QSizePolicy,
QFileDialog, QMessageBox, QScrollArea,
QSlider, QMenu, QCheckBox
QSlider, QMenu, QCheckBox, QAbstractItemView
)
from PyQt5.QtGui import QPixmap, QIcon
from PyQt5.QtCore import (
@ -161,6 +161,7 @@ class AcousticDataTab(QWidget):
self.gridLayout_groupbox_acoustic_file.addWidget(self.clearBtn, 0, 4, 1, 1)
self.fileListWidget = FileListWidget()
self.fileListWidget.setSelectionMode(QAbstractItemView.SingleSelection)
self.gridLayout_groupbox_acoustic_file.addWidget(self.fileListWidget, 1, 0, 1, 5)
# ++++++++++++++++++++++++++++++++++++++
@ -760,7 +761,6 @@ class AcousticDataTab(QWidget):
self.water_attenuation()
self.compute_tmin_tmax()
self.compute_rmin_rmax()
self.set_range_for_spinboxes_bathymetry()
self.combobox_ABS_system_choice.blockSignals(False)
self.fileListWidget.blockSignals(False)
@ -821,7 +821,7 @@ class AcousticDataTab(QWidget):
# self.fileListWidget.itemSelectionChanged.connect(self.plot_profile)
self.update_plot_backscattered_acoustic_signal_recording()
self.update_plot_profile()
self.set_range_for_spinboxes_bathymetry()
self.update_bottom_detection_settings()
self.fileListWidget.blockSignals(False)
@ -1351,7 +1351,6 @@ class AcousticDataTab(QWidget):
("UBSediFlow file", "UBSediFlow file (*.udt)"),
]
system = self.combobox_ABS_system_choice.currentIndex()
if system == 0:
@ -1454,42 +1453,7 @@ class AcousticDataTab(QWidget):
del current_item
# --- Clear variables ---
list_to_pop1 = [
stg.acoustic_data, stg.date, stg.hour,
stg.freq, stg.freq_text,
stg.nb_profiles, stg.nb_profiles_per_sec,
stg.nb_cells, stg.cell_size,
stg.pulse_length, stg.nb_pings_per_sec,
stg.nb_pings_averaged_per_profile,
stg.kt_read, stg.kt_corrected, stg.gain_rx, stg.gain_tx,
stg.filename_BS_raw_data, stg.path_BS_raw_data,
stg.BS_raw_data, stg.time, stg.depth,
stg.BS_raw_data_reshape, stg.time_reshape, stg.depth_reshape
]
for p in list_to_pop1:
if isinstance(p, list):
p.pop(current_row)
if stg.BS_cross_section:
list_to_pop2 = [
stg.rmin, stg.rmax, stg.tmin, stg.tmax,
stg.time_cross_section, stg.depth_cross_section,
stg.BS_cross_section
]
for k in list_to_pop2:
k.pop(current_row)
if stg.BS_stream_bed:
list_to_pop3 = [
stg.BS_stream_bed, stg.depth_bottom,
stg.val_bottom, stg.ind_bottom,
stg.freq_bottom_detection
]
for s in list_to_pop3:
s.pop(current_row)
self.pop_setting_parameters(current_row)
if self.fileListWidget.count() == 0:
self.clear_files_from_ListWidget_reset()
@ -1688,6 +1652,9 @@ class AcousticDataTab(QWidget):
stg.val_bottom.append([])
stg.ind_bottom.append([])
stg.freq_bottom_detection.append((0, 0))
stg.depth_bottom_detection_min.append(0.0)
stg.depth_bottom_detection_max.append(0.0)
stg.depth_bottom_detection_interval.append(0.0)
stg.BS_mean.append(np.array([]))
stg.BS_noise_raw_data.append(np.array([]))
@ -1724,6 +1691,93 @@ class AcousticDataTab(QWidget):
stg.SSC_fine.append(np.array([]))
stg.SSC_sand.append(np.array([]))
def pop_setting_parameters(self, data_id):
stg.acoustic_data = list(
range(
self.fileListWidget.count()
)
)
stg.path_BS_raw_data.pop(data_id)
stg.filename_BS_raw_data.pop(data_id)
stg.ABS_name.pop(data_id)
stg.BS_raw_data.pop(data_id)
stg.BS_raw_data_reshape.pop(data_id)
stg.depth.pop(data_id)
stg.depth_2D.pop(data_id)
stg.depth_reshape.pop(data_id)
stg.time.pop(data_id)
stg.time_reshape.pop(data_id)
stg.freq.pop(data_id)
stg.freq_text.pop(data_id)
stg.date.pop(data_id)
stg.hour.pop(data_id)
stg.distance_from_ABS_to_free_surface.pop(data_id)
stg.nb_profiles.pop(data_id)
stg.nb_profiles_per_sec.pop(data_id)
stg.nb_cells.pop(data_id)
stg.cell_size.pop(data_id)
stg.pulse_length.pop(data_id)
stg.nb_pings_per_sec.pop(data_id)
stg.nb_pings_averaged_per_profile.pop(data_id)
stg.gain_rx.pop(data_id)
stg.gain_tx.pop(data_id)
stg.water_attenuation.pop(data_id)
self.pop_setting_parameters_others(data_id)
def pop_setting_parameters_others(self, data_id):
stg.BS_cross_section.pop(data_id)
stg.depth_cross_section.pop(data_id)
stg.time_cross_section.pop(data_id)
stg.tmin.pop(data_id)
stg.tmax.pop(data_id)
stg.rmin.pop(data_id)
stg.rmax.pop(data_id)
stg.BS_stream_bed.pop(data_id)
stg.depth_bottom.pop(data_id)
stg.val_bottom.pop(data_id)
stg.ind_bottom.pop(data_id)
stg.freq_bottom_detection.pop(data_id)
stg.depth_bottom_detection_min.pop(data_id)
stg.depth_bottom_detection_max.pop(data_id)
stg.depth_bottom_detection_interval.pop(data_id)
stg.BS_mean.pop(data_id)
stg.BS_noise_raw_data.pop(data_id)
stg.BS_noise_averaged_data.pop(data_id)
stg.SNR_raw_data.pop(data_id)
stg.SNR_cross_section.pop(data_id)
stg.SNR_stream_bed.pop(data_id)
stg.time_noise.pop(data_id)
stg.depth_noise.pop(data_id)
stg.noise_method.pop(data_id)
stg.noise_value.pop(data_id)
stg.SNR_filter_value.pop(data_id)
stg.Nb_cells_to_average_BS_signal.pop(data_id)
stg.filename_BS_noise_data.pop(data_id)
stg.path_BS_noise_data.pop(data_id)
stg.BS_raw_data_pre_process_SNR.pop(data_id)
stg.BS_raw_data_pre_process_average.pop(data_id)
stg.BS_cross_section_pre_process_SNR.pop(data_id)
stg.BS_cross_section_pre_process_average.pop(data_id)
stg.BS_stream_bed_pre_process_SNR.pop(data_id)
stg.BS_stream_bed_pre_process_average.pop(data_id)
stg.kt2D.pop(data_id)
stg.kt3D.pop(data_id)
stg.J_cross_section.pop(data_id)
stg.VBI_cross_section.pop(data_id)
stg.SSC_fine.pop(data_id)
stg.SSC_sand.pop(data_id)
def fill_measurements_information_groupbox(self):
if self.fileListWidget.currentRow() == -1:
return
@ -2314,83 +2368,41 @@ class AcousticDataTab(QWidget):
''' rmin and rmax are updated with double slider of depth '''
data_id = self.fileListWidget.currentRow()
stg.rmin[data_id] = ((
np.where(
np.abs(
np.round(
stg.depth[data_id][0, :], 2
) - float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_max_limits.text()
)
)
)
) == np.nanmin(
np.abs(
np.round(stg.depth[data_id][0, :], 2)
- float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_max_limits.text()
)
)
)
)
)
)[0][0]+1,
float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_max_limits.text()
)
round_depth = np.round(stg.depth[data_id][0, :], 2)
depth_max = float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_max_limits.text()
)
)
)
depth_min = float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_min_limits.text()
)
)
)
diff_max = np.abs(round_depth - depth_max)
diff_min = np.abs(round_depth - depth_min)
stg.rmin[data_id] = ((
np.where(diff_max == np.nanmin(diff_max))[0][0]+1,
depth_max
))
stg.rmax[data_id] = ((
np.where(
np.abs(
np.round(
stg.depth[data_id][0, :], 2
) - float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_min_limits.text()
)
)
)
) == np.nanmin(
np.abs(
np.round(stg.depth[data_id][0, :], 2)
- float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_min_limits.text()
)
)
)
)
)
)[0][0],
float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_min_limits.text()
)
)
)
np.where(diff_min == np.nanmin(diff_min))[0][0],
depth_min
))
stg.depth_cross_section[data_id] = (
stg.depth[data_id][:,
stg.rmin[data_id][0]:stg.rmax[data_id][0]]
stg.depth[data_id][
:, stg.rmin[data_id][0]:stg.rmax[data_id][0]
]
)
def compute_BS_cross_section(self):
@ -2868,28 +2880,44 @@ class AcousticDataTab(QWidget):
self.lineEdit_slider.setText(
str(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), self.slider.value()-1]))
def update_bottom_detection_settings(self):
data_id = max(0, self.fileListWidget.currentRow())
if stg.depth_bottom_detection_interval[data_id] == 0.0:
self.set_range_for_spinboxes_bathymetry()
return
self.combobox_frequency_bathymetry.setCurrentIndex(
int(stg.freq_bottom_detection[data_id][0])
)
self.lineEdit_depth_min_bathy.setText(
str(stg.depth_bottom_detection_min)
str(stg.depth_bottom_detection_min[data_id])
)
self.lineEdit_depth_max_bathy.setText(
str(stg.depth_bottom_detection_max)
str(stg.depth_bottom_detection_max[data_id])
)
self.lineEdit_next_cell_bathy.setText(
str(stg.depth_bottom_detection_interval)
str(stg.depth_bottom_detection_interval[data_id])
)
def save_bottom_detection_settings(self):
stg.depth_bottom_detection_min = float(
data_id = max(0, self.fileListWidget.currentRow())
stg.freq_bottom_detection[data_id] = (
int(self.combobox_frequency_bathymetry.currentIndex()),
str(self.combobox_frequency_bathymetry.currentText()),
)
stg.depth_bottom_detection_min[data_id] = float(
self.lineEdit_depth_min_bathy.text()
)
stg.depth_bottom_detection_max = float(
stg.depth_bottom_detection_max[data_id] = float(
self.lineEdit_depth_max_bathy.text()
)
stg.depth_bottom_detection_interval = float(
stg.depth_bottom_detection_interval[data_id] = float(
self.lineEdit_next_cell_bathy.text()
)

View File

@ -936,6 +936,7 @@ class AcousticInversionTab(QWidget):
def fill_combobox_fine_sample(self):
data_id = self.combobox_acoustic_data_choice.currentIndex()
self.combobox_fine_sample_choice.clear()
self.combobox_fine_sample_choice.addItems(
[f for f, _ in stg.sample_fine]
)
@ -1507,121 +1508,39 @@ class AcousticInversionTab(QWidget):
# --- Plot sand SSC : measured vs inverted ---
def fill_combobox_sand_sample(self):
data_id = self.combobox_acoustic_data_choice.currentIndex()
self.combobox_sand_sample_choice.addItems([f for f, _ in stg.sample_sand])
self.combobox_sand_sample_choice.clear()
self.combobox_sand_sample_choice.addItems(
[f for f, _ in stg.sample_sand]
)
# --- Get position (index, value) of sample in acoustic measurement space ---
if ((stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
if stg.time_cross_section[data_id].shape != (0,):
time_data = stg.time_cross_section
else:
time_data = stg.time
for j in range(len(stg.time_sand)):
if stg.depth_cross_section[data_id].shape != (0,):
depth_data = stg.depth_cross_section
else:
depth_data = stg.depth
(stg.sand_sample_position.
append(
(
np.where(
np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j])
==
np.nanmin(np.abs(stg.time_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j]))
)[0][0],
np.where(
np.abs(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))
==
np.nanmin(np.abs(stg.depth_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j])))
)[0][0]
)
)
)
elif ((stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_sand)):
(stg.sand_sample_position.
append(
(
np.where(
np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j])
==
np.nanmin(np.abs(stg.time_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j]))
)[0][0],
np.where(
np.abs(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))
==
np.nanmin(np.abs(stg.depth[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j])))
)[0][0]
)
)
)
elif ((stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_sand)):
(stg.sand_sample_position.
append(
(
np.where(
np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j])
==
np.nanmin(np.abs(stg.time[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j]))
)[0][0],
np.where(
np.abs(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))
==
np.nanmin(np.abs(stg.depth_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j])))
)[0][0]
)
)
)
elif ((stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_sand)):
(stg.sand_sample_position.
append(
(
np.where(
np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j])
==
np.nanmin(np.abs(stg.time[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j]))
)[0][0],
np.where(
np.abs(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))
==
np.nanmin(np.abs(stg.depth[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j])))
)[0][0]
)
)
freq = stg.frequency_for_inversion[1]
for j in range(len(stg.time_sand)):
time_diff = np.abs(time_data[data_id][freq] - stg.time_sand[j])
depth_diff = np.abs(depth_data[data_id][freq] - (-stg.depth_sand[j]))
stg.sand_sample_position.append(
(
np.where(
time_diff == np.nanmin(time_diff)
)[0][0],
np.where(
depth_diff == np.nanmin(depth_diff)
)[0][0]
)
)
def plot_measured_vs_inverted_SSC_sand(self):

View File

@ -67,7 +67,9 @@ class SedimentCalibrationTab(QWidget):
self._setup_widgets()
def _path_icon(self, icon):
return os.path.join("icons", icon)
return os.path.join(
os.path.dirname(__file__), "..", "icons", icon
)
def _setup_icons(self):
self.icon_folder = QIcon(self._path_icon("folder.png"))
@ -1994,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([])
@ -2065,119 +2066,128 @@ class SedimentCalibrationTab(QWidget):
stg.alpha_s = [alpha_s_freq1, alpha_s_freq2]
logger.debug(f"\u03B1s for frequency of freq1 : {alpha_s_freq1:.2f} /m \n")
logger.debug(f"\u03B1s for frequency of freq2 : {alpha_s_freq2:.2f} /m")
logger.debug(
f"\u03B1s for frequency of freq1 : {alpha_s_freq1:.2f} / m"
)
logger.debug(
f"\u03B1s for frequency of freq2 : {alpha_s_freq2:.2f} / m"
)
self.lineEdit_alphas_freq1.clear()
self.lineEdit_alphas_freq1.setText(str("%.5f" % alpha_s_freq1))
self.lineEdit_alphas_freq1.setText(f"{alpha_s_freq1:.5f}")
self.lineEdit_alphas_freq2.clear()
self.lineEdit_alphas_freq2.setText(str("%.5f" % alpha_s_freq2))
self.lineEdit_alphas_freq2.setText(f"{alpha_s_freq2:.5f}")
title = "Alpha computation error"
icon = self._path_icon("no_approved.png")
if (alpha_s_freq1 < 0) or (alpha_s_freq2 < 0):
msgBox = QMessageBox()
msgBox.setWindowTitle("Alpha computation error")
msgBox.setIconPixmap(QPixmap(self._path_icon("no_approved.png")).scaledToHeight(32, Qt.SmoothTransformation))
msgBox.setText("Sediment sound attenuation is negative !")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
text = "Sediment sound attenuation is negative !"
elif isinf(alpha_s_freq1) or isinf(alpha_s_freq2):
msgBox = QMessageBox()
msgBox.setWindowTitle("Alpha computation error")
msgBox.setIconPixmap(
QPixmap(self._path_icon("no_approved.png")).scaledToHeight(32, Qt.SmoothTransformation))
msgBox.setText("Sediment sound attenuation is infinite !")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
text = "Sediment sound attenuation is infinite !"
else:
title = "Alpha computation validation"
icon = self._path_icon("approved.png")
text = "Sediment sound attenuation is positive."
msgBox = QMessageBox()
msgBox.setWindowTitle("Alpha computation validation")
msgBox.setIconPixmap(QPixmap(self._path_icon("approved.png")).scaledToHeight(32, Qt.SmoothTransformation))
msgBox.setText("Sediment sound attenuation is positive.")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
msgBox = QMessageBox()
msgBox.setWindowTitle(title)
msgBox.setIconPixmap(
QPixmap(icon).scaledToHeight(
32, Qt.SmoothTransformation
)
)
msgBox.setText(text)
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
def compute_zeta(self):
# --- Compute zeta ---
if stg.M_profile_fine.shape == (0,):
msgBox = QMessageBox()
msgBox.setWindowTitle("Zeta computation error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText("Please interpolate fine profile")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
return
data_id = self.combobox_acoustic_data_choice.currentIndex()
freq_1 = self.combobox_freq1.currentIndex()
freq_2 = self.combobox_freq2.currentIndex()
if stg.depth_cross_section[data_id].shape != (0,):
depth_data = stg.depth_cross_section
else:
depth_data = stg.depth
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
zeta_freq1 = self.inv_hc.zeta(
alpha_s = stg.alpha_s[0],
r = depth_data[data_id][freq_1, :],
M_profile_fine = stg.M_profile_fine
)
zeta_freq2 = self.inv_hc.zeta(
alpha_s = stg.alpha_s[1],
r = depth_data[data_id][freq_2, :],
M_profile_fine = stg.M_profile_fine
)
zeta_freq1 = self.inv_hc.zeta(alpha_s=stg.alpha_s[0],
r=stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq1.currentIndex(), :],
M_profile_fine=stg.M_profile_fine)
zeta_freq2 = self.inv_hc.zeta(alpha_s=stg.alpha_s[1],
r=stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq2.currentIndex(), :],
M_profile_fine=stg.M_profile_fine)
stg.zeta = [zeta_freq1, zeta_freq2]
else:
zeta_freq1 = self.inv_hc.zeta(alpha_s=stg.alpha_s[0],
r=stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq1.currentIndex(), :],
M_profile_fine=stg.M_profile_fine)
zeta_freq2 = self.inv_hc.zeta(alpha_s=stg.alpha_s[1],
r=stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq2.currentIndex(), :],
M_profile_fine=stg.M_profile_fine)
logger.debug(
f"\u03B6 for frequency of freq1 : {zeta_freq1:.3f} / m"
)
logger.debug(
f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} / m"
)
stg.zeta = [zeta_freq1, zeta_freq2]
self.lineEdit_zeta_freq1.clear()
self.lineEdit_zeta_freq1.setText(f"{zeta_freq1:.5f}")
logger.debug(f"\u03B6 for frequency of freq1 : {zeta_freq1:.3f} /m \n")
logger.debug(f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} /m")
self.lineEdit_zeta_freq1.clear()
self.lineEdit_zeta_freq1.setText(str("%.5f" % zeta_freq1))
self.lineEdit_zeta_freq2.clear()
self.lineEdit_zeta_freq2.setText(str("%.5f" % zeta_freq2))
self.lineEdit_zeta_freq2.clear()
self.lineEdit_zeta_freq2.setText(f"{zeta_freq2:.5f}")
def save_calibration(self):
data_id = self.combobox_acoustic_data_choice.currentIndex()
freq1 = stg.frequencies_for_calibration[0][1]
freq2 = stg.frequencies_for_calibration[1][1]
if stg.alpha_s:
directory = ""
if stg.path_calibration_file != "":
directory = stg.path_calibration_file
elif self.combobox_acoustic_data_choice.count() > 0:
directory = stg.path_BS_raw_data[-1]
dir_save_cal = QFileDialog.getExistingDirectory(
caption="Save calibration",
directory=[stg.path_calibration_file if stg.path_calibration_file else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0],
options=QFileDialog.DontUseNativeDialog)
directory=directory,
options=QFileDialog.DontUseNativeDialog
)
if dir_save_cal:
stg.path_calibration_file = os.path.dirname(dir_save_cal)
cal_array = [[' ', stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[0][1]],
stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]]],
['ks', stg.ks[0], stg.ks[1]],
['sv', stg.sv[0], stg.sv[1]],
['X', stg.X_exponent[0], 0],
['alphas', stg.alpha_s[0], stg.alpha_s[1]],
['zeta', stg.zeta[0], stg.zeta[1]]]
eval("np.savetxt('"+ dir_save_cal + "/Sediment_calibration_" +
str(stg.filename_BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:-4]) + ".csv' ," +
"cal_array, " +
"delimiter=',' ," +
"fmt ='% s'" +
")")
cal_array = [
[
' ', stg.freq_text[data_id][freq1],
stg.freq_text[data_id][freq2]
],
['ks', stg.ks[0], stg.ks[1]],
['sv', stg.sv[0], stg.sv[1]],
['X', stg.X_exponent[0], 0],
['alphas', stg.alpha_s[0], stg.alpha_s[1]],
['zeta', stg.zeta[0], stg.zeta[1]]
]
np.savetxt(
f"{dir_save_cal}/Sediment_calibration_"
+ f"{stg.filename_BS_raw_data[data_id][:-4]}.csv",
cal_array,
delimiter=',', fmt ='% s'
)
else:
msgBox = QMessageBox()
msgBox.setWindowTitle("Save Error")
msgBox.setIcon(QMessageBox.Warning)
@ -2190,68 +2200,49 @@ class SedimentCalibrationTab(QWidget):
# ------------ Computing real cell size ------------ #
def range_cells_function(self):
""" Computing the real cell size, that depends on the temperature """
data_id = self.combobox_acoustic_data_choice.currentIndex()
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
aquascat_cell_size = []
tau = []
real_cell_size = []
stg.depth_real = np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)
for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]):
# defaut Aquascat cell size
aquascat_cell_size.append(
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, 1] -
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, 0])
# Pulse duration
tau.append(aquascat_cell_size[f] * 2 / 1500) # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat
# Real cell size
real_cell_size.append(stg.water_velocity * tau[f] / 2) # voir fig 2.9
# Converting to real cell profile
stg.depth_real[f, :] = (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :]
/ aquascat_cell_size[f] * real_cell_size[f])
aquascat_cell_size = []
tau = []
real_cell_size = []
if stg.depth_cross_section[data_id].shape != (0,):
depth_data = stg.depth_cross_section
else:
depth_data = stg.depth
aquascat_cell_size = []
tau = []
real_cell_size = []
stg.depth_real = np.zeros(depth_data[data_id].shape)
stg.depth_real = (np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape))
for f in range(stg.freq[data_id].shape[0]):
# defaut Aquascat cell size
aquascat_cell_size.append(
depth_data[data_id][f, 1] - depth_data[data_id][f, 0]
)
for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]):
# Pulse duration: figure 2.9 1500 vitesse du son entrée
# pour le paramètrage des mesures aquascat
tau.append(aquascat_cell_size[f] * 2 / 1500)
# defaut Aquascat cell size
aquascat_cell_size.append(
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, 1] -
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, 0])
# voir fig 2.9
real_cell_size.append(stg.water_velocity * tau[f] / 2)
# Pulse duration
tau.append(aquascat_cell_size[f] * 2 / 1500) # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat
# Converting to real cell profile
stg.depth_real[f, :] = (
depth_data[data_id][f, :]
/ aquascat_cell_size[f]
* real_cell_size[f]
)
# Real cell size
real_cell_size.append(stg.water_velocity * tau[f] / 2) # voir fig 2.9
# Converting to real cell profile
stg.depth_real[f, :] = (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] /
aquascat_cell_size[f] * real_cell_size[f])
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.depth_real = \
(np.repeat(stg.depth_real[:, :, np.newaxis],
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
if stg.time_cross_section[data_id].shape != (0,):
time_data = stg.time_cross_section
else:
time_data = stg.time
stg.depth_real = (
np.repeat(stg.depth_real[:, :, np.newaxis],
stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
stg.depth_real = np.repeat(
stg.depth_real[:, :, np.newaxis],
time_data[data_id].shape[1], axis=2
)
def compute_FCB(self):
data_id = self.combobox_acoustic_data_choice.currentIndex()
@ -2414,6 +2405,10 @@ class SedimentCalibrationTab(QWidget):
data_id = self.combobox_acoustic_data_choice.currentIndex()
fcb_id = self.combobox_frequency_FCB.currentIndex()
if (self.lineEdit_FCB_from.text() == ''
or self.lineEdit_FCB_to.text() == ''):
return
self.update_plot_FCB()
if stg.FCB.shape == (0,):
@ -2437,8 +2432,7 @@ class SedimentCalibrationTab(QWidget):
np.round(
np.abs(
x - float(
self.lineEdit_FCB_from\
.text().replace(',','.')
self.lineEdit_FCB_from.text().replace(',','.')
)
), 2
) == np.min(

View File

@ -625,12 +625,14 @@ class SignalProcessingTab(QWidget):
self.compute_average_profile_tail()
if stg.noise_method[data_id] == 0:
if stg.filename_BS_noise_data[data_id] != "":
if len(stg.BS_noise_raw_data) == 0:
self.load_noise_data_and_compute_SNR()
else:
for i in range(self.combobox_acoustic_data_choice.count()):
self.compute_noise(i)
if stg.filename_BS_noise_data[data_id] == "":
return
if len(stg.BS_noise_raw_data) == 0:
self.load_noise_data_and_compute_SNR()
else:
for i in range(self.combobox_acoustic_data_choice.count()):
self.compute_noise(i)
elif stg.noise_method[data_id] == 1:
self.compute_noise_from_profile_tail_value()
@ -920,7 +922,9 @@ class SignalProcessingTab(QWidget):
self.compute_average_profile_tail()
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)
@ -1636,7 +1649,6 @@ class SignalProcessingTab(QWidget):
BS_data_ppa = stg.BS_raw_data_pre_process_average
for i in range(len(BS)):
bs = BS[i]
logger.debug(f"BS data shape {bs[data_id].shape}")
if bs[data_id].shape == (0,):
continue
@ -1645,7 +1657,6 @@ class SignalProcessingTab(QWidget):
BS_data_ppa = BS_ppa[i]
break
logger.debug(f"BS_data: {BS_data[data_id].shape}")
# BS_data_ppa[data_id] = deepcopy(BS_data[data_id])
#
@ -1674,11 +1685,11 @@ class SignalProcessingTab(QWidget):
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(
f"BS_data_ppa: {BS_data_ppa[data_id].shape}"
)
BS_data_ppa[data_id] = np.append(
BS_data_ppa[data_id],
np.array([temp_list[j+1]]),
axis=0
)
def plot_pre_processed_profile(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())

View File

@ -1,41 +1,15 @@
astropy==6.1.7
astropy-iers-data==0.2025.3.3.0.34.45
contourpy==1.0.7
cycler==0.11.0
defusedxml==0.7.1
et-xmlfile==1.1.0
fonttools==4.38.0
importlib-resources==5.12.0
joblib==1.2.0
kiwisolver==1.4.4
llvmlite==0.39.1
matplotlib==3.6.3
numba==0.56.4
numpy==1.23.5
odfpy==1.4.1
openpyxl==3.0.10
packaging==23.0
pandas==1.5.3
Pillow==9.4.0
profilehooks==1.12.0
pyerfa==2.0.1.5
pyparsing==3.0.9
pyqt-checkbox-table-widget==0.0.14
pyqt-file-list-widget==0.0.1
pyqt-files-already-exists-dialog==0.0.1
pyqt-tooltip-list-widget==0.0.1
PyQt5==5.15.9
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.0
python-dateutil==2.8.2
pytz==2022.7.1
PyYAML==6.0.2
scikit-learn==1.2.1
scipy==1.10.0
simplePyQt5==0.0.1
six==1.16.0
threadpoolctl==3.1.0
utm==0.7.0
xlrd==2.0.1
xmltodict==0.13.0
zipp==3.15.0
odfpy==1.4.1
openpyxl==3.0.10
pyinstaller==6.12.0
pyqt_file_list_widget==0.0.1