Start Pierre Antoine - Brahim

This commit is contained in:
brahim committed 2025-03-03 12:01:58 +01:00
1 parent cf4eee9617
commit f78d0fabb1
44 files changed
+1609 -850

No files matched your search

@@ -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]))]
+44 -52
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()
+114 -32
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()
+349 -75
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])))
+1 -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):
+105 -25
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()