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 TAGS
Error_file.txt Error_file.txt
# Windows executable file
*.exe
# Created by https://www.toptal.com/developers/gitignore/api/python # Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=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 = QGroupBox()
self.groupbox_gps.setTitle("Convert recording time to distance from bank") self.groupbox_gps.setTitle("Convert recording time to distance from bank")
self.horizontal_gps_input_data = QHBoxLayout(self.groupbox_gps) self.horizontal_gps_input_data = QHBoxLayout(self.groupbox_gps)
self.groupbox_gps.setEnabled(False)
self.verticalLayout_groupbox_display_option.addWidget(self.groupbox_gps) 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.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 = QLabel()
self.label_distance_from_bank_min.setText("0.00") 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 = QLineEdit()
self.lineEdit_distance_from_bank_min_limits.setText("0.00") self.lineEdit_distance_from_bank_min_limits.setText("0.00")
self.lineEdit_distance_from_bank_min_limits.setMaximumWidth(80) 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, self.gridLayout_groupbox_display_option_limits.addWidget(
Qt.AlignCenter) 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 = QLineEdit()
self.lineEdit_distance_from_bank_max_limits.setText("0.00") self.lineEdit_distance_from_bank_max_limits.setText("0.00")
self.lineEdit_distance_from_bank_max_limits.setMaximumWidth(80) 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, self.gridLayout_groupbox_display_option_limits.addWidget(
Qt.AlignCenter) 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 = QLabel()
self.label_distance_from_bank_max.setText("0.00") 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.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 = QPushButton()
self.pushbutton_apply_distance_from_bank_limits.setIcon(self.icon_apply_limits) 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) 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:
print("c'est bon") print("c'est bon")
if event.button == Qt.RightButton: if event.button == Qt.RightButton:
@ -1372,7 +1400,10 @@ class AcousticDataTab(QWidget):
menu.addAction('Rename') menu.addAction('Rename')
def remove_file_from_ListWidget(self): def remove_file_from_ListWidget(self):
if self.fileListWidget.count() > 0: if self.fileListWidget.count() <= 0:
return
self.fileListWidget.blockSignals(True)
# --- Clear files included in list Widget --- # --- Clear files included in list Widget ---
current_row = self.fileListWidget.currentRow() current_row = self.fileListWidget.currentRow()
@ -1382,134 +1413,56 @@ class AcousticDataTab(QWidget):
# --- Clear variables --- # --- Clear variables ---
list_to_pop1 = [ list_to_pop1 = [
"stg.acoustic_data", "stg.date", "stg.hour", stg.acoustic_data, stg.date, stg.hour,
"stg.freq", "stg.freq_text", stg.freq, stg.freq_text,
"stg.nb_profiles", "stg.nb_profiles_per_sec", stg.nb_profiles, stg.nb_profiles_per_sec,
"stg.nb_cells", "stg.cell_size", stg.nb_cells, stg.cell_size,
"stg.pulse_length", "stg.nb_pings_per_sec", stg.pulse_length, stg.nb_pings_per_sec,
"stg.nb_pings_averaged_per_profile", stg.nb_pings_averaged_per_profile,
"stg.kt_read", "stg.kt_corrected", "stg.gain_rx", "stg.gain_tx", stg.kt_read, stg.kt_corrected, stg.gain_rx, stg.gain_tx,
"stg.filename_BS_raw_data", "stg.path_BS_raw_data", stg.filename_BS_raw_data, stg.path_BS_raw_data,
"stg.BS_raw_data", "stg.time", "stg.depth", stg.BS_raw_data, stg.time, stg.depth,
"stg.BS_raw_data_reshape", "stg.time_reshape", "stg.depth_reshape" stg.BS_raw_data_reshape, stg.time_reshape, stg.depth_reshape
] ]
for p in list_to_pop1: for p in list_to_pop1:
if isinstance(eval(p), list): if isinstance(p, list):
exec(p + ".pop(current_row)") p.pop(current_row)
if stg.BS_cross_section: if stg.BS_cross_section:
list_to_pop2 = [
list_to_pop2 = ["stg.rmin", "stg.rmax", "stg.tmin", "stg.tmax", stg.rmin, stg.rmax, stg.tmin, stg.tmax,
"stg.time_cross_section", "stg.depth_cross_section", "stg.BS_cross_section"] 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"
] ]
for k in list_to_clear: for k in list_to_pop2:
if isinstance(eval(k), list): k.pop(current_row)
exec(k + ".clear()")
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.clear()
# self.fileListWidget.takeItem(0) # self.fileListWidget.takeItem(0)
@ -1586,6 +1539,27 @@ class AcousticDataTab(QWidget):
self.slider.setValue(0) self.slider.setValue(0)
self.slider.setMaximum(10) 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): def load_BS_acoustic_raw_data(self):
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,
@ -1972,7 +1946,7 @@ class AcousticDataTab(QWidget):
14, 1, 1, 1, Qt.AlignLeft 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: if self.combobox_frequency_information.count() > 0:
self.lineEdit_kt.setText( self.lineEdit_kt.setText(
str("%.4f" % stg.kt_corrected[freq_id]) str("%.4f" % stg.kt_corrected[freq_id])

View File

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