Compare commits

..

No commits in common. "60b367b7ef0ebce0ff6bac3c5d170b1dbcf1e618" and "fbc46f334463ec78b7befe20c2d613938a0190d8" have entirely different histories.

14 changed files with 747 additions and 731 deletions

3
.gitignore vendored
View File

@ -1,9 +1,6 @@
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

@ -32,7 +32,7 @@ from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
import settings as stg
from settings import ABS_name
logger = logging.getLogger("acoused")
logger = logging.getLogger()
class CreateTableForSaveAs:

View File

@ -34,7 +34,7 @@ from settings import BS_raw_data, acoustic_data
from View.acoustic_data_tab import AcousticDataTab
logger = logging.getLogger("acoused")
logger = logging.getLogger()
class ReadTableForOpen:

View File

@ -64,7 +64,7 @@ locale.setlocale(locale.LC_ALL, '')
_translate = QCoreApplication.translate
logger = logging.getLogger("acoused")
logger = logging.getLogger()
class AcousticDataTab(QWidget):
COMPTEUR = 1
@ -294,8 +294,6 @@ 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)
@ -447,61 +445,34 @@ 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.label_distance_from_bank.setEnabled(False)
self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank, 3, 0, 1, 1, Qt.AlignRight)
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.label_distance_from_bank_min.setEnabled(False)
self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank_min, 3, 1, 1, 1, Qt.AlignCenter)
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.lineEdit_distance_from_bank_min_limits.setEnabled(False)
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_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.lineEdit_distance_from_bank_max_limits.setEnabled(False)
self.gridLayout_groupbox_display_option_limits.addWidget(self.lineEdit_distance_from_bank_max_limits, 3, 3, 1, 1,
Qt.AlignCenter)
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.label_distance_from_bank_max.setEnabled(False)
self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank_max, 3, 4, 1, 1, Qt.AlignCenter)
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.label_distance_from_bank_unit_meter.setEnabled(False)
self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank_unit_meter, 3, 5, 1, 1, Qt.AlignCenter)
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.pushbutton_apply_distance_from_bank_limits.setEnabled(False)
self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_distance_from_bank_limits, 3, 6, 1, 1)
# ---------------------------------------
@ -776,7 +747,6 @@ class AcousticDataTab(QWidget):
self.groupbox_transect_2Dplot_raw_BS_data.setTitle(_translate("CONSTANT_STRING", cs.RAW_ACOUSTIC_DATA_2D_FIELD))
def fileListWidget_event(self):
self.fileListWidget.blockSignals(True)
self.print_selected_file()
self.fill_measurements_information_groupbox()
@ -790,8 +760,6 @@ class AcousticDataTab(QWidget):
self.update_plot_profile()
self.set_range_for_spinboxes_bathymetry()
self.fileListWidget.blockSignals(False)
def print_selected_file(self):
print(f"Selected file in list widget : {self.fileListWidget.selectedItems()}")
print("self.fileListWidget.selectedItems()[1:] : ", self.fileListWidget.selectedItems()[1:])
@ -1391,6 +1359,7 @@ 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:
@ -1403,10 +1372,7 @@ class AcousticDataTab(QWidget):
menu.addAction('Rename')
def remove_file_from_ListWidget(self):
if self.fileListWidget.count() <= 0:
return
self.fileListWidget.blockSignals(True)
if self.fileListWidget.count() > 0:
# --- Clear files included in list Widget ---
current_row = self.fileListWidget.currentRow()
@ -1416,56 +1382,134 @@ class AcousticDataTab(QWidget):
# --- 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
"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 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
]
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)
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
]
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)
exec(s + ".pop(current_row)")
if self.fileListWidget.count() == 0:
self.clear_files_from_ListWidget_reset()
self.fileListWidget.blockSignals(False)
# --- 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):
self.fileListWidget.blockSignals(True)
self.clear_files_data()
self.clear_files_from_ListWidget_reset()
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"
]
self.fileListWidget.blockSignals(False)
for k in list_to_clear:
if isinstance(eval(k), list):
exec(k + ".clear()")
def clear_files_from_ListWidget_reset(self):
self.fileListWidget.clear()
# self.fileListWidget.takeItem(0)
@ -1542,27 +1586,6 @@ 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,
@ -1949,7 +1972,7 @@ class AcousticDataTab(QWidget):
14, 1, 1, 1, Qt.AlignLeft
)
if self.checkbox_kt.isChecked() and len(stg.kt_corrected) > freq_id:
if self.checkbox_kt.isChecked():
if self.combobox_frequency_information.count() > 0:
self.lineEdit_kt.setText(
str("%.4f" % stg.kt_corrected[freq_id])

View File

@ -39,7 +39,6 @@ from View.about_window import AboutWindow
import settings as stg
import numpy as np
import pandas as pd
from subprocess import Popen
import time
@ -326,21 +325,23 @@ 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:
name = QtWidgets.QFileDialog.getExistingDirectory(
caption="Select Directory - Acoustic BS raw data Table"
)
# --- Open file dialog to select the directory ---
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([[]])
@ -350,42 +351,27 @@ 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],
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]
)
)
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]))
))
)
)
DataFrame_acoustic = pd.DataFrame(None)
DataFrame_acoustic = pd.DataFrame(
data=table_data.transpose(), columns=header_list
)
exec("DataFrame_acoustic_" + str(i) + "= pd.DataFrame(None)")
exec("DataFrame_acoustic_" + str(i) + "= pd.DataFrame(data=table_data.transpose(), columns=header_list)")
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=',',
)
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" + ")")
t1 = time.time() - t0
print("time duration export BS ", t1)

View File

@ -50,7 +50,7 @@ import settings as stg
_translate = QCoreApplication.translate
logger = logging.getLogger("acoused")
logger = logging.getLogger()
class SampleDataTab(QWidget):

View File

@ -48,7 +48,7 @@ import settings as stg
from View.checkable_combobox import CheckableComboBox
from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration
logger = logging.getLogger("acoused")
logger = logging.getLogger()
class SedimentCalibrationTab(QWidget):
@ -1569,10 +1569,6 @@ class SedimentCalibrationTab(QWidget):
self._data_validity_message_box()
return
if len(stg.fine_sample_profile) == 0:
self._data_validity_message_box()
return
data_choice = self.combobox_acoustic_data_choice\
.currentIndex()
@ -1663,8 +1659,8 @@ class SedimentCalibrationTab(QWidget):
.scaledToHeight(32, Qt.SmoothTransformation)
)
msgBox.setText(
"Please select and valid the find and sand"
+ "sample data with click on 'sample plot' button"
"Please select and valid the sample data with"
+ "click on 'sample plot' button"
)
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
@ -2766,3 +2762,4 @@ class SedimentCalibrationTab(QWidget):
self.lineEdit_slider_FCB.setText(
str(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_frequency_FCB.currentIndex(), self.slider_FCB.value()-1]))

File diff suppressed because it is too large Load Diff

View File

@ -28,13 +28,13 @@ PERCENT_SCREEN_SIZE = 0.85
_translate = QCoreApplication.translate
logging.basicConfig(
level=logging.INFO,
level=logging.DEBUG,
format=('[AcouSed][%(levelname)s] %(message)s')
)
logger = logging.getLogger("acoused")
logger.setLevel(logging.DEBUG)
#logger.setLevel(logging.INFO)
logger = logging.getLogger()
# logger.setLevel(logging.DEBUG)
logger.setLevel(logging.INFO)
class MainApplication(QMainWindow):

View File

@ -1,5 +0,0 @@
@ECHO OFF
start cmd /c test3\Acoused.exe

View File

@ -1,35 +0,0 @@
@ECHO OFF
rem Python environment (-U = update python packages / -r = texte file)
python -m pip install -U -r ..\virtualenv\requirements.txt
rem Build windows version
mkdir acoused_packaging
pyinstaller --name "acoused" ..\main.py -y
rem Icons
mkdir acoused_packaging\icons
copy /y ..\icons\*.png acoused_packaging\icons
rem Logos
mkdir acoused_packaging\logos
copy /y ..\logos\* acoused_packaging\logos
rem Doc
copy /y ..\ABS_calibration_constant_kt.xlsx acoused_packaging
copy /y ..\AcouSed_UserManual.pdf acoused_packaging
copy /y ..\Acoustic_Inversion_theory.pdf acoused_packaging
copy /y ..\Tutorial_AQUAscat_software.pdf acoused_packaging
rem move exe
move /y dist\AcouSed\acoused.exe acoused_packaging
move /y dist\acoused\_internal acoused_packaging
copy debug.bat acoused_packaging
rmdir /s /q build
rmdir /s /q dist
del /q AcouSed.spec
set PATH=%PATH%;C:\Program Files (x86)/7-Zip
7z a -tzip acoused_packaging.zip acoused_packaging

13
requirements.txt Normal file
View File

@ -0,0 +1,13 @@
matplotlib==3.6.3
numpy==1.23.5
pandas==1.5.3
PyQt5==5.15.9
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.0
python-dateutil==2.8.2
scikit-learn==1.2.1
scipy==1.10.0
pyqt-file-list-widget==0.0.1
qtrangeslider==0.1.5
astropy==6.1.7
odfpy==1.4.1

View File

@ -1,45 +0,0 @@
import os
import time
import logging
import traceback
from datetime import datetime, timedelta
from pathlib import Path
from functools import wraps
###########
# LOGGING #
###########
logger = logging.getLogger("acoused")
#########
# WRAPS #
#########
def trace(func):
@wraps(func)
def wrapper(*args, **kwargs):
t = time.time()
head = f"[TRACE]"
logger.debug(
f"{head} Call {func.__module__}." +
f"{func.__qualname__}({args}, {kwargs})"
)
value = func(*args, **kwargs)
t1 = time.time()
logger.debug(
f"{head} Return {func.__module__}." +
f"{func.__qualname__}: {value}"
)
logger.debug(
f"{head}[TIME] {func.__module__}." +
f"{func.__qualname__}: {t1-t} sec"
)
return value
return wrapper

View File

@ -0,0 +1,33 @@
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
pyparsing==3.0.9
pyqt-checkbox-table-widget==0.0.14
PyQt5==5.15.9
PyQt5-Qt5==5.15.2
PyQt5-sip==12.11.0
python-dateutil==2.8.2
pytz==2022.7.1
scikit-learn==1.2.1
scipy==1.10.0
six==1.16.0
threadpoolctl==3.1.0
utm==0.7.0
xlrd==2.0.1
xmltodict==0.13.0
zipp==3.15.0