Compare commits

...

3 Commits

8 changed files with 410 additions and 714 deletions

View File

@ -155,6 +155,17 @@ class CreateTableForSaveAs:
)
"""
self.create_Calibration_parameters = """
CREATE TABLE CalibrationParameters(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
acoustic_data INTEGER,
freq_1 INTEGER,
freq_2 INTEGER,
fine_profiles TEXT,
sand_target INTEGER
)
"""
self.create_Calibration = """
CREATE TABLE Calibration(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
@ -184,8 +195,14 @@ class CreateTableForSaveAs:
)
"""
def save_as(self):
self.open_file_dialog()
self.save()
def save(self):
start = time.time()
self.create_table()
print(f"end : {time.time() - start} sec")
def open_file_dialog(self):
name, _ = QFileDialog.getSaveFileName(
@ -209,10 +226,6 @@ class CreateTableForSaveAs:
os.chdir(stg.dirname_save_as)
except OSError as e:
logger.warning(f"chdir: {str(e)}")
start = time.time()
self.create_table()
print(f"end : {time.time() - start} sec")
else:
msgBox = QMessageBox()
msgBox.setWindowTitle("Save Error")
@ -231,6 +244,7 @@ class CreateTableForSaveAs:
self.create_table_settings(cnx, cur)
self.create_table_sediments_file(cnx, cur)
self.create_table_sediments_data(cnx, cur)
self.create_table_calibration_parameters(cnx, cur)
self.create_table_calibration(cnx, cur)
self.create_table_inversion(cnx, cur)
@ -517,6 +531,36 @@ class CreateTableForSaveAs:
logger.info(f"table SedimentsData : {time.time() - start_table_SedimentsData} sec")
def create_table_calibration_parameters(self, cnx, cur):
start_table = time.time()
cur.execute("DROP TABLE if exists CalibrationParameters")
cur.execute(self.create_Calibration_parameters)
if stg.calib_acoustic_data != -1:
cur.execute(
"""
INSERT INTO CalibrationParameters(
acoustic_data,
freq_1, freq_2,
fine_profiles,
sand_target
)
VALUES(?, ?, ?, ?, ?)
""",
(
stg.calib_acoustic_data,
stg.calib_freq_1, stg.calib_freq_2,
",".join(map(str, stg.calib_fine_profiles)),
stg.calib_sand_target,
)
)
cnx.commit()
logger.info(f"table CalibrationParameters : {time.time() - start_table} sec")
def create_table_calibration(self, cnx, cur):
start_table_Calibration = time.time()
@ -527,7 +571,7 @@ class CreateTableForSaveAs:
if len(stg.range_lin_interp) != 0:
cur.execute(
"""
INSERT into Calibration(
INSERT INTO Calibration(
path_calibration_file, filename_calibration_file,
range_lin_interp, M_profile_fine,
ks, sv, X_exponent, alpha_s, zeta,

View File

@ -83,6 +83,7 @@ class ReadTableForOpen:
self.read_table_settings()
self.read_table_sediment_file()
self.read_table_table_sediment_data()
self.read_table_table_calibration_parameters()
self.read_table_table_calibration()
logger.debug(f"Reading '{stg.filename_open}' done")
@ -609,6 +610,69 @@ class ReadTableForOpen:
logger.debug(f"fine: {stg.Ctot_fine}, sand: {stg.sample_sand}")
@trace
def read_table_table_calibration_parameters(self):
np_f64_parse = lambda d: np.frombuffer(d, dtype=np.float64)
query = f'''
SELECT
acoustic_data,
freq_1, freq_2,
fine_profiles,
sand_target
FROM CalibrationParameters
'''
data = self.execute(query)
it = iter(data[0])
stg.calib_acoustic_data = next(it)
stg.calib_freq_1 = next(it)
stg.calib_freq_2 = next(it)
stg.calib_fine_profiles = list(
map(
int,
filter(
lambda x: x != '',
next(it).split(",")
)
)
)
stg.calib_sand_target = next(it)
logger.debug(f"stg.calib_acoustic_data: {stg.calib_acoustic_data}")
logger.debug(f"stg.calib_freq_1: {stg.calib_freq_1}")
logger.debug(f"stg.calib_freq_2: {stg.calib_freq_2}")
logger.debug(f"stg.calib_fine_profiles: {stg.calib_fine_profiles}")
logger.debug(f"stg.calib_sand_target: {stg.calib_sand_target}")
stg.frequencies_for_calibration.clear()
for freq in [stg.calib_freq_1, stg.calib_freq_2]:
stg.frequencies_for_calibration.append(
(
stg.freq[stg.calib_acoustic_data][freq],
freq
)
)
stg.fine_sample_profile.clear()
for profile_id in stg.calib_fine_profiles:
stg.fine_sample_profile.append(
(
stg.sample_fine[profile_id],
profile_id
)
)
stg.sand_sample_target.clear()
if stg.calib_sand_target != -1:
stg.sand_sample_target.append(
(
stg.sample_sand[stg.calib_sand_target],
stg.calib_sand_target
)
)
@trace
def read_table_table_calibration(self):
np_f64_parse = lambda d: np.frombuffer(d, dtype=np.float64)

View File

@ -1,469 +0,0 @@
# ============================================================================== #
# update_table_for_save.py - AcouSed #
# Copyright (C) 2024 INRAE #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# by Brahim MOUDJED #
# ============================================================================== #
# -*- coding: utf-8 -*-
import numpy as np
from PyQt5.QtWidgets import QFileDialog, QApplication, QMessageBox
import sqlite3
import settings as stg
from os import chdir, getcwd
import time
class UpdateTableForSave:
def __init__(self):
if stg.dirname_save_as:
start = time.time()
chdir(stg.dirname_save_as)
print("get cwd for save :", getcwd())
print("stg.filename_save_as ", stg.filename_save_as)
self.update_table()
print(f"end : {time.time() - start} sec")
else:
msgBox = QMessageBox()
msgBox.setWindowTitle("Save Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText("Use 'Save as' before 'Save'")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
def update_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)
# Create database cursor to execute SQL statements and fetch results from SQL queries.
cur = cnx.cursor()
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++++++++
# --- Table Acoustic File ---
# +++++++++++++++++++++++++++
start_table_AcousticFile = time.time()
cur.execute('''DROP TABLE AcousticFile''')
cur.execute("""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
)"""
)
for i in stg.acoustic_data:
print("stg.acoustic_data ", stg.acoustic_data[i])
print("stg.filename_BS_raw_data ", stg.filename_BS_raw_data[i])
print('stg.ABS_name', stg.ABS_name)
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,
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()
print(f"Table AcousticFile : {time.time() - start_table_AcousticFile} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++
# --- Table Measurements ---
# ++++++++++++++++++++++++++
start_table_Measure = time.time()
# Drop Table if exists
cur.execute("DROP TABLE if exists Measure")
cur.execute(
"""
CREATE TABLE Measure(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
acoustic_data INTEGER,
Date STRING,
Hour STRING,
frequency FLOAT,
sound_attenuation FLOAT,
kt_read FLOAT,
kt_corrected FLOAT,
NbProfiles FLOAT,
NbProfilesPerSeconds FLOAT,
NbCells FLOAT,
CellSize FLOAT,
PulseLength FLOAT,
NbPingsPerSeconds FLOAT,
NbPingsAveragedPerProfile FLOAT,
GainRx FLOAT,
GainTx FLOAT
)"""
)
# Fill the table Measure
for i in stg.acoustic_data:
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, NbProfilesPerSeconds,
NbCells, CellSize,
PulseLength,
NbPingsPerSeconds,
NbPingsAveragedPerProfile,
GainRx, GainTx
) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(
stg.acoustic_data[i],
stg.date[i].isoformat(),
stg.hour[i].isoformat(),
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.
cnx.commit()
print(f"table Measure : {time.time() - start_table_Measure} sec")
# --------------------------------------------------------------------------------------------------------------
# +++++++++++++++++++++++++++
# --- Table Acoustic Data ---
# +++++++++++++++++++++++++++
start_table_BSRawData = time.time()
cur.execute(''' DROP TABLE BSRawData ''')
cur.execute('''CREATE TABLE BSRawData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
acoustic_data INTEGER,
time BLOB, depth BLOB, BS_raw_data BLOB,
time_reshape BLOB, depth_reshape BLOB, BS_raw_data_reshape BLOB,
time_cross_section BLOB, depth_cross_section BLOB, BS_cross_section BLOB, BS_stream_bed BLOB,
depth_bottom, val_bottom, ind_bottom,
time_noise BLOB, depth_noise BLOB, BS_noise_raw_data BLOB,
SNR_raw_data BLOB, SNR_cross_section BLOB, SNR_stream_bed BLOB,
BS_raw_data_pre_process_SNR BLOB, BS_raw_data_pre_process_average BLOB,
BS_cross_section_pre_process_SNR BLOB, BS_cross_section_pre_process_average BLOB,
BS_stream_bed_pre_process_SNR BLOB, BS_stream_bed_pre_process_average BLOB,
BS_mean BLOB
)''')
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(),
np.array(stg.BS_stream_bed[i]).tobytes(),
np.array(stg.depth_bottom[i]).tobytes(),
np.array(stg.val_bottom[i]).tobytes(),
np.array(stg.ind_bottom[i]).tobytes(),
np.array(stg.time_noise[i]).tobytes(),
np.array(stg.depth_noise[i]).tobytes(),
np.array(stg.BS_noise_raw_data[i]).tobytes(),
np.array(stg.SNR_raw_data[i]).tobytes(),
np.array(stg.SNR_cross_section[i]).tobytes(),
np.array(stg.SNR_stream_bed[i]).tobytes(),
np.array(stg.BS_raw_data_pre_process_SNR[i]).tobytes(),
np.array(stg.BS_raw_data_pre_process_average[i]).tobytes(),
np.array(stg.BS_cross_section_pre_process_SNR[i]).tobytes(),
np.array(stg.BS_cross_section_pre_process_average[i]).tobytes(),
np.array(stg.BS_stream_bed_pre_process_SNR[i]).tobytes(),
np.array(stg.BS_stream_bed_pre_process_average[i]).tobytes(),
np.array(stg.BS_mean[i]).tobytes()
)
)
cnx.commit()
print(f"table BSRawData : {time.time() - start_table_BSRawData} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++
# --- Table Settings ---
# ++++++++++++++++++++++
start_table_Settings = time.time()
cur.execute(''' DROP TABLE Settings''')
cur.execute('''
CREATE TABLE Settings(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
acoustic_data INTEGER,
temperature FLOAT,
distance_to_free_surface FLOAT,
tmin_index FLOAT, tmin_value FLOAT,
tmax_index FLOAT, tmax_value FLOAT,
rmin_index FLOAT, rmin_value FLOAT,
rmax_index FLOAT, rmax_value FLOAT,
freq_bottom_detection_index FLOAT,
freq_bottom_detection_value STRING,
SNR_filter_value FLOAT,
Nb_cells_to_average_BS_signal FLOAT
)
'''
)
for i in stg.acoustic_data:
cur.execute('''
INSERT into Settings(
acoustic_data, temperature,
distance_to_free_surface,
tmin_index, tmin_value, tmax_index, tmax_value,
rmin_index, rmin_value, rmax_index, rmax_value,
freq_bottom_detection_index, freq_bottom_detection_value,
SNR_filter_value, Nb_cells_to_average_BS_signal
) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
''',
(
stg.acoustic_data[i], stg.temperature,
stg.distance_from_ABS_to_free_surface[i],
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()
print(f"table Settings : {time.time() - start_table_Settings} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++++
# --- Table Sediments File ---
# ++++++++++++++++++++++++++++
start_table_SedimentsFile = time.time()
cur.execute("DROP TABLE if exists SedimentsFile")
cur.execute("""CREATE TABLE SedimentsFile(ID INTEGER PRIMARY KEY AUTOINCREMENT,
path_fine STRING,
filename_fine STRING,
radius_grain_fine BLOB,
path_sand STRING,
filename_sand STRING,
radius_grain_sand BLOB,
time_column_label STRING,
distance_from_bank_column_label STRING,
depth_column_label STRING,
Ctot_fine_column_label STRING,
D50_fine_column_label STRING,
Ctot_sand_column_label STRING,
D50_sand_column_label STRING
)"""
)
cur.execute('''INSERT into SedimentsFile(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, Ctot_fine_column_label,
D50_fine_column_label, 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()
print(f"table SedimentsFile : {time.time() - start_table_SedimentsFile} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++++
# --- Table Sediments Data ---
# ++++++++++++++++++++++++++++
start_table_SedimentsData = time.time()
cur.execute("DROP TABLE if exists SedimentsData")
cur.execute("""CREATE TABLE SedimentsData(ID INTEGER PRIMARY KEY AUTOINCREMENT,
sample_fine_name STRING,
sample_fine_index INTEGER,
distance_from_bank_fine FLOAT,
depth_fine FLOAT,
time_fine FLOAT,
Ctot_fine FLOAT,
Ctot_fine_per_cent FLOAT,
D50_fine FLOAT,
frac_vol_fine BLOB,
frac_vol_fine_cumul BLOB,
sample_sand_name STRING,
sample_sand_index INTEGER,
distance_from_bank_sand FLOAT,
depth_sand FLOAT,
time_sand FLOAT,
Ctot_sand FLOAT,
Ctot_sand_per_cent FLOAT,
D50_sand FLOAT,
frac_vol_sand BLOB,
frac_vol_sand_cumul BLOB
)"""
)
for f in range(len(stg.sample_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,
frac_vol_fine_cumul,
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)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''',
(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()
print(f"table SedimentsData : {time.time() - start_table_SedimentsData} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++++++
# --- Table Calibration ---
# ++++++++++++++++++++++++++++++
start_table_Calibration = time.time()
cur.execute("DROP TABLE if exists Calibration")
cur.execute("""CREATE TABLE Calibration(ID INTEGER PRIMARY KEY AUTOINCREMENT,
path_calibration_file STRING,
filename_calibration_file STRING,
range_lin_interp BLOB,
M_profile_fine BLOB,
ks BLOB,
sv BLOB,
X_exponent BLOB,
alpha_s BLOB,
zeta BLOB,
FCB BLOB,
depth_real BLOB,
lin_reg BLOB
)"""
)
cur.execute('''INSERT into Calibration(path_calibration_file, filename_calibration_file,
range_lin_interp, M_profile_fine,
ks, sv, X_exponent, alpha_s, zeta,
FCB, depth_real, lin_reg)
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()
print(f"table Calibration : {time.time() - start_table_Calibration} sec")
# --------------------------------------------------------------------------------------------------------------
# ++++++++++++++++++++++++++++++
# --- Table Inversion ---
# ++++++++++++++++++++++++++++++
start_table_Inversion = time.time()
cur.execute("DROP TABLE if exists Inversion")
cur.execute("""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
)""")
for i in range(len(stg.SSC_fine)):
cur.execute('''INSERT into Inversion(J_cross_section_freq1, J_cross_section_freq2,
VBI_cross_section, SSC_fine, SSC_sand)
VALUES(?, ?, ?, ?, ?)''',
(stg.J_cross_section[i][0].tobytes(), stg.J_cross_section[i][1].tobytes(),
stg.VBI_cross_section[i].tobytes(), stg.SSC_fine[i].tobytes(), stg.SSC_sand[i].tobytes())
)
cnx.commit()
print(f"table Inversion : {time.time() - start_table_Inversion} sec")
# --------------------------------------------------------------------------------------------------------------
# Close database cursor
cur.close()
# Close database connection
cnx.close()

View File

@ -438,18 +438,21 @@ class AcousticInversionTab(QWidget):
self.plot_measured_vs_inverted_SSC_sand()
def compute_VBI(self):
data_id = self.combobox_acoustic_data_choice.currentIndex()
stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.VBI_cross_section[data_id] = np.array([])
stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.VBI_cross_section(
stg.VBI_cross_section[data_id] = self.inv_hc.VBI_cross_section(
freq1=stg.frequencies_for_calibration[0][0],
freq2=stg.frequencies_for_calibration[1][0],
zeta_freq1=stg.zeta[0], zeta_freq2=stg.zeta[1],
j_cross_section_freq1=stg.J_cross_section[self.combobox_acoustic_data_choice.currentIndex()][0],
j_cross_section_freq2=stg.J_cross_section[self.combobox_acoustic_data_choice.currentIndex()][1],
r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
water_attenuation_freq1=stg.alpha_s[0], water_attenuation_freq2=stg.alpha_s[1],
j_cross_section_freq1=stg.J_cross_section[data_id][0],
j_cross_section_freq2=stg.J_cross_section[data_id][1],
r2D=stg.depth_2D[data_id][
stg.frequency_for_inversion[1]
],
water_attenuation_freq1=stg.alpha_s[0],
water_attenuation_freq2=stg.alpha_s[1],
X=stg.X_exponent[0]
)

View File

@ -121,6 +121,18 @@ class CheckableComboBox(QComboBox):
res.append(self.model().item(i).data())
return res
def currentIndexes(self):
# Return the list of selected items id
res = []
for i in range(self.model().rowCount()):
if self.model().item(i).checkState() == Qt.Checked:
res.append(i)
return res
def setCurrentIndexes(self, indexes):
for i in range(self.model().rowCount()):
if i in indexes:
self.model().item(i).setCheckState(Qt.Checked)
# class CheckableComboBox(QComboBox):
# def __init__(self):
@ -151,4 +163,3 @@ class CheckableComboBox(QComboBox):
# def itemChecked(self, index):
# item = self.model().item(index, self.modelColumn())
# return item.checkState() == Qt.Checked

View File

@ -39,7 +39,6 @@ from subprocess import Popen
from PyQt5 import QtCore, QtGui, QtWidgets
from Model.create_table_for_save_as import CreateTableForSaveAs
from Model.update_table_for_save import UpdateTableForSave
from Model.read_table_for_open import ReadTableForOpen
from Model.calibration_constant_kt import CalibrationConstantKt
from View.about_window import AboutWindow
@ -266,7 +265,9 @@ class Ui_MainWindow(object):
self.centralwidget.addAction(self.actionDB_Browser_for_SQLite)
def save_as(self):
CreateTableForSaveAs()
db = CreateTableForSaveAs()
db.save_as()
self.mainwindow.setWindowTitle(
"AcouSed - " +
stg.filename_save_as
@ -274,7 +275,8 @@ class Ui_MainWindow(object):
def save(self):
if stg.dirname_save_as:
UpdateTableForSave()
db = CreateTableForSaveAs()
db.save()
else:
self.save_as()

View File

@ -866,8 +866,39 @@ class SedimentCalibrationTab(QWidget):
self.function_pushbutton_update_acoustic_file()
self._update_calibration_parameters()
self.function_pushbutton_plot_sample()
self.blockSignals(False)
def _update_calibration_parameters(self):
if stg.calib_acoustic_data == -1:
return
self.combobox_acoustic_data_choice.blockSignals(True)
self.combobox_freq1.blockSignals(True)
self.combobox_freq2.blockSignals(True)
self.combobox_fine_sample_choice.blockSignals(True)
self.combobox_sand_sample_choice.blockSignals(True)
self.combobox_acoustic_data_choice\
.setCurrentIndex(stg.calib_acoustic_data)
self.combobox_freq1.setCurrentIndex(stg.calib_freq_1)
self.combobox_freq2.setCurrentIndex(stg.calib_freq_2)
self.combobox_fine_sample_choice\
.setCurrentIndexes(stg.calib_fine_profiles)
self.combobox_sand_sample_choice\
.setCurrentIndex(stg.calib_sand_target)
self.combobox_sand_sample_choice.blockSignals(False)
self.combobox_fine_sample_choice.blockSignals(False)
self.combobox_freq2.blockSignals(False)
self.combobox_freq1.blockSignals(False)
self.combobox_acoustic_data_choice.blockSignals(False)
def function_pushbutton_update_acoustic_file(self):
if len(stg.data_preprocessed) == 0:
return
@ -914,8 +945,6 @@ class SedimentCalibrationTab(QWidget):
[s[0] for s in stg.sample_sand]
)
self.plot_acoustic_recording()
self.label_temperature.clear()
self.label_temperature.setText("T = " + str(stg.temperature) + " °C")
@ -937,30 +966,34 @@ class SedimentCalibrationTab(QWidget):
data_id = self.combobox_acoustic_data_choice.currentIndex()
# --- Record frequencies for calibration ---
stg.calib_acoustic_data = data_id
freq1 = self.combobox_freq1.currentIndex()
freq2 = self.combobox_freq2.currentIndex()
stg.frequencies_for_calibration.clear()
stg.frequencies_for_calibration.append(
(
stg.freq[data_id][
self.combobox_freq1.currentIndex()
],
self.combobox_freq1.currentIndex()
stg.freq[data_id][freq1],
freq1
)
)
stg.calib_freq_1 = freq1
stg.frequencies_for_calibration.append(
(
stg.freq[data_id][
self.combobox_freq2.currentIndex()
],
self.combobox_freq2.currentIndex()
stg.freq[data_id][freq2],
freq2
)
)
stg.calib_freq_2 = freq2
stg.frequency_for_inversion = tuple()
stg.frequency_for_inversion = (
stg.freq[data_id][
self.combobox_freq2.currentIndex()
freq2
],
self.combobox_freq2.currentIndex()
freq2
)
# --- Plot acoustic data recording ---
@ -981,14 +1014,14 @@ class SedimentCalibrationTab(QWidget):
stg.BS_stream_bed_pre_process_average[
data_id
][
self.combobox_freq2.currentIndex(), :, :
freq2, :, :
]
)
val_max = np.nanmax(
stg.BS_stream_bed_pre_process_average[
data_id
][
self.combobox_freq2.currentIndex(), :, :
freq2, :, :
]
)
if val_min == 0:
@ -998,39 +1031,39 @@ class SedimentCalibrationTab(QWidget):
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_stream_bed_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_stream_bed_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_stream_bed_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_stream_bed_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
@ -1039,10 +1072,10 @@ class SedimentCalibrationTab(QWidget):
val_min = np.nanmin(
stg.BS_stream_bed_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
val_max = np.nanmax(
stg.BS_stream_bed_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
if val_min == 0:
val_min = 1e-5
@ -1050,48 +1083,48 @@ class SedimentCalibrationTab(QWidget):
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_stream_bed_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_stream_bed_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_stream_bed_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_stream_bed_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_stream_bed[data_id].shape != (0,):
val_min = np.nanmin(
stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(),
stg.BS_stream_bed[data_id][freq2,
:, :])
val_max = np.nanmax(
stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(),
stg.BS_stream_bed[data_id][freq2,
:, :])
if val_min == 0:
val_min = 1e-5
@ -1100,19 +1133,19 @@ class SedimentCalibrationTab(QWidget):
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(),
freq2, :],
stg.BS_stream_bed[data_id][freq2,
:, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(),
freq2, :],
stg.BS_stream_bed[data_id][freq2,
:, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
@ -1120,19 +1153,19 @@ class SedimentCalibrationTab(QWidget):
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(),
freq2, :],
stg.BS_stream_bed[data_id][freq2,
:, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(),
freq2, :],
stg.BS_stream_bed[data_id][freq2,
:, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
@ -1140,10 +1173,10 @@ class SedimentCalibrationTab(QWidget):
val_min = np.nanmin(
stg.BS_cross_section_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
val_max = np.nanmax(
stg.BS_cross_section_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
if val_min == 0:
val_min = 1e-5
@ -1151,49 +1184,49 @@ class SedimentCalibrationTab(QWidget):
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_cross_section_pre_process_SNR[data_id].shape != (0,):
val_min = np.nanmin(
stg.BS_cross_section_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
val_max = np.nanmax(
stg.BS_cross_section_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
if val_min == 0:
val_min = 1e-5
@ -1201,49 +1234,49 @@ class SedimentCalibrationTab(QWidget):
if stg.depth_cross_section[data_id].shape != (0):
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
if stg.depth_cross_section[data_id].shape != (0):
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_cross_section[data_id].shape != (0,):
val_min = np.nanmin(
stg.BS_cross_section[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
val_max = np.nanmax(
stg.BS_cross_section[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
if val_min == 0:
val_min = 1e-5
@ -1251,56 +1284,56 @@ class SedimentCalibrationTab(QWidget):
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
if stg.depth_cross_section[data_id].shape != (0,):
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
else:
self.axis_BS.pcolormesh(
stg.time[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
stg.BS_cross_section[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_raw_data_pre_process_average[data_id].shape != (0,):
val_min = np.nanmin(stg.BS_raw_data_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
val_max = np.nanmax(stg.BS_raw_data_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
if val_min == 0:
val_min = 1e-5
self.axis_BS.pcolormesh(
stg.time[data_id][self.combobox_freq2.currentIndex(), :],
-stg.depth[data_id][self.combobox_freq2.currentIndex(), :],
stg.time[data_id][freq2, :],
-stg.depth[data_id][freq2, :],
stg.BS_raw_data_pre_process_average[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
@ -1308,33 +1341,33 @@ class SedimentCalibrationTab(QWidget):
elif stg.BS_raw_data_pre_process_SNR[data_id].shape != (0,):
val_min = np.nanmin(stg.BS_raw_data_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
val_max = np.nanmax(stg.BS_raw_data_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
if val_min == 0:
val_min = 1e-5
self.axis_BS.pcolormesh(
stg.time[data_id][self.combobox_freq2.currentIndex(), :],
-stg.depth[data_id][self.combobox_freq2.currentIndex(), :],
stg.time[data_id][freq2, :],
-stg.depth[data_id][freq2, :],
stg.BS_raw_data_pre_process_SNR[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif stg.BS_raw_data[data_id].shape != (0,):
val_min = np.nanmin(stg.BS_raw_data[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
val_max = np.nanmax(stg.BS_raw_data[data_id][
self.combobox_freq2.currentIndex(), :, :])
freq2, :, :])
if val_min == 0:
val_min = 1e-5
self.axis_BS.pcolormesh(
stg.time[data_id][self.combobox_freq2.currentIndex(), :],
-stg.depth[data_id][self.combobox_freq2.currentIndex(), :],
stg.time[data_id][freq2, :],
-stg.depth[data_id][freq2, :],
stg.BS_raw_data[data_id][
self.combobox_freq2.currentIndex(), :, :],
freq2, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
# --- Plot samples ---
@ -1379,10 +1412,10 @@ class SedimentCalibrationTab(QWidget):
self.red_line_plot_return, = (
self.axis_BS.plot(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), stg.sand_sample_target_indice[0][1]] *
freq2, stg.sand_sample_target_indice[0][1]] *
np.ones(stg.depth_cross_section[data_id].shape[1]),
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
color='red', linestyle="solid", linewidth=2))
else:
@ -1390,10 +1423,10 @@ class SedimentCalibrationTab(QWidget):
self.red_line_plot_return, = (
self.axis_BS.plot(
stg.time[data_id][
self.combobox_freq2.currentIndex(), stg.sand_sample_target_indice[0][1]] *
freq2, stg.sand_sample_target_indice[0][1]] *
np.ones(stg.depth_cross_section[data_id].shape[1]),
-stg.depth_cross_section[data_id][
self.combobox_freq2.currentIndex(), :],
freq2, :],
color='red', linestyle="solid", linewidth=2))
else:
@ -1403,10 +1436,9 @@ class SedimentCalibrationTab(QWidget):
self.red_line_plot_return, = (
self.axis_BS.plot(
stg.time_cross_section[data_id][
self.combobox_freq2.currentIndex(), stg.sand_sample_target_indice[0][1]] *
freq2, stg.sand_sample_target_indice[0][1]] *
np.ones(stg.depth[data_id].shape[1]),
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
-stg.depth[data_id][freq2, :],
color='red', linestyle="solid", linewidth=2))
else:
@ -1414,10 +1446,9 @@ class SedimentCalibrationTab(QWidget):
self.red_line_plot_return, = (
self.axis_BS.plot(
stg.time[data_id][
self.combobox_freq2.currentIndex(), stg.sand_sample_target_indice[0][1]] *
freq2, stg.sand_sample_target_indice[0][1]] *
np.ones(stg.depth[data_id].shape[1]),
-stg.depth[data_id][
self.combobox_freq2.currentIndex(), :],
-stg.depth[data_id][freq2, :],
color='red', linestyle="solid", linewidth=2))
self.axis_BS.set_xlabel("Time (sec)")
@ -1427,11 +1458,13 @@ class SedimentCalibrationTab(QWidget):
def sample_choice_for_calibration(self):
# --- List selected fine samples ---
stg.fine_sample_profile = [(f, int(f[1:]) - 1) for f in self.combobox_fine_sample_choice.currentData()]
stg.calib_fine_profiles = self.combobox_fine_sample_choice.currentIndexes()
# --- List selected sand samples ---
# stg.sand_sample_target = [(s, int(s[1:]) - 1) for s in self.combobox_sand_sample_choice.currentData()]
stg.sand_sample_target = [(self.combobox_sand_sample_choice.currentText(),
self.combobox_sand_sample_choice.currentIndex())]
stg.calib_sand_target = self.combobox_sand_sample_choice.currentIndex()
# --- Find index in time (along acoustic recording) of sand sample target ---
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
@ -1813,14 +1846,16 @@ class SedimentCalibrationTab(QWidget):
)
def read_calibration_file_and_fill_parameter(self):
if stg.filename_calibration_file == "":
return
pass
else:
# --- Read calibration file ---
data = pd.read_csv(os.path.join(stg.path_calibration_file, stg.filename_calibration_file), header=0, index_col=0)
data = pd.read_csv(
os.path.join(
stg.path_calibration_file,
stg.filename_calibration_file
), header=0, index_col=0
)
# --- Fill spinboxes of calibration parameter ---
self.label_temperature.clear()
@ -1833,6 +1868,8 @@ class SedimentCalibrationTab(QWidget):
data_id = self.combobox_acoustic_data_choice.currentIndex()
stg.calib_acoustic_data = data_id
index_freq1 = np.where(
np.asarray(
stg.freq_text[data_id]
@ -1846,6 +1883,7 @@ class SedimentCalibrationTab(QWidget):
index_freq1
)
)
stg.calib_freq_1 = index_freq1
self.label_freq2.clear()
self.label_freq2.setText(data.columns[1])
@ -1862,6 +1900,7 @@ class SedimentCalibrationTab(QWidget):
index_freq2
)
)
stg.calib_freq_2 = index_freq2
stg.frequency_for_inversion = tuple()
stg.frequency_for_inversion = (

View File

@ -215,6 +215,12 @@ frac_vol_sand_cumul = [] # Cumulated volume fraction (%) of the sand sedi
# --- Parameters choice for calibration ---
calib_acoustic_data = -1
calib_freq_1 = -1
calib_freq_2 = -1
calib_fine_profiles = []
calib_sand_target = -1
frequencies_for_calibration = [] # Frequencies chosen for calibration [(f1_val, f1_ind), (f2_val, f2_ind)] # List of 2 tuples
frequency_for_inversion = tuple() # Frequency chosen for inversion (finv_val, finv_ind) # Tuple
@ -259,7 +265,3 @@ fine_sample_position = [] # Fine samples indexes position for time and dep
sand_sample_position = [] # Sand samples indexes position for time and depth [(time_index, depth_index)] # List of tuples
SSC_fine = [] # Suspended Sediment Concentration of the fine sediments # List of one 3D array
SSC_sand = [] # Suspended Sediment Concentration of the sand sediments # List of one 3D array