SQL: Some refactoring.
parent
f5eb9a18c6
commit
87098ff152
|
|
@ -38,132 +38,151 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.create_AcousticFile = """CREATE TABLE AcousticFile(
|
self.create_AcousticFile = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE AcousticFile(
|
||||||
acoustic_data INTEGER,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_file STRING,
|
acoustic_data INTEGER,
|
||||||
ABS_name STRING,
|
acoustic_file STRING,
|
||||||
path_BS_noise_data STRING,
|
ABS_name STRING,
|
||||||
filename_BS_noise_data STRING,
|
path_BS_noise_data STRING,
|
||||||
noise_method FLOAT,
|
filename_BS_noise_data STRING,
|
||||||
noise_value FLOAT,
|
noise_method FLOAT,
|
||||||
data_preprocessed STRING
|
noise_value FLOAT,
|
||||||
)
|
data_preprocessed STRING
|
||||||
"""
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
self.create_Measure = """ CREATE TABLE Measure(
|
self.create_Measure = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE Measure(
|
||||||
acoustic_data INTEGER,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
Date DATE,
|
acoustic_data INTEGER,
|
||||||
Hour TIME,
|
Date DATE,
|
||||||
frequency FLOAT,
|
Hour TIME,
|
||||||
sound_attenuation FLOAT,
|
frequency FLOAT,
|
||||||
kt_read FLOAT,
|
sound_attenuation FLOAT,
|
||||||
kt_corrected FLOAT,
|
kt_read FLOAT,
|
||||||
NbProfiles FLOAT,
|
kt_corrected FLOAT,
|
||||||
NbProfilesPerSeconds FLOAT,
|
NbProfiles FLOAT,
|
||||||
NbCells FLOAT,
|
NbProfilesPerSeconds FLOAT,
|
||||||
CellSize FLOAT,
|
NbCells FLOAT,
|
||||||
PulseLength FLOAT,
|
CellSize FLOAT,
|
||||||
NbPingsPerSeconds FLOAT,
|
PulseLength FLOAT,
|
||||||
NbPingsAveragedPerProfile FLOAT,
|
NbPingsPerSeconds FLOAT,
|
||||||
GainRx FLOAT,
|
NbPingsAveragedPerProfile FLOAT,
|
||||||
GainTx FLOAT
|
GainRx FLOAT,
|
||||||
)
|
GainTx FLOAT
|
||||||
"""
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
self.create_BSRawData = '''CREATE TABLE BSRawData(
|
self.create_BSRawData = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE BSRawData(
|
||||||
acoustic_data INTEGER,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
time BLOB, depth BLOB, BS_raw_data BLOB,
|
acoustic_data INTEGER,
|
||||||
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape 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,
|
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
|
||||||
depth_bottom, val_bottom, ind_bottom,
|
time_cross_section BLOB, depth_cross_section BLOB,
|
||||||
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
BS_cross_section BLOB, BS_stream_bed BLO B,
|
||||||
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
|
depth_bottom, val_bottom, ind_bottom,
|
||||||
BS_raw_data_pre_process_SNR BLOB, BS_raw_data_pre_process_average BLOB,
|
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
||||||
BS_cross_section_pre_process_SNR BLOB, BS_cross_section_pre_process_average BLOB,
|
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
|
||||||
BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
|
BS_raw_data_pre_process_SNR BLOB,
|
||||||
BS_mean 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 = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE Settings(
|
||||||
acoustic_data INTEGER,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
temperature FLOAT,
|
acoustic_data INTEGER,
|
||||||
tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value FLOAT,
|
temperature FLOAT,
|
||||||
rmin_index FLOAT, rmin_value FLOAT, rmax_index FLOAT, rmax_value FLOAT,
|
tmin_index FLOAT, tmin_value FLOAT,
|
||||||
freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
|
tmax_index FLOAT, tmax_value FLOAT,
|
||||||
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal 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 = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE SedimentsFile(
|
||||||
path_fine STRING,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
filename_fine STRING,
|
path_fine STRING,
|
||||||
radius_grain_fine BLOB,
|
filename_fine STRING,
|
||||||
path_sand STRING,
|
radius_grain_fine BLOB,
|
||||||
filename_sand STRING,
|
path_sand STRING,
|
||||||
radius_grain_sand BLOB,
|
filename_sand STRING,
|
||||||
time_column_label STRING,
|
radius_grain_sand BLOB,
|
||||||
distance_from_bank_column_label STRING,
|
time_column_label STRING,
|
||||||
depth_column_label STRING,
|
distance_from_bank_column_label STRING,
|
||||||
Ctot_fine_column_label STRING,
|
depth_column_label STRING,
|
||||||
D50_fine_column_label STRING,
|
Ctot_fine_column_label STRING,
|
||||||
Ctot_sand_column_label STRING,
|
D50_fine_column_label STRING,
|
||||||
D50_sand_column_label STRING
|
Ctot_sand_column_label STRING,
|
||||||
)
|
D50_sand_column_label STRING
|
||||||
"""
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
self.create_SedimentsData = """CREATE TABLE SedimentsData(
|
self.create_SedimentsData = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE SedimentsData(
|
||||||
sample_fine_name STRING,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
sample_fine_index INTEGER,
|
sample_fine_name STRING,
|
||||||
distance_from_bank_fine FLOAT,
|
sample_fine_index INTEGER,
|
||||||
depth_fine FLOAT,
|
distance_from_bank_fine FLOAT,
|
||||||
time_fine FLOAT,
|
depth_fine FLOAT,
|
||||||
Ctot_fine FLOAT,
|
time_fine FLOAT,
|
||||||
Ctot_fine_per_cent FLOAT,
|
Ctot_fine FLOAT,
|
||||||
D50_fine FLOAT,
|
Ctot_fine_per_cent FLOAT,
|
||||||
frac_vol_fine BLOB,
|
D50_fine FLOAT,
|
||||||
frac_vol_fine_cumul BLOB,
|
frac_vol_fine BLOB,
|
||||||
sample_sand_name STRING,
|
frac_vol_fine_cumul BLOB,
|
||||||
sample_sand_index INTEGER,
|
sample_sand_name STRING,
|
||||||
distance_from_bank_sand FLOAT,
|
sample_sand_index INTEGER,
|
||||||
depth_sand FLOAT,
|
distance_from_bank_sand FLOAT,
|
||||||
time_sand FLOAT,
|
depth_sand FLOAT,
|
||||||
Ctot_sand FLOAT,
|
time_sand FLOAT,
|
||||||
Ctot_sand_per_cent FLOAT,
|
Ctot_sand FLOAT,
|
||||||
D50_sand FLOAT,
|
Ctot_sand_per_cent FLOAT,
|
||||||
frac_vol_sand BLOB,
|
D50_sand FLOAT,
|
||||||
frac_vol_sand_cumul BLOB
|
frac_vol_sand BLOB,
|
||||||
)
|
frac_vol_sand_cumul BLOB
|
||||||
"""
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
self.create_Calibration = """CREATE TABLE Calibration(
|
self.create_Calibration = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE Calibration(
|
||||||
path_calibration_file STRING,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
filename_calibration_file STRING,
|
path_calibration_file STRING,
|
||||||
range_lin_interp BLOB,
|
filename_calibration_file STRING,
|
||||||
M_profile_fine BLOB,
|
range_lin_interp BLOB,
|
||||||
ks BLOB,
|
M_profile_fine BLOB,
|
||||||
sv BLOB,
|
ks BLOB,
|
||||||
X_exponent BLOB,
|
sv BLOB,
|
||||||
alpha_s BLOB,
|
X_exponent BLOB,
|
||||||
zeta BLOB,
|
alpha_s BLOB,
|
||||||
FCB BLOB,
|
zeta BLOB,
|
||||||
depth_real BLOB,
|
FCB BLOB,
|
||||||
lin_reg BLOB
|
depth_real BLOB,
|
||||||
)"""
|
lin_reg BLOB
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
self.create_Inversion = """CREATE TABLE Inversion(
|
self.create_Inversion = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE Inversion(
|
||||||
J_cross_section_freq1 BLOB,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
J_cross_section_freq2 BLOB,
|
J_cross_section_freq1 BLOB,
|
||||||
VBI_cross_section BLOB,
|
J_cross_section_freq2 BLOB,
|
||||||
SSC_fine BLOB,
|
VBI_cross_section BLOB,
|
||||||
SSC_sand BLOB
|
SSC_fine BLOB,
|
||||||
)"""
|
SSC_sand BLOB
|
||||||
|
)
|
||||||
|
"""
|
||||||
|
|
||||||
self.open_file_dialog()
|
self.open_file_dialog()
|
||||||
|
|
||||||
|
|
@ -240,7 +259,7 @@ class CreateTableForSaveAs:
|
||||||
logger.debug(f"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(
|
INSERT into AcousticFile(
|
||||||
acoustic_data,
|
acoustic_data,
|
||||||
acoustic_file,
|
acoustic_file,
|
||||||
|
|
@ -251,7 +270,7 @@ class CreateTableForSaveAs:
|
||||||
noise_value,
|
noise_value,
|
||||||
data_preprocessed)
|
data_preprocessed)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''',
|
""",
|
||||||
(
|
(
|
||||||
stg.acoustic_data[i],
|
stg.acoustic_data[i],
|
||||||
stg.filename_BS_raw_data[i].split('.')[0],
|
stg.filename_BS_raw_data[i].split('.')[0],
|
||||||
|
|
@ -282,7 +301,7 @@ class CreateTableForSaveAs:
|
||||||
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(
|
INSERT into Measure(
|
||||||
acoustic_data,
|
acoustic_data,
|
||||||
Date, Hour,
|
Date, Hour,
|
||||||
|
|
@ -297,7 +316,7 @@ class CreateTableForSaveAs:
|
||||||
GainRx, GainTx
|
GainRx, GainTx
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''',
|
""",
|
||||||
(
|
(
|
||||||
stg.acoustic_data[i], #stg.date[i], stg.hour[i],
|
stg.acoustic_data[i], #stg.date[i], stg.hour[i],
|
||||||
str(stg.date[i].year) + str('-')
|
str(stg.date[i].year) + str('-')
|
||||||
|
|
@ -331,7 +350,7 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
for i in stg.acoustic_data:
|
for i in stg.acoustic_data:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
'''
|
"""
|
||||||
INSERT into BSRawData(
|
INSERT into BSRawData(
|
||||||
acoustic_data,
|
acoustic_data,
|
||||||
time, depth,
|
time, depth,
|
||||||
|
|
@ -351,7 +370,7 @@ class CreateTableForSaveAs:
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||||
?, ?, ?, ?, ?, ?)
|
?, ?, ?, ?, ?, ?)
|
||||||
''',
|
""",
|
||||||
(
|
(
|
||||||
stg.acoustic_data[i], stg.time[i].tobytes(),
|
stg.acoustic_data[i], stg.time[i].tobytes(),
|
||||||
stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes(),
|
stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes(),
|
||||||
|
|
@ -399,7 +418,7 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
for i in stg.acoustic_data:
|
for i in stg.acoustic_data:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
'''
|
"""
|
||||||
INSERT into Settings(
|
INSERT into Settings(
|
||||||
acoustic_data, temperature,
|
acoustic_data, temperature,
|
||||||
tmin_index, tmin_value, tmax_index, tmax_value,
|
tmin_index, tmin_value, tmax_index, tmax_value,
|
||||||
|
|
@ -408,7 +427,7 @@ class CreateTableForSaveAs:
|
||||||
SNR_filter_value, Nb_cells_to_average_BS_signal
|
SNR_filter_value, Nb_cells_to_average_BS_signal
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''',
|
""",
|
||||||
(
|
(
|
||||||
stg.acoustic_data[i], stg.temperature,
|
stg.acoustic_data[i], stg.temperature,
|
||||||
stg.tmin[i][0], stg.tmin[i][1],
|
stg.tmin[i][0], stg.tmin[i][1],
|
||||||
|
|
@ -435,7 +454,7 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
if stg.path_fine != "" and path_sand != "":
|
if stg.path_fine != "" and path_sand != "":
|
||||||
cur.execute(
|
cur.execute(
|
||||||
'''
|
"""
|
||||||
INSERT into SedimentsFile(
|
INSERT into SedimentsFile(
|
||||||
path_fine, filename_fine, radius_grain_fine,
|
path_fine, filename_fine, radius_grain_fine,
|
||||||
path_sand, filename_sand, radius_grain_sand,
|
path_sand, filename_sand, radius_grain_sand,
|
||||||
|
|
@ -445,7 +464,7 @@ class CreateTableForSaveAs:
|
||||||
Ctot_sand_column_label, D50_sand_column_label
|
Ctot_sand_column_label, D50_sand_column_label
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''',
|
""",
|
||||||
(
|
(
|
||||||
stg.path_fine, stg.filename_fine,
|
stg.path_fine, stg.filename_fine,
|
||||||
stg.radius_grain_fine.tobytes(),
|
stg.radius_grain_fine.tobytes(),
|
||||||
|
|
@ -472,7 +491,7 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
for f in range(len(stg.sample_fine)):
|
for f in range(len(stg.sample_fine)):
|
||||||
cur.execute(
|
cur.execute(
|
||||||
'''
|
"""
|
||||||
INSERT into SedimentsData(
|
INSERT into SedimentsData(
|
||||||
sample_fine_name, sample_fine_index,
|
sample_fine_name, sample_fine_index,
|
||||||
distance_from_bank_fine,
|
distance_from_bank_fine,
|
||||||
|
|
@ -487,7 +506,7 @@ class CreateTableForSaveAs:
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||||
?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''',
|
""",
|
||||||
(
|
(
|
||||||
stg.sample_fine[f][0] , stg.sample_fine[f][1],
|
stg.sample_fine[f][0] , stg.sample_fine[f][1],
|
||||||
stg.distance_from_bank_fine[f], stg.depth_fine[f],
|
stg.distance_from_bank_fine[f], stg.depth_fine[f],
|
||||||
|
|
@ -517,7 +536,7 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
if len(stg.range_lin_interp) != 0:
|
if len(stg.range_lin_interp) != 0:
|
||||||
cur.execute(
|
cur.execute(
|
||||||
'''
|
"""
|
||||||
INSERT into Calibration(
|
INSERT into Calibration(
|
||||||
path_calibration_file, filename_calibration_file,
|
path_calibration_file, filename_calibration_file,
|
||||||
range_lin_interp, M_profile_fine,
|
range_lin_interp, M_profile_fine,
|
||||||
|
|
@ -525,7 +544,7 @@ class CreateTableForSaveAs:
|
||||||
FCB, depth_real, lin_reg
|
FCB, depth_real, lin_reg
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''',
|
""",
|
||||||
(
|
(
|
||||||
stg.path_calibration_file, stg.filename_calibration_file,
|
stg.path_calibration_file, stg.filename_calibration_file,
|
||||||
stg.range_lin_interp.tobytes(),
|
stg.range_lin_interp.tobytes(),
|
||||||
|
|
@ -552,13 +571,13 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
for i in range(len(stg.SSC_fine)):
|
for i in range(len(stg.SSC_fine)):
|
||||||
cur.execute(
|
cur.execute(
|
||||||
'''
|
"""
|
||||||
INSERT into Inversion(
|
INSERT into Inversion(
|
||||||
J_cross_section_freq1, J_cross_section_freq2,
|
J_cross_section_freq1, J_cross_section_freq2,
|
||||||
VBI_cross_section, SSC_fine, SSC_sand
|
VBI_cross_section, SSC_fine, SSC_sand
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?)
|
VALUES(?, ?, ?, ?, ?)
|
||||||
''',
|
""",
|
||||||
(
|
(
|
||||||
stg.J_cross_section[i][0].tobytes(),
|
stg.J_cross_section[i][0].tobytes(),
|
||||||
stg.J_cross_section[i][1].tobytes(),
|
stg.J_cross_section[i][1].tobytes(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue