Merge branch 'dev-parouby' into dev

dev-brahim
Pierre-Antoine 2025-03-17 17:34:25 +01:00
commit b5338366cf
3 changed files with 160 additions and 169 deletions

3
.gitignore vendored
View File

@ -1,6 +1,9 @@
TAGS
Error_file.txt
# Windows executable file
*.exe
# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

View File

@ -294,6 +294,8 @@ class AcousticDataTab(QWidget):
self.groupbox_gps = QGroupBox()
self.groupbox_gps.setTitle("Convert recording time to distance from bank")
self.horizontal_gps_input_data = QHBoxLayout(self.groupbox_gps)
self.groupbox_gps.setEnabled(False)
self.verticalLayout_groupbox_display_option.addWidget(self.groupbox_gps)
@ -445,34 +447,61 @@ class AcousticDataTab(QWidget):
# ---------------------------------
self.label_distance_from_bank = QLabel("Distance from bank")
self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank, 3, 0, 1, 1, Qt.AlignRight)
self.gridLayout_groupbox_display_option_limits.addWidget(
self.label_distance_from_bank,
3, 0, 1, 1, Qt.AlignRight
)
self.label_distance_from_bank.setEnabled(False)
self.label_distance_from_bank_min = QLabel()
self.label_distance_from_bank_min.setText("0.00")
self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank_min, 3, 1, 1, 1, Qt.AlignCenter)
self.gridLayout_groupbox_display_option_limits.addWidget(
self.label_distance_from_bank_min,
3, 1, 1, 1, Qt.AlignCenter
)
self.label_distance_from_bank_min.setEnabled(False)
self.lineEdit_distance_from_bank_min_limits = QLineEdit()
self.lineEdit_distance_from_bank_min_limits.setText("0.00")
self.lineEdit_distance_from_bank_min_limits.setMaximumWidth(80)
self.gridLayout_groupbox_display_option_limits.addWidget(self.lineEdit_distance_from_bank_min_limits, 3, 2, 1, 1,
Qt.AlignCenter)
self.gridLayout_groupbox_display_option_limits.addWidget(
self.lineEdit_distance_from_bank_min_limits,
3, 2, 1, 1, Qt.AlignCenter
)
self.lineEdit_distance_from_bank_min_limits.setEnabled(False)
self.lineEdit_distance_from_bank_max_limits = QLineEdit()
self.lineEdit_distance_from_bank_max_limits.setText("0.00")
self.lineEdit_distance_from_bank_max_limits.setMaximumWidth(80)
self.gridLayout_groupbox_display_option_limits.addWidget(self.lineEdit_distance_from_bank_max_limits, 3, 3, 1, 1,
Qt.AlignCenter)
self.gridLayout_groupbox_display_option_limits.addWidget(
self.lineEdit_distance_from_bank_max_limits,
3, 3, 1, 1, Qt.AlignCenter
)
self.lineEdit_distance_from_bank_max_limits.setEnabled(False)
self.label_distance_from_bank_max = QLabel()
self.label_distance_from_bank_max.setText("0.00")
self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank_max, 3, 4, 1, 1, Qt.AlignCenter)
self.gridLayout_groupbox_display_option_limits.addWidget(
self.label_distance_from_bank_max,
3, 4, 1, 1, Qt.AlignCenter
)
self.label_distance_from_bank_max.setEnabled(False)
self.label_distance_from_bank_unit_meter = QLabel("meters")
self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank_unit_meter, 3, 5, 1, 1, Qt.AlignCenter)
self.gridLayout_groupbox_display_option_limits.addWidget(
self.label_distance_from_bank_unit_meter,
3, 5, 1, 1, Qt.AlignCenter
)
self.label_distance_from_bank_unit_meter.setEnabled(False)
self.pushbutton_apply_distance_from_bank_limits = QPushButton()
self.pushbutton_apply_distance_from_bank_limits.setIcon(self.icon_apply_limits)
self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_distance_from_bank_limits, 3, 6, 1, 1)
self.gridLayout_groupbox_display_option_limits.addWidget(
self.pushbutton_apply_distance_from_bank_limits,
3, 6, 1, 1
)
self.pushbutton_apply_distance_from_bank_limits.setEnabled(False)
# ---------------------------------------
@ -1359,7 +1388,6 @@ class AcousticDataTab(QWidget):
self.fileListWidget.blockSignals(False)
def rename_file_in_ListWidget(self, event):
if event == QEvent.MouseButtonPress:
print("c'est bon")
if event.button == Qt.RightButton:
@ -1372,144 +1400,69 @@ class AcousticDataTab(QWidget):
menu.addAction('Rename')
def remove_file_from_ListWidget(self):
if self.fileListWidget.count() > 0:
if self.fileListWidget.count() <= 0:
return
# --- Clear files included in list Widget ---
current_row = self.fileListWidget.currentRow()
if current_row >= 0:
current_item = self.fileListWidget.takeItem(current_row)
del current_item
self.fileListWidget.blockSignals(True)
# --- 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"
]
# --- Clear files included in list Widget ---
current_row = self.fileListWidget.currentRow()
if current_row >= 0:
current_item = self.fileListWidget.takeItem(current_row)
del current_item
for p in list_to_pop1:
if isinstance(eval(p), list):
exec(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:
exec(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:
exec(s + ".pop(current_row)")
if self.fileListWidget.count() == 0:
# --- Clear measurements information ---
self.label_date_acoustic_file.clear()
self.label_date_acoustic_file.setText("Date: ")
self.label_hour_acoustic_file.clear()
self.label_hour_acoustic_file.setText("Hour: ")
self.lineEdit_sound_attenuation.setText("0.00")
self.combobox_frequency_information.clear()
self.label_profiles_value.clear()
self.label_profiles_per_sec_value.clear()
self.label_cells_value.clear()
self.label_cell_size_value.clear()
self.label_pulse_length_value.clear()
self.label_pings_per_sec_value.clear()
self.label_pings_per_profile_value.clear()
self.lineEdit_kt.setText("0.00")
self.lineEdit_rx.setText("0.00")
self.lineEdit_tx.setText("0.00")
# --- Clear display options ---
self.label_time_min.setText("0.00")
self.lineEdit_time_min_limits.setText("0.00")
self.lineEdit_time_max_limits.setText("0.00")
self.label_time_max.setText("0.00")
self.label_depth_min.setText("0.00")
self.lineEdit_depth_min_limits.setText("0.00")
self.lineEdit_depth_max_limits.setText("0.00")
self.label_depth_max.setText("0.00")
self.label_distance_from_bank_min.setText("0.00")
self.lineEdit_distance_from_bank_min_limits.setText("0.00")
self.lineEdit_distance_from_bank_max_limits.setText("0.00")
self.label_distance_from_bank_max.setText("0.00")
self.combobox_frequency_bathymetry.clear()
self.lineEdit_depth_min_bathy.setText("0.00")
self.lineEdit_depth_max_bathy.setText("0.00")
self.lineEdit_next_cell_bathy.setText("0.00")
# --- Clear table of values ---
self.tableView.reset()
data = pd.DataFrame(np.zeros((10, 10)))
self.tableModel = TableModel(data)
self.tableView.setModel(self.tableModel)
# --- Clear figure : 2D plot of the acoustic recording ---
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS)
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.toolbar_BS)
self.canvas_BS = FigureCanvas()
self.toolbar_BS = NavigationToolBar(self.canvas_BS, self)
self.scroll_BS.setWidget(self.canvas_BS)
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.toolbar_BS)
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS)
# --- Clear figure : profile ---
self.combobox_frequency_profile.clear()
self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile)
self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile)
self.canvas_plot_profile = FigureCanvas()
self.toolbar_profile = NavigationToolBar(self.canvas_plot_profile, self)
self.verticalLayout_groupbox_plot_profile.addWidget(self.toolbar_profile)
self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile)
self.slider.setValue(0)
self.slider.setMaximum(10)
def clear_files_from_ListWidget(self):
list_to_clear = [
"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",
"stg.rmin", "stg.rmax", "stg.tmin", "stg.tmax",
"stg.time_cross_section", "stg.depth_cross_section",
"stg.BS_cross_section", "stg.BS_stream_bed"
# --- 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 k in list_to_clear:
if isinstance(eval(k), list):
exec(k + ".clear()")
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)
if self.fileListWidget.count() == 0:
self.clear_files_from_ListWidget_reset()
self.fileListWidget.blockSignals(False)
def clear_files_from_ListWidget(self):
self.fileListWidget.blockSignals(True)
self.clear_files_data()
self.clear_files_from_ListWidget_reset()
self.fileListWidget.blockSignals(False)
def clear_files_from_ListWidget_reset(self):
self.fileListWidget.clear()
# self.fileListWidget.takeItem(0)
@ -1586,6 +1539,27 @@ class AcousticDataTab(QWidget):
self.slider.setValue(0)
self.slider.setMaximum(10)
def clear_files_data(self):
list_to_clear = [
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,
stg.rmin, stg.rmax, stg.tmin, stg.tmax,
stg.time_cross_section, stg.depth_cross_section,
stg.BS_cross_section, stg.BS_stream_bed
]
for k in list_to_clear:
if isinstance(k, list):
k.clear()
def load_BS_acoustic_raw_data(self):
if self.fileListWidget.count() == 0:
for p, f in zip(stg.path_BS_raw_data,
@ -1972,7 +1946,7 @@ class AcousticDataTab(QWidget):
14, 1, 1, 1, Qt.AlignLeft
)
if self.checkbox_kt.isChecked():
if self.checkbox_kt.isChecked() and len(stg.kt_corrected) > freq_id:
if self.combobox_frequency_information.count() > 0:
self.lineEdit_kt.setText(
str("%.4f" % stg.kt_corrected[freq_id])

View File

@ -39,6 +39,7 @@ from View.about_window import AboutWindow
import settings as stg
import numpy as np
import pandas as pd
from subprocess import Popen
import time
@ -325,23 +326,21 @@ class Ui_MainWindow(object):
self.open_doc_file('Tutorial_AQUAscat_software.pdf')
def export_table_of_acoustic_BS_values_to_excel_or_libreOfficeCalc_file(self):
if len(stg.BS_raw_data_reshape) != 0:
# --- Open file dialog to select the directory ---
name = QtWidgets.QFileDialog.getExistingDirectory(caption="Select Directory - Acoustic BS raw data Table")
name = QtWidgets.QFileDialog.getExistingDirectory(
caption="Select Directory - Acoustic BS raw data Table"
)
print("name table to save ", name)
# --- Save the raw acoustic backscatter data from a Dataframe to csv file ---
# --- Save the raw acoustic backscatter data from a
# --- Dataframe to csv file ---
t0 = time.time()
print("len(stg.BS_raw_data_reshape) ", len(stg.BS_raw_data_reshape))
print("len(stg.BS_raw_data_reshape) ",
len(stg.BS_raw_data_reshape))
if name:
for i in range(len(stg.BS_raw_data_reshape)):
header_list = []
header_list.clear()
table_data = np.array([[]])
@ -351,27 +350,42 @@ class Ui_MainWindow(object):
header_list.append("BS - " + freq_value)
if freq_ind == 0:
table_data = np.vstack((np.vstack((stg.time_reshape[i][:, freq_ind],
stg.depth_reshape[i][:, freq_ind])),
stg.BS_raw_data_reshape[i][:, freq_ind]))
table_data = np.vstack(
(
np.vstack(
(stg.time_reshape[i][:, freq_ind],
stg.depth_reshape[i][:, freq_ind])),
stg.BS_raw_data_reshape[i][:, freq_ind]
)
)
else:
table_data = np.vstack((table_data,
np.vstack((np.vstack(
(stg.time_reshape[i][:, freq_ind],
stg.depth_reshape[i][:, freq_ind])),
stg.BS_raw_data_reshape[i][:, freq_ind]))
))
table_data = np.vstack(
(
table_data,
np.vstack((
np.vstack((
stg.time_reshape[i][:, freq_ind],
stg.depth_reshape[i][:, freq_ind]
)),
stg.BS_raw_data_reshape[i][:, freq_ind]
))
)
)
exec("DataFrame_acoustic_" + str(i) + "= pd.DataFrame(None)")
exec("DataFrame_acoustic_" + str(i) + "= pd.DataFrame(data=table_data.transpose(), columns=header_list)")
DataFrame_acoustic = pd.DataFrame(None)
DataFrame_acoustic = pd.DataFrame(
data=table_data.transpose(), columns=header_list
)
exec("DataFrame_acoustic_" + str(i) + ".to_csv(" +
"path_or_buf=" +
"'" + name + "/" + "Table_" +
str(stg.filename_BS_raw_data[i][:-4]) + ".csv'" + ", " +
"sep=" + "',' " + ", " +
"header=DataFrame_acoustic_" + str(i) + ".columns" + ")")
DataFrame_acoustic.to_csv(
path_or_buf=os.path.join(
name,
f"Table_{str(stg.filename_BS_raw_data[i][:-4])}.csv"
),
header=DataFrame_acoustic.columns,
sep=',',
)
t1 = time.time() - t0
print("time duration export BS ", t1)