The study can be saved to a file (.acd) and the saving process can be updated.
parent
ddcfd4b6c4
commit
bc811b03e3
|
|
@ -1,28 +1,38 @@
|
|||
import numpy as np
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
|
||||
import sqlite3
|
||||
import settings as stg
|
||||
from os import chdir
|
||||
import time
|
||||
|
||||
from settings import ABS_name
|
||||
|
||||
class CreateTableForSaveAs():
|
||||
class CreateTableForSaveAs:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.create_AcousticFile = """CREATE TABLE File(
|
||||
self.create_AcousticFile = """CREATE TABLE AcousticFile(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
acoustic_file STRING)"""
|
||||
acoustic_data INTEGER,
|
||||
acoustic_file STRING,
|
||||
ABS_name STRING,
|
||||
path_BS_noise_data STRING,
|
||||
filename_BS_noise_data STRING,
|
||||
noise_method FLOAT,
|
||||
noise_value FLOAT,
|
||||
data_preprocessed STRING
|
||||
)
|
||||
"""
|
||||
|
||||
self.create_Measure = """ CREATE TABLE Measure(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
frequency FLOAT,
|
||||
kt FLOAT,
|
||||
NbProfiles INTEGER,
|
||||
kt_read FLOAT,
|
||||
kt_corrected FLOAT,
|
||||
NbProfiles FLOAT,
|
||||
NbProfilesPerSeconds FLOAT,
|
||||
NbCells INTEGER,
|
||||
NbCells FLOAT,
|
||||
CellSize FLOAT,
|
||||
PulseLength FLOAT,
|
||||
NbPingsPerSeconds FLOAT,
|
||||
|
|
@ -31,62 +41,103 @@ class CreateTableForSaveAs():
|
|||
GainTx FLOAT)
|
||||
"""
|
||||
|
||||
# for i in stg.acoustic_data:
|
||||
# exec("self.create_BSRawData_" + str(i) + " = '''CREATE TABLE BSRawData_" + str(i) +
|
||||
# "(ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
# "acoustic_data INTEGER, " +
|
||||
# " ".join(["time_" + str(int(f)) + " FLOAT," for f in stg.freq[i][:-1]]) +
|
||||
# ["time_" + str(int(stg.freq[i][-1]))][0] + " FLOAT" + ")''' ")
|
||||
|
||||
# for i in stg.acoustic_data:
|
||||
# exec("self.create_BSRawData_" + str(i) + " = '''CREATE TABLE BSRawData_" + str(i) +
|
||||
# "(ID INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
# "acoustic_data INTEGER, " +
|
||||
# " ".join(["time_" + str(int(f)) + " FLOAT," for f in stg.freq[i]]) +
|
||||
# " ".join(["depth_" + str(int(f)) + " FLOAT," for f in stg.freq[i]]) +
|
||||
# " ".join(["BS_raw_data_" + str(int(f)) + " FLOAT," for f in stg.freq[i][:-1]]) +
|
||||
# ["BS_raw_data_" + str(int(stg.freq[i][-1]))][0] + " FLOAT" + ")''' ")
|
||||
|
||||
self.create_BSRawData = '''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_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
|
||||
)'''
|
||||
|
||||
self.create_Settings = '''CREATE TABLE Settings(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
temperature FLOAT,
|
||||
time_min_ind INTEGER,
|
||||
time_min_val FLOAT,
|
||||
time_max_ind INTEGER,
|
||||
time_max_val FLOAT,
|
||||
depth_min_ind INTEGER,
|
||||
depth_min_val FLOAT,
|
||||
depth_max_ind INTEGER,
|
||||
depth_max_val 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,
|
||||
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
|
||||
)
|
||||
"""
|
||||
|
||||
self.create_SedimentsData = """CREATE TABLE SedimentsData(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
sample_fine_name STRING,
|
||||
sample_fine_index INTEGER,
|
||||
distance_from_bank_fine FLOAT,
|
||||
depth_fine FLOAT,
|
||||
time_fine FLOAT,
|
||||
Ctot_fine FLOAT,
|
||||
Ctot_fine_per_cent FLOAT,
|
||||
D50_fine FLOAT,
|
||||
frac_vol_fine BLOB,
|
||||
frac_vol_fine_cumul BLOB
|
||||
)
|
||||
"""
|
||||
|
||||
self.create_Calibration = """CREATE TABLE Calibration(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path_calibration_file STRING,
|
||||
filename_calibration_file STRING,
|
||||
range_lin_interp BLOB,
|
||||
M_profile_fine BLOB,
|
||||
ks BLOB,
|
||||
sv BLOB,
|
||||
X_exponent BLOB,
|
||||
alpha_s BLOB,
|
||||
zeta BLOB,
|
||||
FCB BLOB,
|
||||
depth_real BLOB,
|
||||
lin_reg BLOB
|
||||
)"""
|
||||
|
||||
self.create_Inversion = """CREATE TABLE Inversion(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
J_cross_section_freq1 BLOB,
|
||||
J_cross_section_freq2 BLOB,
|
||||
VBI_cross_section BLOB,
|
||||
SSC_fine BLOB,
|
||||
SSC_sand BLOB
|
||||
)"""
|
||||
|
||||
self.open_file_dialog()
|
||||
start = time.time()
|
||||
self.create_table()
|
||||
print(f"end : {time.time() - start} sec")
|
||||
|
||||
|
||||
def open_file_dialog(self):
|
||||
options = QFileDialog.Options()
|
||||
name = QFileDialog.getSaveFileName(
|
||||
caption="Save As", directory="", filter="AcouSed Files (*.acd)", options=options)
|
||||
caption="Save As", directory="", filter="AcouSed Files (*.acd)", options=QFileDialog.DontUseNativeDialog)
|
||||
|
||||
if name:
|
||||
if name[0]:
|
||||
|
||||
stg.dirname_save_as = "/".join(name[0].split("/")[:-1]) + "/"
|
||||
stg.filename_save_as = name[0].split("/")[-1]
|
||||
|
||||
chdir(stg.dirname_save_as)
|
||||
|
||||
# file = open(stg.filename_save_as, 'w')
|
||||
# file.write(self.create_Measure)
|
||||
# file.close()
|
||||
start = time.time()
|
||||
self.create_table()
|
||||
print(f"end : {time.time() - start} sec")
|
||||
|
||||
else:
|
||||
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Save Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
msgBox.setText("No file saved")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
|
||||
def create_table(self):
|
||||
|
||||
|
|
@ -97,24 +148,39 @@ class CreateTableForSaveAs():
|
|||
cur = cnx.cursor()
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# --- Table File ---
|
||||
# ++++++++++++++++++
|
||||
# --- Table File ---
|
||||
# ++++++++++++++++++
|
||||
|
||||
start_table_File = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists File")
|
||||
cur.execute("DROP TABLE if exists AcousticFile")
|
||||
|
||||
cur.execute(self.create_AcousticFile)
|
||||
|
||||
for i in stg.acoustic_data:
|
||||
query0 = (f"INSERT into File(acoustic_data, acoustic_file)"
|
||||
f"VALUES({stg.acoustic_data[i]}, {str(stg.filename_BS_raw_data[i]).split('.')[0]})")
|
||||
print("stg.acoustic_data ", stg.acoustic_data[i])
|
||||
print("stg.filename_BS_raw_data ", stg.filename_BS_raw_data[i])
|
||||
print('stg.ABS_name', stg.ABS_name)
|
||||
print("stg.path_BS_raw_data ", stg.path_BS_raw_data[i])
|
||||
|
||||
cur.execute(query0)
|
||||
cnx.commit()
|
||||
cur.execute(''' INSERT into AcousticFile(acoustic_data, acoustic_file, ABS_name, path_BS_noise_data,
|
||||
filename_BS_noise_data, noise_method, noise_value, data_preprocessed)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.acoustic_data[i], stg.filename_BS_raw_data[i].split('.')[0], stg.ABS_name[i],
|
||||
stg.path_BS_noise_data[i], stg.filename_BS_noise_data[i], stg.noise_method[i],
|
||||
stg.noise_value[i], stg.data_preprocessed[i])
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table File : {time.time() - start_table_File} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# --- Table Measure ---
|
||||
# +++++++++++++++++++++
|
||||
# --- Table Measure ---
|
||||
# +++++++++++++++++++++
|
||||
|
||||
start_table_Measure = time.time()
|
||||
|
||||
# Drop Table if exists
|
||||
|
|
@ -126,170 +192,67 @@ class CreateTableForSaveAs():
|
|||
# Fill the table Measure
|
||||
for i in stg.acoustic_data:
|
||||
|
||||
for f, k, r, t in zip(stg.freq[i], stg.kt[i], stg.gain_rx[i], stg.gain_tx[i]):
|
||||
for j in range(stg.freq[i].shape[0]):
|
||||
|
||||
query = (f"INSERT into Measure(acoustic_data, frequency, kt, NbProfiles, NbProfilesPerSeconds, "
|
||||
f"NbCells, CellSize, PulseLength, NbPingsPerSeconds, "
|
||||
f"NbPingsAveragedPerProfile, GainRx, GainTx) "
|
||||
f"VALUES({i}, {f}, {k}, {stg.nb_profiles[i]}, {stg.nb_profiles_per_sec[i]}, "
|
||||
f"{stg.nb_cells[i]}, {stg.cell_size[i]}, {stg.pulse_length[i]}, {stg.nb_pings_per_sec[i]}, "
|
||||
f"{stg.nb_pings_averaged_per_profile[i]}, {r}, {t})")
|
||||
cur.execute(query)
|
||||
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],
|
||||
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]))
|
||||
|
||||
# Commit the transaction after executing INSERT.
|
||||
cnx.commit()
|
||||
# Commit the transaction after executing INSERT.
|
||||
cnx.commit()
|
||||
|
||||
print(f"table Measure : {time.time() - start_table_Measure} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# --- Table BSRawData_i ---
|
||||
# +++++++++++++++++++++++++
|
||||
# --- Table BSRawData_i ---
|
||||
# +++++++++++++++++++++++++
|
||||
|
||||
start_table_BSRawData = time.time()
|
||||
|
||||
cur.execute('DROP TABLE if exists BSRawData')
|
||||
|
||||
# # Drop Table BSRawData_i if exists
|
||||
# for i in stg.acoustic_data:
|
||||
# exec("cur.execute('DROP TABLE if exists BSRawData_" + str(i) + "')")
|
||||
#
|
||||
# # Execute the CREATE TABLE BSRawData_i statement
|
||||
# for i in stg.acoustic_data:
|
||||
# exec("cur.execute(self.create_BSRawData_" + str(i) + ")")
|
||||
|
||||
# Fill the table BSRawData_i
|
||||
|
||||
# # --- Fill table BSRawData_i with acoustic data integer ---
|
||||
# for i in stg.acoustic_data:
|
||||
# for j in range(stg.time_reshape[i].shape[0]):
|
||||
# exec(f"query1 = ('''INSERT into BSRawData_" + str(i) + "(acoustic_data)" +
|
||||
# f" VALUES({i}) ''') ")
|
||||
#
|
||||
# exec("cur.execute(query1)")
|
||||
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
# for i in stg.acoustic_data:
|
||||
# , depth, BS_raw_data
|
||||
# Drop Table BSRawData_i if exists
|
||||
cur.execute(self.create_BSRawData)
|
||||
# homer = np.array([1, 2, 3, 4, 5])
|
||||
# bart = np.array([6, 7, 8, 9, 10])
|
||||
# lisa = np.array([11, 12, 13, 14, 15])
|
||||
# marge = homer.tobytes()
|
||||
# print("to string : ", homer.tostring())
|
||||
# print("to bytes : ", homer.tobytes())
|
||||
# query2 = f''' INSERT into BSRawData(acoustic_data, time) VALUES({0}, {marge}) '''
|
||||
# cur.execute('''CREATE TABLE IF NOT EXISTS BSRawData(time BLOB)''')
|
||||
|
||||
for i in stg.acoustic_data:
|
||||
|
||||
# cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data) VALUES(?, ?, ?, ?)''',
|
||||
# (stg.acoustic_data[i], homer.tobytes(),
|
||||
# bart.tobytes(), lisa.tobytes()))
|
||||
|
||||
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data, BS_cross_section)
|
||||
VALUES(?, ?, ?, ?)''',
|
||||
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
|
||||
time_cross_section, depth_cross_section,
|
||||
BS_cross_section, BS_stream_bed,
|
||||
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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.acoustic_data[i], stg.time[i].tobytes(),
|
||||
stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes()))
|
||||
|
||||
# cur.execute(''' INSERT into BSRawData(time) VALUES(?)''', (marge,))
|
||||
# query2 = f''' INSERT into BSRawData(acoustic_data, time) VALUES({0}, {stg.time[0][0, :].tobytes()}) ''' # , {stg.depth[i].tobytes()}, {stg.BS_raw_data[i].tobytes()}
|
||||
|
||||
# for j in range(stg.time_reshape[i].shape[0]):
|
||||
#
|
||||
# # print("query2 = ('''INSERT into BSRawData_" + str(i) + "(acoustic_data, " +
|
||||
# # ", ".join(["time_" + str(int(f)) for f in stg.freq[i]]) + ", " +
|
||||
# # ", ".join(["depth_" + str(int(f)) for f in stg.freq[i]]) + ")" +
|
||||
# # f" VALUES" + str(eval("0, " +
|
||||
# # ", ".join(["stg.time_reshape[" + str(i) + "][" + str(
|
||||
# # j) + ", " + str(k) + "]" for k, _ in
|
||||
# # enumerate(stg.freq[i])]) + ", " +
|
||||
# # ", ".join(["stg.depth_reshape[" + str(i) + "][" + str(j) + ", " + str(k) + "]" for k, _ in enumerate(stg.freq[i])]))) + " ''' )")
|
||||
#
|
||||
# exec("query2 = ('''INSERT into BSRawData_" + str(i) + "(acoustic_data, " +
|
||||
# ", ".join(["time_" + str(int(f)) for f in stg.freq[i]]) + ", " +
|
||||
# ", ".join(["depth_" + str(int(f)) for f in stg.freq[i]]) + ", " +
|
||||
# ", ".join(["BS_raw_data_" + str(int(f)) for f in stg.freq[i]]) + ")"
|
||||
# f" VALUES" + str(eval(str(i) + ", " +
|
||||
# ", ".join(["stg.time_reshape[" + str(i) + "][" + str(
|
||||
# j) + ", " + str(k) + "]" for k, _ in
|
||||
# enumerate(stg.freq[i])]) + ", " +
|
||||
# ", ".join(["stg.depth_reshape[" + str(i) + "][" + str(
|
||||
# j) + ", " + str(k) + "]" for k, _ in
|
||||
# enumerate(stg.freq[i])]) + ", " +
|
||||
# ", ".join(["stg.BS_raw_data_reshape[" + str(i) + "][" + str(
|
||||
# j) + ", " + str(k) + "]" for k, _ in
|
||||
# enumerate(stg.freq[i])]))) + " ''' )")
|
||||
|
||||
# cur.execute(query2)
|
||||
stg.depth[i].tobytes(), stg.BS_raw_data[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_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()
|
||||
)
|
||||
)
|
||||
|
||||
# Commit the transaction after executing INSERT.
|
||||
cnx.commit()
|
||||
|
||||
print(f"table BSRawData : {time.time() - start_table_BSRawData} sec")
|
||||
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
# # --- Fill table BSRawData_i with data stg.time_reshape ---
|
||||
# for i in stg.acoustic_data:
|
||||
# for j in range(stg.time_reshape[i].shape[0]):
|
||||
#
|
||||
# # print("query2 = ('''INSERT into BSRawData_" + str(i) + "(acoustic_data, " +
|
||||
# # ", ".join(["time_" + str(int(f)) for f in stg.freq[i]]) + ")" +
|
||||
# # f" VALUES" + str(eval("0, " + ", ".join(["stg.time_reshape[" + str(i) + "][" + str(j) + ", " + str(k) + "]" for k, _ in enumerate(stg.freq[i])]))) + " ''' )")
|
||||
#
|
||||
# exec("query2 = ('''INSERT into BSRawData_" + str(i) + "(acoustic_data, " +
|
||||
# ", ".join(["time_" + str(int(f)) for f in stg.freq[i]]) + ")" +
|
||||
# f" VALUES" + str(eval("0, " + ", ".join(["stg.time_reshape[" + str(i) + "][" + str(j) + ", " + str(k) + "]" for k, _ in enumerate(stg.freq[i])]))) + " ''' )")
|
||||
#
|
||||
# exec("cur.execute(query2)")
|
||||
#
|
||||
# # Commit the transaction after executing INSERT.
|
||||
# cnx.commit()
|
||||
#
|
||||
# # --- Fill table BSRawData_i with data stg.depth_reshape ---
|
||||
# for i in stg.acoustic_data:
|
||||
# for f in stg.freq[i]:
|
||||
# exec("query3 = ('''ALTER TABLE BSRawData_" + str(i) +
|
||||
# " ADD " + ["depth_" + str(int(f)) + " FLOAT"][0] + " ''')")
|
||||
#
|
||||
# exec("cur.execute(query3)")
|
||||
#
|
||||
# # Commit the transaction after executing INSERT.
|
||||
# cnx.commit()
|
||||
#
|
||||
# for i in stg.acoustic_data:
|
||||
# for k, f in enumerate(stg.freq[i]):
|
||||
# for j in range(stg.depth_reshape[i].shape[0]):
|
||||
# exec("query4 = '''UPDATE BSRawData_" + str(i) +
|
||||
# " SET " + ["depth_" + str(int(f))][0] + " = " +
|
||||
# str(eval("stg.depth_reshape[" + str(i) + "][" + str(j) + ", " + str(k) + "]")) +
|
||||
# " WHERE ID = " + str(j + 1) + " ''' ")
|
||||
#
|
||||
# exec("cur.execute(query4)")
|
||||
|
||||
# # --- Fill table BSRawData_i with data stg.BS_raw_data_reshape ---
|
||||
# for i in stg.acoustic_data:
|
||||
# for f in stg.freq[i]:
|
||||
#
|
||||
# exec("query5 = ('''ALTER TABLE BSRawData_" + str(i) +
|
||||
# " ADD " + ["BS_raw_data_" + str(int(f)) + " FLOAT"][0] + " ''')")
|
||||
#
|
||||
# exec("cur.execute(query5)")
|
||||
#
|
||||
# # Commit the transaction after executing INSERT.
|
||||
# cnx.commit()
|
||||
#
|
||||
# for i in stg.acoustic_data:
|
||||
# for k, f in enumerate(stg.freq[i]):
|
||||
# for j in range(stg.BS_raw_data_reshape[i].shape[0]):
|
||||
#
|
||||
# exec("query6 = '''UPDATE BSRawData_" + str(i) +
|
||||
# " SET " + ["BS_raw_data_" + str(int(f))][0] + " = " +
|
||||
# str(eval("stg.BS_raw_data_reshape[" + str(i) + "][" + str(j) + ", " + str(k) + "]")) +
|
||||
# " WHERE ID = " + str(j+1) + " ''' ")
|
||||
#
|
||||
# exec("cur.execute(query6)")
|
||||
#
|
||||
# cnx.commit()
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# --- Table Settings ---
|
||||
# ++++++++++++++++++++++
|
||||
# --- Table Settings ---
|
||||
# ++++++++++++++++++++++
|
||||
|
||||
start_table_Settings = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists Settings")
|
||||
|
|
@ -299,25 +262,116 @@ class CreateTableForSaveAs():
|
|||
print(stg.acoustic_data, stg.temperature, stg.rmin, stg.rmax, stg.tmin, stg.tmax)
|
||||
|
||||
for i in stg.acoustic_data:
|
||||
query7 = (f'''INSERT into Settings(acoustic_data, temperature,
|
||||
time_min_ind, time_min_val, time_max_ind, time_max_val,
|
||||
depth_min_ind, depth_min_val, depth_max_ind, depth_max_val)
|
||||
VALUES({stg.acoustic_data[i]},
|
||||
{stg.temperature[i]},
|
||||
{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]})''')
|
||||
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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(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])
|
||||
)
|
||||
|
||||
cur.execute(query7)
|
||||
cnx.commit()
|
||||
cnx.commit()
|
||||
|
||||
print(f"table Settings : {time.time() - start_table_Settings} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++++
|
||||
# --- Table Sediments File ---
|
||||
# ++++++++++++++++++++++++++++
|
||||
|
||||
start_table_SedimentsFile = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists SedimentsFile")
|
||||
|
||||
cur.execute(self.create_SedimentsFile)
|
||||
|
||||
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine) VALUES(?, ?)''',
|
||||
(stg.path_fine, stg.filename_fine))
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table SedimentsFile : {time.time() - start_table_SedimentsFile} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++++
|
||||
# --- Table Sediments Data ---
|
||||
# ++++++++++++++++++++++++++++
|
||||
|
||||
start_table_SedimentsData = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists SedimentsData")
|
||||
|
||||
cur.execute(self.create_SedimentsData)
|
||||
|
||||
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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(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()))
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table SedimentsData : {time.time() - start_table_SedimentsData} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++++++
|
||||
# --- Table Calibration ---
|
||||
# ++++++++++++++++++++++++++++++
|
||||
|
||||
start_table_Calibration = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists Calibration")
|
||||
|
||||
cur.execute(self.create_Calibration)
|
||||
|
||||
cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
|
||||
range_lin_interp, M_profile_fine,
|
||||
ks, sv, X_exponent, alpha_s, zeta,
|
||||
FCB, depth_real, lin_reg)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.path_calibration_file, stg.filename_calibration_file,
|
||||
stg.range_lin_interp.tobytes(), stg.M_profile_fine.tobytes(),
|
||||
np.array(stg.ks).tobytes(), np.array(stg.sv).tobytes(), np.array(stg.X_exponent).tobytes(),
|
||||
np.array(stg.alpha_s).tobytes(), np.array(stg.zeta).tobytes(),
|
||||
stg.FCB.tobytes(), stg.depth_real.tobytes(), np.array(stg.lin_reg).tobytes())
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table Calibration : {time.time() - start_table_Calibration} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++++++
|
||||
# --- Table Inversion ---
|
||||
# ++++++++++++++++++++++++++++++
|
||||
|
||||
start_table_Inversion = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists Inversion")
|
||||
|
||||
cur.execute(self.create_Inversion)
|
||||
|
||||
for i in range(len(stg.SSC_fine)):
|
||||
cur.execute('''INSERT into Inversion(J_cross_section_freq1, J_cross_section_freq2,
|
||||
VBI_cross_section, SSC_fine, SSC_sand)
|
||||
VALUES(?, ?, ?, ?, ?)''',
|
||||
(stg.J_cross_section[i][0].tobytes(), stg.J_cross_section[i][1].tobytes(),
|
||||
stg.VBI_cross_section[i].tobytes(), stg.SSC_fine[i].tobytes(), stg.SSC_sand[i].tobytes())
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table Inversion : {time.time() - start_table_Inversion} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Close database cursor
|
||||
cur.close()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import numpy as np
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication
|
||||
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
|
||||
import sqlite3
|
||||
import settings as stg
|
||||
from os import chdir, getcwd
|
||||
|
|
@ -10,12 +10,20 @@ class UpdateTableForSave:
|
|||
|
||||
def __init__(self):
|
||||
|
||||
start = time.time()
|
||||
chdir(stg.dirname_save_as)
|
||||
print("get cwd for save :", getcwd())
|
||||
print("stg.filename_save_as ", stg.filename_save_as)
|
||||
self.update_table()
|
||||
print(f"end : {time.time() - start} sec")
|
||||
if stg.dirname_save_as:
|
||||
start = time.time()
|
||||
chdir(stg.dirname_save_as)
|
||||
print("get cwd for save :", getcwd())
|
||||
print("stg.filename_save_as ", stg.filename_save_as)
|
||||
self.update_table()
|
||||
print(f"end : {time.time() - start} sec")
|
||||
else:
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Save Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
msgBox.setText("Use 'Save as' before 'Save'")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
|
||||
def update_table(self):
|
||||
|
||||
|
|
@ -26,58 +34,303 @@ class UpdateTableForSave:
|
|||
cur = cnx.cursor()
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# --- Table BSRawData_i ---
|
||||
# +++++++++++++++++++++++++++
|
||||
# --- Table Acoustic File ---
|
||||
# +++++++++++++++++++++++++++
|
||||
|
||||
start_table_AcousticFile = time.time()
|
||||
|
||||
cur.execute('''DROP TABLE AcousticFile''')
|
||||
|
||||
cur.execute("""CREATE TABLE AcousticFile(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
acoustic_file STRING,
|
||||
ABS_name STRING,
|
||||
path_BS_noise_data STRING,
|
||||
filename_BS_noise_data STRING,
|
||||
noise_method FLOAT,
|
||||
noise_value FLOAT,
|
||||
data_preprocessed STRING
|
||||
)"""
|
||||
)
|
||||
|
||||
for i in stg.acoustic_data:
|
||||
print("stg.acoustic_data ", stg.acoustic_data[i])
|
||||
print("stg.filename_BS_raw_data ", stg.filename_BS_raw_data[i])
|
||||
print('stg.ABS_name', stg.ABS_name)
|
||||
print("stg.path_BS_raw_data ", stg.path_BS_raw_data[i])
|
||||
|
||||
cur.execute(''' INSERT into AcousticFile(acoustic_data, acoustic_file, ABS_name, path_BS_noise_data,
|
||||
filename_BS_noise_data, noise_method, noise_value, data_preprocessed)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.acoustic_data[i], stg.filename_BS_raw_data[i].split('.')[0], stg.ABS_name[i],
|
||||
stg.path_BS_noise_data[i], stg.filename_BS_noise_data[i], stg.noise_method[i],
|
||||
stg.noise_value[i], stg.data_preprocessed[i])
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
print(f"Table AcousticFile : {time.time() - start_table_AcousticFile} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++
|
||||
# --- Table Measurements ---
|
||||
# ++++++++++++++++++++++++++
|
||||
|
||||
start_table_Measure = time.time()
|
||||
|
||||
# Drop Table if exists
|
||||
cur.execute("DROP TABLE if exists Measure")
|
||||
|
||||
cur.execute("""CREATE TABLE Measure(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
frequency FLOAT,
|
||||
kt_read FLOAT,
|
||||
kt_corrected FLOAT,
|
||||
NbProfiles FLOAT,
|
||||
NbProfilesPerSeconds FLOAT,
|
||||
NbCells FLOAT,
|
||||
CellSize FLOAT,
|
||||
PulseLength FLOAT,
|
||||
NbPingsPerSeconds FLOAT,
|
||||
NbPingsAveragedPerProfile FLOAT,
|
||||
GainRx 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,
|
||||
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],
|
||||
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]))
|
||||
|
||||
# Commit the transaction after executing INSERT.
|
||||
cnx.commit()
|
||||
|
||||
print(f"table Measure : {time.time() - start_table_Measure} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# +++++++++++++++++++++++++++
|
||||
# --- Table Acoustic Data ---
|
||||
# +++++++++++++++++++++++++++
|
||||
|
||||
start_table_BSRawData = time.time()
|
||||
|
||||
# # --- Fill table BSRawData_i with data stg.depth_reshape ---
|
||||
#
|
||||
# for i in stg.acoustic_data:
|
||||
# exec("query1 = '''ALTER TABLE BSRawData ADD COLUMN BS_cross_section BLOB''' ")
|
||||
#
|
||||
# exec("cur.execute(query1)")
|
||||
#
|
||||
# # Commit the transaction after executing INSERT.
|
||||
# cnx.commit()
|
||||
#
|
||||
# for i in stg.acoustic_data:
|
||||
# cur.execute(f"''' UPDATE BSRawData SET BS_cross_section = " + str(stg.BS_cross_section[i].tobytes()) + " WHERE acoustic_data =" + str(i) + " ''' ")
|
||||
#
|
||||
# # Commit the transaction after executing INSERT.
|
||||
# cnx.commit()
|
||||
#
|
||||
# print(f"end : {time.time() - start_table_BSRawData} sec")
|
||||
cur.execute(''' DROP TABLE BSRawData ''')
|
||||
|
||||
if stg.BS_cross_section:
|
||||
|
||||
cur.execute(''' DROP TABLE BSRawData ''')
|
||||
print(f"end : {time.time() - start_table_BSRawData} sec")
|
||||
|
||||
cur.execute('''CREATE TABLE BSRawData(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
cur.execute('''CREATE TABLE BSRawData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
time BLOB,
|
||||
time_cross_section BLOB,
|
||||
depth BLOB,
|
||||
depth_cross_section BLOB,
|
||||
BS_raw_data BLOB,
|
||||
BS_cross_section BLOB)''')
|
||||
time BLOB, depth BLOB, BS_raw_data 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
|
||||
)''')
|
||||
|
||||
for i in stg.acoustic_data:
|
||||
for i in stg.acoustic_data:
|
||||
|
||||
cur.execute(''' INSERT into BSRawData(acoustic_data, time, time_cross_section,
|
||||
depth, depth_cross_section,
|
||||
BS_raw_data, BS_cross_section)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.acoustic_data[i], stg.time[i].tobytes(), stg.time_cross_section[i].tobytes(),
|
||||
stg.depth[i].tobytes(), stg.depth_cross_section[i].tobytes(),
|
||||
stg.BS_raw_data[i].tobytes(), stg.BS_cross_section[i].tobytes()))
|
||||
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
|
||||
time_cross_section, depth_cross_section,
|
||||
BS_cross_section, BS_stream_bed,
|
||||
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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.acoustic_data[i], stg.time[i].tobytes(), stg.depth[i].tobytes(), stg.BS_raw_data[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_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()
|
||||
)
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
cnx.commit()
|
||||
|
||||
if stg.depth_bottom:
|
||||
print(f"table BSRawData : {time.time() - start_table_BSRawData} sec")
|
||||
|
||||
pass
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++
|
||||
# --- Table Settings ---
|
||||
# ++++++++++++++++++++++
|
||||
|
||||
start_table_Settings = time.time()
|
||||
|
||||
cur.execute(''' DROP TABLE Settings''')
|
||||
|
||||
cur.execute('''CREATE TABLE Settings(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
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,
|
||||
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
||||
)'''
|
||||
)
|
||||
|
||||
for i in stg.acoustic_data:
|
||||
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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(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])
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table Settings : {time.time() - start_table_Settings} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++++
|
||||
# --- Table Sediments File ---
|
||||
# ++++++++++++++++++++++++++++
|
||||
|
||||
start_table_SedimentsFile = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists SedimentsFile")
|
||||
|
||||
cur.execute("""CREATE TABLE SedimentsFile(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path_fine STRING,
|
||||
filename_fine STRING
|
||||
)"""
|
||||
)
|
||||
|
||||
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine) VALUES(?, ?)''',
|
||||
(stg.path_fine, stg.filename_fine))
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table SedimentsFile : {time.time() - start_table_SedimentsFile} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++++
|
||||
# --- Table Sediments Data ---
|
||||
# ++++++++++++++++++++++++++++
|
||||
|
||||
start_table_SedimentsData = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists SedimentsData")
|
||||
|
||||
cur.execute("""CREATE TABLE SedimentsData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
sample_fine_name STRING,
|
||||
sample_fine_index INTEGER,
|
||||
distance_from_bank_fine FLOAT,
|
||||
depth_fine FLOAT,
|
||||
time_fine FLOAT,
|
||||
Ctot_fine FLOAT,
|
||||
Ctot_fine_per_cent FLOAT,
|
||||
D50_fine FLOAT,
|
||||
frac_vol_fine BLOB,
|
||||
frac_vol_fine_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(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(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()))
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table SedimentsData : {time.time() - start_table_SedimentsData} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++++++
|
||||
# --- Table Calibration ---
|
||||
# ++++++++++++++++++++++++++++++
|
||||
|
||||
start_table_Calibration = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists Calibration")
|
||||
|
||||
cur.execute("""CREATE TABLE Calibration(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path_calibration_file STRING,
|
||||
filename_calibration_file STRING,
|
||||
range_lin_interp BLOB,
|
||||
M_profile_fine BLOB,
|
||||
ks BLOB,
|
||||
sv BLOB,
|
||||
X_exponent BLOB,
|
||||
alpha_s BLOB,
|
||||
zeta BLOB,
|
||||
FCB BLOB,
|
||||
depth_real BLOB,
|
||||
lin_reg BLOB
|
||||
)"""
|
||||
)
|
||||
|
||||
cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
|
||||
range_lin_interp, M_profile_fine,
|
||||
ks, sv, X_exponent, alpha_s, zeta,
|
||||
FCB, depth_real, lin_reg)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||
(stg.path_calibration_file, stg.filename_calibration_file,
|
||||
stg.range_lin_interp.tobytes(), stg.M_profile_fine.tobytes(),
|
||||
np.array(stg.ks).tobytes(), np.array(stg.sv).tobytes(), np.array(stg.X_exponent).tobytes(),
|
||||
np.array(stg.alpha_s).tobytes(), np.array(stg.zeta).tobytes(),
|
||||
stg.FCB.tobytes(), stg.depth_real.tobytes(), np.array(stg.lin_reg).tobytes())
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table Calibration : {time.time() - start_table_Calibration} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
# ++++++++++++++++++++++++++++++
|
||||
# --- Table Inversion ---
|
||||
# ++++++++++++++++++++++++++++++
|
||||
|
||||
start_table_Inversion = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists Inversion")
|
||||
|
||||
cur.execute("""CREATE TABLE Inversion(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
J_cross_section_freq1 BLOB,
|
||||
J_cross_section_freq2 BLOB,
|
||||
VBI_cross_section BLOB,
|
||||
SSC_fine BLOB,
|
||||
SSC_sand BLOB
|
||||
)""")
|
||||
|
||||
for i in range(len(stg.SSC_fine)):
|
||||
cur.execute('''INSERT into Inversion(J_cross_section_freq1, J_cross_section_freq2,
|
||||
VBI_cross_section, SSC_fine, SSC_sand)
|
||||
VALUES(?, ?, ?, ?, ?)''',
|
||||
(stg.J_cross_section[i][0].tobytes(), stg.J_cross_section[i][1].tobytes(),
|
||||
stg.VBI_cross_section[i].tobytes(), stg.SSC_fine[i].tobytes(), stg.SSC_sand[i].tobytes())
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
|
||||
print(f"table Inversion : {time.time() - start_table_Inversion} sec")
|
||||
|
||||
# --------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Close database cursor
|
||||
cur.close()
|
||||
|
|
|
|||
|
|
@ -2593,9 +2593,9 @@ class AcousticDataTab(QWidget):
|
|||
stg.BS_stream_bed_pre_process_SNR.append(np.array([]))
|
||||
stg.BS_stream_bed_pre_process_average.append(np.array([]))
|
||||
|
||||
# stg.FCB.append([])
|
||||
# stg.depth_real.append([])
|
||||
# stg.lin_reg.append(tuple())
|
||||
stg.FCB = np.array([])
|
||||
stg.depth_real = np.array([])
|
||||
stg.lin_reg = []
|
||||
#
|
||||
# stg.frequencies_for_calibration.append([])
|
||||
# stg.frequency_for_inversion.append([])
|
||||
|
|
@ -2603,7 +2603,7 @@ class AcousticDataTab(QWidget):
|
|||
# stg.fine_sample_position.append([])
|
||||
# stg.sand_sample_position.append([])
|
||||
|
||||
stg.J_cross_section.append([])
|
||||
stg.J_cross_section.append([np.array([]), np.array([])])
|
||||
stg.VBI_cross_section.append(np.array([]))
|
||||
stg.SSC_fine.append(np.array([]))
|
||||
stg.SSC_sand.append(np.array([]))
|
||||
|
|
|
|||
Loading…
Reference in New Issue