Compare commits

..

No commits in common. "f872b625c2dcb5a4dae83cafe9f77387389d64ed" and "b7ae9dfe692256eb59b4770c52f871604abdb846" have entirely different histories.

1 changed files with 292 additions and 404 deletions

View File

@ -37,151 +37,133 @@ logger = logging.getLogger()
class CreateTableForSaveAs: class CreateTableForSaveAs:
def __init__(self): def __init__(self):
self.create_AcousticFile = """
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
)
"""
self.create_Measure = """ self.create_AcousticFile = """CREATE TABLE AcousticFile(
CREATE TABLE Measure( ID INTEGER PRIMARY KEY AUTOINCREMENT,
ID INTEGER PRIMARY KEY AUTOINCREMENT, acoustic_data INTEGER,
acoustic_data INTEGER, acoustic_file STRING,
Date DATE, ABS_name STRING,
Hour TIME, path_BS_noise_data STRING,
frequency FLOAT, filename_BS_noise_data STRING,
sound_attenuation FLOAT, noise_method FLOAT,
kt_read FLOAT, noise_value FLOAT,
kt_corrected FLOAT, data_preprocessed STRING
NbProfiles FLOAT, )
NbProfilesPerSeconds FLOAT, """
NbCells FLOAT,
CellSize FLOAT,
PulseLength FLOAT,
NbPingsPerSeconds FLOAT,
NbPingsAveragedPerProfile FLOAT,
GainRx FLOAT,
GainTx FLOAT
)
"""
self.create_BSRawData = """ self.create_Measure = """ CREATE TABLE Measure(
CREATE TABLE BSRawData( ID INTEGER PRIMARY KEY AUTOINCREMENT,
ID INTEGER PRIMARY KEY AUTOINCREMENT, acoustic_data INTEGER,
acoustic_data INTEGER, Date DATE,
time BLOB, depth BLOB, BS_raw_data BLOB, Hour TIME,
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB, frequency FLOAT,
time_cross_section BLOB, depth_cross_section BLOB, sound_attenuation FLOAT,
BS_cross_section BLOB, BS_stream_bed BLO B, kt_read FLOAT,
depth_bottom, val_bottom, ind_bottom, kt_corrected FLOAT,
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB, NbProfiles FLOAT,
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB, NbProfilesPerSeconds FLOAT,
BS_raw_data_pre_process_SNR BLOB, NbCells FLOAT,
BS_raw_data_pre_process_average BLOB, CellSize FLOAT,
BS_cross_section_pre_process_SNR BLOB, PulseLength FLOAT,
BS_cross_section_pre_process_average BLOB, NbPingsPerSeconds FLOAT,
BS_stream_bed_pre_process_SNR BLOB, NbPingsAveragedPerProfile FLOAT,
BS_stream_bed_pre_process_average BLOB, GainRx FLOAT,
BS_mean BLOB GainTx FLOAT
) )
""" """
self.create_Settings = """ self.create_BSRawData = '''CREATE TABLE BSRawData(
CREATE TABLE Settings( ID INTEGER PRIMARY KEY AUTOINCREMENT,
ID INTEGER PRIMARY KEY AUTOINCREMENT, acoustic_data INTEGER,
acoustic_data INTEGER, time BLOB, depth BLOB, BS_raw_data BLOB,
temperature FLOAT, time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
tmin_index FLOAT, tmin_value FLOAT, time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
tmax_index FLOAT, tmax_value FLOAT, depth_bottom, val_bottom, ind_bottom,
rmin_index FLOAT, rmin_value FLOAT, time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
rmax_index FLOAT, rmax_value FLOAT, SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
freq_bottom_detection_index FLOAT, BS_raw_data_pre_process_SNR BLOB, BS_raw_data_pre_process_average BLOB,
freq_bottom_detection_value STRING, BS_cross_section_pre_process_SNR BLOB, BS_cross_section_pre_process_average BLOB,
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
) BS_mean BLOB
""" )'''
self.create_SedimentsFile = """ self.create_Settings = '''CREATE TABLE Settings(
CREATE TABLE SedimentsFile( ID INTEGER PRIMARY KEY AUTOINCREMENT,
ID INTEGER PRIMARY KEY AUTOINCREMENT, acoustic_data INTEGER,
path_fine STRING, temperature FLOAT,
filename_fine STRING, tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value FLOAT,
radius_grain_fine BLOB, rmin_index FLOAT, rmin_value FLOAT, rmax_index FLOAT, rmax_value FLOAT,
path_sand STRING, freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
filename_sand STRING, SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
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 = """ self.create_SedimentsFile = """CREATE TABLE SedimentsFile(
CREATE TABLE SedimentsData( ID INTEGER PRIMARY KEY AUTOINCREMENT,
ID INTEGER PRIMARY KEY AUTOINCREMENT, path_fine STRING,
sample_fine_name STRING, filename_fine STRING,
sample_fine_index INTEGER, radius_grain_fine BLOB,
distance_from_bank_fine FLOAT, path_sand STRING,
depth_fine FLOAT, filename_sand STRING,
time_fine FLOAT, radius_grain_sand BLOB,
Ctot_fine FLOAT, time_column_label STRING,
Ctot_fine_per_cent FLOAT, distance_from_bank_column_label STRING,
D50_fine FLOAT, depth_column_label STRING,
frac_vol_fine BLOB, Ctot_fine_column_label STRING,
frac_vol_fine_cumul BLOB, D50_fine_column_label STRING,
sample_sand_name STRING, Ctot_sand_column_label STRING,
sample_sand_index INTEGER, D50_sand_column_label STRING
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
)
"""
self.create_Calibration = """ self.create_SedimentsData = """CREATE TABLE SedimentsData(
CREATE TABLE Calibration( ID INTEGER PRIMARY KEY AUTOINCREMENT,
ID INTEGER PRIMARY KEY AUTOINCREMENT, sample_fine_name STRING,
path_calibration_file STRING, sample_fine_index INTEGER,
filename_calibration_file STRING, distance_from_bank_fine FLOAT,
range_lin_interp BLOB, depth_fine FLOAT,
M_profile_fine BLOB, time_fine FLOAT,
ks BLOB, Ctot_fine FLOAT,
sv BLOB, Ctot_fine_per_cent FLOAT,
X_exponent BLOB, D50_fine FLOAT,
alpha_s BLOB, frac_vol_fine BLOB,
zeta BLOB, frac_vol_fine_cumul BLOB,
FCB BLOB, sample_sand_name STRING,
depth_real BLOB, sample_sand_index INTEGER,
lin_reg BLOB 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
)
"""
self.create_Inversion = """ self.create_Calibration = """CREATE TABLE Calibration(
CREATE TABLE Inversion( ID INTEGER PRIMARY KEY AUTOINCREMENT,
ID INTEGER PRIMARY KEY AUTOINCREMENT, path_calibration_file STRING,
J_cross_section_freq1 BLOB, filename_calibration_file STRING,
J_cross_section_freq2 BLOB, range_lin_interp BLOB,
VBI_cross_section BLOB, M_profile_fine BLOB,
SSC_fine BLOB, ks BLOB,
SSC_sand 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() self.open_file_dialog()
@ -221,24 +203,18 @@ class CreateTableForSaveAs:
msgBox.exec() msgBox.exec()
def create_table(self): def create_table(self):
# Create a new database and open a database connection to allow sqlite3 to work with it.
cnx = sqlite3.connect(stg.filename_save_as) cnx = sqlite3.connect(stg.filename_save_as)
# Create database cursor to execute SQL statements and fetch results from SQL queries.
cur = cnx.cursor() cur = cnx.cursor()
self.create_table_acoustic_file(cnx, cur) # --------------------------------------------------------------------------------------------------------------
self.create_table_measure(cnx, cur) # +++++++++++++++++++++++++++
self.create_table_BSRawData(cnx, cur) # --- Table Acoustic File ---
self.create_table_settings(cnx, cur) # +++++++++++++++++++++++++++
self.create_table_sediments_file(cnx, cur)
self.create_table_sediments_data(cnx, cur)
self.create_table_calibration(cnx, cur)
self.create_table_inversion(cnx, cur)
cnx.commit()
cur.close()
cnx.close()
def create_table_acoustic_file(self, cnx, cur):
start_table_File = time.time() start_table_File = time.time()
cur.execute("DROP TABLE if exists AcousticFile") cur.execute("DROP TABLE if exists AcousticFile")
@ -246,42 +222,28 @@ class CreateTableForSaveAs:
cur.execute(self.create_AcousticFile) cur.execute(self.create_AcousticFile)
for i in stg.acoustic_data: for i in stg.acoustic_data:
logger.debug(f"stg.acoustic_data: {stg.acoustic_data[i]}") print("stg.acoustic_data ", stg.acoustic_data[i])
logger.debug("stg.filename_BS_raw_data: " print("stg.filename_BS_raw_data ", stg.filename_BS_raw_data[i])
+ f"{stg.filename_BS_raw_data[i]}") print('stg.ABS_name', stg.ABS_name)
logger.debug(f"stg.ABS_name: {stg.ABS_name}") print("stg.path_BS_raw_data ", stg.path_BS_raw_data[i])
logger.debug(f"stg.path_BS_raw_data: {stg.path_BS_raw_data[i]}")
cur.execute( 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)
INSERT into AcousticFile( VALUES(?, ?, ?, ?, ?, ?, ?, ?)''',
acoustic_data, (stg.acoustic_data[i], stg.filename_BS_raw_data[i].split('.')[0], stg.ABS_name[i],
acoustic_file, stg.path_BS_noise_data[i], stg.filename_BS_noise_data[i], stg.noise_method[i],
ABS_name, stg.noise_value[i], stg.data_preprocessed[i])
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() cnx.commit()
logger.info(f"table File : {time.time() - start_table_File} sec") print(f"table File : {time.time() - start_table_File} sec")
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++
# --- Table Measure ---
# +++++++++++++++++++++
def create_table_measure(self, cnx, cur):
start_table_Measure = time.time() start_table_Measure = time.time()
# Drop Table if exists # Drop Table if exists
@ -289,52 +251,35 @@ class CreateTableForSaveAs:
# Execute the CREATE TABLE statement # Execute the CREATE TABLE statement
cur.execute(self.create_Measure) cur.execute(self.create_Measure)
print("stg.date ", stg.date, "stg.hour ", stg.hour)
logger.debug(f"stg.date: {stg.date}, stg.hour: {stg.hour}") # Fill the table Measure
for i in stg.acoustic_data: for i in stg.acoustic_data:
for j in range(stg.freq[i].shape[0]): for j in range(stg.freq[i].shape[0]):
cur.execute(
""" cur.execute(''' INSERT into Measure(acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected,
INSERT into Measure( NbProfiles, NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
acoustic_data, NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx
Date, Hour, )
frequency, VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
sound_attenuation, (stg.acoustic_data[i], #stg.date[i], stg.hour[i],
kt_read, kt_corrected, str(stg.date[i].year) + str('-') + str(stg.date[i].month) + str('-') + str(stg.date[i].day),
NbProfiles, NbProfilesPerSeconds, str(stg.hour[i].hour) + str(':') + str(stg.hour[i].minute),
NbCells, CellSize, stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], stg.kt_corrected[j],
PulseLength, stg.nb_profiles[i][j], stg.nb_profiles_per_sec[i][j], stg.nb_cells[i][j],
NbPingsPerSeconds, stg.cell_size[i][j], stg.pulse_length[i][j], stg.nb_pings_per_sec[i][j],
NbPingsAveragedPerProfile, stg.nb_pings_averaged_per_profile[i][j], stg.gain_rx[i][j], stg.gain_tx[i][j]))
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]
)
)
# Commit the transaction after executing INSERT. # Commit the transaction after executing INSERT.
cnx.commit() cnx.commit()
logger.info(f"table Measure : {time.time() - start_table_Measure} sec") print(f"table Measure : {time.time() - start_table_Measure} sec")
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++++++
# --- Table BSRawData_i ---
# +++++++++++++++++++++++++
def create_table_BSRawData(self, cnx, cur):
start_table_BSRawData = time.time() start_table_BSRawData = time.time()
cur.execute('DROP TABLE if exists BSRawData') cur.execute('DROP TABLE if exists BSRawData')
@ -343,140 +288,105 @@ class CreateTableForSaveAs:
cur.execute(self.create_BSRawData) cur.execute(self.create_BSRawData)
for i in stg.acoustic_data: 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,
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_mean[i].tobytes()
)
)
logger.debug(f"stg.ind_bottom: {stg.ind_bottom[i]}") cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
logger.debug(np.array([stg.ind_bottom[i]]), time_reshape, depth_reshape, BS_raw_data_reshape,
np.array(stg.ind_bottom[i]).shape) 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)
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_mean[i].tobytes()
)
)
# Commit the transaction after executing INSERT. 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() cnx.commit()
logger.info(f"table BSRawData : {time.time() - start_table_BSRawData} sec") print(f"table BSRawData : {time.time() - start_table_BSRawData} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++
# --- Table Settings ---
# ++++++++++++++++++++++
def create_table_settings(self, cnx, cur):
start_table_Settings = time.time() start_table_Settings = time.time()
cur.execute("DROP TABLE if exists Settings") cur.execute("DROP TABLE if exists Settings")
cur.execute(self.create_Settings) cur.execute(self.create_Settings)
logger.debug(f"acoustic_data: {stg.acoustic_data}") print(stg.acoustic_data, stg.temperature, stg.rmin, stg.rmax, stg.tmin, stg.tmax)
logger.debug(f"temperature: {stg.temperature}")
logger.debug(f"rmin: {stg.rmin}, rmax: {stg.rmax}")
logger.debug(f"tmin: {stg.tmin}, tmax: {stg.tmax}")
for i in stg.acoustic_data: for i in stg.acoustic_data:
cur.execute( cur.execute('''INSERT into Settings(acoustic_data, temperature,
""" tmin_index, tmin_value, tmax_index, tmax_value,
INSERT into Settings( rmin_index, rmin_value, rmax_index, rmax_value,
acoustic_data, temperature, freq_bottom_detection_index, freq_bottom_detection_value,
tmin_index, tmin_value, tmax_index, tmax_value, SNR_filter_value, Nb_cells_to_average_BS_signal
rmin_index, rmin_value, rmax_index, rmax_value, )
freq_bottom_detection_index, freq_bottom_detection_value, VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
SNR_filter_value, Nb_cells_to_average_BS_signal (stg.acoustic_data[i], stg.temperature,
) stg.tmin[i][0], stg.tmin[i][1], stg.tmax[i][0], stg.tmax[i][1],
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 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]
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]
)
)
cnx.commit() cnx.commit()
logger.info(f"table Settings : {time.time() - start_table_Settings} sec") print(f"table Settings : {time.time() - start_table_Settings} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++++
# --- Table Sediments File ---
# ++++++++++++++++++++++++++++
def create_table_sediments_file(self, cnx, cur):
start_table_SedimentsFile = time.time() start_table_SedimentsFile = time.time()
cur.execute("DROP TABLE if exists SedimentsFile") cur.execute("DROP TABLE if exists SedimentsFile")
cur.execute(self.create_SedimentsFile) cur.execute(self.create_SedimentsFile)
if stg.path_fine != "" and path_sand != "": cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine, radius_grain_fine,
cur.execute( path_sand, filename_sand, radius_grain_sand,
""" time_column_label, distance_from_bank_column_label,
INSERT into SedimentsFile( depth_column_label, Ctot_fine_column_label, D50_fine_column_label,
path_fine, filename_fine, radius_grain_fine, Ctot_sand_column_label, D50_sand_column_label)
path_sand, filename_sand, radius_grain_sand, VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
time_column_label, distance_from_bank_column_label, (stg.path_fine, stg.filename_fine, stg.radius_grain_fine.tobytes(),
depth_column_label, Ctot_fine_column_label, stg.path_sand, stg.filename_sand, stg.radius_grain_sand.tobytes(),
D50_fine_column_label, stg.columns_fine[0], stg.columns_fine[1], stg.columns_fine[2],
Ctot_sand_column_label, D50_sand_column_label stg.columns_fine[3], stg.columns_fine[4], stg.columns_sand[3], stg.columns_sand[4]))
)
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() cnx.commit()
logger.info(f"table SedimentsFile : {time.time() - start_table_SedimentsFile} sec") print(f"table SedimentsFile : {time.time() - start_table_SedimentsFile} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++++
# --- Table Sediments Data ---
# ++++++++++++++++++++++++++++
def create_table_sediments_data(self, cnx, cur):
start_table_SedimentsData = time.time() start_table_SedimentsData = time.time()
cur.execute("DROP TABLE if exists SedimentsData") cur.execute("DROP TABLE if exists SedimentsData")
@ -484,79 +394,59 @@ class CreateTableForSaveAs:
cur.execute(self.create_SedimentsData) cur.execute(self.create_SedimentsData)
for f in range(len(stg.sample_fine)): for f in range(len(stg.sample_fine)):
cur.execute( 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,
INSERT into SedimentsData( frac_vol_fine, frac_vol_fine_cumul,
sample_fine_name, sample_fine_index, sample_sand_name, sample_sand_index, distance_from_bank_sand,
distance_from_bank_fine, depth_sand, time_sand, Ctot_sand, Ctot_sand_per_cent, D50_sand,
depth_fine, time_fine, Ctot_fine, frac_vol_sand, frac_vol_sand_cumul
Ctot_fine_per_cent, D50_fine, )
frac_vol_fine, frac_vol_fine_cumul, VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
sample_sand_name, sample_sand_index, (stg.sample_fine[f][0] , stg.sample_fine[f][1],
distance_from_bank_sand, stg.distance_from_bank_fine[f], stg.depth_fine[f], stg.time_fine[f], stg.Ctot_fine[f],
depth_sand, time_sand, Ctot_sand, stg.Ctot_fine_per_cent[f], stg.D50_fine[f],
Ctot_sand_per_cent, D50_sand, stg.frac_vol_fine[f].tobytes(), stg.frac_vol_fine_cumul[f].tobytes(),
frac_vol_sand, frac_vol_sand_cumul 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],
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, stg.Ctot_sand_per_cent[f], stg.D50_sand[f],
?, ?, ?, ?, ?, ?, ?, ?, ?, ?) stg.frac_vol_sand[f].tobytes(), stg.frac_vol_sand_cumul[f].tobytes()))
""",
(
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.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() cnx.commit()
logger.info(f"table SedimentsData : {time.time() - start_table_SedimentsData} sec") print(f"table SedimentsData : {time.time() - start_table_SedimentsData} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++++++
# --- Table Calibration ---
# ++++++++++++++++++++++++++++++
def create_table_calibration(self, cnx, cur):
start_table_Calibration = time.time() start_table_Calibration = time.time()
cur.execute("DROP TABLE if exists Calibration") cur.execute("DROP TABLE if exists Calibration")
cur.execute(self.create_Calibration) cur.execute(self.create_Calibration)
if len(stg.range_lin_interp) != 0: cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
cur.execute( range_lin_interp, M_profile_fine,
""" ks, sv, X_exponent, alpha_s, zeta,
INSERT into Calibration( FCB, depth_real, lin_reg)
path_calibration_file, filename_calibration_file, VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
range_lin_interp, M_profile_fine, (stg.path_calibration_file, stg.filename_calibration_file,
ks, sv, X_exponent, alpha_s, zeta, stg.range_lin_interp.tobytes(), stg.M_profile_fine.tobytes(),
FCB, depth_real, lin_reg 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(),
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) stg.FCB.tobytes(), stg.depth_real.tobytes(), np.array(stg.lin_reg).tobytes())
""", )
(
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() cnx.commit()
logger.info(f"table Calibration : {time.time() - start_table_Calibration} sec") print(f"table Calibration : {time.time() - start_table_Calibration} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++++++
# --- Table Inversion ---
# ++++++++++++++++++++++++++++++
def create_table_inversion(self, cnx, cur):
start_table_Inversion = time.time() start_table_Inversion = time.time()
cur.execute("DROP TABLE if exists Inversion") cur.execute("DROP TABLE if exists Inversion")
@ -564,23 +454,21 @@ class CreateTableForSaveAs:
cur.execute(self.create_Inversion) cur.execute(self.create_Inversion)
for i in range(len(stg.SSC_fine)): for i in range(len(stg.SSC_fine)):
cur.execute( cur.execute('''INSERT into Inversion(J_cross_section_freq1, J_cross_section_freq2,
""" VBI_cross_section, SSC_fine, SSC_sand)
INSERT into Inversion( VALUES(?, ?, ?, ?, ?)''',
J_cross_section_freq1, J_cross_section_freq2, (stg.J_cross_section[i][0].tobytes(), stg.J_cross_section[i][1].tobytes(),
VBI_cross_section, SSC_fine, SSC_sand stg.VBI_cross_section[i].tobytes(), stg.SSC_fine[i].tobytes(), stg.SSC_sand[i].tobytes())
) )
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() cnx.commit()
logger.info(f"table Inversion : {time.time() - start_table_Inversion} sec") print(f"table Inversion : {time.time() - start_table_Inversion} sec")
# --------------------------------------------------------------------------------------------------------------
# Close database cursor
cur.close()
# Close database connection
cnx.close()