SQL: Some refactoring.
parent
f5eb9a18c6
commit
87098ff152
|
|
@ -38,132 +38,151 @@ class CreateTableForSaveAs:
|
|||
|
||||
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_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 = """ CREATE TABLE Measure(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
Date DATE,
|
||||
Hour TIME,
|
||||
frequency FLOAT,
|
||||
sound_attenuation 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
|
||||
)
|
||||
"""
|
||||
self.create_Measure = """
|
||||
CREATE TABLE Measure(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
Date DATE,
|
||||
Hour TIME,
|
||||
frequency FLOAT,
|
||||
sound_attenuation 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
|
||||
)
|
||||
"""
|
||||
|
||||
self.create_BSRawData = '''CREATE TABLE BSRawData(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
acoustic_data INTEGER,
|
||||
time BLOB, depth BLOB, BS_raw_data BLOB,
|
||||
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
|
||||
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
|
||||
depth_bottom, val_bottom, ind_bottom,
|
||||
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
||||
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
|
||||
BS_raw_data_pre_process_SNR BLOB, BS_raw_data_pre_process_average BLOB,
|
||||
BS_cross_section_pre_process_SNR BLOB, BS_cross_section_pre_process_average BLOB,
|
||||
BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
|
||||
BS_mean BLOB
|
||||
)'''
|
||||
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 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_mean BLOB
|
||||
)
|
||||
"""
|
||||
|
||||
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,
|
||||
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
||||
)'''
|
||||
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,
|
||||
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,
|
||||
radius_grain_fine BLOB,
|
||||
path_sand STRING,
|
||||
filename_sand STRING,
|
||||
radius_grain_sand BLOB,
|
||||
time_column_label STRING,
|
||||
distance_from_bank_column_label STRING,
|
||||
depth_column_label STRING,
|
||||
Ctot_fine_column_label STRING,
|
||||
D50_fine_column_label STRING,
|
||||
Ctot_sand_column_label STRING,
|
||||
D50_sand_column_label STRING
|
||||
)
|
||||
"""
|
||||
self.create_SedimentsFile = """
|
||||
CREATE TABLE SedimentsFile(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
path_fine STRING,
|
||||
filename_fine STRING,
|
||||
radius_grain_fine BLOB,
|
||||
path_sand STRING,
|
||||
filename_sand STRING,
|
||||
radius_grain_sand BLOB,
|
||||
time_column_label STRING,
|
||||
distance_from_bank_column_label STRING,
|
||||
depth_column_label STRING,
|
||||
Ctot_fine_column_label STRING,
|
||||
D50_fine_column_label STRING,
|
||||
Ctot_sand_column_label STRING,
|
||||
D50_sand_column_label STRING
|
||||
)
|
||||
"""
|
||||
|
||||
self.create_SedimentsData = """CREATE TABLE SedimentsData(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
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,
|
||||
sample_sand_name STRING,
|
||||
sample_sand_index INTEGER,
|
||||
distance_from_bank_sand FLOAT,
|
||||
depth_sand FLOAT,
|
||||
time_sand FLOAT,
|
||||
Ctot_sand FLOAT,
|
||||
Ctot_sand_per_cent FLOAT,
|
||||
D50_sand FLOAT,
|
||||
frac_vol_sand BLOB,
|
||||
frac_vol_sand_cumul BLOB
|
||||
)
|
||||
"""
|
||||
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,
|
||||
sample_sand_name STRING,
|
||||
sample_sand_index INTEGER,
|
||||
distance_from_bank_sand FLOAT,
|
||||
depth_sand FLOAT,
|
||||
time_sand FLOAT,
|
||||
Ctot_sand FLOAT,
|
||||
Ctot_sand_per_cent FLOAT,
|
||||
D50_sand FLOAT,
|
||||
frac_vol_sand BLOB,
|
||||
frac_vol_sand_cumul BLOB
|
||||
)
|
||||
"""
|
||||
|
||||
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_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.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