SQL: Some refactoring.
parent
f5eb9a18c6
commit
87098ff152
|
|
@ -38,7 +38,8 @@ class CreateTableForSaveAs:
|
|||
|
||||
def __init__(self):
|
||||
|
||||
self.create_AcousticFile = """CREATE TABLE AcousticFile(
|
||||
self.create_AcousticFile = """
|
||||
CREATE TABLE AcousticFile(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
acoustic_file STRING,
|
||||
|
|
@ -51,7 +52,8 @@ class CreateTableForSaveAs:
|
|||
)
|
||||
"""
|
||||
|
||||
self.create_Measure = """ CREATE TABLE Measure(
|
||||
self.create_Measure = """
|
||||
CREATE TABLE Measure(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
Date DATE,
|
||||
|
|
@ -72,32 +74,44 @@ class CreateTableForSaveAs:
|
|||
)
|
||||
"""
|
||||
|
||||
self.create_BSRawData = '''CREATE TABLE BSRawData(
|
||||
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,
|
||||
time_cross_section BLOB, depth_cross_section BLOB,
|
||||
BS_cross_section BLOB, BS_stream_bed BLO B,
|
||||
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_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_mean BLOB
|
||||
)'''
|
||||
)
|
||||
"""
|
||||
|
||||
self.create_Settings = '''CREATE TABLE Settings(
|
||||
self.create_Settings = """
|
||||
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_index FLOAT, freq_bottom_detection_value STRING,
|
||||
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_index FLOAT,
|
||||
freq_bottom_detection_value STRING,
|
||||
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
||||
)'''
|
||||
)
|
||||
"""
|
||||
|
||||
self.create_SedimentsFile = """CREATE TABLE SedimentsFile(
|
||||
self.create_SedimentsFile = """
|
||||
CREATE TABLE SedimentsFile(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path_fine STRING,
|
||||
filename_fine STRING,
|
||||
|
|
@ -115,7 +129,8 @@ class CreateTableForSaveAs:
|
|||
)
|
||||
"""
|
||||
|
||||
self.create_SedimentsData = """CREATE TABLE SedimentsData(
|
||||
self.create_SedimentsData = """
|
||||
CREATE TABLE SedimentsData(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
sample_fine_name STRING,
|
||||
sample_fine_index INTEGER,
|
||||
|
|
@ -140,7 +155,8 @@ class CreateTableForSaveAs:
|
|||
)
|
||||
"""
|
||||
|
||||
self.create_Calibration = """CREATE TABLE Calibration(
|
||||
self.create_Calibration = """
|
||||
CREATE TABLE Calibration(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path_calibration_file STRING,
|
||||
filename_calibration_file STRING,
|
||||
|
|
@ -154,16 +170,19 @@ class CreateTableForSaveAs:
|
|||
FCB BLOB,
|
||||
depth_real BLOB,
|
||||
lin_reg BLOB
|
||||
)"""
|
||||
)
|
||||
"""
|
||||
|
||||
self.create_Inversion = """CREATE TABLE Inversion(
|
||||
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()
|
||||
|
||||
|
|
@ -240,7 +259,7 @@ class CreateTableForSaveAs:
|
|||
logger.debug(f"stg.path_BS_raw_data: {stg.path_BS_raw_data[i]}")
|
||||
|
||||
cur.execute(
|
||||
'''
|
||||
"""
|
||||
INSERT into AcousticFile(
|
||||
acoustic_data,
|
||||
acoustic_file,
|
||||
|
|
@ -251,7 +270,7 @@ class CreateTableForSaveAs:
|
|||
noise_value,
|
||||
data_preprocessed)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''',
|
||||
""",
|
||||
(
|
||||
stg.acoustic_data[i],
|
||||
stg.filename_BS_raw_data[i].split('.')[0],
|
||||
|
|
@ -282,7 +301,7 @@ class CreateTableForSaveAs:
|
|||
for i in stg.acoustic_data:
|
||||
for j in range(stg.freq[i].shape[0]):
|
||||
cur.execute(
|
||||
'''
|
||||
"""
|
||||
INSERT into Measure(
|
||||
acoustic_data,
|
||||
Date, Hour,
|
||||
|
|
@ -297,7 +316,7 @@ class CreateTableForSaveAs:
|
|||
GainRx, GainTx
|
||||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''',
|
||||
""",
|
||||
(
|
||||
stg.acoustic_data[i], #stg.date[i], stg.hour[i],
|
||||
str(stg.date[i].year) + str('-')
|
||||
|
|
@ -331,7 +350,7 @@ class CreateTableForSaveAs:
|
|||
|
||||
for i in stg.acoustic_data:
|
||||
cur.execute(
|
||||
'''
|
||||
"""
|
||||
INSERT into BSRawData(
|
||||
acoustic_data,
|
||||
time, depth,
|
||||
|
|
@ -351,7 +370,7 @@ class CreateTableForSaveAs:
|
|||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?)
|
||||
''',
|
||||
""",
|
||||
(
|
||||
stg.acoustic_data[i], stg.time[i].tobytes(),
|
||||
stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes(),
|
||||
|
|
@ -399,7 +418,7 @@ class CreateTableForSaveAs:
|
|||
|
||||
for i in stg.acoustic_data:
|
||||
cur.execute(
|
||||
'''
|
||||
"""
|
||||
INSERT into Settings(
|
||||
acoustic_data, temperature,
|
||||
tmin_index, tmin_value, tmax_index, tmax_value,
|
||||
|
|
@ -408,7 +427,7 @@ class CreateTableForSaveAs:
|
|||
SNR_filter_value, Nb_cells_to_average_BS_signal
|
||||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''',
|
||||
""",
|
||||
(
|
||||
stg.acoustic_data[i], stg.temperature,
|
||||
stg.tmin[i][0], stg.tmin[i][1],
|
||||
|
|
@ -435,7 +454,7 @@ class CreateTableForSaveAs:
|
|||
|
||||
if stg.path_fine != "" and path_sand != "":
|
||||
cur.execute(
|
||||
'''
|
||||
"""
|
||||
INSERT into SedimentsFile(
|
||||
path_fine, filename_fine, radius_grain_fine,
|
||||
path_sand, filename_sand, radius_grain_sand,
|
||||
|
|
@ -445,7 +464,7 @@ class CreateTableForSaveAs:
|
|||
Ctot_sand_column_label, D50_sand_column_label
|
||||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''',
|
||||
""",
|
||||
(
|
||||
stg.path_fine, stg.filename_fine,
|
||||
stg.radius_grain_fine.tobytes(),
|
||||
|
|
@ -472,7 +491,7 @@ 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,
|
||||
|
|
@ -487,7 +506,7 @@ class CreateTableForSaveAs:
|
|||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''',
|
||||
""",
|
||||
(
|
||||
stg.sample_fine[f][0] , stg.sample_fine[f][1],
|
||||
stg.distance_from_bank_fine[f], stg.depth_fine[f],
|
||||
|
|
@ -517,7 +536,7 @@ class CreateTableForSaveAs:
|
|||
|
||||
if len(stg.range_lin_interp) != 0:
|
||||
cur.execute(
|
||||
'''
|
||||
"""
|
||||
INSERT into Calibration(
|
||||
path_calibration_file, filename_calibration_file,
|
||||
range_lin_interp, M_profile_fine,
|
||||
|
|
@ -525,7 +544,7 @@ class CreateTableForSaveAs:
|
|||
FCB, depth_real, lin_reg
|
||||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''',
|
||||
""",
|
||||
(
|
||||
stg.path_calibration_file, stg.filename_calibration_file,
|
||||
stg.range_lin_interp.tobytes(),
|
||||
|
|
@ -552,13 +571,13 @@ class CreateTableForSaveAs:
|
|||
|
||||
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(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue