parent
4af3c4c9ea
commit
5ebd842346
|
|
@ -20,50 +20,54 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import sqlite3
|
||||||
|
import logging
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
|
|
||||||
import sqlite3
|
|
||||||
import settings as stg
|
|
||||||
from os import chdir
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
|
||||||
|
|
||||||
|
import settings as stg
|
||||||
from settings import ABS_name
|
from settings import ABS_name
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class CreateTableForSaveAs:
|
class CreateTableForSaveAs:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.create_AcousticFile = """CREATE TABLE AcousticFile(
|
self.create_AcousticFile = """CREATE TABLE AcousticFile(
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
acoustic_file STRING,
|
acoustic_file STRING,
|
||||||
ABS_name STRING,
|
ABS_name STRING,
|
||||||
path_BS_noise_data STRING,
|
path_BS_noise_data STRING,
|
||||||
filename_BS_noise_data STRING,
|
filename_BS_noise_data STRING,
|
||||||
noise_method FLOAT,
|
noise_method FLOAT,
|
||||||
noise_value FLOAT,
|
noise_value FLOAT,
|
||||||
data_preprocessed STRING
|
data_preprocessed STRING
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.create_Measure = """ CREATE TABLE Measure(
|
self.create_Measure = """ CREATE TABLE Measure(
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
Date DATE,
|
Date DATE,
|
||||||
Hour TIME,
|
Hour TIME,
|
||||||
frequency FLOAT,
|
frequency FLOAT,
|
||||||
sound_attenuation FLOAT,
|
sound_attenuation FLOAT,
|
||||||
kt_read FLOAT,
|
kt_read FLOAT,
|
||||||
kt_corrected FLOAT,
|
kt_corrected FLOAT,
|
||||||
NbProfiles FLOAT,
|
NbProfiles FLOAT,
|
||||||
NbProfilesPerSeconds FLOAT,
|
NbProfilesPerSeconds FLOAT,
|
||||||
NbCells FLOAT,
|
NbCells FLOAT,
|
||||||
CellSize FLOAT,
|
CellSize FLOAT,
|
||||||
PulseLength FLOAT,
|
PulseLength FLOAT,
|
||||||
NbPingsPerSeconds FLOAT,
|
NbPingsPerSeconds FLOAT,
|
||||||
NbPingsAveragedPerProfile FLOAT,
|
NbPingsAveragedPerProfile FLOAT,
|
||||||
GainRx FLOAT,
|
GainRx FLOAT,
|
||||||
GainTx FLOAT
|
GainTx FLOAT
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
@ -71,15 +75,15 @@ class CreateTableForSaveAs:
|
||||||
self.create_BSRawData = '''CREATE TABLE BSRawData(
|
self.create_BSRawData = '''CREATE TABLE BSRawData(
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
time BLOB, depth BLOB, BS_raw_data BLOB,
|
time BLOB, depth BLOB, BS_raw_data BLOB,
|
||||||
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
|
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
|
||||||
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
|
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
|
||||||
depth_bottom, val_bottom, ind_bottom,
|
depth_bottom, val_bottom, ind_bottom,
|
||||||
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
||||||
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed 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_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_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_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
|
||||||
BS_mean BLOB
|
BS_mean BLOB
|
||||||
)'''
|
)'''
|
||||||
|
|
||||||
|
|
@ -88,76 +92,76 @@ class CreateTableForSaveAs:
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
temperature FLOAT,
|
temperature FLOAT,
|
||||||
tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value 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,
|
rmin_index FLOAT, rmin_value FLOAT, rmax_index FLOAT, rmax_value FLOAT,
|
||||||
freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
|
freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
|
||||||
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
||||||
)'''
|
)'''
|
||||||
|
|
||||||
self.create_SedimentsFile = """CREATE TABLE SedimentsFile(
|
self.create_SedimentsFile = """CREATE TABLE SedimentsFile(
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
path_fine STRING,
|
path_fine STRING,
|
||||||
filename_fine STRING,
|
filename_fine STRING,
|
||||||
radius_grain_fine BLOB,
|
radius_grain_fine BLOB,
|
||||||
path_sand STRING,
|
path_sand STRING,
|
||||||
filename_sand STRING,
|
filename_sand STRING,
|
||||||
radius_grain_sand BLOB,
|
radius_grain_sand BLOB,
|
||||||
time_column_label STRING,
|
time_column_label STRING,
|
||||||
distance_from_bank_column_label STRING,
|
distance_from_bank_column_label STRING,
|
||||||
depth_column_label STRING,
|
depth_column_label STRING,
|
||||||
Ctot_fine_column_label STRING,
|
Ctot_fine_column_label STRING,
|
||||||
D50_fine_column_label STRING,
|
D50_fine_column_label STRING,
|
||||||
Ctot_sand_column_label STRING,
|
Ctot_sand_column_label STRING,
|
||||||
D50_sand_column_label STRING
|
D50_sand_column_label STRING
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.create_SedimentsData = """CREATE TABLE SedimentsData(
|
self.create_SedimentsData = """CREATE TABLE SedimentsData(
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
sample_fine_name STRING,
|
sample_fine_name STRING,
|
||||||
sample_fine_index INTEGER,
|
sample_fine_index INTEGER,
|
||||||
distance_from_bank_fine FLOAT,
|
distance_from_bank_fine FLOAT,
|
||||||
depth_fine FLOAT,
|
depth_fine FLOAT,
|
||||||
time_fine FLOAT,
|
time_fine FLOAT,
|
||||||
Ctot_fine FLOAT,
|
Ctot_fine FLOAT,
|
||||||
Ctot_fine_per_cent FLOAT,
|
Ctot_fine_per_cent FLOAT,
|
||||||
D50_fine FLOAT,
|
D50_fine FLOAT,
|
||||||
frac_vol_fine BLOB,
|
frac_vol_fine BLOB,
|
||||||
frac_vol_fine_cumul BLOB,
|
frac_vol_fine_cumul BLOB,
|
||||||
sample_sand_name STRING,
|
sample_sand_name STRING,
|
||||||
sample_sand_index INTEGER,
|
sample_sand_index INTEGER,
|
||||||
distance_from_bank_sand FLOAT,
|
distance_from_bank_sand FLOAT,
|
||||||
depth_sand FLOAT,
|
depth_sand FLOAT,
|
||||||
time_sand FLOAT,
|
time_sand FLOAT,
|
||||||
Ctot_sand FLOAT,
|
Ctot_sand FLOAT,
|
||||||
Ctot_sand_per_cent FLOAT,
|
Ctot_sand_per_cent FLOAT,
|
||||||
D50_sand FLOAT,
|
D50_sand FLOAT,
|
||||||
frac_vol_sand BLOB,
|
frac_vol_sand BLOB,
|
||||||
frac_vol_sand_cumul BLOB
|
frac_vol_sand_cumul BLOB
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.create_Calibration = """CREATE TABLE Calibration(
|
self.create_Calibration = """CREATE TABLE Calibration(
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
path_calibration_file STRING,
|
path_calibration_file STRING,
|
||||||
filename_calibration_file STRING,
|
filename_calibration_file STRING,
|
||||||
range_lin_interp BLOB,
|
range_lin_interp BLOB,
|
||||||
M_profile_fine BLOB,
|
M_profile_fine BLOB,
|
||||||
ks BLOB,
|
ks BLOB,
|
||||||
sv BLOB,
|
sv BLOB,
|
||||||
X_exponent BLOB,
|
X_exponent BLOB,
|
||||||
alpha_s BLOB,
|
alpha_s BLOB,
|
||||||
zeta BLOB,
|
zeta BLOB,
|
||||||
FCB BLOB,
|
FCB BLOB,
|
||||||
depth_real BLOB,
|
depth_real BLOB,
|
||||||
lin_reg BLOB
|
lin_reg BLOB
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
self.create_Inversion = """CREATE TABLE Inversion(
|
self.create_Inversion = """CREATE TABLE Inversion(
|
||||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
J_cross_section_freq1 BLOB,
|
J_cross_section_freq1 BLOB,
|
||||||
J_cross_section_freq2 BLOB,
|
J_cross_section_freq2 BLOB,
|
||||||
VBI_cross_section BLOB,
|
VBI_cross_section BLOB,
|
||||||
SSC_fine BLOB,
|
SSC_fine BLOB,
|
||||||
SSC_sand BLOB
|
SSC_sand BLOB
|
||||||
)"""
|
)"""
|
||||||
|
|
||||||
|
|
@ -165,23 +169,32 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
|
|
||||||
def open_file_dialog(self):
|
def open_file_dialog(self):
|
||||||
options = QFileDialog.Options()
|
name, _ = QFileDialog.getSaveFileName(
|
||||||
name = QFileDialog.getSaveFileName(
|
caption="Save As",
|
||||||
caption="Save As", directory="", filter="AcouSed Files (*.acd)", options=QFileDialog.DontUseNativeDialog)
|
directory="",
|
||||||
|
filter="AcouSed Files (*.acd)",
|
||||||
|
options=QFileDialog.DontUseNativeDialog
|
||||||
|
)
|
||||||
|
|
||||||
if name[0]:
|
if name != "":
|
||||||
|
filename = os.path.basename(name)
|
||||||
|
if os.path.splitext(filename)[1] != ".acd":
|
||||||
|
filename += ".acd"
|
||||||
|
|
||||||
stg.dirname_save_as = "/".join(name[0].split("/")[:-1]) + "/"
|
logger.debug(f"selected save file: '{filename}'")
|
||||||
stg.filename_save_as = name[0].split("/")[-1]
|
|
||||||
|
|
||||||
chdir(stg.dirname_save_as)
|
stg.dirname_save_as = os.path.dirname(name)
|
||||||
|
stg.filename_save_as = filename
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.chdir(stg.dirname_save_as)
|
||||||
|
except OSError as e:
|
||||||
|
logger.warning(f"chdir: {str(e)}")
|
||||||
|
|
||||||
start = time.time()
|
start = time.time()
|
||||||
self.create_table()
|
self.create_table()
|
||||||
print(f"end : {time.time() - start} sec")
|
print(f"end : {time.time() - start} sec")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
msgBox.setWindowTitle("Save Error")
|
msgBox.setWindowTitle("Save Error")
|
||||||
msgBox.setIcon(QMessageBox.Warning)
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
|
@ -190,9 +203,9 @@ 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.
|
# Create a new database and open a database connection to allow sqlite3 to work with it.
|
||||||
cnx = sqlite3.connect(stg.filename_save_as + '.acd')
|
cnx = sqlite3.connect(stg.filename_save_as)
|
||||||
|
|
||||||
# Create database cursor to execute SQL statements and fetch results from SQL queries.
|
# Create database cursor to execute SQL statements and fetch results from SQL queries.
|
||||||
cur = cnx.cursor()
|
cur = cnx.cursor()
|
||||||
|
|
@ -214,8 +227,8 @@ class CreateTableForSaveAs:
|
||||||
print('stg.ABS_name', stg.ABS_name)
|
print('stg.ABS_name', stg.ABS_name)
|
||||||
print("stg.path_BS_raw_data ", stg.path_BS_raw_data[i])
|
print("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(''' INSERT into AcousticFile(acoustic_data, acoustic_file, ABS_name, path_BS_noise_data,
|
||||||
filename_BS_noise_data, noise_method, noise_value, data_preprocessed)
|
filename_BS_noise_data, noise_method, noise_value, data_preprocessed)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(stg.acoustic_data[i], stg.filename_BS_raw_data[i].split('.')[0], stg.ABS_name[i],
|
(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.path_BS_noise_data[i], stg.filename_BS_noise_data[i], stg.noise_method[i],
|
||||||
|
|
@ -244,9 +257,9 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
for j in range(stg.freq[i].shape[0]):
|
for j in range(stg.freq[i].shape[0]):
|
||||||
|
|
||||||
cur.execute(''' INSERT into Measure(acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected,
|
cur.execute(''' INSERT into Measure(acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected,
|
||||||
NbProfiles, NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
|
NbProfiles, NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
|
||||||
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx
|
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(stg.acoustic_data[i], #stg.date[i], stg.hour[i],
|
(stg.acoustic_data[i], #stg.date[i], stg.hour[i],
|
||||||
|
|
@ -276,16 +289,16 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
for i in stg.acoustic_data:
|
for i in stg.acoustic_data:
|
||||||
|
|
||||||
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
|
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
|
||||||
time_reshape, depth_reshape, BS_raw_data_reshape,
|
time_reshape, depth_reshape, BS_raw_data_reshape,
|
||||||
time_cross_section, depth_cross_section,
|
time_cross_section, depth_cross_section,
|
||||||
BS_cross_section, BS_stream_bed,
|
BS_cross_section, BS_stream_bed,
|
||||||
depth_bottom, val_bottom, ind_bottom,
|
depth_bottom, val_bottom, ind_bottom,
|
||||||
time_noise, depth_noise, BS_noise_raw_data,
|
time_noise, depth_noise, BS_noise_raw_data,
|
||||||
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
|
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
|
||||||
BS_raw_data_pre_process_SNR, BS_raw_data_pre_process_average,
|
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_cross_section_pre_process_SNR, BS_cross_section_pre_process_average,
|
||||||
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average,
|
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average,
|
||||||
BS_mean)
|
BS_mean)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(stg.acoustic_data[i], stg.time[i].tobytes(),
|
(stg.acoustic_data[i], stg.time[i].tobytes(),
|
||||||
|
|
@ -327,9 +340,9 @@ class CreateTableForSaveAs:
|
||||||
cur.execute('''INSERT into Settings(acoustic_data, temperature,
|
cur.execute('''INSERT into Settings(acoustic_data, temperature,
|
||||||
tmin_index, tmin_value, tmax_index, tmax_value,
|
tmin_index, tmin_value, tmax_index, tmax_value,
|
||||||
rmin_index, rmin_value, rmax_index, rmax_value,
|
rmin_index, rmin_value, rmax_index, rmax_value,
|
||||||
freq_bottom_detection_index, freq_bottom_detection_value,
|
freq_bottom_detection_index, freq_bottom_detection_value,
|
||||||
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.tmax[i][0], stg.tmax[i][1],
|
stg.tmin[i][0], stg.tmin[i][1], stg.tmax[i][0], stg.tmax[i][1],
|
||||||
|
|
@ -355,8 +368,8 @@ class CreateTableForSaveAs:
|
||||||
cur.execute(self.create_SedimentsFile)
|
cur.execute(self.create_SedimentsFile)
|
||||||
|
|
||||||
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine, radius_grain_fine,
|
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine, radius_grain_fine,
|
||||||
path_sand, filename_sand, radius_grain_sand,
|
path_sand, filename_sand, radius_grain_sand,
|
||||||
time_column_label, distance_from_bank_column_label,
|
time_column_label, distance_from_bank_column_label,
|
||||||
depth_column_label, Ctot_fine_column_label, D50_fine_column_label,
|
depth_column_label, Ctot_fine_column_label, D50_fine_column_label,
|
||||||
Ctot_sand_column_label, D50_sand_column_label)
|
Ctot_sand_column_label, D50_sand_column_label)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
|
|
@ -382,11 +395,11 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
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('''INSERT into SedimentsData(sample_fine_name, sample_fine_index, distance_from_bank_fine,
|
||||||
depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine,
|
depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine,
|
||||||
frac_vol_fine, frac_vol_fine_cumul,
|
frac_vol_fine, frac_vol_fine_cumul,
|
||||||
sample_sand_name, sample_sand_index, distance_from_bank_sand,
|
sample_sand_name, sample_sand_index, distance_from_bank_sand,
|
||||||
depth_sand, time_sand, Ctot_sand, Ctot_sand_per_cent, D50_sand,
|
depth_sand, time_sand, Ctot_sand, Ctot_sand_per_cent, D50_sand,
|
||||||
frac_vol_sand, frac_vol_sand_cumul
|
frac_vol_sand, frac_vol_sand_cumul
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(stg.sample_fine[f][0] , stg.sample_fine[f][1],
|
(stg.sample_fine[f][0] , stg.sample_fine[f][1],
|
||||||
|
|
@ -413,10 +426,10 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
cur.execute(self.create_Calibration)
|
cur.execute(self.create_Calibration)
|
||||||
|
|
||||||
cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
|
cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
|
||||||
range_lin_interp, M_profile_fine,
|
range_lin_interp, M_profile_fine,
|
||||||
ks, sv, X_exponent, alpha_s, zeta,
|
ks, sv, X_exponent, alpha_s, zeta,
|
||||||
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.M_profile_fine.tobytes(),
|
stg.range_lin_interp.tobytes(), stg.M_profile_fine.tobytes(),
|
||||||
|
|
@ -441,8 +454,8 @@ 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('''INSERT into Inversion(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][1].tobytes(),
|
(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())
|
stg.VBI_cross_section[i].tobytes(), stg.SSC_fine[i].tobytes(), stg.SSC_sand[i].tobytes())
|
||||||
|
|
@ -459,6 +472,3 @@ class CreateTableForSaveAs:
|
||||||
|
|
||||||
# Close database connection
|
# Close database connection
|
||||||
cnx.close()
|
cnx.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,37 +20,50 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import numpy as np
|
|
||||||
from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget, QTabWidget
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from os import path, chdir
|
import logging
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget, QTabWidget
|
||||||
|
|
||||||
import settings as stg
|
import settings as stg
|
||||||
from settings import BS_raw_data, acoustic_data
|
from settings import BS_raw_data, acoustic_data
|
||||||
|
|
||||||
from View.acoustic_data_tab import AcousticDataTab
|
from View.acoustic_data_tab import AcousticDataTab
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
class ReadTableForOpen:
|
class ReadTableForOpen:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.opened = False
|
||||||
|
|
||||||
pass
|
self.open_file_dialog()
|
||||||
|
|
||||||
def open_file_dialog(self):
|
def open_file_dialog(self):
|
||||||
|
name, _ = QFileDialog.getOpenFileName(
|
||||||
|
caption="Open Acoused file",
|
||||||
|
directory="",
|
||||||
|
filter="Acoused file (*.acd)",
|
||||||
|
options=QFileDialog.DontUseNativeDialog
|
||||||
|
)
|
||||||
|
|
||||||
name = QFileDialog.getOpenFileName(caption="Open Acoused file", directory="", filter="Acoused file (*.acd)",
|
if name != "":
|
||||||
options=QFileDialog.DontUseNativeDialog)
|
stg.dirname_open = os.path.dirname(name)
|
||||||
|
stg.filename_open = os.path.basename(name)
|
||||||
|
|
||||||
if name:
|
try:
|
||||||
|
os.chdir(stg.dirname_open)
|
||||||
|
except OSError as e:
|
||||||
|
logger.warning(f"chdir: {str(e)}")
|
||||||
|
|
||||||
stg.dirname_open = path.dirname(name[0])
|
|
||||||
stg.filename_open = path.basename(name[0])
|
|
||||||
|
|
||||||
chdir(stg.dirname_open)
|
|
||||||
self.sql_file_to_open = open(stg.filename_open)
|
self.sql_file_to_open = open(stg.filename_open)
|
||||||
|
|
||||||
self.read_table()
|
self.read_table()
|
||||||
|
self.opened = True
|
||||||
|
|
||||||
|
|
||||||
def read_table(self):
|
def read_table(self):
|
||||||
|
|
||||||
|
|
@ -76,7 +89,7 @@ class ReadTableForOpen:
|
||||||
|
|
||||||
for k in range(len(stg.acoustic_data)):
|
for k in range(len(stg.acoustic_data)):
|
||||||
print("hello")
|
print("hello")
|
||||||
query = f'''SELECT acoustic_data, acoustic_file, ABS_name, path_BS_noise_data, filename_BS_noise_data,
|
query = f'''SELECT acoustic_data, acoustic_file, ABS_name, path_BS_noise_data, filename_BS_noise_data,
|
||||||
noise_method, noise_value, data_preprocessed FROM AcousticFile WHERE (acoustic_data = {k})'''
|
noise_method, noise_value, data_preprocessed FROM AcousticFile WHERE (acoustic_data = {k})'''
|
||||||
data = cur.execute(query).fetchall()
|
data = cur.execute(query).fetchall()
|
||||||
print("data acoustic file", data)
|
print("data acoustic file", data)
|
||||||
|
|
@ -101,8 +114,8 @@ class ReadTableForOpen:
|
||||||
stg.hour = [0]*len(stg.acoustic_data)
|
stg.hour = [0]*len(stg.acoustic_data)
|
||||||
for i in range(len(stg.acoustic_data)):
|
for i in range(len(stg.acoustic_data)):
|
||||||
print("i = ", i)
|
print("i = ", i)
|
||||||
query1 = f'''SELECT acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles,
|
query1 = f'''SELECT acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles,
|
||||||
NbProfilesPerSeconds, NbCells, CellSize, PulseLength, NbPingsPerSeconds, NbPingsAveragedPerProfile,
|
NbProfilesPerSeconds, NbCells, CellSize, PulseLength, NbPingsPerSeconds, NbPingsAveragedPerProfile,
|
||||||
GainRx, GainTx FROM Measure WHERE (acoustic_data = {i})'''
|
GainRx, GainTx FROM Measure WHERE (acoustic_data = {i})'''
|
||||||
data1 = cur.execute(query1).fetchall()
|
data1 = cur.execute(query1).fetchall()
|
||||||
|
|
||||||
|
|
@ -140,16 +153,16 @@ class ReadTableForOpen:
|
||||||
print("len stg.acoustic_data ", len(stg.acoustic_data))
|
print("len stg.acoustic_data ", len(stg.acoustic_data))
|
||||||
for j in range(len(stg.acoustic_data)):
|
for j in range(len(stg.acoustic_data)):
|
||||||
print(f"j = {j}")
|
print(f"j = {j}")
|
||||||
query2 = f'''SELECT acoustic_data, time, depth, BS_raw_data,
|
query2 = f'''SELECT acoustic_data, time, depth, BS_raw_data,
|
||||||
time_reshape, depth_reshape, BS_raw_data_reshape,
|
time_reshape, depth_reshape, BS_raw_data_reshape,
|
||||||
time_cross_section, depth_cross_section,
|
time_cross_section, depth_cross_section,
|
||||||
BS_cross_section, BS_stream_bed,
|
BS_cross_section, BS_stream_bed,
|
||||||
depth_bottom, val_bottom, ind_bottom,
|
depth_bottom, val_bottom, ind_bottom,
|
||||||
time_noise, depth_noise, BS_noise_raw_data,
|
time_noise, depth_noise, BS_noise_raw_data,
|
||||||
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
|
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
|
||||||
BS_raw_data_pre_process_SNR, BS_raw_data_pre_process_average,
|
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_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
|
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average, BS_mean
|
||||||
FROM BSRawData WHERE (acoustic_data = {j})'''
|
FROM BSRawData WHERE (acoustic_data = {j})'''
|
||||||
|
|
||||||
data2 = cur.execute(query2).fetchall()
|
data2 = cur.execute(query2).fetchall()
|
||||||
|
|
@ -270,10 +283,10 @@ class ReadTableForOpen:
|
||||||
# +++++++++++++++++++++++
|
# +++++++++++++++++++++++
|
||||||
|
|
||||||
for s in range(len(stg.acoustic_data)):
|
for s in range(len(stg.acoustic_data)):
|
||||||
query3 = f'''SELECT acoustic_data, temperature,
|
query3 = f'''SELECT acoustic_data, temperature,
|
||||||
tmin_index, tmin_value, tmax_index, tmax_value,
|
tmin_index, tmin_value, tmax_index, tmax_value,
|
||||||
rmin_index, rmin_value, rmax_index, rmax_value,
|
rmin_index, rmin_value, rmax_index, rmax_value,
|
||||||
freq_bottom_detection_index, freq_bottom_detection_value,
|
freq_bottom_detection_index, freq_bottom_detection_value,
|
||||||
SNR_filter_value, Nb_cells_to_average_BS_signal
|
SNR_filter_value, Nb_cells_to_average_BS_signal
|
||||||
FROM Settings WHERE (acoustic_data = {s})'''
|
FROM Settings WHERE (acoustic_data = {s})'''
|
||||||
|
|
||||||
|
|
@ -293,10 +306,10 @@ class ReadTableForOpen:
|
||||||
# --- Table Sediment File ---
|
# --- Table Sediment File ---
|
||||||
# +++++++++++++++++++++++++++
|
# +++++++++++++++++++++++++++
|
||||||
|
|
||||||
query4 = f'''SELECT path_fine, filename_fine, radius_grain_fine, path_sand, filename_sand, radius_grain_sand,
|
query4 = f'''SELECT path_fine, filename_fine, radius_grain_fine, path_sand, filename_sand, radius_grain_sand,
|
||||||
time_column_label, distance_from_bank_column_label, depth_column_label,
|
time_column_label, distance_from_bank_column_label, depth_column_label,
|
||||||
Ctot_fine_column_label, D50_fine_column_label,
|
Ctot_fine_column_label, D50_fine_column_label,
|
||||||
Ctot_sand_column_label, D50_sand_column_label
|
Ctot_sand_column_label, D50_sand_column_label
|
||||||
from SedimentsFile'''
|
from SedimentsFile'''
|
||||||
|
|
||||||
data4 = cur.execute(query4).fetchall()
|
data4 = cur.execute(query4).fetchall()
|
||||||
|
|
@ -321,10 +334,10 @@ class ReadTableForOpen:
|
||||||
# --- Table Sediment Data ---
|
# --- Table Sediment Data ---
|
||||||
# +++++++++++++++++++++++++++
|
# +++++++++++++++++++++++++++
|
||||||
|
|
||||||
query5 = f'''SELECT sample_fine_name, sample_fine_index, distance_from_bank_fine, depth_fine, time_fine,
|
query5 = f'''SELECT sample_fine_name, sample_fine_index, distance_from_bank_fine, depth_fine, time_fine,
|
||||||
Ctot_fine, Ctot_fine_per_cent, D50_fine, frac_vol_fine, frac_vol_fine_cumul,
|
Ctot_fine, Ctot_fine_per_cent, D50_fine, frac_vol_fine, frac_vol_fine_cumul,
|
||||||
sample_sand_name, sample_sand_index, distance_from_bank_sand, depth_sand, time_sand,
|
sample_sand_name, sample_sand_index, distance_from_bank_sand, depth_sand, time_sand,
|
||||||
Ctot_sand, Ctot_sand_per_cent, D50_sand, frac_vol_sand, frac_vol_sand_cumul
|
Ctot_sand, Ctot_sand_per_cent, D50_sand, frac_vol_sand, frac_vol_sand_cumul
|
||||||
from SedimentsData'''
|
from SedimentsData'''
|
||||||
|
|
||||||
data5 = cur.execute(query5).fetchall()
|
data5 = cur.execute(query5).fetchall()
|
||||||
|
|
@ -428,4 +441,3 @@ class ReadTableForOpen:
|
||||||
|
|
||||||
stg.BS_raw_data.append(np.reshape(stg.BS_raw_data_reshape[i],
|
stg.BS_raw_data.append(np.reshape(stg.BS_raw_data_reshape[i],
|
||||||
(len(stg.freq[i]), stg.depth[i].shape[1], stg.time[i].shape[1])))
|
(len(stg.freq[i]), stg.depth[i].shape[1], stg.time[i].shape[1])))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class UpdateTableForSave:
|
||||||
def update_table(self):
|
def update_table(self):
|
||||||
|
|
||||||
# Create a new database and open a database connection to allow sqlite3 to work with it.
|
# Create a new database and open a database connection to allow sqlite3 to work with it.
|
||||||
cnx = sqlite3.connect(stg.filename_save_as + '.acd')
|
cnx = sqlite3.connect(stg.filename_save_as)
|
||||||
|
|
||||||
# Create database cursor to execute SQL statements and fetch results from SQL queries.
|
# Create database cursor to execute SQL statements and fetch results from SQL queries.
|
||||||
cur = cnx.cursor()
|
cur = cnx.cursor()
|
||||||
|
|
@ -67,12 +67,12 @@ class UpdateTableForSave:
|
||||||
|
|
||||||
cur.execute("""CREATE TABLE AcousticFile(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
cur.execute("""CREATE TABLE AcousticFile(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
acoustic_file STRING,
|
acoustic_file STRING,
|
||||||
ABS_name STRING,
|
ABS_name STRING,
|
||||||
path_BS_noise_data STRING,
|
path_BS_noise_data STRING,
|
||||||
filename_BS_noise_data STRING,
|
filename_BS_noise_data STRING,
|
||||||
noise_method FLOAT,
|
noise_method FLOAT,
|
||||||
noise_value FLOAT,
|
noise_value FLOAT,
|
||||||
data_preprocessed STRING
|
data_preprocessed STRING
|
||||||
)"""
|
)"""
|
||||||
)
|
)
|
||||||
|
|
@ -83,8 +83,8 @@ class UpdateTableForSave:
|
||||||
print('stg.ABS_name', stg.ABS_name)
|
print('stg.ABS_name', stg.ABS_name)
|
||||||
print("stg.path_BS_raw_data ", stg.path_BS_raw_data[i])
|
print("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(''' INSERT into AcousticFile(acoustic_data, acoustic_file, ABS_name, path_BS_noise_data,
|
||||||
filename_BS_noise_data, noise_method, noise_value, data_preprocessed)
|
filename_BS_noise_data, noise_method, noise_value, data_preprocessed)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(stg.acoustic_data[i], stg.filename_BS_raw_data[i].split('.')[0], stg.ABS_name[i],
|
(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.path_BS_noise_data[i], stg.filename_BS_noise_data[i], stg.noise_method[i],
|
||||||
|
|
@ -105,21 +105,21 @@ class UpdateTableForSave:
|
||||||
cur.execute("DROP TABLE if exists Measure")
|
cur.execute("DROP TABLE if exists Measure")
|
||||||
|
|
||||||
cur.execute("""CREATE TABLE Measure(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
cur.execute("""CREATE TABLE Measure(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
Date STRING,
|
Date STRING,
|
||||||
Hour STRING,
|
Hour STRING,
|
||||||
frequency FLOAT,
|
frequency FLOAT,
|
||||||
sound_attenuation FLOAT,
|
sound_attenuation FLOAT,
|
||||||
kt_read FLOAT,
|
kt_read FLOAT,
|
||||||
kt_corrected FLOAT,
|
kt_corrected FLOAT,
|
||||||
NbProfiles FLOAT,
|
NbProfiles FLOAT,
|
||||||
NbProfilesPerSeconds FLOAT,
|
NbProfilesPerSeconds FLOAT,
|
||||||
NbCells FLOAT,
|
NbCells FLOAT,
|
||||||
CellSize FLOAT,
|
CellSize FLOAT,
|
||||||
PulseLength FLOAT,
|
PulseLength FLOAT,
|
||||||
NbPingsPerSeconds FLOAT,
|
NbPingsPerSeconds FLOAT,
|
||||||
NbPingsAveragedPerProfile FLOAT,
|
NbPingsAveragedPerProfile FLOAT,
|
||||||
GainRx FLOAT,
|
GainRx FLOAT,
|
||||||
GainTx FLOAT
|
GainTx FLOAT
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
|
|
@ -128,9 +128,9 @@ class UpdateTableForSave:
|
||||||
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(''' INSERT into Measure(acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles,
|
cur.execute(''' INSERT into Measure(acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles,
|
||||||
NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
|
NbProfilesPerSeconds, NbCells, CellSize, PulseLength,
|
||||||
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx,
|
NbPingsPerSeconds, NbPingsAveragedPerProfile, GainRx, GainTx,
|
||||||
)
|
)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(stg.acoustic_data[i], stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], stg.kt_corrected[j],
|
(stg.acoustic_data[i], stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], stg.kt_corrected[j],
|
||||||
|
|
@ -150,7 +150,7 @@ class UpdateTableForSave:
|
||||||
# +++++++++++++++++++++++++++
|
# +++++++++++++++++++++++++++
|
||||||
# --- Table Acoustic Data ---
|
# --- Table Acoustic Data ---
|
||||||
# +++++++++++++++++++++++++++
|
# +++++++++++++++++++++++++++
|
||||||
|
|
||||||
start_table_BSRawData = time.time()
|
start_table_BSRawData = time.time()
|
||||||
|
|
||||||
cur.execute(''' DROP TABLE BSRawData ''')
|
cur.execute(''' DROP TABLE BSRawData ''')
|
||||||
|
|
@ -158,29 +158,29 @@ class UpdateTableForSave:
|
||||||
cur.execute('''CREATE TABLE BSRawData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
cur.execute('''CREATE TABLE BSRawData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
time BLOB, depth BLOB, BS_raw_data BLOB,
|
time BLOB, depth BLOB, BS_raw_data BLOB,
|
||||||
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
|
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
|
||||||
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
|
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
|
||||||
depth_bottom, val_bottom, ind_bottom,
|
depth_bottom, val_bottom, ind_bottom,
|
||||||
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
|
||||||
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed 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_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_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_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
|
||||||
BS_mean BLOB
|
BS_mean BLOB
|
||||||
)''')
|
)''')
|
||||||
|
|
||||||
for i in stg.acoustic_data:
|
for i in stg.acoustic_data:
|
||||||
|
|
||||||
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
|
cur.execute(''' INSERT into BSRawData(acoustic_data, time, depth, BS_raw_data,
|
||||||
time_reshape, depth_reshape, BS_raw_data_reshape,
|
time_reshape, depth_reshape, BS_raw_data_reshape,
|
||||||
time_cross_section, depth_cross_section,
|
time_cross_section, depth_cross_section,
|
||||||
BS_cross_section, BS_stream_bed,
|
BS_cross_section, BS_stream_bed,
|
||||||
depth_bottom, val_bottom, ind_bottom,
|
depth_bottom, val_bottom, ind_bottom,
|
||||||
time_noise, depth_noise, BS_noise_raw_data,
|
time_noise, depth_noise, BS_noise_raw_data,
|
||||||
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
|
SNR_raw_data, SNR_cross_section, SNR_stream_bed,
|
||||||
BS_raw_data_pre_process_SNR, BS_raw_data_pre_process_average,
|
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_cross_section_pre_process_SNR, BS_cross_section_pre_process_average,
|
||||||
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average,
|
BS_stream_bed_pre_process_SNR, BS_stream_bed_pre_process_average,
|
||||||
BS_mean)
|
BS_mean)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(stg.acoustic_data[i], stg.time[i].tobytes(), stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes(),
|
(stg.acoustic_data[i], stg.time[i].tobytes(), stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes(),
|
||||||
|
|
@ -219,8 +219,8 @@ class UpdateTableForSave:
|
||||||
acoustic_data INTEGER,
|
acoustic_data INTEGER,
|
||||||
temperature FLOAT,
|
temperature FLOAT,
|
||||||
tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value 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,
|
rmin_index FLOAT, rmin_value FLOAT, rmax_index FLOAT, rmax_value FLOAT,
|
||||||
freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
|
freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING,
|
||||||
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
||||||
)'''
|
)'''
|
||||||
)
|
)
|
||||||
|
|
@ -229,8 +229,8 @@ class UpdateTableForSave:
|
||||||
cur.execute('''INSERT into Settings(acoustic_data, temperature,
|
cur.execute('''INSERT into Settings(acoustic_data, temperature,
|
||||||
tmin_index, tmin_value, tmax_index, tmax_value,
|
tmin_index, tmin_value, tmax_index, tmax_value,
|
||||||
rmin_index, rmin_value, rmax_index, rmax_value,
|
rmin_index, rmin_value, rmax_index, rmax_value,
|
||||||
freq_bottom_detection_index, freq_bottom_detection_value,
|
freq_bottom_detection_index, freq_bottom_detection_value,
|
||||||
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.tmax[i][0], stg.tmax[i][1],
|
stg.tmin[i][0], stg.tmin[i][1], stg.tmax[i][0], stg.tmax[i][1],
|
||||||
|
|
@ -252,29 +252,29 @@ class UpdateTableForSave:
|
||||||
|
|
||||||
cur.execute("DROP TABLE if exists SedimentsFile")
|
cur.execute("DROP TABLE if exists SedimentsFile")
|
||||||
|
|
||||||
cur.execute("""CREATE TABLE SedimentsFile(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
cur.execute("""CREATE TABLE SedimentsFile(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
path_fine STRING,
|
path_fine STRING,
|
||||||
filename_fine STRING,
|
filename_fine STRING,
|
||||||
radius_grain_fine BLOB,
|
radius_grain_fine BLOB,
|
||||||
path_sand STRING,
|
path_sand STRING,
|
||||||
filename_sand STRING,
|
filename_sand STRING,
|
||||||
radius_grain_sand BLOB,
|
radius_grain_sand BLOB,
|
||||||
time_column_label STRING,
|
time_column_label STRING,
|
||||||
distance_from_bank_column_label STRING,
|
distance_from_bank_column_label STRING,
|
||||||
depth_column_label STRING,
|
depth_column_label STRING,
|
||||||
Ctot_fine_column_label STRING,
|
Ctot_fine_column_label STRING,
|
||||||
D50_fine_column_label STRING,
|
D50_fine_column_label STRING,
|
||||||
Ctot_sand_column_label STRING,
|
Ctot_sand_column_label STRING,
|
||||||
D50_sand_column_label STRING
|
D50_sand_column_label STRING
|
||||||
)"""
|
)"""
|
||||||
)
|
)
|
||||||
|
|
||||||
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine, radius_grain_fine,
|
cur.execute('''INSERT into SedimentsFile(path_fine, filename_fine, radius_grain_fine,
|
||||||
path_sand, filename_sand, radius_grain_sand,
|
path_sand, filename_sand, radius_grain_sand,
|
||||||
time_column_label, distance_from_bank_column_label,
|
time_column_label, distance_from_bank_column_label,
|
||||||
depth_column_label, Ctot_fine_column_label,
|
depth_column_label, Ctot_fine_column_label,
|
||||||
D50_fine_column_label, Ctot_sand_column_label,
|
D50_fine_column_label, Ctot_sand_column_label,
|
||||||
D50_sand_column_label)
|
D50_sand_column_label)
|
||||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
|
||||||
(stg.path_fine, stg.filename_fine, stg.radius_grain_fine.tobytes(),
|
(stg.path_fine, stg.filename_fine, stg.radius_grain_fine.tobytes(),
|
||||||
stg.path_sand, stg.filename_sand, stg.radius_grain_sand.tobytes(),
|
stg.path_sand, stg.filename_sand, stg.radius_grain_sand.tobytes(),
|
||||||
|
|
@ -294,26 +294,26 @@ class UpdateTableForSave:
|
||||||
|
|
||||||
cur.execute("DROP TABLE if exists SedimentsData")
|
cur.execute("DROP TABLE if exists SedimentsData")
|
||||||
|
|
||||||
cur.execute("""CREATE TABLE SedimentsData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
cur.execute("""CREATE TABLE SedimentsData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
sample_fine_name STRING,
|
sample_fine_name STRING,
|
||||||
sample_fine_index INTEGER,
|
sample_fine_index INTEGER,
|
||||||
distance_from_bank_fine FLOAT,
|
distance_from_bank_fine FLOAT,
|
||||||
depth_fine FLOAT,
|
depth_fine FLOAT,
|
||||||
time_fine FLOAT,
|
time_fine FLOAT,
|
||||||
Ctot_fine FLOAT,
|
Ctot_fine FLOAT,
|
||||||
Ctot_fine_per_cent FLOAT,
|
Ctot_fine_per_cent FLOAT,
|
||||||
D50_fine FLOAT,
|
D50_fine FLOAT,
|
||||||
frac_vol_fine BLOB,
|
frac_vol_fine BLOB,
|
||||||
frac_vol_fine_cumul BLOB,
|
frac_vol_fine_cumul BLOB,
|
||||||
sample_sand_name STRING,
|
sample_sand_name STRING,
|
||||||
sample_sand_index INTEGER,
|
sample_sand_index INTEGER,
|
||||||
distance_from_bank_sand FLOAT,
|
distance_from_bank_sand FLOAT,
|
||||||
depth_sand FLOAT,
|
depth_sand FLOAT,
|
||||||
time_sand FLOAT,
|
time_sand FLOAT,
|
||||||
Ctot_sand FLOAT,
|
Ctot_sand FLOAT,
|
||||||
Ctot_sand_per_cent FLOAT,
|
Ctot_sand_per_cent FLOAT,
|
||||||
D50_sand FLOAT,
|
D50_sand FLOAT,
|
||||||
frac_vol_sand BLOB,
|
frac_vol_sand BLOB,
|
||||||
frac_vol_sand_cumul BLOB
|
frac_vol_sand_cumul BLOB
|
||||||
)"""
|
)"""
|
||||||
)
|
)
|
||||||
|
|
@ -321,7 +321,7 @@ class UpdateTableForSave:
|
||||||
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('''INSERT into SedimentsData(sample_fine_name, sample_fine_index, distance_from_bank_fine,
|
||||||
depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine, frac_vol_fine,
|
depth_fine, time_fine, Ctot_fine, Ctot_fine_per_cent, D50_fine, frac_vol_fine,
|
||||||
frac_vol_fine_cumul,
|
frac_vol_fine_cumul,
|
||||||
sample_sand_name, sample_sand_index, distance_from_bank_sand,
|
sample_sand_name, sample_sand_index, distance_from_bank_sand,
|
||||||
depth_sand, time_sand, Ctot_sand, Ctot_sand_per_cent, D50_sand, frac_vol_sand,
|
depth_sand, time_sand, Ctot_sand, Ctot_sand_per_cent, D50_sand, frac_vol_sand,
|
||||||
frac_vol_sand_cumul)
|
frac_vol_sand_cumul)
|
||||||
|
|
@ -349,26 +349,26 @@ class UpdateTableForSave:
|
||||||
|
|
||||||
cur.execute("DROP TABLE if exists Calibration")
|
cur.execute("DROP TABLE if exists Calibration")
|
||||||
|
|
||||||
cur.execute("""CREATE TABLE Calibration(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
cur.execute("""CREATE TABLE Calibration(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
path_calibration_file STRING,
|
path_calibration_file STRING,
|
||||||
filename_calibration_file STRING,
|
filename_calibration_file STRING,
|
||||||
range_lin_interp BLOB,
|
range_lin_interp BLOB,
|
||||||
M_profile_fine BLOB,
|
M_profile_fine BLOB,
|
||||||
ks BLOB,
|
ks BLOB,
|
||||||
sv BLOB,
|
sv BLOB,
|
||||||
X_exponent BLOB,
|
X_exponent BLOB,
|
||||||
alpha_s BLOB,
|
alpha_s BLOB,
|
||||||
zeta BLOB,
|
zeta BLOB,
|
||||||
FCB BLOB,
|
FCB BLOB,
|
||||||
depth_real BLOB,
|
depth_real BLOB,
|
||||||
lin_reg BLOB
|
lin_reg BLOB
|
||||||
)"""
|
)"""
|
||||||
)
|
)
|
||||||
|
|
||||||
cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
|
cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
|
||||||
range_lin_interp, M_profile_fine,
|
range_lin_interp, M_profile_fine,
|
||||||
ks, sv, X_exponent, alpha_s, zeta,
|
ks, sv, X_exponent, alpha_s, zeta,
|
||||||
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.M_profile_fine.tobytes(),
|
stg.range_lin_interp.tobytes(), stg.M_profile_fine.tobytes(),
|
||||||
|
|
@ -390,17 +390,17 @@ class UpdateTableForSave:
|
||||||
|
|
||||||
cur.execute("DROP TABLE if exists Inversion")
|
cur.execute("DROP TABLE if exists Inversion")
|
||||||
|
|
||||||
cur.execute("""CREATE TABLE Inversion(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
cur.execute("""CREATE TABLE Inversion(ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
J_cross_section_freq1 BLOB,
|
J_cross_section_freq1 BLOB,
|
||||||
J_cross_section_freq2 BLOB,
|
J_cross_section_freq2 BLOB,
|
||||||
VBI_cross_section BLOB,
|
VBI_cross_section BLOB,
|
||||||
SSC_fine BLOB,
|
SSC_fine BLOB,
|
||||||
SSC_sand BLOB
|
SSC_sand BLOB
|
||||||
)""")
|
)""")
|
||||||
|
|
||||||
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('''INSERT into Inversion(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][1].tobytes(),
|
(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())
|
stg.VBI_cross_section[i].tobytes(), stg.SSC_fine[i].tobytes(), stg.SSC_sand[i].tobytes())
|
||||||
|
|
@ -417,6 +417,3 @@ class UpdateTableForSave:
|
||||||
|
|
||||||
# Close database connection
|
# Close database connection
|
||||||
cnx.close()
|
cnx.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,13 +262,18 @@ class Ui_MainWindow(object):
|
||||||
|
|
||||||
def save_as(self):
|
def save_as(self):
|
||||||
CreateTableForSaveAs()
|
CreateTableForSaveAs()
|
||||||
self.mainwindow.setWindowTitle("AcouSed - " + stg.filename_save_as + ".acd")
|
self.mainwindow.setWindowTitle(
|
||||||
|
"AcouSed - " +
|
||||||
|
stg.filename_save_as
|
||||||
|
)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
UpdateTableForSave()
|
UpdateTableForSave()
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
ReadTableForOpen()
|
reader = ReadTableForOpen()
|
||||||
|
if reader.opened:
|
||||||
|
self.mainwindow.open_study_update_tabs()
|
||||||
|
|
||||||
def load_calibration_constant_values(self):
|
def load_calibration_constant_values(self):
|
||||||
cc_kt = CalibrationConstantKt()
|
cc_kt = CalibrationConstantKt()
|
||||||
|
|
|
||||||
18
main.py
18
main.py
|
|
@ -33,7 +33,7 @@ logging.basicConfig(
|
||||||
)
|
)
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
class MainApplication(QMainWindow):
|
class MainApplication(QMainWindow):
|
||||||
|
|
||||||
|
|
@ -49,15 +49,18 @@ class MainApplication(QMainWindow):
|
||||||
height = size.height()
|
height = size.height()
|
||||||
self.resize(int(PERCENT_SCREEN_SIZE*width), int(PERCENT_SCREEN_SIZE*height))
|
self.resize(int(PERCENT_SCREEN_SIZE*width), int(PERCENT_SCREEN_SIZE*height))
|
||||||
try:
|
try:
|
||||||
self.read_table_open = ReadTableForOpen()
|
|
||||||
# **************************************************
|
# **************************************************
|
||||||
# -------------- 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))
|
print("0 AcousticDataTab ", id(AcousticDataTab))
|
||||||
|
|
||||||
self.acoustic_data_tab.combobox_ABS_system_choice.editTextChanged.connect(
|
self.acoustic_data_tab\
|
||||||
self.acoustic_data_tab.ABS_system_choice)
|
.combobox_ABS_system_choice\
|
||||||
|
.editTextChanged\
|
||||||
|
.connect(
|
||||||
|
self.acoustic_data_tab.ABS_system_choice
|
||||||
|
)
|
||||||
|
|
||||||
# **************************************************
|
# **************************************************
|
||||||
# --------- Signal pre-processing data tab ----------
|
# --------- Signal pre-processing data tab ----------
|
||||||
|
|
@ -92,8 +95,6 @@ class MainApplication(QMainWindow):
|
||||||
|
|
||||||
# self.user_manual_tab = UserManualTab(self.ui_mainwindow.tab7)
|
# self.user_manual_tab = UserManualTab(self.ui_mainwindow.tab7)
|
||||||
|
|
||||||
self.ui_mainwindow.actionOpen.triggered.connect(self.trig_open)
|
|
||||||
|
|
||||||
# **************************************************
|
# **************************************************
|
||||||
# ---------------- Text File Error -----------------
|
# ---------------- Text File Error -----------------
|
||||||
|
|
||||||
|
|
@ -106,9 +107,7 @@ class MainApplication(QMainWindow):
|
||||||
sortie.write(traceback.format_exc())
|
sortie.write(traceback.format_exc())
|
||||||
# traceback.TracebackException.from_exception(e).print(file=sortie)
|
# traceback.TracebackException.from_exception(e).print(file=sortie)
|
||||||
|
|
||||||
def trig_open(self):
|
def open_study_update_tabs(self):
|
||||||
self.read_table_open.open_file_dialog()
|
|
||||||
|
|
||||||
self.acoustic_data_tab.combobox_ABS_system_choice.setCurrentText(stg.ABS_name[0])
|
self.acoustic_data_tab.combobox_ABS_system_choice.setCurrentText(stg.ABS_name[0])
|
||||||
self.acoustic_data_tab.fileListWidget.addFilenames(stg.filename_BS_raw_data)
|
self.acoustic_data_tab.fileListWidget.addFilenames(stg.filename_BS_raw_data)
|
||||||
|
|
||||||
|
|
@ -119,7 +118,6 @@ class MainApplication(QMainWindow):
|
||||||
self.sample_data_tab.lineEdit_fine_sediment.setToolTip(stg.path_fine)
|
self.sample_data_tab.lineEdit_fine_sediment.setToolTip(stg.path_fine)
|
||||||
# self.sample_data_tab.fill_table_fine()
|
# self.sample_data_tab.fill_table_fine()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# print("sys.argv:", [arg for arg in sys.argv])
|
# print("sys.argv:", [arg for arg in sys.argv])
|
||||||
# app = MainApplication(sys.argv)
|
# app = MainApplication(sys.argv)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue