Start Pierre Antoine - Brahim

dev-brahim
brahim 2025-03-03 12:01:58 +01:00
parent cf4eee9617
commit f78d0fabb1
44 changed files with 1609 additions and 850 deletions

Binary file not shown.

BIN
AcouSed_UserManual.pdf Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,3 +1,26 @@
# ============================================================================== #
# mainwindow.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import settings as stg
@ -277,6 +300,7 @@ class AcousticInversionMethodHighConcentration():
def M_profile_SCC_fine_interpolated(self, sample_depth, M_profile, range_cells, r_bottom):
res = np.zeros((len(range_cells),)) * np.nan
print("range_cells ", range_cells.shape)
l0 = sample_depth
print("l0 = ", l0)
l1 = [l0.index(x) for x in sorted(l0)]
@ -322,6 +346,9 @@ class AcousticInversionMethodHighConcentration():
i += -1
if r_bottom.size != 0:
print("res ", res.shape)
print("range_cells ", len(range_cells))
# print("r_bottom ", len(r_bottom))
res[np.where(range_cells > r_bottom)] = np.nan
loc_point_lin_interp0 = range_cells[np.where((range_cells > l2[0]) & (range_cells < l2[-1]))]

View File

@ -1,68 +1,60 @@
import sys
# ============================================================================== #
# calibration_constant_kt.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
import os
import pandas as pd
from PyQt5.QtGui import QIcon, QPixmap
from PyQt5.QtWidgets import (QWidget, QLabel, QHBoxLayout, QVBoxLayout, QApplication, QMainWindow, QGridLayout,
QDialog, QDialogButtonBox, QPushButton, QTextEdit, QFrame, QTabWidget, QScrollArea,
QLineEdit, QFileDialog)
from PyQt5.QtCore import Qt
# by Brahim MOUDJED #
# ============================================================================== #
import numpy as np
from os import path
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar
from matplotlib.colors import LogNorm, BoundaryNorm
import datetime
import settings as stg
from Translation.constant_string import HORIZONTAL
from settings import depth_cross_section
import pandas as pd
from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QDialog, QTabWidget, QGridLayout, QScrollArea,
QFileDialog, QMessageBox, QLabel)
from PyQt5.QtCore import Qt
class CalibrationConstantKt(QDialog):
icon_folder = (
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/acoused/icons/folder.png")
def __init__(self, parent=None):
super(CalibrationConstantKt, self).__init__(parent)
self.setGeometry(400, 200, 300, 400)
self.setWindowTitle("Calibration constant kt")
self.verticalLayout_Main = QVBoxLayout()
self.setLayout(self.verticalLayout_Main)
self.horizontalLayout_file = QHBoxLayout()
self.verticalLayout_Main.addLayout(self.horizontalLayout_file)
self.pushbutton_file = QPushButton()
self.pushbutton_file.setIcon(QIcon(CalibrationConstantKt.icon_folder))
self.horizontalLayout_file.addWidget(self.pushbutton_file)
# self.pushbutton_file.clicked.connect(self.open_dialog_box)
self.lineEdit_file = QLineEdit()
self.horizontalLayout_file.addWidget(self.lineEdit_file)
self.tab = QTabWidget()
self.verticalLayout_Main.addWidget(self.tab)
# "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/acoused/
self.data_ABS = pd.read_excel("ABS_calibration_constant_kt.xlsx", header=0, sheet_name=None)
self.lineEdit_file.setText("ABS_calibration_constant_kt.xlsx")
try:
self.data_ABS = pd.read_excel("ABS_calibration_constant_kt.xlsx", header=0, sheet_name=None)
print([*self.data_ABS.values()][0].columns[1])
except FileNotFoundError as e:
msgBox = QMessageBox()
msgBox.setWindowTitle("File Not Found Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText("Please check Excel file name for the calibration constant kt \n"
"It should be an excel file named : 'ABS_calibration_constant_kt.xlsx'")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
self.setLayout(self.verticalLayout_Main)
self.load_freq_and_kt_values()
def open_dialog_box(self):
@ -86,12 +78,12 @@ class CalibrationConstantKt(QDialog):
for t_index, t_value in enumerate(list(self.data_ABS.keys())):
exec("self.tab_" + str(t_index) + "= QWidget()")
eval("self.tab.addTab(self.tab_" + str(t_index) + ", '" + str(t_value) + "')")
exec("self.tab_calib_" + str(t_index) + "= QWidget()")
eval("self.tab.addTab(self.tab_calib_" + str(t_index) + ", '" + str(t_value) + "')")
exec("self.verticalLayout_tab_" + str(t_index) + "= QVBoxLayout(self.tab_" + str(t_index) + ")")
exec("self.verticalLayout_tab_" + str(t_index) + "= QVBoxLayout(self.tab_calib_" + str(t_index) + ")")
exec("self.scrollarea_tab_" + str(t_index) + " = QScrollArea(self.tab_" + str(t_index) + ")")
exec("self.scrollarea_tab_" + str(t_index) + " = QScrollArea(self.tab_calib_" + str(t_index) + ")")
eval("self.scrollarea_tab_" + str(t_index) + ".setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)")
eval("self.scrollarea_tab_" + str(t_index) + ".setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)")
eval("self.scrollarea_tab_" + str(t_index) + ".setWidgetResizable(True)")
@ -122,10 +114,10 @@ class CalibrationConstantKt(QDialog):
", " + str(x+1) + ", 1, 1, 1, Qt.AlignCenter)")
if __name__ == "__main__":
app = QApplication(sys.argv)
cal = CalibrationConstantKt()
cal.show()
# sys.exit(app.exec_())
app.exec()
# if __name__ == "__main__":
# app = QApplication(sys.argv)
# cal = CalibrationConstantKt()
# cal.show()
# # sys.exit(app.exec_())
# app.exec()

View File

@ -1,3 +1,26 @@
# ============================================================================== #
# create_table_for_save_as.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import numpy as np
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
import sqlite3
@ -26,8 +49,11 @@ class CreateTableForSaveAs:
self.create_Measure = """ CREATE TABLE Measure(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
acoustic_data INTEGER,
frequency FLOAT,
acoustic_data INTEGER,
Date DATE,
Hour TIME,
frequency FLOAT,
sound_attenuation FLOAT,
kt_read FLOAT,
kt_corrected FLOAT,
NbProfiles FLOAT,
@ -38,20 +64,23 @@ class CreateTableForSaveAs:
NbPingsPerSeconds FLOAT,
NbPingsAveragedPerProfile FLOAT,
GainRx FLOAT,
GainTx FLOAT)
GainTx FLOAT
)
"""
self.create_BSRawData = '''CREATE TABLE BSRawData(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
acoustic_data INTEGER,
time BLOB, depth BLOB, BS_raw_data BLOB,
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
depth_bottom, val_bottom, ind_bottom,
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
BS_raw_data_pre_process_SNR BLOB, BS_raw_data_pre_process_average BLOB,
BS_cross_section_pre_process_SNR BLOB, BS_cross_section_pre_process_average BLOB,
BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB
BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
BS_mean BLOB
)'''
self.create_Settings = '''CREATE TABLE Settings(
@ -60,16 +89,27 @@ class CreateTableForSaveAs:
temperature FLOAT,
tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value FLOAT,
rmin_index FLOAT, rmin_value FLOAT, rmax_index FLOAT, rmax_value FLOAT,
freq_bottom_detection, dept_bottom_detection_min, depth_bottom_detection_max, depth_bottom_detection_1st_int_area,
freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
)'''
self.create_SedimentsFile = """CREATE TABLE SedimentsFile(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
path_fine STRING,
filename_fine STRING
)
"""
ID INTEGER PRIMARY KEY AUTOINCREMENT,
path_fine STRING,
filename_fine STRING,
radius_grain_fine BLOB,
path_sand STRING,
filename_sand STRING,
radius_grain_sand BLOB,
time_column_label STRING,
distance_from_bank_column_label STRING,
depth_column_label STRING,
Ctot_fine_column_label STRING,
D50_fine_column_label STRING,
Ctot_sand_column_label STRING,
D50_sand_column_label STRING
)
"""
self.create_SedimentsData = """CREATE TABLE SedimentsData(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
@ -82,7 +122,17 @@ class CreateTableForSaveAs:
Ctot_fine_per_cent FLOAT,
D50_fine FLOAT,
frac_vol_fine BLOB,
frac_vol_fine_cumul BLOB
frac_vol_fine_cumul BLOB,
sample_sand_name STRING,
sample_sand_index INTEGER,
distance_from_bank_sand FLOAT,
depth_sand FLOAT,
time_sand FLOAT,
Ctot_sand FLOAT,
Ctot_sand_per_cent FLOAT,
D50_sand FLOAT,
frac_vol_sand BLOB,
frac_vol_sand_cumul BLOB
)
"""
@ -148,9 +198,9 @@ class CreateTableForSaveAs:
cur = cnx.cursor()
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++
# --- Table File ---
# ++++++++++++++++++
# +++++++++++++++++++++++++++
# --- Table Acoustic File ---
# +++++++++++++++++++++++++++
start_table_File = time.time()
@ -188,17 +238,21 @@ class CreateTableForSaveAs:
# Execute the CREATE TABLE statement
cur.execute(self.create_Measure)
print("stg.date ", stg.date, "stg.hour ", stg.hour)
# Fill the table Measure
for i in stg.acoustic_data:
for j in range(stg.freq[i].shape[0]):
cur.execute(''' INSERT into Measure(acoustic_data, frequency, kt_read, kt_corrected, NbProfiles,
NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.acoustic_data[i], stg.freq[i][j], stg.kt_read[j], stg.kt_corrected[j],
cur.execute(''' INSERT into Measure(acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected,
NbProfiles, NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx
)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.acoustic_data[i], #stg.date[i], stg.hour[i],
str(stg.date[i].year) + str('-') + str(stg.date[i].month) + str('-') + str(stg.date[i].day),
str(stg.hour[i].hour) + str(':') + str(stg.hour[i].minute),
stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], stg.kt_corrected[j],
stg.nb_profiles[i][j], stg.nb_profiles_per_sec[i][j], stg.nb_cells[i][j],
stg.cell_size[i][j], stg.pulse_length[i][j], stg.nb_pings_per_sec[i][j],
stg.nb_pings_averaged_per_profile[i][j], stg.gain_rx[i][j], stg.gain_tx[i][j]))
@ -223,26 +277,34 @@ class CreateTableForSaveAs:
for i in stg.acoustic_data:
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
time_reshape, depth_reshape, BS_raw_data_reshape,
time_cross_section, depth_cross_section,
BS_cross_section, BS_stream_bed,
depth_bottom, val_bottom, ind_bottom,
time_noise, depth_noise, BS_noise_raw_data,
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
BS_raw_data_pre_process_SNR, BS_raw_data_pre_process_average,
BS_cross_section_pre_process_SNR, BS_cross_section_pre_process_average,
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average,
BS_mean)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.acoustic_data[i], stg.time[i].tobytes(),
stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes(),
stg.time_reshape[i].tobytes(), stg.depth_reshape[i].tobytes(), stg.BS_raw_data_reshape[i].tobytes(),
stg.time_cross_section[i].tobytes(), stg.depth_cross_section[i].tobytes(),
stg.BS_cross_section[i].tobytes(), stg.BS_stream_bed[i].tobytes(),
stg.depth_bottom[i].tobytes(), np.array(stg.val_bottom[i]).tobytes(), np.array(stg.ind_bottom[i]).tobytes(),
stg.time_noise[i].tobytes(), stg.depth_noise[i].tobytes(), stg.BS_noise_raw_data[i].tobytes(),
stg.SNR_raw_data[i].tobytes(), stg.SNR_cross_section[i].tobytes(), stg.SNR_stream_bed[i].tobytes(),
stg.BS_raw_data_pre_process_SNR[i].tobytes(), stg.BS_raw_data_pre_process_average[i].tobytes(),
stg.BS_cross_section_pre_process_SNR[i].tobytes(), stg.BS_cross_section_pre_process_average[i].tobytes(),
stg.BS_stream_bed_pre_process_SNR[i].tobytes(), stg.BS_stream_bed_pre_process_average[i].tobytes()
stg.BS_stream_bed_pre_process_SNR[i].tobytes(), stg.BS_stream_bed_pre_process_average[i].tobytes(),
stg.BS_mean[i].tobytes()
)
)
print("stg.ind_bottom ", stg.ind_bottom[i])
print(np.array([stg.ind_bottom[i]]), np.array(stg.ind_bottom[i]).shape)
# Commit the transaction after executing INSERT.
cnx.commit()
@ -265,12 +327,16 @@ class CreateTableForSaveAs:
cur.execute('''INSERT into Settings(acoustic_data, temperature,
tmin_index, tmin_value, tmax_index, tmax_value,
rmin_index, rmin_value, rmax_index, rmax_value,
SNR_filter_value, Nb_cells_to_average_BS_signal)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
freq_bottom_detection_index, freq_bottom_detection_value,
SNR_filter_value, Nb_cells_to_average_BS_signal
)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.acoustic_data[i], stg.temperature,
stg.tmin[i][0], stg.tmin[i][1], stg.tmax[i][0], stg.tmax[i][1],
stg.rmin[i][0], stg.rmin[i][1], stg.rmax[i][0], stg.rmax[i][1],
stg.SNR_filter_value[i], stg.Nb_cells_to_average_BS_signal[i])
stg.freq_bottom_detection[i][0], stg.freq_bottom_detection[i][1],
stg.SNR_filter_value[i], stg.Nb_cells_to_average_BS_signal[i]
)
)
cnx.commit()
@ -288,8 +354,16 @@ class CreateTableForSaveAs:
cur.execute(self.create_SedimentsFile)
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine) VALUES(?, ?)''',
(stg.path_fine, stg.filename_fine))
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine, radius_grain_fine,
path_sand, filename_sand, radius_grain_sand,
time_column_label, distance_from_bank_column_label,
depth_column_label, Ctot_fine_column_label, D50_fine_column_label,
Ctot_sand_column_label, D50_sand_column_label)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.path_fine, stg.filename_fine, stg.radius_grain_fine.tobytes(),
stg.path_sand, stg.filename_sand, stg.radius_grain_sand.tobytes(),
stg.columns_fine[0], stg.columns_fine[1], stg.columns_fine[2],
stg.columns_fine[3], stg.columns_fine[4], stg.columns_sand[3], stg.columns_sand[4]))
cnx.commit()
@ -308,13 +382,21 @@ class CreateTableForSaveAs:
for f in range(len(stg.sample_fine)):
cur.execute('''INSERT into SedimentsData(sample_fine_name, sample_fine_index, distance_from_bank_fine,
depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine, frac_vol_fine,
frac_vol_fine_cumul)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine,
frac_vol_fine, frac_vol_fine_cumul,
sample_sand_name, sample_sand_index, distance_from_bank_sand,
depth_sand, time_sand, Ctot_sand, Ctot_sand_per_cent, D50_sand,
frac_vol_sand, frac_vol_sand_cumul
)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.sample_fine[f][0] , stg.sample_fine[f][1],
stg.distance_from_bank_fine[f], stg.depth_fine[f], stg.time_fine[f], stg.Ctot_fine[f],
stg.Ctot_fine_per_cent[f], stg.D50_fine[f],
stg.frac_vol_fine[f].tobytes(), stg.frac_vol_fine_cumul[f].tobytes()))
stg.frac_vol_fine[f].tobytes(), stg.frac_vol_fine_cumul[f].tobytes(),
stg.sample_sand[f][0], stg.sample_sand[f][1],
stg.distance_from_bank_sand[f], stg.depth_sand[f], stg.time_sand[f], stg.Ctot_sand[f],
stg.Ctot_sand_per_cent[f], stg.D50_sand[f],
stg.frac_vol_sand[f].tobytes(), stg.frac_vol_sand_cumul[f].tobytes()))
cnx.commit()

View File

@ -1,112 +1,370 @@
# ============================================================================== #
# read_table_for_open.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import sys
import numpy as np
from PyQt5.QtWidgets import QFileDialog, QApplication
from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget, QTabWidget
import sqlite3
from os import path, chdir
import settings as stg
from settings import BS_raw_data, acoustic_data
from View.acoustic_data_tab import AcousticDataTab
class ReadTableForOpen:
def __init__(self):
self.open_file_dialog()
chdir(stg.dirname_open)
self.sql_file_to_open = open(stg.filename_open)
self.read_table()
# self.reshape_variables()
pass
def open_file_dialog(self):
name = QFileDialog.getOpenFileName(caption="Open Acoused file", directory="", filter="Acoused file (*.acd)")
name = QFileDialog.getOpenFileName(caption="Open Acoused file", directory="", filter="Acoused file (*.acd)",
options=QFileDialog.DontUseNativeDialog)
if name:
stg.dirname_open = path.dirname(name[0])
stg.filename_open = path.basename(name[0])
chdir(stg.dirname_open)
self.sql_file_to_open = open(stg.filename_open)
self.read_table()
def read_table(self):
stg.read_table_trigger = 1
# connexion to File db
cnx = sqlite3.connect(stg.filename_open)
# Create database cursor to execute SQL statements and fetch results from SQL queries.
cur = cnx.cursor()
query = '''SELECT acoustic_data, acoustic_file FROM File'''
data = cur.execute(query).fetchall()
stg.acoustic_data, stg.filename_BS_raw_data = [x[0] for x in data], [y[1] for y in data]
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++++++++
# --- Table Acoustic File ---
# +++++++++++++++++++++++++++
for i in stg.acoustic_data:
query0 = f'''SELECT acoustic_data FROM AcousticFile'''
data0 = cur.execute(query0).fetchall()
print("data0 ", data0)
query1 = f'''SELECT frequency, kt, NbProfiles, NbProfilesPerSeconds, "
f"NbCells, CellSize, PulseLength, NbPingsPerSeconds, "
f"NbPingsAveragedPerProfile, GainRx, GainTx
FROM Measure WHERE (acoustic_data = {i})'''
stg.acoustic_data = [x[0] for x in data0]
print("stg.acoustic_data ", stg.acoustic_data)
for k in range(len(stg.acoustic_data)):
print("hello")
query = f'''SELECT acoustic_data, acoustic_file, ABS_name, path_BS_noise_data, filename_BS_noise_data,
noise_method, noise_value, data_preprocessed FROM AcousticFile WHERE (acoustic_data = {k})'''
data = cur.execute(query).fetchall()
print("data acoustic file", data)
stg.filename_BS_raw_data.append([str(y[1]) + '.aqa' for y in data][0])
stg.ABS_name.append([z[2] for z in data][0])
stg.path_BS_noise_data.append([z[3] for z in data][0])
stg.filename_BS_noise_data.append([z[4] for z in data][0])
stg.noise_method.append([z[5] for z in data][0])
stg.noise_value.append([z[6] for z in data][0])
stg.data_preprocessed.append([z[7] for z in data][0])
print("data acoustic file ", stg.filename_BS_raw_data, stg.ABS_name, stg.path_BS_noise_data, stg.filename_BS_noise_data,
stg.noise_method, stg.noise_value, stg.data_preprocessed)
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++
# --- Table Measure ---
# +++++++++++++++++++++
stg.date = [0]*len(stg.acoustic_data)
stg.hour = [0]*len(stg.acoustic_data)
for i in range(len(stg.acoustic_data)):
print("i = ", i)
query1 = f'''SELECT acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles,
NbProfilesPerSeconds, NbCells, CellSize, PulseLength, NbPingsPerSeconds, NbPingsAveragedPerProfile,
GainRx, GainTx FROM Measure WHERE (acoustic_data = {i})'''
data1 = cur.execute(query1).fetchall()
# print(data1)
# print([x[0] for x in data1])
stg.freq.append([x[0] for x in data1])
stg.kt.append([x[1] for x in data1])
stg.nb_profiles.append([x[2] for x in data1])
stg.nb_profiles_per_sec.append([x[3] for x in data1])
stg.nb_cells.append([x[4] for x in data1])
stg.cell_size.append([x[5] for x in data1])
stg.pulse_length.append([x[6] for x in data1])
stg.nb_pings_per_sec.append([x[7] for x in data1])
stg.nb_pings_averaged_per_profile.append([x[8] for x in data1])
stg.gain_rx.append([x[9] for x in data1])
stg.gain_tx.append([x[10] for x in data1])
# for f_ind, f_val in enumerate(stg.freq[i]):
#
# exec("query2 = '''SELECT time_" + str(int(f_val)) + ", depth_" + str(int(f_val)) + ", BS_raw_data_" + str(int(f_val)) +
# " FROM BSRawData_" + str(int(i)) + " WHERE (acoustic_data = " + str(i) + ") ''' ")
# exec("data2 = cur.execute(query2).fetchall()")
# # print(eval("data2"))
#
# if f_ind == 0:
# time_reshape_temp = np.array([[x[0] for x in eval("data2")]])
# # print("1 time_reshape_temp.shape ", time_reshape_temp.shape)
# depth_reshape_temp = np.array([[x[1] for x in eval("data2")]])
# BS_raw_data_reshape_temp = np.array([[x[2] for x in eval("data2")]])
# else:
# time_reshape_temp = np.insert(time_reshape_temp, f_ind, [x[0] for x in eval("data2")], axis=0)
# # print("2 time_reshape_temp.shape ", time_reshape_temp.shape)
# depth_reshape_temp = np.insert(depth_reshape_temp, f_ind, [x[1] for x in eval("data2")], axis=0)
# BS_raw_data_reshape_temp = np.insert(BS_raw_data_reshape_temp, f_ind, [x[1] for x in eval("data2")], axis=0)
#
# stg.time_reshape.append(time_reshape_temp.transpose())
# # print(len(stg.time_reshape))
# # print(stg.time_reshape[i].shape)
# stg.depth_reshape.append(depth_reshape_temp.transpose())
# stg.BS_raw_data_reshape.append(BS_raw_data_reshape_temp.transpose())
print("--------------------------------------")
print("data1 ", data1)
query2 = f'''SELECT acoustic_data, time, depth, BS_raw_data FROM BSRawData WHERE (acoustic_data = {i})'''
stg.date[i] = data1[0][1]
stg.hour[i] = data1[0][2]
stg.freq.append(np.array([x[3] for x in data1]))
stg.freq_text.append([str(x[3]*1e-6) + 'MHz' for x in data1])
stg.water_attenuation.append([x[4] for x in data1])
stg.kt_read.append([x[5] for x in data1])
stg.kt_corrected = [x[6] for x in data1]
stg.nb_profiles.append([x[7] for x in data1])
stg.nb_profiles_per_sec.append([x[8] for x in data1])
stg.nb_cells.append([x[9] for x in data1])
stg.cell_size.append([x[10] for x in data1])
stg.pulse_length.append([x[11] for x in data1])
stg.nb_pings_per_sec.append([x[12] for x in data1])
stg.nb_pings_averaged_per_profile.append([x[13] for x in data1])
stg.gain_rx.append([x[14] for x in data1])
stg.gain_tx.append([x[15] for x in data1])
print(stg.acoustic_data, stg.freq, stg.water_attenuation, stg.kt_read, stg.kt_corrected, 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.gain_rx, stg.gain_tx)
print(stg.date)
print(stg.hour)
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++++
# --- Table BSRawData ---
# ++++++++++++++++++++++
print("len stg.acoustic_data ", len(stg.acoustic_data))
for j in range(len(stg.acoustic_data)):
print(f"j = {j}")
query2 = f'''SELECT acoustic_data, time, depth, BS_raw_data,
time_reshape, depth_reshape, BS_raw_data_reshape,
time_cross_section, depth_cross_section,
BS_cross_section, BS_stream_bed,
depth_bottom, val_bottom, ind_bottom,
time_noise, depth_noise, BS_noise_raw_data,
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
BS_raw_data_pre_process_SNR, BS_raw_data_pre_process_average,
BS_cross_section_pre_process_SNR, BS_cross_section_pre_process_average,
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average, BS_mean
FROM BSRawData WHERE (acoustic_data = {j})'''
data2 = cur.execute(query2).fetchall()
print("len(data2) ", len(data2[0]))
# print("data2 : ", data2)
# data2_retreived = np.frombuffer(data2[0][1], dtype=np.float64)
# print("", data2_retreived)
print("len data2 ", len(data2))
stg.time.append(np.frombuffer(data2[0][1], dtype=np.float64).reshape((len(stg.freq[i]), -1)))
print(stg.time[0].shape)
stg.time.append(np.frombuffer(data2[0][1], dtype=np.float64).reshape((stg.freq[j].shape[0], -1)))
print("stg.time[0].shape ", stg.time[j].shape, np.frombuffer(data2[0][1], dtype=np.float64).shape)
print(stg.time)
stg.depth.append(np.frombuffer(data2[0][2], dtype=np.float64).reshape(len(stg.freq[i]), -1))
print(stg.depth[0].shape)
stg.depth.append(np.frombuffer(data2[0][2], dtype=np.float64).reshape((stg.freq[j].shape[0], -1)))
print("stg.depth[0].shape ", stg.depth[j].shape)
print(stg.depth)
stg.BS_raw_data.append(np.frombuffer(data2[0][3], dtype=np.float64))
stg.BS_raw_data.append(np.frombuffer(data2[0][3], dtype=np.float64).reshape((stg.freq[j].shape[0], stg.depth[j].shape[1], stg.time[j].shape[1])))
print("BS_raw_data ", stg.BS_raw_data[j].shape)
stg.time_reshape.append(np.frombuffer(data2[0][4], dtype=np.float64).reshape((-1, stg.freq[j].shape[0])))
print("stg.time_reshape[0].shape ", stg.time_reshape[j].shape)
stg.depth_reshape.append(np.frombuffer(data2[0][5], dtype=np.float64).reshape((-1, stg.freq[j].shape[0])))
stg.BS_raw_data_reshape.append(np.frombuffer(data2[0][6], dtype=np.float64).reshape((-1, stg.freq[j].shape[0])))
print("time cross section ", stg.time_cross_section, stg.time_cross_section == [])
# time_reshape_temp = np.insert(time_reshape_temp, time_reshape_temp.shape[0], [x[0] for x in eval("data2")], axis=0)
# stg.depth_reshape.append([x[2] for x in data2])
# stg.BS_raw_data_reshape.append([x[3] for x in data2])
print("np.frombuffer(data2[0][9], dtype=np.float64) ", np.frombuffer(data2[0][9], dtype=np.float64))
if len(np.frombuffer(data2[0][9], dtype=np.float64)) == 0:
print("Je suis là")
stg.time_cross_section.append(np.array([]))
stg.depth_cross_section.append(np.array([]))
stg.BS_cross_section.append(np.array([]))
else:
print("Je suis ici")
print(stg.freq[j].shape)
print(np.frombuffer(data2[0][7], dtype=np.float64).shape)
stg.time_cross_section.append(np.frombuffer(data2[0][7], dtype=np.float64).reshape((stg.freq[j].shape[0], -1)))
print("time cross section ", stg.time_cross_section, stg.time_cross_section[j].shape)
stg.depth_cross_section.append(np.frombuffer(data2[0][8], dtype=np.float64).reshape((stg.freq[j].shape[0], -1)))
print("depth cross section ", stg.depth_cross_section, stg.depth_cross_section[j].shape)
stg.BS_cross_section.append(np.frombuffer(data2[0][9], dtype=np.float64).reshape(
(stg.freq[j].shape[0], stg.depth_cross_section[j].shape[1], stg.time_cross_section[j].shape[1])))
if len(np.frombuffer(data2[0][10], dtype=np.float64)) == 0:
stg.BS_stream_bed.append(np.array([]))
else:
stg.BS_stream_bed.append(np.frombuffer(data2[0][10], dtype=np.float64).reshape(
(stg.freq[j].shape[0], stg.depth_cross_section[j].shape[1], stg.time_cross_section[j].shape[1])))
if len(np.frombuffer(data2[0][11], dtype=np.float64)) == 0:
stg.depth_bottom.append(np.array([]))
stg.val_bottom.append([])
stg.ind_bottom.append([])
else:
stg.depth_bottom.append(np.frombuffer(data2[0][11], dtype=np.float64))
stg.val_bottom.append(np.frombuffer(data2[0][12], dtype=np.float64).tolist())
stg.ind_bottom.append(np.frombuffer(data2[0][13], dtype=np.float64).tolist())
print("stg.depth_bottom ", stg.depth_bottom)
print("stg.val_bottom ", stg.val_bottom)
print("stg.ind_bottom ", stg.ind_bottom)
if len(np.frombuffer(data2[0][14], dtype=np.float64)) == 0:
stg.time_noise.append(np.array([]))
stg.depth_noise.append(np.array([]))
stg.BS_noise_raw_data.append(np.array([]))
else:
stg.time_noise.append(np.frombuffer(data2[0][14], dtype=np.float64).reshape((stg.freq[j].shape[0], -1)))
stg.depth_noise.append(np.frombuffer(data2[0][15], dtype=np.float64).reshape((stg.freq[j].shape[0], -1)))
stg.BS_noise_raw_data.append(np.frombuffer(data2[0][16], dtype=np.float64).reshape(
(stg.freq[j].shape[0], stg.depth_noise[j].shape[1], stg.time_noise[j].shape[1])))
if len(np.frombuffer(data2[0][17], dtype=np.float64)) == 0:
stg.SNR_raw_data.append(np.array([]))
else:
stg.SNR_raw_data.append(np.frombuffer(data2[0][17], dtype=np.float64).reshape(stg.BS_raw_data[j].shape))
if len(np.frombuffer(data2[0][18], dtype=np.float64)) == 0:
stg.SNR_cross_section.append(np.array([]))
else:
stg.SNR_cross_section.append(np.frombuffer(data2[0][18], dtype=np.float64).reshape(stg.BS_cross_section[j].shape))
if len(np.frombuffer(data2[0][19], dtype=np.float64)) == 0:
stg.SNR_stream_bed.append(np.array([]))
else:
stg.SNR_stream_bed.append(np.frombuffer(data2[0][19], dtype=np.float64).reshape(stg.BS_stream_bed[j].shape))
if len(np.frombuffer(data2[0][20], dtype=np.float64)) == 0:
stg.BS_raw_data_pre_process_SNR.append(np.array([]))
else:
stg.BS_raw_data_pre_process_SNR.append(np.frombuffer(data2[0][20], dtype=np.float64).reshape(stg.BS_raw_data[j].shape))
if len(np.frombuffer(data2[0][21], dtype=np.float64)) == 0:
stg.BS_raw_data_pre_process_average.append(np.array([]))
else:
stg.BS_raw_data_pre_process_average.append(np.frombuffer(data2[0][21], dtype=np.float64).reshape(stg.BS_raw_data[j].shape))
if len(np.frombuffer(data2[0][22], dtype=np.float64)) == 0:
stg.BS_cross_section_pre_process_SNR.append(np.array([]))
else:
stg.BS_cross_section_pre_process_SNR.append(np.frombuffer(data2[0][22], dtype=np.float64).reshape(stg.BS_cross_section[j].shape))
if len(np.frombuffer(data2[0][23], dtype=np.float64)) == 0:
stg.BS_cross_section_pre_process_average.append(np.array([]))
else:
stg.BS_cross_section_pre_process_average.append(np.frombuffer(data2[0][23], dtype=np.float64).reshape(stg.BS_cross_section[j].shape))
if len(np.frombuffer(data2[0][24], dtype=np.float64)) == 0:
stg.BS_stream_bed_pre_process_SNR.append(np.array([]))
else:
stg.BS_stream_bed_pre_process_SNR.append(np.frombuffer(data2[0][24], dtype=np.float64).reshape(stg.BS_stream_bed[j].shape))
if len(np.frombuffer(data2[0][25], dtype=np.float64)) == 0:
stg.BS_stream_bed_pre_process_average.append(np.array([]))
else:
stg.BS_stream_bed_pre_process_average.append(np.frombuffer(data2[0][25], dtype=np.float64).reshape(stg.BS_stream_bed[j].shape))
if len(np.frombuffer(data2[0][26], dtype=np.float64)) == 0:
stg.BS_mean.append(np.array([]))
else:
stg.BS_mean.append(np.frombuffer(data2[0][26], dtype=np.float64).reshape((stg.freq[j].shape[0], -1)))
print(stg.BS_mean[j].shape)
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++++
# --- Table Settings ---
# +++++++++++++++++++++++
for s in range(len(stg.acoustic_data)):
query3 = f'''SELECT acoustic_data, temperature,
tmin_index, tmin_value, tmax_index, tmax_value,
rmin_index, rmin_value, rmax_index, rmax_value,
freq_bottom_detection_index, freq_bottom_detection_value,
SNR_filter_value, Nb_cells_to_average_BS_signal
FROM Settings WHERE (acoustic_data = {s})'''
data3 = cur.execute(query3).fetchall()
stg.temperature = [x[1] for x in data3][0]
stg.tmin.append([(x[2], x[3]) for x in data3])
stg.tmax.append([(x[4], x[5]) for x in data3])
stg.rmin.append([(x[6], x[7]) for x in data3])
stg.rmax.append([(x[8], x[9]) for x in data3])
stg.freq_bottom_detection.append([(x[10], x[11]) for x in data3])
stg.SNR_filter_value.append([x[12] for x in data3])
stg.Nb_cells_to_average_BS_signal.append([x[13] for x in data3])
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++++++++
# --- Table Sediment File ---
# +++++++++++++++++++++++++++
query4 = f'''SELECT path_fine, filename_fine, radius_grain_fine, path_sand, filename_sand, radius_grain_sand,
time_column_label, distance_from_bank_column_label, depth_column_label,
Ctot_fine_column_label, D50_fine_column_label,
Ctot_sand_column_label, D50_sand_column_label
from SedimentsFile'''
data4 = cur.execute(query4).fetchall()
print("data4 ", data4)
stg.path_fine = data4[0][0]
stg.filename_fine = data4[0][1]
stg.radius_grain_fine = np.array(np.frombuffer(data4[0][2], dtype=np.float64))
stg.path_sand = data4[0][3]
stg.filename_sand = data4[0][4]
stg.radius_grain_sand = np.array(np.frombuffer(data4[0][5], dtype=np.float64))
stg.columns_fine = [data4[0][6], data4[0][7], data4[0][8], data4[0][9], data4[0][10]] + list(stg.radius_grain_fine)
stg.columns_sand = [data4[0][6], data4[0][7], data4[0][8], data4[0][11], data4[0][12]] + list(stg.radius_grain_sand)
print("sediment file : ", stg.path_fine, stg.filename_fine, stg.path_sand, stg.filename_sand)
print(stg.radius_grain_fine, stg.radius_grain_sand)
print('stg.columns_fine ', stg.columns_fine)
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++++++++
# --- Table Sediment Data ---
# +++++++++++++++++++++++++++
query5 = f'''SELECT sample_fine_name, sample_fine_index, distance_from_bank_fine, depth_fine, time_fine,
Ctot_fine, Ctot_fine_per_cent, D50_fine, frac_vol_fine, frac_vol_fine_cumul,
sample_sand_name, sample_sand_index, distance_from_bank_sand, depth_sand, time_sand,
Ctot_sand, Ctot_sand_per_cent, D50_sand, frac_vol_sand, frac_vol_sand_cumul
from SedimentsData'''
data5 = cur.execute(query5).fetchall()
stg.frac_vol_fine = []
stg.frac_vol_fine_cumul = []
stg.frac_vol_sand = []
stg.frac_vol_sand_cumul = []
for f in range(len(data5)):
stg.sample_fine.append((data5[f][0], data5[f][1]))
stg.distance_from_bank_fine.append(data5[f][2])
stg.depth_fine.append(data5[f][3])
stg.time_fine.append(data5[f][4])
stg.Ctot_fine.append(data5[f][5])
stg.Ctot_fine_per_cent.append(data5[f][6])
stg.D50_fine.append(data5[f][7])
print("np.frombuffer(data4[f][8], dtype=np.float64) ", np.frombuffer(data5[f][8], dtype=np.float64))
stg.frac_vol_fine.append(np.frombuffer(data5[f][8], dtype=np.float64))
stg.frac_vol_fine_cumul.append(np.frombuffer(data5[f][9], dtype=np.float64))
stg.sample_sand.append((data5[f][10], data5[f][11]))
stg.distance_from_bank_sand.append(data5[f][12])
stg.depth_sand.append(data5[f][13])
stg.time_sand.append(data5[f][14])
stg.Ctot_sand.append(data5[f][15])
stg.Ctot_sand_per_cent.append(data5[f][16])
stg.D50_sand.append(data5[f][17])
stg.frac_vol_sand.append(np.frombuffer(data5[f][18], dtype=np.float64))
stg.frac_vol_sand_cumul.append(np.frombuffer(data5[f][19], dtype=np.float64))
stg.frac_vol_fine = np.array(stg.frac_vol_fine)
stg.frac_vol_fine_cumul = np.array(stg.frac_vol_fine_cumul)
stg.frac_vol_sand = np.array(stg.frac_vol_sand)
stg.frac_vol_sand_cumul = np.array(stg.frac_vol_sand_cumul)
# print("data 4 : ", len(data4), data4)
print('data 5 :')
print(stg.Ctot_fine, stg.sample_sand)
print(type(stg.frac_vol_fine_cumul), stg.frac_vol_fine_cumul)
# query = '''SELECT acoustic_file FROM File'''
# cur.execute(query)
# stg.acoustic_data = cur.fetchall()
# Close database cursor
cur.close()
@ -114,6 +372,27 @@ class ReadTableForOpen:
# Close database connection
cnx.close()
print("read table finished")
def fill_acoustic_data_tab(self):
print("start fill acoustic data tab")
# tab_adt = AcousticDataTab(self.master_widget)
print("1 AcousticDataTab ", id(AcousticDataTab))
print("tab_adt.combobox_ABS_system_choice ", self.tab.combobox_ABS_system_choice)
self.tab.combobox_ABS_system_choice.editTextChanged.connect(self.tab.ABS_system_choice)
if stg.ABS_name[0] == "AQUAscat":
self.tab.combobox_ABS_system_choice.setCurrentText(stg.ABS_name[0])
print("combobox_ABS_system_choice.setCurrentIndex(1)", self.tab.combobox_ABS_system_choice.itemText(1),
self.tab.combobox_ABS_system_choice.itemText(2))
else:
self.tab.combobox_ABS_system_choice.setCurrentText(stg.ABS_name[0])
self.tab.plot_backscattered_acoustic_signal_recording()
# app = QApplication(sys.argv)
# sys.exit(app.exec_())
def reshape_variables(self):
for i in stg.acoustic_data:
@ -150,8 +429,3 @@ class ReadTableForOpen:
stg.BS_raw_data.append(np.reshape(stg.BS_raw_data_reshape[i],
(len(stg.freq[i]), stg.depth[i].shape[1], stg.time[i].shape[1])))

View File

@ -161,7 +161,7 @@ def translate_key(raw_key, _type="data"):
#if translated_key == None:
# print("delete %s"%raw_key)
print(f"translated_key : {translated_key}")
# print(f"translated_key : {translated_key}")
return translated_key
def translate_paramdict(param_dict):

View File

@ -1,3 +1,26 @@
# ============================================================================== #
# update_table_for_save.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import numpy as np
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
import sqlite3
@ -82,8 +105,11 @@ class UpdateTableForSave:
cur.execute("DROP TABLE if exists Measure")
cur.execute("""CREATE TABLE Measure(ID INTEGER PRIMARY KEY AUTOINCREMENT,
acoustic_data INTEGER,
frequency FLOAT,
acoustic_data INTEGER,
Date STRING,
Hour STRING,
frequency FLOAT,
sound_attenuation FLOAT,
kt_read FLOAT,
kt_corrected FLOAT,
NbProfiles FLOAT,
@ -94,21 +120,26 @@ class UpdateTableForSave:
NbPingsPerSeconds FLOAT,
NbPingsAveragedPerProfile FLOAT,
GainRx FLOAT,
GainTx FLOAT)
GainTx FLOAT
)
""")
# Fill the table Measure
for i in stg.acoustic_data:
for j in range(stg.freq[i].shape[0]):
cur.execute(''' INSERT into Measure(acoustic_data, frequency, kt_read, kt_corrected, NbProfiles,
cur.execute(''' INSERT into Measure(acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles,
NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.acoustic_data[i], stg.freq[i][j], stg.kt_read[j], stg.kt_corrected[j],
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx,
)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.acoustic_data[i], stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], stg.kt_corrected[j],
stg.nb_profiles[i][j], stg.nb_profiles_per_sec[i][j], stg.nb_cells[i][j],
stg.cell_size[i][j], stg.pulse_length[i][j], stg.nb_pings_per_sec[i][j],
stg.nb_pings_averaged_per_profile[i][j], stg.gain_rx[i][j], stg.gain_tx[i][j]))
stg.nb_pings_averaged_per_profile[i][j], stg.gain_rx[i][j], stg.gain_tx[i][j],
str(stg.date[i].year) + str('-') + str(stg.date[i].month) + str('-') + str(stg.date[i].day),
str(stg.hour[i].hour) + str(':') + str(stg.hour[i].minute)
))
# Commit the transaction after executing INSERT.
cnx.commit()
@ -126,30 +157,38 @@ class UpdateTableForSave:
cur.execute('''CREATE TABLE BSRawData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
acoustic_data INTEGER,
time BLOB, depth BLOB, BS_raw_data BLOB,
time BLOB, depth BLOB, BS_raw_data BLOB,
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
depth_bottom, val_bottom, ind_bottom,
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
BS_raw_data_pre_process_SNR BLOB, BS_raw_data_pre_process_average BLOB,
BS_cross_section_pre_process_SNR BLOB, BS_cross_section_pre_process_average BLOB,
BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB
BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
BS_mean BLOB
)''')
for i in stg.acoustic_data:
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
time_reshape, depth_reshape, BS_raw_data_reshape,
time_cross_section, depth_cross_section,
BS_cross_section, BS_stream_bed,
depth_bottom, val_bottom, ind_bottom,
time_noise, depth_noise, BS_noise_raw_data,
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
BS_raw_data_pre_process_SNR, BS_raw_data_pre_process_average,
BS_cross_section_pre_process_SNR, BS_cross_section_pre_process_average,
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average,
BS_mean)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.acoustic_data[i], stg.time[i].tobytes(), stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes(),
stg.time_reshape[i].tobytes(), stg.depth_reshape[i].tobytes(), stg.BS_raw_data_reshape[i].tobytes(),
stg.time_cross_section[i].tobytes(), stg.depth_cross_section[i].tobytes(), stg.BS_cross_section[i].tobytes(),
stg.BS_stream_bed[i].tobytes(), stg.time_noise[i].tobytes(), stg.depth_noise[i].tobytes(),
stg.BS_stream_bed[i].tobytes(),
stg.depth_bottom[i].tobytes(), stg.val_bottom[i].tobytes(), np.array(stg.ind_bottom[i]).tobytes(),
stg.time_noise[i].tobytes(), stg.depth_noise[i].tobytes(),
stg.BS_noise_raw_data[i].tobytes(),
stg.SNR_raw_data[i].tobytes(), stg.SNR_cross_section[i].tobytes(),
stg.SNR_stream_bed[i].tobytes(),
@ -158,7 +197,8 @@ class UpdateTableForSave:
stg.BS_cross_section_pre_process_SNR[i].tobytes(),
stg.BS_cross_section_pre_process_average[i].tobytes(),
stg.BS_stream_bed_pre_process_SNR[i].tobytes(),
stg.BS_stream_bed_pre_process_average[i].tobytes()
stg.BS_stream_bed_pre_process_average[i].tobytes(),
stg.BS_mean[i].tobytes()
)
)
@ -180,7 +220,7 @@ class UpdateTableForSave:
temperature FLOAT,
tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value FLOAT,
rmin_index FLOAT, rmin_value FLOAT, rmax_index FLOAT, rmax_value FLOAT,
freq_bottom_detection, dept_bottom_detection_min, depth_bottom_detection_max, depth_bottom_detection_1st_int_area,
freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
)'''
)
@ -189,11 +229,13 @@ class UpdateTableForSave:
cur.execute('''INSERT into Settings(acoustic_data, temperature,
tmin_index, tmin_value, tmax_index, tmax_value,
rmin_index, rmin_value, rmax_index, rmax_value,
freq_bottom_detection_index, freq_bottom_detection_value,
SNR_filter_value, Nb_cells_to_average_BS_signal)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.acoustic_data[i], stg.temperature,
stg.tmin[i][0], stg.tmin[i][1], stg.tmax[i][0], stg.tmax[i][1],
stg.rmin[i][0], stg.rmin[i][1], stg.rmax[i][0], stg.rmax[i][1],
stg.freq_bottom_detection[i][0], stg.freq_bottom_detection[i][1],
stg.SNR_filter_value[i], stg.Nb_cells_to_average_BS_signal[i])
)
@ -211,13 +253,33 @@ class UpdateTableForSave:
cur.execute("DROP TABLE if exists SedimentsFile")
cur.execute("""CREATE TABLE SedimentsFile(ID INTEGER PRIMARY KEY AUTOINCREMENT,
path_fine STRING,
filename_fine STRING
)"""
path_fine STRING,
filename_fine STRING,
radius_grain_fine BLOB,
path_sand STRING,
filename_sand STRING,
radius_grain_sand BLOB,
time_column_label STRING,
distance_from_bank_column_label STRING,
depth_column_label STRING,
Ctot_fine_column_label STRING,
D50_fine_column_label STRING,
Ctot_sand_column_label STRING,
D50_sand_column_label STRING
)"""
)
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine) VALUES(?, ?)''',
(stg.path_fine, stg.filename_fine))
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine, radius_grain_fine,
path_sand, filename_sand, radius_grain_sand,
time_column_label, distance_from_bank_column_label,
depth_column_label, Ctot_fine_column_label,
D50_fine_column_label, Ctot_sand_column_label,
D50_sand_column_label)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.path_fine, stg.filename_fine, stg.radius_grain_fine.tobytes(),
stg.path_sand, stg.filename_sand, stg.radius_grain_sand.tobytes(),
stg.columns_fine[0], stg.columns_fine[1], stg.columns_fine[2],
stg.columns_fine[3], stg.columns_fine[4], stg.columns_sand[3], stg.columns_sand[4]))
cnx.commit()
@ -242,19 +304,37 @@ class UpdateTableForSave:
Ctot_fine_per_cent FLOAT,
D50_fine FLOAT,
frac_vol_fine BLOB,
frac_vol_fine_cumul BLOB
frac_vol_fine_cumul BLOB,
sample_sand_name STRING,
sample_sand_index INTEGER,
distance_from_bank_sand FLOAT,
depth_sand FLOAT,
time_sand FLOAT,
Ctot_sand FLOAT,
Ctot_sand_per_cent FLOAT,
D50_sand FLOAT,
frac_vol_sand BLOB,
frac_vol_sand_cumul BLOB
)"""
)
for f in range(len(stg.sample_fine)):
cur.execute('''INSERT into SedimentsData(sample_fine_name, sample_fine_index, distance_from_bank_fine,
depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine, frac_vol_fine,
frac_vol_fine_cumul)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
frac_vol_fine_cumul,
sample_sand_name, sample_sand_index, distance_from_bank_sand,
depth_sand, time_sand, Ctot_sand, Ctot_sand_per_cent, D50_sand, frac_vol_sand,
frac_vol_sand_cumul)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(stg.sample_fine[f][0], stg.sample_fine[f][1],
stg.distance_from_bank_fine[f], stg.depth_fine[f], stg.time_fine[f], stg.Ctot_fine[f],
stg.Ctot_fine_per_cent[f], stg.D50_fine[f],
stg.frac_vol_fine[f].tobytes(), stg.frac_vol_fine_cumul[f].tobytes()))
stg.frac_vol_fine[f].tobytes(), stg.frac_vol_fine_cumul[f].tobytes(),
stg.sample_sand[f][0], stg.sample_sand[f][1],
stg.distance_from_bank_sand[f], stg.depth_sand[f], stg.time_sand[f], stg.Ctot_sand[f],
stg.Ctot_sand_per_cent[f], stg.D50_sand[f],
stg.frac_vol_sand[f].tobytes(), stg.frac_vol_sand_cumul[f].tobytes()
))
cnx.commit()

Binary file not shown.

View File

@ -1,12 +1,28 @@
import sys
# ============================================================================== #
# about_window.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
import sys
from PyQt5.QtGui import QIcon, QPixmap, QFont
from PyQt5.QtWidgets import (QWidget, QLabel, QHBoxLayout, QVBoxLayout, QApplication, QMainWindow, QGridLayout,
QDialog, QDialogButtonBox, QPushButton, QTextEdit, QFrame)
QDialog, QDialogButtonBox, QPushButton, QTextEdit, QFrame, QLineEdit)
from PyQt5.QtCore import Qt
from datetime import date
from Translation.constant_string import HORIZONTAL
class AboutWindow(QDialog):
@ -15,7 +31,7 @@ class AboutWindow(QDialog):
super().__init__()
self.logo_path = "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/acoused/Logo/"
self.logo_path = "./Logo"
self.logo_AcouSed = QPixmap(self.logo_path + "/" + "Logo_AcouSed_AboutAcouSedWindow.png")
self.logo_AcouSed.scaled(16, 16, Qt.KeepAspectRatio, Qt.SmoothTransformation)
@ -25,8 +41,6 @@ class AboutWindow(QDialog):
self.setWindowTitle("About AcouSed")
# self.buttonBox = QDialogButtonBox.close
self.verticalLayout_Main = QVBoxLayout()
self.setLayout(self.verticalLayout_Main)
@ -40,12 +54,12 @@ class AboutWindow(QDialog):
self.gridLayout.addWidget(self.label_logo_AcouSed, 0, 0, 3, 1, Qt.AlignCenter)
self.label_acoused = QLabel()
self.label_acoused.setText("Acoused 1.15")
self.label_acoused.setText("Acoused 2.0")
self.label_acoused.setFont(QFont("Ubuntu", 14))
self.gridLayout.addWidget(self.label_acoused, 0, 1, 1, 1, Qt.AlignCenter)
self.label_date = QLabel()
self.label_date.setText("2024.11.04")
self.label_date.setText("2025.01.01")
self.label_date.setFont(QFont("Ubuntu", 12))
self.gridLayout.addWidget(self.label_date, 1, 1, 1, 1, Qt.AlignCenter)
@ -53,14 +67,10 @@ class AboutWindow(QDialog):
self.label_logo_INRAE.setPixmap(self.logo_INRAE.scaledToHeight(42, Qt.SmoothTransformation))
self.gridLayout.addWidget(self.label_logo_INRAE, 2, 1, 1, 1, Qt.AlignCenter)
# self.label_date = QLabel()
# self.label_date.setText(f"")
# self.verticalLayout_AcouSed_info.addWidget(self.label_date)
#
# self.label_copyright = QLabel()
# self.label_copyright.setText(f"")
# self.verticalLayout_AcouSed_info.addWidget(self.label_copyright)
# print("je suis la")
self.label_contact = QLabel()
self.label_contact.setText("Contact : celine.berni@inrae.fr \n"
" jerome.lecoz@inrae.fr")
self.gridLayout.addWidget(self.label_contact, 3, 1, 1, 1, Qt.AlignLeft)
# ----------------------------------------------------------
@ -114,7 +124,7 @@ class Licence(QDialog):
self.setWindowTitle("Licence")
self.setGeometry(500, 300, 400, 400)
self.setGeometry(500, 300, 450, 300)
self.verticalLayout = QVBoxLayout()
self.setLayout(self.verticalLayout)
@ -122,11 +132,18 @@ class Licence(QDialog):
self.textEdit = QTextEdit()
self.verticalLayout.addWidget(self.textEdit)
self.textEdit.setText("A. HISTORY OF THE SOFTWARE \n "
"========================== \n\n "
"B. TERMS AND CONDITIONS \n"
"======================= \n\n"
"Open source software .... ")
self.textEdit.setText("AcouSed \n"
"Copyright (C) 2024 - INRAE \n\n"
"This program is free software: you can redistribute it and/or modify \n"
"it under the terms of the GNU General Public License as published by \n"
"the Free Software Foundation, either version 3 of the License, or \n "
"(at your option) any later version. \n\n"
"This program is distributed in the hope that it will be useful, \n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of \n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \n"
"GNU General Public License for more details. \n\n"
"You should have received a copy of the GNU General Public License \n"
"along with this program. If not, see <https://www.gnu.org/licenses/>.")
class Copyright(QDialog):
@ -135,19 +152,26 @@ class Copyright(QDialog):
super().__init__()
self.logo_path = "./Logo"
self.logo_INRAE = QPixmap(self.logo_path + "/" + "BlocMarque-INRAE-Inter.jpg")
self.setWindowTitle("Copyright")
self.setGeometry(500, 300, 400, 400)
self.setGeometry(500, 300, 200, 200)
self.verticalLayout = QVBoxLayout()
self.setLayout(self.verticalLayout)
self.gridLayout = QGridLayout()
self.setLayout(self.gridLayout)
self.textEdit = QTextEdit()
self.verticalLayout.addWidget(self.textEdit)
self.gridLayout.addWidget(self.textEdit, 0, 0, 1, 1)
self.textEdit.setText("Copyright (c) 2024-2030. \n"
self.textEdit.setText("Copyright (c) 2024. INRAE \n"
"All Rights Reserved.")
self.label_INRAE = QLabel()
self.label_INRAE.setPixmap(self.logo_INRAE.scaledToHeight(64, Qt.SmoothTransformation))
self.gridLayout.addWidget(self.label_INRAE, 1, 0, 1, 1, Qt.AlignCenter)
class Support(QDialog):
@ -155,149 +179,49 @@ class Support(QDialog):
super().__init__()
self.logo_path = "./Logo"
self.logo_OSR = QPixmap(self.logo_path + '/' + "OSR.png")
self.logo_CNR = QPixmap(self.logo_path + '/' + "CNR.png")
self.logo_EDF = QPixmap(self.logo_path + '/' + "EDF.png")
self.logo_Ubertone = QPixmap(self.logo_path + '/' + "Ubertone.jpeg")
self.setWindowTitle("Support")
self.setGeometry(500, 300, 400, 400)
self.setGeometry(500, 300, 300, 300)
self.verticalLayout = QVBoxLayout()
self.setLayout(self.verticalLayout)
self.gridLayout = QGridLayout()
self.setLayout(self.gridLayout)
self.textEdit = QTextEdit()
self.verticalLayout.addWidget(self.textEdit)
self.label_support = QLabel()
self.label_support.setText("The development of AcouSed was supported by OSR6 and CNR Company.")
self.gridLayout.addWidget(self.label_support, 0, 0, 1, 2, Qt.AlignLeft)
self.textEdit.setText("The development of AcouSed was supported by OSR6 and CNR. \n"
"It was made in collaboration with Ubertone and EDF Companies.")
self.label_OSR = QLabel()
self.label_OSR.setPixmap(self.logo_OSR.scaledToHeight(96, Qt.SmoothTransformation))
self.gridLayout.addWidget(self.label_OSR, 1, 0, 1, 1, Qt.AlignCenter)
self.label_CNR = QLabel()
self.label_CNR.setPixmap(self.logo_CNR.scaledToHeight(32, Qt.SmoothTransformation))
self.gridLayout.addWidget(self.label_CNR, 1, 1, 1, 1, Qt.AlignCenter)
self.label_collaboration = QLabel()
self.label_collaboration.setText("It was made in collaboration with Ubertone and EDF Companies.")
self.gridLayout.addWidget(self.label_collaboration, 2, 0, 1, 2, Qt.AlignLeft)
self.label_Ubertone = QLabel()
self.label_Ubertone.setPixmap(self.logo_Ubertone.scaledToHeight(48, Qt.SmoothTransformation))
self.gridLayout.addWidget(self.label_Ubertone, 3, 0, 1, 1, Qt.AlignCenter)
self.label_EDF = QLabel()
self.label_EDF.setPixmap(self.logo_EDF.scaledToHeight(48, Qt.SmoothTransformation))
self.gridLayout.addWidget(self.label_EDF, 3, 1, 1, 1, Qt.AlignCenter)
# app = QApplication(sys.argv)
# w = AboutWindow()
# sys.exit(app.exec_())
if __name__ == "__main__":
app = QApplication(sys.argv)
# otherwindow = QMainWindow()
# w = AboutWindow(otherwindow)
w = AboutWindow()
print(w)
w.show()
print("et ici")
# otherwindow.show()
# MainWindow = QMainWindow()
# ui = Ui_MainWindow()
# ui.setupUi(MainWindow)
# MainWindow.show()
sys.exit(app.exec_())
# if __name__ == "__main__":
# app = QApplication(sys.argv)
# w = AboutWindow()
# w.show()
# sys.exit(app.exec_())
# import sys
# from PyQt5.QtWidgets import *
# from PyQt5.QtGui import *
# from PyQt5.QtCore import *
#
#
# class AboutWindow(QWidget):
#
# def __init__(self):
#
# super().__init__()
#
# # self.centralwidget = QWidget(window)
#
# self.execute()
#
# def execute(self):
#
# self.resize(300, 500)
# self.move(200, 200)
# self.setWindowTitle("Ma première fenêtre simple")
# # self.setWindowFlags(Qt.Popup)
#
# # QIcon
# icone = QIcon("PyQt5_icone.jpeg")
# self.setWindowIcon(icone)
#
# # QLabel
# label1 = QLabel("PyQt", self)
# label1.setText(label1.text() + "5")
# label1.setMargin(5)
# label1.setIndent(50)
#
# # QPixmap
# pic = QPixmap("PyQt5_icone.jpeg")
# label2 = QLabel(self)
# label2.setPixmap(pic)
# label2.setScaledContents(True)
# label2.resize(50, 50)
# label2.move(60, 50)
#
# # label3 = QLabel("Phrase test :", self)
# label3 = QLabel(self)
# label3.setText("Phrase test :")
# label3.move(10, 125)
#
# # QLineEdit
# line_edit = QLineEdit(self)
# line_edit.move(100, 125)
# line_edit.resize(150, 20)
# line_edit.setText("Ma Valeur par défaut")
#
# # QPushButton
# button = QPushButton(self)
# button.setText('Cliquez')
# button.move(30, 150)
#
# # QCheckBox
# checkbox = QCheckBox(self)
# checkbox.setText("Bouton Check Box")
# checkbox.move(30, 200)
# checkbox.setChecked(True)
#
# if checkbox.isChecked() == True:
# label1.setText("La case est coché")
# else:
# label1.setText("la case n'est pas coché")
#
# # QRadioButton
# radiobutton = QRadioButton(self)
# radiobutton.setText('Bouton Radio')
# radiobutton.move(30, 220)
#
# # QComboBox
# combobox = QComboBox(self)
# combobox.addItems(["France", "Espagne", "Italie", "Allemagne", "Royaume-Uni"])
# combobox.move(100, 250)
#
# label4 = QLabel("Choix du pays", self)
# label4.move(5, 250)
#
# # QSpinBox
# spinbox = QSpinBox(self)
# spinbox.move(75, 300)
#
# label5 = QLabel("Valeur :", self)
# label5.move(5, 300)
#
# # QProgressBar
# progressbar = QProgressBar(self)
# progressbar.setGeometry(5, 350, 150, 30)
# progressbar.setValue(0)
#
# # QTextEdit
# textedit = QTextEdit(self)
# textedit.move(20, 400)
# textedit.resize(150, 40)
# textedit.setText("azertyuiopqsdfghjklmwxcvbn azertyuiopqsdfghjklmwxcvbn")
#
# self.show()
# print("coucou")
#
# # if __name__ == "__main__":
# # application = QApplication(sys.argv)
# #
# # fenetre = AboutWindow()
# #
# # fenetre.show()
# #
# # sys.exit(application.exec_())
#

View File

@ -1,3 +1,26 @@
# ============================================================================== #
# acoustic_data_tab.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QPushButton, QComboBox, QLineEdit, QLabel,
@ -47,7 +70,7 @@ _translate = QCoreApplication.translate
class AcousticDataTab(QWidget):
COMPTEUR = 1
"""
This class generates the Acoustic Data Tab
"""
@ -61,7 +84,8 @@ class AcousticDataTab(QWidget):
def __init__(self, tab_widget):
super().__init__()
self.numero = AcousticDataTab.COMPTEUR
AcousticDataTab.COMPTEUR += 1
# Utiliser os.path.split() OU os.path.join()
# if name == 'posix':
@ -83,12 +107,15 @@ class AcousticDataTab(QWidget):
self.icon_clear = QIcon(self.path_icon + "clear.png")
self.icon_between = QPixmap(self.path_icon + "between.png")
self.icon_refresh = QIcon(self.path_icon + "update.png")
print("CONSTRUCTEUR ", self.numero)
self.calib_kt = CalibrationConstantKt()
### --- General layout of widgets ---
self.verticalLayoutMain = QVBoxLayout(tab_widget)
# tab_widget = QTabWidget()
# self.verticalLayoutMain = QVBoxLayout()
# tab_widget.addLayout(self.verticalLayoutMain)
# self.setLayout(self.verticalLayoutMain)
self.horizontalLayoutTop = QHBoxLayout()
@ -154,8 +181,6 @@ class AcousticDataTab(QWidget):
# | Group box Download file |
# +++++++++++++++++++++++++++
# --- Group box Download multiple file ---
# self.groupbox_multiple_acoustic_file = QGroupBox()
@ -174,6 +199,7 @@ class AcousticDataTab(QWidget):
self.gridLayout_groupbox_acoustic_file = QGridLayout(self.groupbox_acoustic_file)
self.combobox_ABS_system_choice = QComboBox()
print("tab1 combobox_ABS_system_choice ", self.combobox_ABS_system_choice)
self.combobox_ABS_system_choice.addItems([" ", "AQUAscat", "UBSediFlow"])
self.gridLayout_groupbox_acoustic_file.addWidget(self.combobox_ABS_system_choice, 0, 0, 1, 1)
@ -1313,6 +1339,7 @@ class AcousticDataTab(QWidget):
self.delBtn.clicked.connect(self.remove_file_from_ListWidget)
self.clearBtn.clicked.connect(self.clear_files_from_ListWidget)
# self.fileListWidget.itemSelectionChanged.connect(self.fileListWidget_function)
self.fileListWidget.itemSelectionChanged.connect(self.print_selected_file)
self.fileListWidget.itemSelectionChanged.connect(self.fill_measurements_information_groupbox)
self.fileListWidget.itemSelectionChanged.connect(self.fill_table)
@ -1403,6 +1430,19 @@ class AcousticDataTab(QWidget):
def print_range_changed(self):
print(f"tmax = {self.doubleRangeSlider_depth.value()[1]}")
# def fileListWidget_function(self):
# self.print_selected_file()
# self.fill_measurements_information_groupbox()
# self.fill_table()
# self.compute_tmin_tmax()
# self.compute_rmin_rmax()
# self.update_frequency_combobox()
# self.plot_backscattered_acoustic_signal_recording()
# self.plot_profile()
# self.update_plot_backscattered_acoustic_signal_recording()
# self.update_plot_profile()
# self.set_range_for_spinboxes_bathymetry()
def retranslate_acoustic_data_tab(self):
# self.groupbox_download.setTitle(_translate("CONSTANT_STRING", cs.DOWNLOAD))
@ -1530,11 +1570,14 @@ class AcousticDataTab(QWidget):
def ABS_system_choice(self):
if self.combobox_ABS_system_choice.currentText() == " ":
print("0 combobox_ABS_system_choice ", self.combobox_ABS_system_choice.currentText())
self.groupbox_measurement_information_no_ABS()
elif self.combobox_ABS_system_choice.currentText() == "AQUAscat":
print("1 combobox_ABS_system_choice ", self.combobox_ABS_system_choice.currentText())
self.groupbox_measurement_information_Aquascat()
# self.lineEdit_acoustic_file.clear()
elif self.combobox_ABS_system_choice.currentText() == "UBSediFlow":
print("2 combobox_ABS_system_choice ", self.combobox_ABS_system_choice.currentText())
self.groupbox_measurement_information_UBSediFlow()
# self.lineEdit_acoustic_file.clear()
# self.label_date_groupbox_acoustic_file.clear()
@ -1653,7 +1696,7 @@ class AcousticDataTab(QWidget):
# self.spinbox_tx.hide()
self.lineEdit_tx.hide()
self.checkbox_tx.hide()
print("Coucou 0")
for i in reversed(range(self.gridLayout_groupbox_info.count())):
widgetToRemove = self.gridLayout_groupbox_info.itemAt(i).widget()
# remove it from the layout list
@ -1700,6 +1743,7 @@ class AcousticDataTab(QWidget):
self.gridLayout_groupbox_info.addWidget(self.lineEdit_speed_of_sound, 4, 1, 1, 1, Qt.AlignLeft)
self.label_speed_of_sound_unit.show()
self.gridLayout_groupbox_info.addWidget(self.label_speed_of_sound_unit, 4, 2, 1, 1, Qt.AlignLeft)
print("Coucou 1.5")
self.label_freq.show()
self.gridLayout_groupbox_info.addWidget(self.label_freq, 5, 0, 1, 1, Qt.AlignLeft)
@ -1754,6 +1798,7 @@ class AcousticDataTab(QWidget):
self.gridLayout_groupbox_info.addWidget(self.lineEdit_tx, 16, 1, 1, 1, Qt.AlignLeft)
self.checkbox_tx.show()
self.gridLayout_groupbox_info.addWidget(self.checkbox_tx, 16, 3, 1, 1, Qt.AlignLeft)
print("Coucou 2")
def groupbox_measurement_information_UBSediFlow(self):
# --- Hide Aquascat information ---
@ -2099,7 +2144,7 @@ class AcousticDataTab(QWidget):
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
elif self.combobox_ABS_system_choice.currentIndex() == 1:
print("hello ", [stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0])
# print("hello ", [stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0])
filename = QFileDialog.getOpenFileNames(self, "AQUAscat file",
[stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0],
"Aquascat file (*.aqa)",
@ -2519,7 +2564,7 @@ class AcousticDataTab(QWidget):
stg.BS_raw_data.append(acoustic_data._BS_raw_data)
stg.BS_raw_data_reshape.append(acoustic_data.reshape_BS_raw_data())
stg.depth.append(acoustic_data._r)
stg.depth_2D.append(acoustic_data.compute_r_2D())
stg.depth_2D.append(np.array([]))
print("stg.depth_2D ", len(stg.depth_2D), stg.depth_2D[0].shape)
# stg.depth_2D.append(np.array([]))
stg.depth_reshape.append(acoustic_data.reshape_r())
@ -2531,6 +2576,7 @@ class AcousticDataTab(QWidget):
print("stg.freq text", stg.freq_text)
stg.date.append(acoustic_data._date)
stg.hour.append(acoustic_data._hour)
print("date ", stg.date, "hour ", stg.hour)
stg.distance_from_ABS_to_free_surface.append(0.00)
stg.nb_profiles.append(acoustic_data._nb_profiles)
stg.nb_profiles_per_sec.append(acoustic_data._nb_profiles_per_sec)
@ -2557,16 +2603,16 @@ class AcousticDataTab(QWidget):
stg.depth_cross_section.append(np.array([]))
stg.time_cross_section.append(np.array([]))
stg.tmin.append("")
stg.tmax.append("")
stg.rmin.append("")
stg.rmax.append("")
stg.tmin.append((0, 0))
stg.tmax.append((0, 0))
stg.rmin.append((0, 0))
stg.rmax.append((0, 0))
stg.BS_stream_bed.append(np.array([]))
stg.depth_bottom.append(np.array([]))
stg.val_bottom.append([])
stg.ind_bottom.append([])
stg.freq_bottom_detection.append(())
stg.freq_bottom_detection.append((0, 0))
# stg.depth_bottom_detection_1st_int_area.append([])
stg.BS_mean.append(np.array([]))
@ -2603,6 +2649,8 @@ class AcousticDataTab(QWidget):
# stg.fine_sample_position.append([])
# stg.sand_sample_position.append([])
stg.kt2D.append(np.array([]))
stg.kt3D.append(np.array([]))
stg.J_cross_section.append([np.array([]), np.array([])])
stg.VBI_cross_section.append(np.array([]))
stg.SSC_fine.append(np.array([]))
@ -2726,6 +2774,7 @@ class AcousticDataTab(QWidget):
# self.spinbox_tx.setValue(stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()])
# self.spinbox_tx.setEnabled(False)
print("--gain tx-- ", self.fileListWidget.currentRow(), self.combobox_frequency_information.currentIndex(), stg.gain_tx)
self.lineEdit_tx.setText(str("%.2f" % stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]))
self.lineEdit_tx.setEnabled(False)
self.checkbox_tx.stateChanged.connect(self.activate_unactivate_spinbox_tx)
@ -3360,14 +3409,16 @@ class AcousticDataTab(QWidget):
# self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS)
# plt.close(self.fig_BS)
if self.fileListWidget.currentRow() != -1:
print("On est là ")
print("fileList widget ", self.fileListWidget.count())
# if self.fileListWidget.currentRow() != -1:
if self.fileListWidget.count() > 0:
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.toolbar_BS)
self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS)
self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0], ncols=1,
sharex=True, sharey=False, layout="constrained")
sharex=False, sharey=False, layout="constrained")
self.canvas_BS = FigureCanvas(self.fig_BS)
self.toolbar_BS = NavigationToolBar(self.canvas_BS, self)
# self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_BS)
@ -3392,11 +3443,14 @@ class AcousticDataTab(QWidget):
# print(f"freq = {f}")
if self.combobox_ABS_system_choice.currentIndex() == 1:
print("stg.time[self.fileListWidget.currentRow()][f, :]", stg.time[self.fileListWidget.currentRow()][f, :].shape)
print("stg.depth[self.fileListWidget.currentRow()][f, :]", stg.depth[self.fileListWidget.currentRow()][f, :].shape)
print("stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]", stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :].shape)
pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :],
-stg.depth[self.fileListWidget.currentRow()][f, :],
stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :],
# stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
-stg.depth[self.fileListWidget.currentRow()][f, :],
stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :],
# stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :],
@ -3404,6 +3458,7 @@ class AcousticDataTab(QWidget):
np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]),
# np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]),
cmap='Blues')
self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom',
@ -3422,6 +3477,7 @@ class AcousticDataTab(QWidget):
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()
# plt.show()
# plt.close(self.fig_BS)
# self.plot_profile()
@ -3446,7 +3502,7 @@ class AcousticDataTab(QWidget):
if len(self.axis_BS.tolist()) != stg.freq[self.fileListWidget.currentRow()].shape[0]:
self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0],
ncols=1,
sharex=True, sharey=False, layout="constrained")
sharex=False, sharey=False, layout="constrained")
for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]):
self.axis_BS[f].cla()
@ -3827,18 +3883,19 @@ class AcousticDataTab(QWidget):
# if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()):
if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0:
print("slider value : ", self.fileListWidget.currentRow(), self.combobox_frequency_profile.currentIndex(),
slider_value, stg.ind_bottom[self.fileListWidget.currentRow()][slider_value])
self.axis_profile.plot([0,
np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][
np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
:, slider_value])],
-stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] * np.ones(2),
int(stg.ind_bottom[self.fileListWidget.currentRow()][slider_value])] * np.ones(2),
linestyle='solid', color='r', linewidth=1)
position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] /
int(stg.ind_bottom[self.fileListWidget.currentRow()][slider_value])] /
np.nanmax(
stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(),
:]))
@ -3900,13 +3957,13 @@ class AcousticDataTab(QWidget):
:, slider_value])],
-stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][
slider_value]] * np.ones(2),
int(stg.ind_bottom[self.fileListWidget.currentRow()][
slider_value])] * np.ones(2),
linestyle='solid', color='r', linewidth=1)
position_x = (stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] /
int(stg.ind_bottom[self.fileListWidget.currentRow()][slider_value])] /
np.nanmax(stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :]))
@ -3949,13 +4006,13 @@ class AcousticDataTab(QWidget):
:, slider_value])],
-stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][
slider_value]] * np.ones(2),
int(stg.ind_bottom[self.fileListWidget.currentRow()][
slider_value])] * np.ones(2),
linestyle='solid', color='r', linewidth=1)
position_x = (stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] /
int(stg.ind_bottom[self.fileListWidget.currentRow()][slider_value])] /
np.nanmax(stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :]))

View File

@ -1,8 +1,9 @@
import sys
import pandas as pd
from PyQt5.QtWidgets import (QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox,
QGridLayout, QLabel, QPushButton, QSpinBox, QDoubleSpinBox, QAbstractSpinBox, QSpacerItem,
QSizePolicy, QSlider, QLineEdit, QMessageBox)
QSizePolicy, QSlider, QLineEdit, QMessageBox, QFileDialog)
from PyQt5.QtCore import QCoreApplication, Qt, pyqtSignal
from PyQt5.QtGui import QStandardItemModel, QIcon, QPixmap
@ -17,6 +18,7 @@ from matplotlib.colors import LogNorm, BoundaryNorm, CSS4_COLORS
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar
from os import path, chdir
import datetime
from scipy import stats
@ -32,6 +34,7 @@ import settings as stg
from View.show_popup_combobox import ComboBoxShowPopUpWindow
from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration
from settings import SSC_fine
_translate = QCoreApplication.translate
@ -95,6 +98,11 @@ class AcousticInversionTab(QWidget):
self.spacerItem_RunInversion = QSpacerItem(1000, 10)#, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalLayout_Run_Inversion.addSpacerItem(self.spacerItem_RunInversion)
self.pushbutton_save_result = QPushButton()
self.pushbutton_save_result.setText("Save Results")
self.pushbutton_save_result.setMaximumWidth(110)
self.horizontalLayout_Run_Inversion.addWidget(self.pushbutton_save_result)
### --- Layout of groupbox in the Top horizontal layout box
# Plot SSC 2D field | SSC vertical profile | Plot SSC graph sample vs inversion ===>>> FINE
@ -343,6 +351,7 @@ class AcousticInversionTab(QWidget):
self.pushbutton_update_acoustic_data_choice.clicked.connect(self.update_acoustic_data_choice)
self.pushbutton_run_inversion.clicked.connect(self.function_run_inversion)
self.pushbutton_save_result.clicked.connect(self.save_result_in_excel_file)
self.pushbutton_left_to_begin_fine.clicked.connect(self.slider_profile_number_to_begin_fine)
self.pushbutton_left_fine.clicked.connect(self.slider_profile_number_to_left_fine)
@ -476,6 +485,7 @@ class AcousticInversionTab(QWidget):
)
print("stg.SSC_fine ", stg.SSC_fine)
print("stg.SSC_fine shape ", stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape)
def compute_SSC_sand(self):
@ -493,6 +503,7 @@ class AcousticInversionTab(QWidget):
ks=stg.ks[1])
print("stg.SSC_sand ", stg.SSC_sand)
print("stg.SSC_sand shape ", stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape)
def plot_SSC_fine(self):
@ -748,6 +759,7 @@ class AcousticInversionTab(QWidget):
# self.axis_SSC_fine.plot([], [], )
self.axis_vertical_profile_SSC_fine.set_xlim(0, 10)
self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)")
self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_fine.canvas.draw_idle()
@ -852,6 +864,7 @@ class AcousticInversionTab(QWidget):
marker='*', s=48, c='r', edgecolors='r')
self.axis_vertical_profile_SSC_fine.text(stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], f[0])
self.axis_vertical_profile_SSC_fine.set_xlim(0, 10)
self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)")
self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_fine.canvas.draw_idle()
@ -1445,6 +1458,7 @@ class AcousticInversionTab(QWidget):
# self.axis_SSC_fine.plot([], [], )
self.axis_vertical_profile_SSC_sand.set_xlim(0, 10)
self.axis_vertical_profile_SSC_sand.set_xlabel("Inverted Sand SSC (g/L)")
self.axis_vertical_profile_SSC_sand.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_sand.canvas.draw_idle()
@ -1553,6 +1567,7 @@ class AcousticInversionTab(QWidget):
stg.depth_fine[stg.sand_sample_target[0][1]],
stg.sand_sample_target[0][0])
self.axis_vertical_profile_SSC_sand.set_xlim(0, 10)
self.axis_vertical_profile_SSC_sand.set_xlabel("Inverted Sand SSC (g/L)")
self.axis_vertical_profile_SSC_sand.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_sand.canvas.draw_idle()
@ -1864,6 +1879,117 @@ class AcousticInversionTab(QWidget):
self.figure_measured_vs_inverted_sand.canvas.draw_idle()
def save_result_in_excel_file(self):
if self.combobox_acoustic_data_choice.count() > 0:
name = QFileDialog.getSaveFileName(
caption="Save As - Inversion results", directory="", filter="Excel Files (*.xlsx)",
options=QFileDialog.DontUseNativeDialog)
if name[0]:
dirname = "/".join(name[0].split("/")[:-1]) + "/"
filename = name[0].split("/")[-1]
chdir(dirname)
for k in range(self.combobox_acoustic_data_choice.count()):
if stg.time_cross_section[k].shape != (0,):
if stg.depth_cross_section[k].shape != (0,):
t = np.repeat(stg.time_cross_section[k][stg.frequency_for_inversion[1]],
stg.depth_cross_section[k].shape[1])
r = np.zeros((stg.depth_cross_section[k].shape[1] *stg.time_cross_section[k].shape[1],1))
for i in range(stg.time_cross_section[k].shape[1]):
for j in range(stg.depth_cross_section[k].shape[1]):
r[i * stg.depth_cross_section[k].shape[1] + j] = (
stg.depth_cross_section[k][int(stg.frequency_for_inversion[1]), j])
if stg.SSC_fine[k].shape == (0,):
stg.SSC_fine[k] = np.zeros(r.shape[0])
if stg.SSC_sand[k].shape == (0,):
stg.SSC_sand[k] = np.zeros(r.shape[0])
else:
t = np.repeat(stg.time_cross_section[k][stg.frequency_for_inversion[1]], stg.depth[k].shape[1])
r = np.zeros((stg.depth[k].shape[1] * stg.time_cross_section[k].shape[1], 1))
for i in range(stg.time_cross_section[k].shape[1]):
for j in range(stg.depth[k].shape[1]):
r[i * stg.depth[k].shape[1] + j] = (
stg.depth[k][int(stg.frequency_for_inversion[1]), j])
if stg.SSC_fine[k].shape == (0,):
stg.SSC_fine[k] = np.zeros(r.shape[0])
if stg.SSC_sand[k].shape == (0,):
stg.SSC_sand[k] = np.zeros(r.shape[0])
else:
if stg.depth_cross_section[k].shape != (0,):
t = np.repeat(stg.time[k][stg.frequency_for_inversion[1]], stg.depth_cross_section[k].shape[1])
r = np.zeros((stg.depth_cross_section[k].shape[1] * stg.time[k].shape[1], 1))
for i in range(stg.time[k].shape[1]):
for j in range(stg.depth_cross_section[k].shape[1]):
r[i * stg.depth_cross_section[k].shape[1] + j] = (
stg.depth_cross_section[k][int(stg.frequency_for_inversion[1]), j])
if stg.SSC_fine[k].shape == (0,):
stg.SSC_fine[k] = np.zeros(r.shape[0])
if stg.SSC_sand[k].shape == (0,):
stg.SSC_sand[k] = np.zeros(r.shape[0])
else:
t = np.repeat(stg.time[k][stg.frequency_for_inversion[1]], stg.depth[k].shape[1])
r = np.zeros(stg.depth[k].shape[1] * stg.time[k].shape[1])
for i in range(stg.time[k].shape[1]):
for j in range(stg.depth[k].shape[1]):
r[i * stg.depth[k].shape[1] + j] = (
stg.depth[k][int(stg.frequency_for_inversion[1]), j])
if stg.SSC_fine[k].shape == (0,):
stg.SSC_fine[k] = np.zeros(r.shape[0])
if stg.SSC_sand[k].shape == (0,):
stg.SSC_sand[k] = np.zeros(r.shape[0])
print("<<<<<<<<<<<<<<<<<<<<<<<<<")
print(t.shape, r.shape, stg.SSC_fine[k].shape, stg.SSC_sand[k].shape)
exec("result_" + str(k) + "= pd.DataFrame({'Time (sec)': t," +
"'Depth (m)': r," +
"'SSC_fine (g/L)': stg.SSC_fine[" + str(k) + "].reshape(t.shape[0])," +
"'SSC_sand (g/L)': stg.SSC_sand[" + str(k) + "].reshape(t.shape[0])})")
with pd.ExcelWriter(dirname + filename + '.xlsx') as writer:
print("writer ", writer)
for k in range(self.combobox_acoustic_data_choice.count()):
eval("result_" + str(k) + ".to_excel(writer, index=False, " +
"engine='xlsxwriter', na_rep='NA', " +
"sheet_name=stg.data_preprocessed[" + str(k) + "])")
# result.to_excel(excel_writer=filename + '.xlsx', index=False, engine='xlsxwriter', na_rep='NA',
# sheet_name=stg.data_preprocessed[k])
# except ValueError as e:
# print("error = ", e)
# msgBox = QMessageBox()
# msgBox.setWindowTitle("Save Inversion Result Error")
# msgBox.setIcon(QMessageBox.Warning)
# msgBox.setText("No saved file")
# msgBox.setStandardButtons(QMessageBox.Ok)
# msgBox.exec()
# --------------------------------------------------------------------------------------------------------------
# ______ _______

View File

@ -1,4 +1,25 @@
# ============================================================================== #
# mainwindow.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import os
# Form implementation generated from reading ui file 'mainwindow.ui'
@ -21,7 +42,8 @@ import numpy as np
from subprocess import check_call, run
import time
# from View.acoustic_data_tab import AcousticDataTab
from View.acoustic_data_tab import AcousticDataTab
class Ui_MainWindow(object):
@ -92,11 +114,11 @@ class Ui_MainWindow(object):
self.toolBar = QtWidgets.QToolBar(self.mainwindow)
self.toolBar.setObjectName("toolBar")
self.mainwindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
self.actionNew = QtWidgets.QAction(self.mainwindow)
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("icons/new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionNew.setIcon(icon)
self.actionNew.setObjectName("actionNew")
# self.actionNew = QtWidgets.QAction(self.mainwindow)
# icon = QtGui.QIcon()
# icon.addPixmap(QtGui.QPixmap("icons/new.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
# self.actionNew.setIcon(icon)
# self.actionNew.setObjectName("actionNew")
self.actionOpen = QtWidgets.QAction(self.mainwindow)
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap("icons/icon_folder.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
@ -107,21 +129,21 @@ class Ui_MainWindow(object):
icon2.addPixmap(QtGui.QPixmap("icons/save.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionSave.setIcon(icon2)
self.actionSave.setObjectName("actionSave")
self.actionCopy = QtWidgets.QAction(self.mainwindow)
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap("icons/copy.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionCopy.setIcon(icon3)
self.actionCopy.setObjectName("actionCopy")
self.actionCut = QtWidgets.QAction(self.mainwindow)
icon4 = QtGui.QIcon()
icon4.addPixmap(QtGui.QPixmap("icons/cut.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionCut.setIcon(icon4)
self.actionCut.setObjectName("actionCut")
self.actionPaste = QtWidgets.QAction(self.mainwindow)
icon5 = QtGui.QIcon()
icon5.addPixmap(QtGui.QPixmap("icons/paste.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionPaste.setIcon(icon5)
self.actionPaste.setObjectName("actionPaste")
# self.actionCopy = QtWidgets.QAction(self.mainwindow)
# icon3 = QtGui.QIcon()
# icon3.addPixmap(QtGui.QPixmap("icons/copy.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
# self.actionCopy.setIcon(icon3)
# self.actionCopy.setObjectName("actionCopy")
# self.actionCut = QtWidgets.QAction(self.mainwindow)
# icon4 = QtGui.QIcon()
# icon4.addPixmap(QtGui.QPixmap("icons/cut.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
# self.actionCut.setIcon(icon4)
# self.actionCut.setObjectName("actionCut")
# self.actionPaste = QtWidgets.QAction(self.mainwindow)
# icon5 = QtGui.QIcon()
# icon5.addPixmap(QtGui.QPixmap("icons/paste.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
# self.actionPaste.setIcon(icon5)
# self.actionPaste.setObjectName("actionPaste")
self.actionEnglish = QtWidgets.QAction(self.mainwindow)
icon6 = QtGui.QIcon()
icon6.addPixmap(QtGui.QPixmap("icons/en.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
@ -142,6 +164,10 @@ class Ui_MainWindow(object):
self.actionAbout.setObjectName("actionAbout")
self.actionUserManual = QtWidgets.QAction(self.mainwindow)
self.actionUserManual.setText("User Manual")
self.action_AcousticInversionTheory = QtWidgets.QAction(self.mainwindow)
self.action_AcousticInversionTheory.setText("Acoustic inversion theory")
self.action_AQUAscatUserManual = QtWidgets.QAction(self.mainwindow)
self.action_AQUAscatUserManual.setText("Tutorial AQUAscat software")
self.actionDB_Browser_for_SQLite = QtWidgets.QAction(self.mainwindow)
self.actionDB_Browser_for_SQLite.setObjectName("actionDB_Browser_for_SQLite")
self.menuLanguage.addAction(self.actionEnglish)
@ -159,16 +185,18 @@ class Ui_MainWindow(object):
self.menuTools.addAction(self.actionDB_Browser_for_SQLite)
self.menuHelp.addAction(self.actionAbout)
self.menuHelp.addAction(self.actionUserManual)
self.menuHelp.addAction(self.action_AcousticInversionTheory)
self.menuHelp.addAction(self.action_AQUAscatUserManual)
self.menubar.addAction(self.menuFile.menuAction())
self.menubar.addAction(self.menuTools.menuAction())
self.menubar.addAction(self.menuHelp.menuAction())
self.toolBar.addAction(self.actionNew)
# self.toolBar.addAction(self.actionNew)
self.toolBar.addAction(self.actionOpen)
self.toolBar.addAction(self.actionSave)
self.toolBar.addSeparator()
self.toolBar.addAction(self.actionCopy)
self.toolBar.addAction(self.actionCut)
self.toolBar.addAction(self.actionPaste)
# self.toolBar.addAction(self.actionCopy)
# self.toolBar.addAction(self.actionCut)
# self.toolBar.addAction(self.actionPaste)
self.toolBar.addSeparator()
self.toolBar.addAction(self.actionEnglish)
self.toolBar.addAction(self.actionFrench)
@ -188,7 +216,7 @@ class Ui_MainWindow(object):
# --- Connect Action Open ---
self.actionOpen.triggered.connect(self.open)
self.actionOpen.triggered.connect(lambda: print('tott'))
# self.actionOpen.triggered.connect(lambda: print('tott'))
# --- Connect Action ABS calibration constant kt ---
self.action_ABSCalibrationConstant.triggered.connect(self.load_calibration_constant_values)
@ -205,6 +233,8 @@ class Ui_MainWindow(object):
# --- Connect Action User Manual ---
self.actionUserManual.triggered.connect(self.user_manual)
self.action_AcousticInversionTheory.triggered.connect(self.inversion_acoustic_theory)
self.action_AQUAscatUserManual.triggered.connect(self.tutorial_AQUAscat_software)
def createContextMenu(self):
@ -227,7 +257,8 @@ class Ui_MainWindow(object):
UpdateTableForSave()
def open(self):
ReadTableForOpen()
pass
# ReadTableForOpen()
# acoustic_data_tab = AcousticDataTab()
#
@ -246,10 +277,16 @@ class Ui_MainWindow(object):
aw.exec()
def user_manual(self):
print(os.getcwd())
print(check_call("ls"))
open('User_manual_0.pdf')
run(["open", 'User_manual_0.pdf'])
open('AcouSed_UserManual.pdf')
run(["open", 'AcouSed_UserManual.pdf'])
def inversion_acoustic_theory(self):
open('Acoustic_Inversion_theory.pdf')
run(["open", 'Acoustic_Inversion_theory.pdf'])
def tutorial_AQUAscat_software(self):
open('Tutorial_AQUAscat_software.pdf')
run(["open", 'Tutorial_AQUAscat_software.pdf'])
def export_table_of_acoustic_BS_values_to_excel_or_libreOfficeCalc_file(self):
@ -328,12 +365,12 @@ class Ui_MainWindow(object):
self.menuTools.setTitle(_translate("MainWindow", "Tools"))
self.menuHelp.setTitle(_translate("MainWindow", "Help"))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar"))
self.actionNew.setText(_translate("MainWindow", "New"))
# self.actionNew.setText(_translate("MainWindow", "New"))
self.actionOpen.setText(_translate("MainWindow", "Open ..."))
self.actionSave.setText(_translate("MainWindow", "Save"))
self.actionCopy.setText(_translate("MainWindow", "Copy"))
self.actionCut.setText(_translate("MainWindow", "Cut"))
self.actionPaste.setText(_translate("MainWindow", "Paste"))
# self.actionCopy.setText(_translate("MainWindow", "Copy"))
# self.actionCut.setText(_translate("MainWindow", "Cut"))
# self.actionPaste.setText(_translate("MainWindow", "Paste"))
self.actionEnglish.setText(_translate("MainWindow", "English"))
self.actionFrench.setText(_translate("MainWindow", "French"))
self.actionTable_of_Backscatter_values.setText(_translate("MainWindow", "Table of Backscatter values"))
@ -342,11 +379,11 @@ class Ui_MainWindow(object):
self.actionDB_Browser_for_SQLite.setText(_translate("MainWindow", "DB Browser for SQLite"))
# if __name__ == "__main__":
# import sys
# app = QtWidgets.QApplication(sys.argv)
# MainWindow = QtWidgets.QMainWindow()
# ui = Ui_MainWindow()
# ui.setupUi(MainWindow)
# MainWindow.show()
# sys.exit(app.exec_())
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

View File

@ -1,3 +1,26 @@
# ============================================================================== #
# mainwindow.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QLabel, QSpinBox, QSpacerItem, QSizePolicy, \
QTabWidget, QTableWidget, QPushButton, QLineEdit, QTableView, QCheckBox, \
QAbstractScrollArea, QTableWidgetItem, QComboBox, QFileDialog, QGridLayout, QMessageBox, \
@ -18,7 +41,7 @@ from copy import deepcopy
from os import path
import csv
from View.show_popup_combobox import ComboBoxShowPopUpWindow
# from View.show_popup_combobox import ComboBoxShowPopUpWindow
from Model.granulo_loader import GranuloLoader
@ -685,6 +708,7 @@ class SampleDataTab(QWidget):
# --- Set horizontal header ---
# horizontal_header = list(map(str, ["Color", "Sample"] + stg.fine_sediment_columns +
# stg.sand_sediment_columns[2:]))
print("stg.columns_fine ", stg.columns_fine)
horizontal_header = list(itertools.chain(["Color", "Sample"],
list(map(str, stg.columns_fine[[0, 2]])),
list(map(str, stg.columns_fine[3:]))))
@ -1330,7 +1354,7 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.scatter(
stg.time_fine, stg.depth_fine,
linestyle='None', marker="x", s=15, c=color_list_fine)
linestyle='None', marker="x", s=15, c=color_list_fine, label='fine')
for i in range(len(stg.time_fine)):
self.axis_plot_sample_position_on_transect.text(
@ -1342,7 +1366,7 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.scatter(
stg.time_sand, stg.depth_sand,
linestyle='None', marker="o", s=60, facecolors='None', edgecolors=color_list_sand)
linestyle='None', marker="o", s=60, facecolors='None', edgecolors=color_list_sand, label='sand')
for i in range(len(stg.time_sand)):
self.axis_plot_sample_position_on_transect.text(
@ -1540,7 +1564,7 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.scatter(
stg.time_fine, stg.depth_fine,
linestyle='None', marker="x", s=15, c=color_list_fine)
linestyle='None', marker="x", s=15, c=color_list_fine, label='fine')
for i in range(len(stg.time_fine)):
self.axis_plot_sample_position_on_transect.text(
@ -1552,7 +1576,7 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.scatter(
stg.time_sand, stg.depth_sand,
linestyle='None', marker="o", s=60, facecolors='None', edgecolors=color_list_sand)
linestyle='None', marker="o", s=60, facecolors='None', edgecolors=color_list_sand, label='sand')
for i in range(len(stg.time_sand)):
self.axis_plot_sample_position_on_transect.text(
@ -1568,15 +1592,16 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.tick_params(axis='y', labelrotation=90)
self.axis_plot_sample_position_on_transect.tick_params(axis='both', labelsize=8)
self.axis_plot_sample_position_on_transect.text(.98, .03, "Time",
self.axis_plot_sample_position_on_transect.text(.98, .03, "Time (sec)",
fontsize=10, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.9,
horizontalalignment='right', verticalalignment='bottom', rotation='horizontal',
transform=self.axis_plot_sample_position_on_transect.transAxes)
self.axis_plot_sample_position_on_transect.text(.04, .65, "Depth",
self.axis_plot_sample_position_on_transect.text(.04, .53, "Depth (m)",
fontsize=10, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.9,
horizontalalignment='right', verticalalignment='bottom', rotation='vertical',
transform=self.axis_plot_sample_position_on_transect.transAxes)
self.axis_plot_sample_position_on_transect.legend(loc="lower left")
self.figure_plot_sample_position_on_transect.canvas.draw_idle()
def update_plot_sample_position_on_transect(self):
@ -1598,7 +1623,7 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.scatter(
time_fine_to_plot, depth_fine_to_plot,
linestyle='None', marker="x", s=15, c=color_list_fine)
linestyle='None', marker="x", s=15, c=color_list_fine, label='fine')
for i in range(len(time_fine_to_plot)):
self.axis_plot_sample_position_on_transect.text(
@ -1618,7 +1643,7 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.scatter(
time_sand_to_plot, depth_sand_to_plot,
linestyle='None', marker="o", s=60, facecolors='None', edgecolors=color_list_sand)
linestyle='None', marker="o", s=60, facecolors='None', edgecolors=color_list_sand, label='sand')
for i in range(len(time_sand_to_plot)):
self.axis_plot_sample_position_on_transect.text(
@ -1855,7 +1880,7 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.scatter(
time_fine_to_plot, depth_fine_to_plot,
linestyle='None', marker="x", s=15, c=color_list_fine)
linestyle='None', marker="x", s=15, c=color_list_fine, label='fine')
for i in range(len(time_fine_to_plot)):
self.axis_plot_sample_position_on_transect.text(
@ -1877,7 +1902,7 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.scatter(
time_sand_to_plot, depth_sand_to_plot,
linestyle='None', marker="o", s=60, facecolors='None', edgecolors=color_list_sand)
linestyle='None', marker="o", s=60, facecolors='None', edgecolors=color_list_sand, label='sand')
for i in range(len(time_sand_to_plot)):
self.axis_plot_sample_position_on_transect.text(
@ -1893,19 +1918,20 @@ class SampleDataTab(QWidget):
self.axis_plot_sample_position_on_transect.tick_params(axis='y', labelrotation=90)
self.axis_plot_sample_position_on_transect.tick_params(axis='both', labelsize=8)
self.axis_plot_sample_position_on_transect.text(.98, .03, "Time",
self.axis_plot_sample_position_on_transect.text(.98, .03, "Time (sec)",
fontsize=10, fontweight='bold', fontname="Ubuntu", c="black",
alpha=0.9,
horizontalalignment='right', verticalalignment='bottom',
rotation='horizontal',
transform=self.axis_plot_sample_position_on_transect.transAxes)
self.axis_plot_sample_position_on_transect.text(.04, .65, "Depth",
self.axis_plot_sample_position_on_transect.text(.04, .53, "Depth (m)",
fontsize=10, fontweight='bold', fontname="Ubuntu", c="black",
alpha=0.9,
horizontalalignment='right', verticalalignment='bottom',
rotation='vertical',
transform=self.axis_plot_sample_position_on_transect.transAxes)
self.axis_plot_sample_position_on_transect.legend(loc="lower right")
self.figure_plot_sample_position_on_transect.canvas.draw_idle()
# if stg.BS_raw_data.size == 0:
@ -2030,7 +2056,7 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.cla()
self.axis_total_concentration.scatter(Ctot_fine_to_plot,
sample_depth_to_plot_fine,
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5)
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5, label='fine')
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
@ -2038,7 +2064,7 @@ class SampleDataTab(QWidget):
elif (self.combobox_x_axis.currentIndex() == 1) and (self.combobox_y_axis.currentIndex() == 0):
self.axis_total_concentration.cla()
self.axis_total_concentration.scatter(Ctot_fine_percent_to_plot, sample_depth_to_plot_fine,
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5)
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5, label='fine')
self.axis_total_concentration.set_xlim(0, 100)
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
@ -2051,7 +2077,7 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.scatter(
Ctot_fine_to_plot,
[x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)],
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5)
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5, label='fine')
else:
@ -2074,7 +2100,7 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.scatter(
Ctot_fine_percent_to_plot,
[x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)],
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5)
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5, label='fine')
else:
@ -2090,7 +2116,7 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
self.figure_total_concentration.canvas.draw_idle()
# self.figure_total_concentration.canvas.draw_idle()
# ===================================================
# --- FINE file NOT uploaded / SAND file uploaded ---
@ -2112,7 +2138,7 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.scatter(Ctot_sand_to_plot,
sample_depth_to_plot_sand,
s=300, facecolor="None", edgecolor=color_list_sand,
alpha=0.5)
alpha=0.5, label='sand')
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
@ -2123,7 +2149,7 @@ class SampleDataTab(QWidget):
print("Ctot_sand_percent_to_plot ", Ctot_sand_percent_to_plot)
self.axis_total_concentration.scatter(Ctot_sand_percent_to_plot, sample_depth_to_plot_sand,
s=300, facecolor="None", edgecolor=color_list_sand,
alpha=0.5)
alpha=0.5, label='sand')
self.axis_total_concentration.set_xlim(0, 100)
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
@ -2138,7 +2164,7 @@ class SampleDataTab(QWidget):
Ctot_sand_to_plot,
[x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)],
# stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_sand],
s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5)
s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5, label='sand')
else:
@ -2163,7 +2189,7 @@ class SampleDataTab(QWidget):
Ctot_sand_percent_to_plot,
[x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)],
# stg.depth_bottom[self.combobox_acoustic_data.currentIndex()][indices_bottom_sand],
s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5)
s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5, label='sand')
else:
@ -2179,7 +2205,7 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
self.figure_total_concentration.canvas.draw_idle()
# self.figure_total_concentration.canvas.draw_idle()
# ===============================================
# --- FINE file uploaded / SAND file uploaded ---
@ -2201,11 +2227,11 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.scatter(Ctot_fine_to_plot,
sample_depth_to_plot_fine,
s=100, facecolor=color_list_fine, edgecolor="None",
alpha=0.5)
alpha=0.5, label='fine')
self.axis_total_concentration.scatter(Ctot_sand_to_plot,
sample_depth_to_plot_sand,
s=300, facecolor="None", edgecolor=color_list_sand,
alpha=0.5)
alpha=0.5, label='sand')
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
@ -2216,10 +2242,10 @@ class SampleDataTab(QWidget):
print("sample_depth_to_plot_fine", sample_depth_to_plot_fine)
self.axis_total_concentration.scatter(Ctot_fine_percent_to_plot, sample_depth_to_plot_fine,
s=100, facecolor=color_list_fine, edgecolor="None",
alpha=0.5)
alpha=0.5, label='fine')
self.axis_total_concentration.scatter(Ctot_sand_percent_to_plot, sample_depth_to_plot_sand,
s=300, facecolor="None", edgecolor=color_list_sand,
alpha=0.5)
alpha=0.5, label='sand')
self.axis_total_concentration.set_xlim(0, 100)
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
@ -2232,11 +2258,11 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.scatter(
Ctot_fine_to_plot,
[x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)],
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5)
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5, label='fine')
self.axis_total_concentration.scatter(
Ctot_sand_to_plot,
[x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)],
s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5)
s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5, label='sand')
else:
@ -2259,12 +2285,12 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.scatter(
Ctot_fine_percent_to_plot,
[x / y for x, y in zip(sample_depth_to_plot_fine, depth_bottom_to_plot_fine)],
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5)
s=100, facecolor=color_list_fine, edgecolor="None", alpha=0.5, label='fine')
self.axis_total_concentration.scatter(
Ctot_sand_percent_to_plot,
[x / y for x, y in zip(sample_depth_to_plot_sand, depth_bottom_to_plot_sand)],
s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5)
s=300, facecolor="None", edgecolor=color_list_sand, alpha=0.5, label='sand')
else:
@ -2280,9 +2306,8 @@ class SampleDataTab(QWidget):
self.axis_total_concentration.set_xlabel(self.combobox_x_axis.currentText())
self.axis_total_concentration.set_ylabel(self.combobox_y_axis.currentText())
self.figure_total_concentration.canvas.draw_idle()
self.axis_total_concentration.legend(loc="upper right")
self.figure_total_concentration.canvas.draw_idle()
# ------------------------------------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
from PyQt5.QtWidgets import QComboBox
from PyQt5.QtCore import pyqtSignal
class ComboBoxShowPopUpWindow(QComboBox):
ShowPopUpWindowSignal = pyqtSignal()
def showPopup(self):
self.ShowPopUpWindowSignal.emit()
super(ComboBoxShowPopUpWindow, self).showPopup()

View File

@ -1,3 +1,27 @@
# ============================================================================== #
# mainwindow.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
from cProfile import label
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import sys
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox, QLabel, QCheckBox,
@ -26,6 +50,7 @@ import Translation.constant_string as cs
from Model.acoustic_data_loader import AcousticDataLoader
import settings as stg
from settings import depth_cross_section
_translate = QCoreApplication.translate
@ -716,14 +741,17 @@ class SignalProcessingTab(QWidget):
print("val2 ", val2)
# --- Compute averaged signal ---
if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
np.nanmean(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
np.nanmean(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
# if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
# stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
# np.nanmean(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
# elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
# stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
# np.nanmean(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
# elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
print("self.combobox_acoustic_data_choice.currentIndex() ", self.combobox_acoustic_data_choice.currentIndex(),
self.combobox_acoustic_data_choice.currentText(), val1, val2,
stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape)
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
np.nanmean(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
# for i in range(self.combobox_freq_noise_from_profile_tail.count()):
@ -743,29 +771,29 @@ class SignalProcessingTab(QWidget):
self.verticalLayout_groupbox_plot_profile_tail.addWidget(self.canvas_profile_tail)
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_profile_tail.plot(
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
color="blue", linewidth=1)
self.axis_profile_tail.plot(
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()],
float(self.lineEdit_profile_tail_value.text().replace(",", ".")) *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()].shape[0]),
linestyle='dashed', linewidth=2, color='red')
elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
print(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()].shape)
self.axis_profile_tail.plot(
# if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# self.axis_profile_tail.plot(
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
# stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
# color="blue", linewidth=1)
# self.axis_profile_tail.plot(
# -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_freq_noise_from_profile_tail.currentIndex()],
# float(self.lineEdit_profile_tail_value.text().replace(",", ".")) *
# np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_freq_noise_from_profile_tail.currentIndex()].shape[0]),
# linestyle='dashed', linewidth=2, color='red')
#
# elif stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
#
# print(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
# self.combobox_freq_noise_from_profile_tail.currentIndex()].shape)
self.axis_profile_tail.plot(
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
color="blue", linewidth=1)
self.axis_profile_tail.plot(
self.axis_profile_tail.plot(
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
self.combobox_freq_noise_from_profile_tail.currentIndex()],
float(self.lineEdit_profile_tail_value.text().replace(",", ".")) *
@ -776,11 +804,11 @@ class SignalProcessingTab(QWidget):
self.axis_profile_tail.set_yscale('log')
self.axis_profile_tail.tick_params(axis='both', labelsize=8)
# self.axis_profile_tail.set_yticklabels(fontsize=8)
self.axis_profile_tail.text(.98, .03, "Depth",
self.axis_profile_tail.text(.98, .03, "Depth (m)",
fontsize=8, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.9,
horizontalalignment='right', verticalalignment='bottom', rotation='horizontal',
transform=self.axis_profile_tail.transAxes)
self.axis_profile_tail.text(.1, .50, "BS signal",
self.axis_profile_tail.text(.1, .45, "BS signal (v)",
fontsize=8, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.9,
horizontalalignment='right', verticalalignment='bottom', rotation='vertical',
transform=self.axis_profile_tail.transAxes)
@ -1138,6 +1166,19 @@ class SignalProcessingTab(QWidget):
# np.full(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape,
# self.spinbox_compute_noise_from_value.value()))
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()])
else:
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.time[self.combobox_acoustic_data_choice.currentIndex()])
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.depth_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()])
else:
stg.depth_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.depth[self.combobox_acoustic_data_choice.currentIndex()])
# --- Compute noise from value and compute SNR ---
if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
@ -1154,9 +1195,6 @@ class SignalProcessingTab(QWidget):
- stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()])
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
@ -1171,9 +1209,6 @@ class SignalProcessingTab(QWidget):
- stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()])
else:
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
@ -1187,8 +1222,6 @@ class SignalProcessingTab(QWidget):
- stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) ** 2,
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] ** 2))
stg.time_noise[self.combobox_acoustic_data_choice.currentIndex()] = (
stg.time[self.combobox_acoustic_data_choice.currentIndex()])
# print("stg.BS_noise_averaged_data ", stg.BS_noise_averaged_data)

BIN
icons/add.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 521 B

BIN
icons/add0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
icons/approved.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

BIN
icons/between.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
icons/clear.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

BIN
icons/clear0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
icons/delete.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

BIN
icons/delete0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

BIN
icons/navigation.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 776 B

BIN
icons/no_approved.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
icons/no_entry.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
icons/red_record.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 444 B

BIN
icons/triangle_left_old.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
icons/triangle_left_to_begin.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
icons/triangle_right_to_end.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

BIN
icons/update.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
icons/warning.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
icons/yellow_push.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 743 B

26
main.py
View File

@ -12,6 +12,8 @@ from View.sediment_calibration_tab import SedimentCalibrationTab
from View.acoustic_inversion_tab import AcousticInversionTab
from View.note_tab import NoteTab
from View.user_manual_tab import UserManualTab
import settings as stg
from Model.read_table_for_open import ReadTableForOpen
import matplotlib.pyplot as plt
# plt.close("all")
@ -39,19 +41,24 @@ class MainApplication(QMainWindow):
height = size.height()
self.resize(int(PERCENT_SCREEN_SIZE*width), int(PERCENT_SCREEN_SIZE*height))
try:
self.read_table_open = ReadTableForOpen()
# **************************************************
# -------------- Acoustic data tab ---------------
self.acoustic_data_tab = AcousticDataTab(self.ui_mainwindow.tab1)
print("0 AcousticDataTab ", id(AcousticDataTab))
# Connect push buttons to download data files22
self.acoustic_data_tab.combobox_ABS_system_choice.editTextChanged.connect(
self.acoustic_data_tab.ABS_system_choice)
# **************************************************
# --------- Signal pre-processing data tab ----------
self.signal_processing_tab = SignalProcessingTab(self.ui_mainwindow.tab2)
self.signal_processing_tab.combobox_acoustic_data_choice.editTextChanged.connect(
self.signal_processing_tab.combobox_acoustic_data_choice_change_index)
# **************************************************.
# --------------- Sample data tab ----------------
@ -77,6 +84,8 @@ class MainApplication(QMainWindow):
# self.user_manual_tab = UserManualTab(self.ui_mainwindow.tab7)
self.ui_mainwindow.actionOpen.triggered.connect(self.trig_open)
# **************************************************
# ---------------- Text File Error -----------------
@ -86,6 +95,19 @@ class MainApplication(QMainWindow):
sortie.write(traceback.format_exc())
# traceback.TracebackException.from_exception(e).print(file=sortie)
def trig_open(self):
self.read_table_open.open_file_dialog()
self.acoustic_data_tab.combobox_ABS_system_choice.setCurrentText(stg.ABS_name[0])
self.acoustic_data_tab.fileListWidget.addFilenames(stg.filename_BS_raw_data)
self.signal_processing_tab.combobox_acoustic_data_choice.addItems(stg.filename_BS_raw_data)
self.sample_data_tab.fill_comboboxes_and_plot_transect()
self.sample_data_tab.lineEdit_fine_sediment.setText(stg.filename_fine)
self.sample_data_tab.lineEdit_fine_sediment.setToolTip(stg.path_fine)
# self.sample_data_tab.fill_table_fine()
if __name__ == '__main__':
# print("sys.argv:", [arg for arg in sys.argv])

View File

@ -1,3 +1,26 @@
# ============================================================================== #
# settings .py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
""" this file includs global variables shared between tab """
import numpy as np
@ -216,6 +239,8 @@ X_exponent = [] # List of one value [X_exponent]
alpha_s = [] # List [alphas_freq1, alphas_freq2] # List of floats
zeta = [] # List [zeta_freq1, zeta_freq2] # List of floats
kt2D = [] # List of kt2D, computed from kt_corrected or kt_read # List of 2D arrays
kt3D = [] # List of kt3D, computed from kt2D # List of 3D arrays
J_cross_section = [] # List of J_cross_section compute for all acoustic data recording # List of lists of 3D arrays
# [[J_cross_section_freq1, J_cross_section_freq2], [], []]
FCB = [] # 3D array