Compare commits
17 Commits
6de578a07e
...
761dc9008c
| Author | SHA1 | Date |
|---|---|---|
|
|
761dc9008c | |
|
|
372d002277 | |
|
|
b28978311c | |
|
|
baebe2e8cc | |
|
|
73bf3cf9d3 | |
|
|
12fea4e182 | |
|
|
a5268c6214 | |
|
|
2697acddfe | |
|
|
f872b625c2 | |
|
|
87098ff152 | |
|
|
f5eb9a18c6 | |
|
|
b7ae9dfe69 | |
|
|
0ce60afd04 | |
|
|
86b9f85ec6 | |
|
|
5eb78b812d | |
|
|
8f7e679598 | |
|
|
6628d610de |
|
|
@ -37,133 +37,151 @@ 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_AcousticFile = """CREATE TABLE AcousticFile(
|
self.create_Measure = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE Measure(
|
||||||
acoustic_data INTEGER,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_file STRING,
|
acoustic_data INTEGER,
|
||||||
ABS_name STRING,
|
Date DATE,
|
||||||
path_BS_noise_data STRING,
|
Hour TIME,
|
||||||
filename_BS_noise_data STRING,
|
frequency FLOAT,
|
||||||
noise_method FLOAT,
|
sound_attenuation FLOAT,
|
||||||
noise_value FLOAT,
|
kt_read FLOAT,
|
||||||
data_preprocessed STRING
|
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(
|
self.create_BSRawData = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE BSRawData(
|
||||||
acoustic_data INTEGER,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
Date DATE,
|
acoustic_data INTEGER,
|
||||||
Hour TIME,
|
time BLOB, depth BLOB, BS_raw_data BLOB,
|
||||||
frequency FLOAT,
|
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
|
||||||
sound_attenuation FLOAT,
|
time_cross_section BLOB, depth_cross_section BLOB,
|
||||||
kt_read FLOAT,
|
BS_cross_section BLOB, BS_stream_bed BLO B,
|
||||||
kt_corrected FLOAT,
|
depth_bottom, val_bottom, ind_bottom,
|
||||||
NbProfiles FLOAT,
|
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
||||||
NbProfilesPerSeconds FLOAT,
|
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
|
||||||
NbCells FLOAT,
|
BS_raw_data_pre_process_SNR BLOB,
|
||||||
CellSize FLOAT,
|
BS_raw_data_pre_process_average BLOB,
|
||||||
PulseLength FLOAT,
|
BS_cross_section_pre_process_SNR BLOB,
|
||||||
NbPingsPerSeconds FLOAT,
|
BS_cross_section_pre_process_average BLOB,
|
||||||
NbPingsAveragedPerProfile FLOAT,
|
BS_stream_bed_pre_process_SNR BLOB,
|
||||||
GainRx FLOAT,
|
BS_stream_bed_pre_process_average BLOB,
|
||||||
GainTx FLOAT
|
BS_mean BLOB
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.create_BSRawData = '''CREATE TABLE BSRawData(
|
self.create_Settings = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE Settings(
|
||||||
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,
|
temperature FLOAT,
|
||||||
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
|
tmin_index FLOAT, tmin_value FLOAT,
|
||||||
depth_bottom, val_bottom, ind_bottom,
|
tmax_index FLOAT, tmax_value FLOAT,
|
||||||
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
rmin_index FLOAT, rmin_value FLOAT,
|
||||||
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
|
rmax_index FLOAT, rmax_value FLOAT,
|
||||||
BS_raw_data_pre_process_SNR BLOB, BS_raw_data_pre_process_average BLOB,
|
freq_bottom_detection_index FLOAT,
|
||||||
BS_cross_section_pre_process_SNR BLOB, BS_cross_section_pre_process_average BLOB,
|
freq_bottom_detection_value STRING,
|
||||||
BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
|
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
||||||
BS_mean BLOB
|
)
|
||||||
)'''
|
"""
|
||||||
|
|
||||||
self.create_Settings = '''CREATE TABLE Settings(
|
self.create_SedimentsFile = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE SedimentsFile(
|
||||||
acoustic_data INTEGER,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
temperature FLOAT,
|
path_fine STRING,
|
||||||
tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value FLOAT,
|
filename_fine STRING,
|
||||||
rmin_index FLOAT, rmin_value FLOAT, rmax_index FLOAT, rmax_value FLOAT,
|
radius_grain_fine BLOB,
|
||||||
freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
|
path_sand STRING,
|
||||||
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
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(
|
self.create_SedimentsData = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE SedimentsData(
|
||||||
path_fine STRING,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
filename_fine STRING,
|
sample_fine_name STRING,
|
||||||
radius_grain_fine BLOB,
|
sample_fine_index INTEGER,
|
||||||
path_sand STRING,
|
distance_from_bank_fine FLOAT,
|
||||||
filename_sand STRING,
|
depth_fine FLOAT,
|
||||||
radius_grain_sand BLOB,
|
time_fine FLOAT,
|
||||||
time_column_label STRING,
|
Ctot_fine FLOAT,
|
||||||
distance_from_bank_column_label STRING,
|
Ctot_fine_per_cent FLOAT,
|
||||||
depth_column_label STRING,
|
D50_fine FLOAT,
|
||||||
Ctot_fine_column_label STRING,
|
frac_vol_fine BLOB,
|
||||||
D50_fine_column_label STRING,
|
frac_vol_fine_cumul BLOB,
|
||||||
Ctot_sand_column_label STRING,
|
sample_sand_name STRING,
|
||||||
D50_sand_column_label 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(
|
self.create_Calibration = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE Calibration(
|
||||||
sample_fine_name STRING,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
sample_fine_index INTEGER,
|
path_calibration_file STRING,
|
||||||
distance_from_bank_fine FLOAT,
|
filename_calibration_file STRING,
|
||||||
depth_fine FLOAT,
|
range_lin_interp BLOB,
|
||||||
time_fine FLOAT,
|
M_profile_fine BLOB,
|
||||||
Ctot_fine FLOAT,
|
ks BLOB,
|
||||||
Ctot_fine_per_cent FLOAT,
|
sv BLOB,
|
||||||
D50_fine FLOAT,
|
X_exponent BLOB,
|
||||||
frac_vol_fine BLOB,
|
alpha_s BLOB,
|
||||||
frac_vol_fine_cumul BLOB,
|
zeta BLOB,
|
||||||
sample_sand_name STRING,
|
FCB BLOB,
|
||||||
sample_sand_index INTEGER,
|
depth_real BLOB,
|
||||||
distance_from_bank_sand FLOAT,
|
lin_reg BLOB
|
||||||
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(
|
self.create_Inversion = """
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
CREATE TABLE Inversion(
|
||||||
path_calibration_file STRING,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
filename_calibration_file STRING,
|
J_cross_section_freq1 BLOB,
|
||||||
range_lin_interp BLOB,
|
J_cross_section_freq2 BLOB,
|
||||||
M_profile_fine BLOB,
|
VBI_cross_section BLOB,
|
||||||
ks BLOB,
|
SSC_fine BLOB,
|
||||||
sv BLOB,
|
SSC_sand 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()
|
||||||
|
|
||||||
|
|
@ -203,18 +221,24 @@ 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)
|
||||||
# --- Table Acoustic File ---
|
self.create_table_BSRawData(cnx, cur)
|
||||||
# +++++++++++++++++++++++++++
|
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")
|
||||||
|
|
@ -222,28 +246,42 @@ class CreateTableForSaveAs:
|
||||||
cur.execute(self.create_AcousticFile)
|
cur.execute(self.create_AcousticFile)
|
||||||
|
|
||||||
for i in stg.acoustic_data:
|
for i in stg.acoustic_data:
|
||||||
print("stg.acoustic_data ", stg.acoustic_data[i])
|
logger.debug(f"stg.acoustic_data: {stg.acoustic_data[i]}")
|
||||||
print("stg.filename_BS_raw_data ", stg.filename_BS_raw_data[i])
|
logger.debug("stg.filename_BS_raw_data: "
|
||||||
print('stg.ABS_name', stg.ABS_name)
|
+ f"{stg.filename_BS_raw_data[i]}")
|
||||||
print("stg.path_BS_raw_data ", stg.path_BS_raw_data[i])
|
logger.debug(f"stg.ABS_name: {stg.ABS_name}")
|
||||||
|
logger.debug(f"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,
|
cur.execute(
|
||||||
filename_BS_noise_data, noise_method, noise_value, data_preprocessed)
|
"""
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?)''',
|
INSERT into AcousticFile(
|
||||||
(stg.acoustic_data[i], stg.filename_BS_raw_data[i].split('.')[0], stg.ABS_name[i],
|
acoustic_data,
|
||||||
stg.path_BS_noise_data[i], stg.filename_BS_noise_data[i], stg.noise_method[i],
|
acoustic_file,
|
||||||
stg.noise_value[i], stg.data_preprocessed[i])
|
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()
|
cnx.commit()
|
||||||
|
|
||||||
print(f"table File : {time.time() - start_table_File} sec")
|
logger.info(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
|
||||||
|
|
@ -251,35 +289,52 @@ 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)
|
|
||||||
# Fill the table Measure
|
logger.debug(f"stg.date: {stg.date}, stg.hour: {stg.hour}")
|
||||||
|
|
||||||
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,
|
"""
|
||||||
NbProfiles, NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
|
INSERT into Measure(
|
||||||
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx
|
acoustic_data,
|
||||||
)
|
Date, Hour,
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
frequency,
|
||||||
(stg.acoustic_data[i], #stg.date[i], stg.hour[i],
|
sound_attenuation,
|
||||||
str(stg.date[i].year) + str('-') + str(stg.date[i].month) + str('-') + str(stg.date[i].day),
|
kt_read, kt_corrected,
|
||||||
str(stg.hour[i].hour) + str(':') + str(stg.hour[i].minute),
|
NbProfiles, NbProfilesPerSeconds,
|
||||||
stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], stg.kt_corrected[j],
|
NbCells, CellSize,
|
||||||
stg.nb_profiles[i][j], stg.nb_profiles_per_sec[i][j], stg.nb_cells[i][j],
|
PulseLength,
|
||||||
stg.cell_size[i][j], stg.pulse_length[i][j], stg.nb_pings_per_sec[i][j],
|
NbPingsPerSeconds,
|
||||||
stg.nb_pings_averaged_per_profile[i][j], stg.gain_rx[i][j], stg.gain_tx[i][j]))
|
NbPingsAveragedPerProfile,
|
||||||
|
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()
|
||||||
|
|
||||||
print(f"table Measure : {time.time() - start_table_Measure} sec")
|
logger.info(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')
|
||||||
|
|
@ -288,105 +343,140 @@ 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()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
|
logger.debug(f"stg.ind_bottom: {stg.ind_bottom[i]}")
|
||||||
time_reshape, depth_reshape, BS_raw_data_reshape,
|
logger.debug(np.array([stg.ind_bottom[i]]),
|
||||||
time_cross_section, depth_cross_section,
|
np.array(stg.ind_bottom[i]).shape)
|
||||||
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()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
print("stg.ind_bottom ", stg.ind_bottom[i])
|
# Commit the transaction after executing INSERT.
|
||||||
print(np.array([stg.ind_bottom[i]]), np.array(stg.ind_bottom[i]).shape)
|
|
||||||
# Commit the transaction after executing INSERT.
|
|
||||||
cnx.commit()
|
cnx.commit()
|
||||||
|
|
||||||
print(f"table BSRawData : {time.time() - start_table_BSRawData} sec")
|
logger.info(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)
|
||||||
|
|
||||||
print(stg.acoustic_data, stg.temperature, stg.rmin, stg.rmax, stg.tmin, stg.tmax)
|
logger.debug(f"acoustic_data: {stg.acoustic_data}")
|
||||||
|
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('''INSERT into Settings(acoustic_data, temperature,
|
cur.execute(
|
||||||
tmin_index, tmin_value, tmax_index, tmax_value,
|
"""
|
||||||
rmin_index, rmin_value, rmax_index, rmax_value,
|
INSERT into Settings(
|
||||||
freq_bottom_detection_index, freq_bottom_detection_value,
|
acoustic_data, temperature,
|
||||||
SNR_filter_value, Nb_cells_to_average_BS_signal
|
tmin_index, tmin_value, tmax_index, tmax_value,
|
||||||
)
|
rmin_index, rmin_value, rmax_index, rmax_value,
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
freq_bottom_detection_index, freq_bottom_detection_value,
|
||||||
(stg.acoustic_data[i], stg.temperature,
|
SNR_filter_value, Nb_cells_to_average_BS_signal
|
||||||
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],
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
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()
|
||||||
|
|
||||||
print(f"table Settings : {time.time() - start_table_Settings} sec")
|
logger.info(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)
|
||||||
|
|
||||||
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine, radius_grain_fine,
|
if stg.path_fine != "" and path_sand != "":
|
||||||
path_sand, filename_sand, radius_grain_sand,
|
cur.execute(
|
||||||
time_column_label, distance_from_bank_column_label,
|
"""
|
||||||
depth_column_label, Ctot_fine_column_label, D50_fine_column_label,
|
INSERT into SedimentsFile(
|
||||||
Ctot_sand_column_label, D50_sand_column_label)
|
path_fine, filename_fine, radius_grain_fine,
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
path_sand, filename_sand, radius_grain_sand,
|
||||||
(stg.path_fine, stg.filename_fine, stg.radius_grain_fine.tobytes(),
|
time_column_label, distance_from_bank_column_label,
|
||||||
stg.path_sand, stg.filename_sand, stg.radius_grain_sand.tobytes(),
|
depth_column_label, Ctot_fine_column_label,
|
||||||
stg.columns_fine[0], stg.columns_fine[1], stg.columns_fine[2],
|
D50_fine_column_label,
|
||||||
stg.columns_fine[3], stg.columns_fine[4], stg.columns_sand[3], stg.columns_sand[4]))
|
Ctot_sand_column_label, D50_sand_column_label
|
||||||
|
)
|
||||||
|
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()
|
||||||
|
|
||||||
print(f"table SedimentsFile : {time.time() - start_table_SedimentsFile} sec")
|
logger.info(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")
|
||||||
|
|
@ -394,59 +484,79 @@ 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('''INSERT into SedimentsData(sample_fine_name, sample_fine_index, distance_from_bank_fine,
|
cur.execute(
|
||||||
depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine,
|
"""
|
||||||
frac_vol_fine, frac_vol_fine_cumul,
|
INSERT into SedimentsData(
|
||||||
sample_sand_name, sample_sand_index, distance_from_bank_sand,
|
sample_fine_name, sample_fine_index,
|
||||||
depth_sand, time_sand, Ctot_sand, Ctot_sand_per_cent, D50_sand,
|
distance_from_bank_fine,
|
||||||
frac_vol_sand, frac_vol_sand_cumul
|
depth_fine, time_fine, Ctot_fine,
|
||||||
)
|
Ctot_fine_per_cent, D50_fine,
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
frac_vol_fine, frac_vol_fine_cumul,
|
||||||
(stg.sample_fine[f][0] , stg.sample_fine[f][1],
|
sample_sand_name, sample_sand_index,
|
||||||
stg.distance_from_bank_fine[f], stg.depth_fine[f], stg.time_fine[f], stg.Ctot_fine[f],
|
distance_from_bank_sand,
|
||||||
stg.Ctot_fine_per_cent[f], stg.D50_fine[f],
|
depth_sand, time_sand, Ctot_sand,
|
||||||
stg.frac_vol_fine[f].tobytes(), stg.frac_vol_fine_cumul[f].tobytes(),
|
Ctot_sand_per_cent, D50_sand,
|
||||||
stg.sample_sand[f][0], stg.sample_sand[f][1],
|
frac_vol_sand, frac_vol_sand_cumul
|
||||||
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],
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
|
||||||
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()
|
||||||
|
|
||||||
print(f"table SedimentsData : {time.time() - start_table_SedimentsData} sec")
|
logger.info(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)
|
||||||
|
|
||||||
cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
|
if len(stg.range_lin_interp) != 0:
|
||||||
range_lin_interp, M_profile_fine,
|
cur.execute(
|
||||||
ks, sv, X_exponent, alpha_s, zeta,
|
"""
|
||||||
FCB, depth_real, lin_reg)
|
INSERT into Calibration(
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
path_calibration_file, filename_calibration_file,
|
||||||
(stg.path_calibration_file, stg.filename_calibration_file,
|
range_lin_interp, M_profile_fine,
|
||||||
stg.range_lin_interp.tobytes(), stg.M_profile_fine.tobytes(),
|
ks, sv, X_exponent, alpha_s, zeta,
|
||||||
np.array(stg.ks).tobytes(), np.array(stg.sv).tobytes(), np.array(stg.X_exponent).tobytes(),
|
FCB, depth_real, lin_reg
|
||||||
np.array(stg.alpha_s).tobytes(), np.array(stg.zeta).tobytes(),
|
)
|
||||||
stg.FCB.tobytes(), stg.depth_real.tobytes(), np.array(stg.lin_reg).tobytes())
|
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()
|
cnx.commit()
|
||||||
|
|
||||||
print(f"table Calibration : {time.time() - start_table_Calibration} sec")
|
logger.info(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")
|
||||||
|
|
@ -454,21 +564,23 @@ 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('''INSERT into Inversion(J_cross_section_freq1, J_cross_section_freq2,
|
cur.execute(
|
||||||
VBI_cross_section, SSC_fine, SSC_sand)
|
"""
|
||||||
VALUES(?, ?, ?, ?, ?)''',
|
INSERT into Inversion(
|
||||||
(stg.J_cross_section[i][0].tobytes(), stg.J_cross_section[i][1].tobytes(),
|
J_cross_section_freq1, J_cross_section_freq2,
|
||||||
stg.VBI_cross_section[i].tobytes(), stg.SSC_fine[i].tobytes(), stg.SSC_sand[i].tobytes())
|
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()
|
cnx.commit()
|
||||||
|
|
||||||
print(f"table Inversion : {time.time() - start_table_Inversion} sec")
|
logger.info(f"table Inversion : {time.time() - start_table_Inversion} sec")
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
# Close database cursor
|
|
||||||
cur.close()
|
|
||||||
|
|
||||||
# Close database connection
|
|
||||||
cnx.close()
|
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,8 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QLabel, QSpacerItem, QSizePolicy,
|
import logging
|
||||||
QTableWidget, QPushButton, QLineEdit,
|
|
||||||
QTableWidgetItem, QComboBox, QFileDialog, QGridLayout, QMessageBox)
|
|
||||||
from PyQt5.QtGui import QIcon
|
|
||||||
from PyQt5.QtCore import Qt, QCoreApplication, pyqtSignal
|
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
@ -36,7 +32,13 @@ from matplotlib.colors import LogNorm, BASE_COLORS
|
||||||
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
|
||||||
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar
|
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar
|
||||||
|
|
||||||
from os import path
|
from PyQt5.QtWidgets import (
|
||||||
|
QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QLabel,
|
||||||
|
QSpacerItem, QSizePolicy, QTableWidget, QPushButton, QLineEdit,
|
||||||
|
QTableWidgetItem, QComboBox, QFileDialog, QGridLayout, QMessageBox
|
||||||
|
)
|
||||||
|
from PyQt5.QtGui import QIcon
|
||||||
|
from PyQt5.QtCore import Qt, QCoreApplication, pyqtSignal
|
||||||
|
|
||||||
from Model.granulo_loader import GranuloLoader
|
from Model.granulo_loader import GranuloLoader
|
||||||
|
|
||||||
|
|
@ -48,6 +50,7 @@ import settings as stg
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class SampleDataTab(QWidget):
|
class SampleDataTab(QWidget):
|
||||||
|
|
||||||
|
|
@ -57,8 +60,7 @@ class SampleDataTab(QWidget):
|
||||||
def __init__(self, widget_tab):
|
def __init__(self, widget_tab):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
path_icon = "./icons/"
|
icon_folder = QIcon(os.path.join("icons", "folder.png"))
|
||||||
icon_folder = QIcon(path_icon + "folder.png")
|
|
||||||
|
|
||||||
### --- General layout of widgets ---
|
### --- General layout of widgets ---
|
||||||
|
|
||||||
|
|
@ -269,20 +271,36 @@ class SampleDataTab(QWidget):
|
||||||
|
|
||||||
self.groupbox_plot_PSD.setTitle(_translate("CONSTANT_STRING", cs.DISTRIBUTION_PLOT))
|
self.groupbox_plot_PSD.setTitle(_translate("CONSTANT_STRING", cs.DISTRIBUTION_PLOT))
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------------------------------------------
|
|
||||||
# --- Function to select directory and file name of fine sediments sample data ---
|
|
||||||
def open_dialog_box_fine_sediment(self):
|
|
||||||
|
|
||||||
|
def last_opened_file_path(self, priority="sand"):
|
||||||
|
lst = []
|
||||||
|
|
||||||
|
if priority == "sand":
|
||||||
|
lst += [stg.path_sand]
|
||||||
|
lst += [stg.path_fine]
|
||||||
|
else:
|
||||||
|
lst += [stg.path_fine]
|
||||||
|
lst += [stg.path_sand]
|
||||||
|
|
||||||
|
lst += stg.path_BS_raw_data
|
||||||
|
|
||||||
|
for path in lst:
|
||||||
|
if path != "":
|
||||||
|
return path
|
||||||
|
|
||||||
|
return ""
|
||||||
|
|
||||||
|
def open_dialog_box_fine_sediment(self):
|
||||||
filename_fine_sediment = QFileDialog.getOpenFileName(
|
filename_fine_sediment = QFileDialog.getOpenFileName(
|
||||||
self, "Fine sediment file",
|
self, "Fine sediment file",
|
||||||
[stg.path_fine if stg.path_fine else stg.path_sand if stg.path_sand
|
self.last_opened_file_path(priority="fine"),
|
||||||
else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data.count() > 0 else ""][0],
|
|
||||||
"Fine sediment file (*.xlsx, *xls, *.ods)",
|
"Fine sediment file (*.xlsx, *xls, *.ods)",
|
||||||
options=QFileDialog.DontUseNativeDialog)
|
options=QFileDialog.DontUseNativeDialog
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stg.path_fine = path.dirname(filename_fine_sediment[0])
|
stg.path_fine = os.path.dirname(filename_fine_sediment[0])
|
||||||
stg.filename_fine = path.basename(filename_fine_sediment[0])
|
stg.filename_fine = os.path.basename(filename_fine_sediment[0])
|
||||||
self.load_fine_sediment_data()
|
self.load_fine_sediment_data()
|
||||||
except IsADirectoryError:
|
except IsADirectoryError:
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
|
|
@ -291,25 +309,24 @@ class SampleDataTab(QWidget):
|
||||||
msgBox.setText("Please select a file")
|
msgBox.setText("Please select a file")
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
else:
|
else:
|
||||||
self.lineEdit_fine_sediment.clear()
|
self.lineEdit_fine_sediment.clear()
|
||||||
self.lineEdit_fine_sediment.setText(stg.filename_fine)
|
self.lineEdit_fine_sediment.setText(stg.filename_fine)
|
||||||
self.lineEdit_fine_sediment.setToolTip(stg.path_fine)
|
self.lineEdit_fine_sediment.setToolTip(stg.path_fine)
|
||||||
self.fill_table_fine()
|
self.fill_table_fine()
|
||||||
|
|
||||||
# --- Function to select directory and file name of sand sediments sample data ---
|
|
||||||
def open_dialog_box_sand_sediment(self):
|
def open_dialog_box_sand_sediment(self):
|
||||||
|
|
||||||
filename_sand_sediment = QFileDialog.getOpenFileName(
|
filename_sand_sediment = QFileDialog.getOpenFileName(
|
||||||
self, "Sand sediment file",
|
self, "Sand sediment file",
|
||||||
[stg.path_sand if stg.path_sand else stg.path_fine if stg.path_fine
|
self.last_opened_file_path(priority="sand"),
|
||||||
else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data.count() > 0 else ""][0],
|
|
||||||
"Sand sediment file (*.xlsx, *xls, *.ods)",
|
"Sand sediment file (*.xlsx, *xls, *.ods)",
|
||||||
options=QFileDialog.DontUseNativeDialog)
|
options=QFileDialog.DontUseNativeDialog)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stg.path_sand = path.dirname(filename_sand_sediment[0])
|
stg.path_sand = os.path.dirname(filename_sand_sediment[0])
|
||||||
stg.filename_sand = path.basename(filename_sand_sediment[0])
|
stg.filename_sand = os.path.basename(filename_sand_sediment[0])
|
||||||
self.load_sand_sediment_data()
|
self.load_sand_sediment_data()
|
||||||
except IsADirectoryError:
|
except IsADirectoryError:
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
|
|
@ -318,13 +335,17 @@ class SampleDataTab(QWidget):
|
||||||
msgBox.setText("Please select a file")
|
msgBox.setText("Please select a file")
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(e)
|
||||||
else:
|
else:
|
||||||
self.lineEdit_sand_sediment.setText(stg.filename_sand)
|
self.lineEdit_sand_sediment.setText(stg.filename_sand)
|
||||||
self.lineEdit_sand_sediment.setToolTip(stg.path_sand)
|
self.lineEdit_sand_sediment.setToolTip(stg.path_sand)
|
||||||
self.fill_table_sand()
|
self.fill_table_sand()
|
||||||
|
|
||||||
def load_fine_sediment_data(self):
|
def load_fine_sediment_data(self):
|
||||||
fine_granulo_data = GranuloLoader(stg.path_fine + "/" + stg.filename_fine)
|
fine_granulo_data = GranuloLoader(
|
||||||
|
os.path.join(stg.path_fine, stg.filename_fine)
|
||||||
|
)
|
||||||
stg.columns_fine = fine_granulo_data._data.columns
|
stg.columns_fine = fine_granulo_data._data.columns
|
||||||
stg.time_fine = fine_granulo_data._time
|
stg.time_fine = fine_granulo_data._time
|
||||||
stg.distance_from_bank_fine = fine_granulo_data._y
|
stg.distance_from_bank_fine = fine_granulo_data._y
|
||||||
|
|
@ -336,7 +357,9 @@ class SampleDataTab(QWidget):
|
||||||
stg.frac_vol_fine_cumul = fine_granulo_data._frac_vol_cumul
|
stg.frac_vol_fine_cumul = fine_granulo_data._frac_vol_cumul
|
||||||
|
|
||||||
def load_sand_sediment_data(self):
|
def load_sand_sediment_data(self):
|
||||||
sand_granulo_data = GranuloLoader(stg.path_sand + "/" + stg.filename_sand)
|
sand_granulo_data = GranuloLoader(
|
||||||
|
os.path.join(stg.path_sand, stg.filename_sand)
|
||||||
|
)
|
||||||
stg.columns_sand = sand_granulo_data._data.columns
|
stg.columns_sand = sand_granulo_data._data.columns
|
||||||
stg.time_sand = sand_granulo_data._time
|
stg.time_sand = sand_granulo_data._time
|
||||||
stg.distance_from_bank_sand = sand_granulo_data._y
|
stg.distance_from_bank_sand = sand_granulo_data._y
|
||||||
|
|
@ -359,36 +382,57 @@ class SampleDataTab(QWidget):
|
||||||
# ------------------------------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------------------------------------
|
||||||
# --- Function to fill table of values ---
|
# --- Function to fill table of values ---
|
||||||
def fill_table_fine(self):
|
def fill_table_fine(self):
|
||||||
if self.lineEdit_fine_sediment.text():
|
self.tableWidget_fine.blockSignals(True)
|
||||||
|
|
||||||
self.row_fine = self.tableWidget_fine.setRowCount(len(stg.depth_fine))
|
if self.lineEdit_fine_sediment.text():
|
||||||
self.column_fine = self.tableWidget_fine.setColumnCount(6 + stg.radius_grain_fine.shape[0])
|
self.row_fine = self.tableWidget_fine.setRowCount(
|
||||||
|
len(stg.depth_fine)
|
||||||
|
)
|
||||||
|
self.column_fine = self.tableWidget_fine.setColumnCount(
|
||||||
|
6 + stg.radius_grain_fine.shape[0]
|
||||||
|
)
|
||||||
|
|
||||||
# --- Set horizontal header ---
|
# --- Set horizontal header ---
|
||||||
|
horizontal_header = list(
|
||||||
horizontal_header = list(itertools.chain(["Color", "Sample"],
|
itertools.chain(
|
||||||
list(map(str, stg.columns_fine[[0, 2]])),
|
["Color", "Sample"],
|
||||||
list(map(str, stg.columns_fine[3:]))))
|
list(map(str, stg.columns_fine[[0, 2]])),
|
||||||
|
list(map(str, stg.columns_fine[3:]))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
for horizontal_header_text in horizontal_header:
|
for horizontal_header_text in horizontal_header:
|
||||||
self.horizontal_header_item_fine = QTableWidgetItem()
|
self.horizontal_header_item_fine = QTableWidgetItem()
|
||||||
self.tableWidget_fine.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text),
|
self.tableWidget_fine.setHorizontalHeaderItem(
|
||||||
self.horizontal_header_item_fine)
|
horizontal_header.index(horizontal_header_text),
|
||||||
|
self.horizontal_header_item_fine
|
||||||
|
)
|
||||||
self.horizontal_header_item_fine.setText(horizontal_header_text)
|
self.horizontal_header_item_fine.setText(horizontal_header_text)
|
||||||
|
|
||||||
# --- Set vertical header (color) ---
|
# --- Set vertical header (color) ---
|
||||||
self.tableWidget_fine.verticalHeader().setVisible(False)
|
self.tableWidget_fine.verticalHeader().setVisible(False)
|
||||||
color_list = BASE_COLORS
|
color_list = BASE_COLORS
|
||||||
|
|
||||||
|
self.comboBox_sample_table_fine = []
|
||||||
for i in range(self.tableWidget_fine.rowCount()):
|
for i in range(self.tableWidget_fine.rowCount()):
|
||||||
exec("self.comboBox_sample_table_fine" + str(i) + "= QComboBox()")
|
self.comboBox_sample_table_fine.append(
|
||||||
exec("self.comboBox_sample_table_fine" + str(i) + ".addItems(color_list)")
|
QComboBox()
|
||||||
eval(f"self.tableWidget_fine.setCellWidget(i, 0, self.comboBox_sample_table_fine{i})")
|
)
|
||||||
eval(f"self.comboBox_sample_table_fine{i}.currentTextChanged."
|
|
||||||
f"connect(self.plot_total_concentration)")
|
self.comboBox_sample_table_fine[i].addItems(color_list)
|
||||||
eval(f"self.comboBox_sample_table_fine{i}.currentTextChanged."
|
self.tableWidget_fine.setCellWidget(
|
||||||
f"connect(self.plot_PSD_fine_and_sand_sediments)")
|
i, 0, self.comboBox_sample_table_fine[i]
|
||||||
eval(f"self.comboBox_sample_table_fine{i}.currentTextChanged."
|
)
|
||||||
f"connect(self.update_plot_sample_position_on_transect)")
|
|
||||||
|
self.comboBox_sample_table_fine[i]\
|
||||||
|
.currentTextChanged\
|
||||||
|
.connect(self.plot_total_concentration)
|
||||||
|
self.comboBox_sample_table_fine[i]\
|
||||||
|
.currentTextChanged\
|
||||||
|
.connect(self.plot_PSD_fine_and_sand_sediments)
|
||||||
|
self.comboBox_sample_table_fine[i]\
|
||||||
|
.currentTextChanged\
|
||||||
|
.connect(self.update_plot_sample_position_on_transect)
|
||||||
|
|
||||||
# --- Fill Sample column with checkbox ---
|
# --- Fill Sample column with checkbox ---
|
||||||
for i in range(self.tableWidget_fine.rowCount()):
|
for i in range(self.tableWidget_fine.rowCount()):
|
||||||
|
|
@ -401,12 +445,21 @@ class SampleDataTab(QWidget):
|
||||||
# --- Fill table with data ---
|
# --- Fill table with data ---
|
||||||
for i in range(stg.frac_vol_fine.shape[0]):
|
for i in range(stg.frac_vol_fine.shape[0]):
|
||||||
for j in range(stg.frac_vol_fine.shape[1]):
|
for j in range(stg.frac_vol_fine.shape[1]):
|
||||||
self.tableWidget_fine.setItem(i, 2, QTableWidgetItem(str(stg.time_fine[i])))
|
self.tableWidget_fine.setItem(
|
||||||
self.tableWidget_fine.setItem(i, 3, QTableWidgetItem(str(stg.depth_fine[i])))
|
i, 2, QTableWidgetItem(str(stg.time_fine[i]))
|
||||||
|
)
|
||||||
self.tableWidget_fine.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_fine[i])))
|
self.tableWidget_fine.setItem(
|
||||||
self.tableWidget_fine.setItem(i, 5, QTableWidgetItem(str(stg.D50_fine[i])))
|
i, 3, QTableWidgetItem(str(stg.depth_fine[i]))
|
||||||
self.tableWidget_fine.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_fine[i, j])))
|
)
|
||||||
|
self.tableWidget_fine.setItem(
|
||||||
|
i, 4, QTableWidgetItem(str(stg.Ctot_fine[i]))
|
||||||
|
)
|
||||||
|
self.tableWidget_fine.setItem(
|
||||||
|
i, 5, QTableWidgetItem(str(stg.D50_fine[i]))
|
||||||
|
)
|
||||||
|
self.tableWidget_fine.setItem(
|
||||||
|
i, j + 6, QTableWidgetItem(str(stg.frac_vol_fine[i, j]))
|
||||||
|
)
|
||||||
|
|
||||||
# --- Connect checkbox to all checkboxes of tableWidget ---
|
# --- Connect checkbox to all checkboxes of tableWidget ---
|
||||||
# self.allChkBox.stateChanged.connect(self.check_allChkBox)
|
# self.allChkBox.stateChanged.connect(self.check_allChkBox)
|
||||||
|
|
@ -423,6 +476,7 @@ class SampleDataTab(QWidget):
|
||||||
self.plot_total_concentration()
|
self.plot_total_concentration()
|
||||||
self.plot_PSD_fine_and_sand_sediments()
|
self.plot_PSD_fine_and_sand_sediments()
|
||||||
|
|
||||||
|
self.tableWidget_fine.blockSignals(False)
|
||||||
else:
|
else:
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
msgBox.setWindowTitle("Fill table Error")
|
msgBox.setWindowTitle("Fill table Error")
|
||||||
|
|
@ -432,36 +486,50 @@ class SampleDataTab(QWidget):
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
|
|
||||||
def fill_table_sand(self):
|
def fill_table_sand(self):
|
||||||
if self.lineEdit_sand_sediment.text():
|
self.tableWidget_sand.blockSignals(True)
|
||||||
|
|
||||||
|
if self.lineEdit_sand_sediment.text():
|
||||||
self.row_sand = self.tableWidget_sand.setRowCount(len(stg.depth_sand))
|
self.row_sand = self.tableWidget_sand.setRowCount(len(stg.depth_sand))
|
||||||
self.column_sand = self.tableWidget_sand.setColumnCount(6 + stg.radius_grain_sand.shape[0])
|
self.column_sand = self.tableWidget_sand.setColumnCount(6 + stg.radius_grain_sand.shape[0])
|
||||||
|
|
||||||
# --- Set horizontal header ---
|
# --- Set horizontal header ---
|
||||||
|
horizontal_header = list(
|
||||||
horizontal_header = list(itertools.chain(["Color", "Sample"],
|
itertools.chain(
|
||||||
list(map(str, stg.columns_sand[[0, 2]])),
|
["Color", "Sample"],
|
||||||
list(map(str, stg.columns_sand[3:]))))
|
list(map(str, stg.columns_sand[[0, 2]])),
|
||||||
|
list(map(str, stg.columns_sand[3:]))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
for horizontal_header_text in horizontal_header:
|
for horizontal_header_text in horizontal_header:
|
||||||
self.horizontal_header_item_sand = QTableWidgetItem()
|
self.horizontal_header_item_sand = QTableWidgetItem()
|
||||||
self.tableWidget_sand.setHorizontalHeaderItem(horizontal_header.index(horizontal_header_text),
|
self.tableWidget_sand.setHorizontalHeaderItem(
|
||||||
self.horizontal_header_item_sand)
|
horizontal_header.index(horizontal_header_text),
|
||||||
|
self.horizontal_header_item_sand
|
||||||
|
)
|
||||||
self.horizontal_header_item_sand.setText(horizontal_header_text)
|
self.horizontal_header_item_sand.setText(horizontal_header_text)
|
||||||
|
|
||||||
# --- Set vertical header (color) ---
|
# --- Set vertical header (color) ---
|
||||||
self.tableWidget_sand.verticalHeader().setVisible(False)
|
self.tableWidget_sand.verticalHeader().setVisible(False)
|
||||||
color_list = BASE_COLORS
|
color_list = BASE_COLORS
|
||||||
|
|
||||||
|
self.comboBox_sample_table_sand = []
|
||||||
for i in range(self.tableWidget_sand.rowCount()):
|
for i in range(self.tableWidget_sand.rowCount()):
|
||||||
exec("self.comboBox_sample_table_sand" + str(i) + "= QComboBox()")
|
self.comboBox_sample_table_sand.append(QComboBox())
|
||||||
exec("self.comboBox_sample_table_sand" + str(i) + ".addItems(color_list)")
|
|
||||||
eval(f"self.tableWidget_sand.setCellWidget(i, 0, self.comboBox_sample_table_sand{i})")
|
self.comboBox_sample_table_sand[i].addItems(color_list)
|
||||||
eval(f"self.comboBox_sample_table_sand{i}.currentTextChanged."
|
self.tableWidget_sand.setCellWidget(
|
||||||
f"connect(self.plot_total_concentration)")
|
i, 0, self.comboBox_sample_table_sand[i]
|
||||||
eval(f"self.comboBox_sample_table_sand{i}.currentTextChanged."
|
)
|
||||||
f"connect(self.plot_PSD_fine_and_sand_sediments)")
|
|
||||||
eval(f"self.comboBox_sample_table_sand{i}.currentTextChanged."
|
self.comboBox_sample_table_sand[i]\
|
||||||
f"connect(self.update_plot_sample_position_on_transect)")
|
.currentTextChanged\
|
||||||
|
.connect(self.plot_total_concentration)
|
||||||
|
self.comboBox_sample_table_sand[i]\
|
||||||
|
.currentTextChanged\
|
||||||
|
.connect(self.plot_PSD_fine_and_sand_sediments)
|
||||||
|
self.comboBox_sample_table_sand[i]\
|
||||||
|
.currentTextChanged\
|
||||||
|
.connect(self.update_plot_sample_position_on_transect)
|
||||||
|
|
||||||
# --- Fill Sample column with checkbox ---
|
# --- Fill Sample column with checkbox ---
|
||||||
for i in range(self.tableWidget_sand.rowCount()):
|
for i in range(self.tableWidget_sand.rowCount()):
|
||||||
|
|
@ -474,25 +542,44 @@ class SampleDataTab(QWidget):
|
||||||
# --- Fill table with data ---
|
# --- Fill table with data ---
|
||||||
for i in range(stg.frac_vol_sand.shape[0]):
|
for i in range(stg.frac_vol_sand.shape[0]):
|
||||||
for j in range(stg.frac_vol_sand.shape[1]):
|
for j in range(stg.frac_vol_sand.shape[1]):
|
||||||
self.tableWidget_sand.setItem(i, 2, QTableWidgetItem(str(stg.time_sand[i])))
|
self.tableWidget_sand.setItem(
|
||||||
self.tableWidget_sand.setItem(i, 3, QTableWidgetItem(str(stg.depth_sand[i])))
|
i, 2, QTableWidgetItem(str(stg.time_sand[i]))
|
||||||
|
)
|
||||||
self.tableWidget_sand.setItem(i, 4, QTableWidgetItem(str(stg.Ctot_sand[i])))
|
self.tableWidget_sand.setItem(
|
||||||
self.tableWidget_sand.setItem(i, 5, QTableWidgetItem(str(stg.D50_sand[i])))
|
i, 3, QTableWidgetItem(str(stg.depth_sand[i]))
|
||||||
self.tableWidget_sand.setItem(i, j + 6, QTableWidgetItem(str(stg.frac_vol_sand[i, j])))
|
)
|
||||||
|
self.tableWidget_sand.setItem(
|
||||||
|
i, 4, QTableWidgetItem(str(stg.Ctot_sand[i]))
|
||||||
|
)
|
||||||
|
self.tableWidget_sand.setItem(
|
||||||
|
i, 5, QTableWidgetItem(str(stg.D50_sand[i]))
|
||||||
|
)
|
||||||
|
self.tableWidget_sand.setItem(
|
||||||
|
i, j + 6, QTableWidgetItem(str(stg.frac_vol_sand[i, j]))
|
||||||
|
)
|
||||||
|
|
||||||
# --- Connect checkbox items of tableWidget to update plots ---
|
# --- Connect checkbox items of tableWidget to update plots ---
|
||||||
self.tableWidget_sand.itemChanged.connect(self.update_plot_sample_position_on_transect)
|
self.tableWidget_sand\
|
||||||
self.tableWidget_sand.itemChanged.connect(self.plot_total_concentration)
|
.itemChanged\
|
||||||
self.tableWidget_sand.itemChanged.connect(self.plot_PSD_fine_and_sand_sediments)
|
.connect(self.update_plot_sample_position_on_transect)
|
||||||
|
self.tableWidget_sand\
|
||||||
|
.itemChanged\
|
||||||
|
.connect(self.plot_total_concentration)
|
||||||
|
self.tableWidget_sand\
|
||||||
|
.itemChanged\
|
||||||
|
.connect(self.plot_PSD_fine_and_sand_sediments)
|
||||||
|
|
||||||
self.combobox_x_axis.currentIndexChanged.connect(self.plot_total_concentration)
|
self.combobox_x_axis.currentIndexChanged\
|
||||||
self.combobox_y_axis.currentIndexChanged.connect(self.plot_total_concentration)
|
.connect(self.plot_total_concentration)
|
||||||
|
self.combobox_y_axis.currentIndexChanged\
|
||||||
|
.connect(self.plot_total_concentration)
|
||||||
|
|
||||||
self.plot_sample_position_on_transect()
|
self.plot_sample_position_on_transect()
|
||||||
self.plot_total_concentration()
|
self.plot_total_concentration()
|
||||||
self.plot_PSD_fine_and_sand_sediments()
|
self.plot_PSD_fine_and_sand_sediments()
|
||||||
|
|
||||||
|
self.tableWidget_sand.blockSignals(False)
|
||||||
|
|
||||||
# --- Function to extract position of sample from table checkboxes to update plots ---
|
# --- Function to extract position of sample from table checkboxes to update plots ---
|
||||||
def extract_position_list_and_color_list_from_table_checkboxes_fine(self):
|
def extract_position_list_and_color_list_from_table_checkboxes_fine(self):
|
||||||
position = []
|
position = []
|
||||||
|
|
@ -502,7 +589,7 @@ class SampleDataTab(QWidget):
|
||||||
if self.tableWidget_fine.item(i, 1).checkState() == 2:
|
if self.tableWidget_fine.item(i, 1).checkState() == 2:
|
||||||
if self.tableWidget_fine.item(i, 1).checkState() == Qt.Checked:
|
if self.tableWidget_fine.item(i, 1).checkState() == Qt.Checked:
|
||||||
position.append(i)
|
position.append(i)
|
||||||
eval(f"color_list.append(self.comboBox_sample_table_fine{i}.currentText())")
|
color_list.append(self.comboBox_sample_table_fine[i].currentText())
|
||||||
sample_checkbox[0, i] = 2
|
sample_checkbox[0, i] = 2
|
||||||
|
|
||||||
return position, color_list
|
return position, color_list
|
||||||
|
|
@ -570,7 +657,9 @@ class SampleDataTab(QWidget):
|
||||||
if self.tableWidget_sand.item(i, 1).checkState() == 2:
|
if self.tableWidget_sand.item(i, 1).checkState() == 2:
|
||||||
if self.tableWidget_sand.item(i, 1).checkState() == Qt.Checked:
|
if self.tableWidget_sand.item(i, 1).checkState() == Qt.Checked:
|
||||||
position.append(i)
|
position.append(i)
|
||||||
eval(f"color_list.append(self.comboBox_sample_table_sand{i}.currentText())")
|
color_list.append(
|
||||||
|
self.comboBox_sample_table_sand[i].currentText()
|
||||||
|
)
|
||||||
sample_checkbox[0, i] = 2
|
sample_checkbox[0, i] = 2
|
||||||
return position, color_list
|
return position, color_list
|
||||||
|
|
||||||
|
|
@ -646,7 +735,6 @@ class SampleDataTab(QWidget):
|
||||||
self.combobox_acoustic_data.showPopup()
|
self.combobox_acoustic_data.showPopup()
|
||||||
|
|
||||||
def fill_comboboxes_and_plot_transect(self):
|
def fill_comboboxes_and_plot_transect(self):
|
||||||
|
|
||||||
self.combobox_acoustic_data.clear()
|
self.combobox_acoustic_data.clear()
|
||||||
for n, m in enumerate(stg.noise_method):
|
for n, m in enumerate(stg.noise_method):
|
||||||
if stg.noise_method[n] == 0:
|
if stg.noise_method[n] == 0:
|
||||||
|
|
@ -659,19 +747,23 @@ class SampleDataTab(QWidget):
|
||||||
self.combobox_frequencies.currentIndexChanged.connect(self.update_plot_sample_position_on_transect)
|
self.combobox_frequencies.currentIndexChanged.connect(self.update_plot_sample_position_on_transect)
|
||||||
|
|
||||||
def plot_sample_position_on_transect(self):
|
def plot_sample_position_on_transect(self):
|
||||||
|
self.verticalLayout_groupbox_plot_transect\
|
||||||
|
.removeWidget(self.canvas_plot_sample_position_on_transect)
|
||||||
|
|
||||||
self.verticalLayout_groupbox_plot_transect.removeWidget(self.canvas_plot_sample_position_on_transect)
|
fig, axis = plt.subplots(nrows=1, ncols=1, layout="constrained")
|
||||||
|
|
||||||
self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \
|
self.figure_plot_sample_position_on_transect = fig
|
||||||
plt.subplots(nrows=1, ncols=1, layout="constrained")
|
self.axis_plot_sample_position_on_transect = axis
|
||||||
self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect)
|
|
||||||
|
|
||||||
self.verticalLayout_groupbox_plot_transect.addWidget(self.canvas_plot_sample_position_on_transect)
|
self.canvas_plot_sample_position_on_transect = FigureCanvas(
|
||||||
|
self.figure_plot_sample_position_on_transect
|
||||||
|
)
|
||||||
|
|
||||||
|
self.verticalLayout_groupbox_plot_transect\
|
||||||
|
.addWidget(self.canvas_plot_sample_position_on_transect)
|
||||||
|
|
||||||
if self.combobox_acoustic_data.count() == 0:
|
if self.combobox_acoustic_data.count() == 0:
|
||||||
|
|
||||||
if self.tableWidget_fine.columnCount() > 10:
|
if self.tableWidget_fine.columnCount() > 10:
|
||||||
|
|
||||||
position_list_fine, color_list_fine = self.extract_position_list_and_color_list_from_table_checkboxes_fine()
|
position_list_fine, color_list_fine = self.extract_position_list_and_color_list_from_table_checkboxes_fine()
|
||||||
|
|
||||||
self.axis_plot_sample_position_on_transect.scatter(
|
self.axis_plot_sample_position_on_transect.scatter(
|
||||||
|
|
@ -1696,4 +1788,3 @@ class SampleDataTab(QWidget):
|
||||||
self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction')
|
self.axis_plot_PSD[1].set_ylabel('Cumulative size volume fraction')
|
||||||
|
|
||||||
self.figure_plot_PSD.canvas.draw_idle()
|
self.figure_plot_PSD.canvas.draw_idle()
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -14,19 +14,25 @@
|
||||||
# #
|
# #
|
||||||
# You should have received a copy of the GNU General Public License #
|
# You should have received a copy of the GNU General Public License #
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
|
||||||
from cProfile import label
|
|
||||||
|
|
||||||
# by Brahim MOUDJED #
|
# by Brahim MOUDJED #
|
||||||
# ============================================================================== #
|
# ============================================================================== #
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from cProfile import label
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox, QLabel,
|
from PyQt5.QtWidgets import (
|
||||||
QSpinBox, QComboBox, QLineEdit, QSlider, QGridLayout, QMessageBox,
|
QWidget, QHBoxLayout, QVBoxLayout, QPushButton, QGroupBox,
|
||||||
QScrollArea, QFileDialog, QSpacerItem, QSizePolicy)
|
QLabel, QSpinBox, QComboBox, QLineEdit, QSlider,
|
||||||
|
QGridLayout, QMessageBox, QScrollArea, QFileDialog,
|
||||||
|
QSpacerItem, QSizePolicy
|
||||||
|
)
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon
|
||||||
from PyQt5.QtCore import Qt, QCoreApplication, QEvent, pyqtSignal, QPropertyAnimation, QSize
|
from PyQt5.QtCore import (
|
||||||
|
Qt, QCoreApplication, QEvent, pyqtSignal, QPropertyAnimation,
|
||||||
|
QSize
|
||||||
|
)
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
@ -641,6 +647,9 @@ class SignalProcessingTab(QWidget):
|
||||||
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
|
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()] = (
|
||||||
np.nanmean(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
|
np.nanmean(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:, :, val1:val2], axis=2))
|
||||||
|
|
||||||
|
if stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||||
|
self.compute_noise_from_profile_tail_value()
|
||||||
|
|
||||||
def plot_averaged_profile_tail(self):
|
def plot_averaged_profile_tail(self):
|
||||||
|
|
||||||
# --- Plot averaged signal ---
|
# --- Plot averaged signal ---
|
||||||
|
|
@ -926,7 +935,7 @@ class SignalProcessingTab(QWidget):
|
||||||
# --- Compute noise from value and compute SNR ---
|
# --- Compute noise from value and compute SNR ---
|
||||||
|
|
||||||
if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
if stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||||
|
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
|
||||||
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
|
stg.BS_noise_raw_data[self.combobox_acoustic_data_choice.currentIndex()] = (
|
||||||
np.full(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape,
|
np.full(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape,
|
||||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
||||||
|
|
@ -986,7 +995,7 @@ class SignalProcessingTab(QWidget):
|
||||||
self.plot_pre_processed_BS_signal()
|
self.plot_pre_processed_BS_signal()
|
||||||
self.plot_pre_processed_profile()
|
self.plot_pre_processed_profile()
|
||||||
|
|
||||||
self.activate_list_of_pre_processed_data()
|
# self.activate_list_of_pre_processed_data()
|
||||||
|
|
||||||
def plot_noise(self):
|
def plot_noise(self):
|
||||||
self.horizontalLayout_groupbox_plot_noise_data.removeWidget(self.canvas_noise)
|
self.horizontalLayout_groupbox_plot_noise_data.removeWidget(self.canvas_noise)
|
||||||
|
|
|
||||||
4
main.py
4
main.py
|
|
@ -33,7 +33,8 @@ logging.basicConfig(
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.DEBUG)
|
# logger.setLevel(logging.DEBUG)
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
class MainApplication(QMainWindow):
|
class MainApplication(QMainWindow):
|
||||||
|
|
||||||
|
|
@ -53,7 +54,6 @@ class MainApplication(QMainWindow):
|
||||||
# -------------- Acoustic data tab ---------------
|
# -------------- Acoustic data tab ---------------
|
||||||
|
|
||||||
self.acoustic_data_tab = AcousticDataTab(self.ui_mainwindow.tab1)
|
self.acoustic_data_tab = AcousticDataTab(self.ui_mainwindow.tab1)
|
||||||
print("0 AcousticDataTab ", id(AcousticDataTab))
|
|
||||||
|
|
||||||
self.acoustic_data_tab\
|
self.acoustic_data_tab\
|
||||||
.combobox_ABS_system_choice\
|
.combobox_ABS_system_choice\
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue