Compare commits
No commits in common. "f23dceb42b2a853c36fd41dbd15adb6001cc062d" and "9ae6393d9dfb0a7d17bfddcb84f89b64b1805b87" have entirely different histories.
f23dceb42b
...
9ae6393d9d
|
|
@ -20,16 +20,11 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
import numpy as np
|
||||
import settings as stg
|
||||
from Model.GrainSizeTools import demodul_granulo, mix_gaussian_model
|
||||
|
||||
from tools import trace
|
||||
|
||||
logger = logging.getLogger("acoused")
|
||||
|
||||
|
||||
class AcousticInversionMethodHighConcentration():
|
||||
|
||||
|
|
@ -208,6 +203,7 @@ class AcousticInversionMethodHighConcentration():
|
|||
r2D,
|
||||
water_attenuation_freq1, water_attenuation_freq2,
|
||||
X):
|
||||
|
||||
logVBI = ((zeta_freq2 *
|
||||
np.log(j_cross_section_freq1 * np.exp(4 * r2D * water_attenuation_freq1) /
|
||||
(freq1 ** X)) -
|
||||
|
|
@ -227,3 +223,5 @@ class AcousticInversionMethodHighConcentration():
|
|||
def SSC_sand(self, VBI, freq, X, ks):
|
||||
SSC_sand = (16 * np.pi * VBI * freq ** X) / (3 * ks**2)
|
||||
return SSC_sand
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -100,17 +100,13 @@ class CreateTableForSaveAs:
|
|||
acoustic_data INTEGER,
|
||||
temperature FLOAT,
|
||||
distance_to_free_surface FLOAT,
|
||||
tmin_index INTEGER, tmin_value FLOAT,
|
||||
tmax_index INTEGER, tmax_value FLOAT,
|
||||
rmin_index INTEGER, rmin_value FLOAT,
|
||||
rmax_index INTEGER, rmax_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,
|
||||
freq_bottom_detection_index FLOAT,
|
||||
freq_bottom_detection_value STRING,
|
||||
depth_bottom_detection_min FLOAT,
|
||||
depth_bottom_detection_max FLOAT,
|
||||
depth_bottom_detection_inverval FLOAT,
|
||||
SNR_filter_value FLOAT,
|
||||
Nb_cells_to_average_BS_signal FLOAT
|
||||
SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT
|
||||
)
|
||||
"""
|
||||
|
||||
|
|
@ -159,17 +155,6 @@ 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,
|
||||
|
|
@ -199,21 +184,8 @@ class CreateTableForSaveAs:
|
|||
)
|
||||
"""
|
||||
|
||||
self.create_Notes = """
|
||||
CREATE TABLE Notes(
|
||||
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
notes TEXT
|
||||
)
|
||||
"""
|
||||
|
||||
def save_as(self):
|
||||
self.open_file_dialog()
|
||||
self.save()
|
||||
|
||||
def save(self):
|
||||
start = time.time()
|
||||
self.create_table()
|
||||
logger.info(f"end : {time.time() - start} sec")
|
||||
|
||||
def open_file_dialog(self):
|
||||
name, _ = QFileDialog.getSaveFileName(
|
||||
|
|
@ -237,6 +209,10 @@ 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")
|
||||
|
|
@ -255,10 +231,8 @@ 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)
|
||||
self.create_table_notes(cnx, cur)
|
||||
|
||||
cnx.commit()
|
||||
|
||||
|
|
@ -439,25 +413,19 @@ class CreateTableForSaveAs:
|
|||
tmin_index, tmin_value, tmax_index, tmax_value,
|
||||
rmin_index, rmin_value, rmax_index, rmax_value,
|
||||
freq_bottom_detection_index, freq_bottom_detection_value,
|
||||
depth_bottom_detection_min,
|
||||
depth_bottom_detection_max,
|
||||
depth_bottom_detection_inverval,
|
||||
SNR_filter_value, Nb_cells_to_average_BS_signal
|
||||
)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
stg.acoustic_data[i], stg.temperature,
|
||||
stg.distance_from_ABS_to_free_surface[i],
|
||||
int(stg.tmin[i][0]), stg.tmin[i][1],
|
||||
int(stg.tmax[i][0]), stg.tmax[i][1],
|
||||
int(stg.rmin[i][0]), stg.rmin[i][1],
|
||||
int(stg.rmax[i][0]), stg.rmax[i][1],
|
||||
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.depth_bottom_detection_min,
|
||||
stg.depth_bottom_detection_max,
|
||||
stg.depth_bottom_detection_interval,
|
||||
stg.SNR_filter_value[i],
|
||||
stg.Nb_cells_to_average_BS_signal[i]
|
||||
)
|
||||
|
|
@ -549,36 +517,6 @@ 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()
|
||||
|
||||
|
|
@ -589,7 +527,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,
|
||||
|
|
@ -643,25 +581,3 @@ class CreateTableForSaveAs:
|
|||
cnx.commit()
|
||||
|
||||
logger.info(f"table Inversion : {time.time() - start_table_Inversion} sec")
|
||||
|
||||
def create_table_notes(self, cnx, cur):
|
||||
start_table = time.time()
|
||||
|
||||
cur.execute("DROP TABLE if exists Notes")
|
||||
|
||||
cur.execute(self.create_Notes)
|
||||
|
||||
for i in range(len(stg.SSC_fine)):
|
||||
cur.execute(
|
||||
"""
|
||||
INSERT into Notes(
|
||||
notes
|
||||
)
|
||||
VALUES(?)
|
||||
""",
|
||||
(stg.notes,)
|
||||
)
|
||||
|
||||
cnx.commit()
|
||||
|
||||
logger.info(f"table Notes : {time.time() - start_table} sec")
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ class ReadTableForOpen:
|
|||
self.read_table()
|
||||
self.opened = True
|
||||
|
||||
|
||||
def execute(self, query):
|
||||
return self._cur.execute(query).fetchall()
|
||||
|
||||
|
|
@ -83,9 +84,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()
|
||||
self.read_table_table_notes()
|
||||
|
||||
logger.debug(f"Reading '{stg.filename_open}' done")
|
||||
|
||||
|
|
@ -113,6 +112,7 @@ class ReadTableForOpen:
|
|||
WHERE (acoustic_data = {k})
|
||||
'''
|
||||
data = self.execute(query)[0]
|
||||
print("data acoustic file", data)
|
||||
|
||||
stg.filename_BS_raw_data.append(
|
||||
str(data[1]) + '.aqa'
|
||||
|
|
@ -125,8 +125,6 @@ class ReadTableForOpen:
|
|||
stg.noise_value.append(data[6])
|
||||
stg.data_preprocessed.append(data[7])
|
||||
|
||||
self.read_table_acoustic_file_init_others_data()
|
||||
|
||||
logger.debug("data acoustic file:")
|
||||
logger.debug(f"- {stg.filename_BS_raw_data}")
|
||||
logger.debug(f"- {stg.ABS_name}")
|
||||
|
|
@ -136,14 +134,6 @@ class ReadTableForOpen:
|
|||
logger.debug(f"- {stg.noise_value}")
|
||||
logger.debug(f"- {stg.data_preprocessed}")
|
||||
|
||||
def read_table_acoustic_file_init_others_data(self):
|
||||
stg.kt2D.append(np.array([]))
|
||||
stg.kt3D.append(np.array([]))
|
||||
stg.J_cross_section.append([np.array([]), np.array([])])
|
||||
stg.VBI_cross_section.append(np.array([]))
|
||||
stg.SSC_fine.append(np.array([]))
|
||||
stg.SSC_sand.append(np.array([]))
|
||||
|
||||
def read_table_measure(self):
|
||||
stg.date = [0]*len(stg.acoustic_data)
|
||||
stg.hour = [0]*len(stg.acoustic_data)
|
||||
|
|
@ -199,17 +189,12 @@ class ReadTableForOpen:
|
|||
logger.debug(f"- stg.kt_read {stg.kt_read}")
|
||||
logger.debug(f"- stg.kt_corrected {stg.kt_corrected}")
|
||||
logger.debug(f"- stg.nb_profiles {stg.nb_profiles}")
|
||||
logger.debug(
|
||||
f"- stg.nb_profiles_per_sec {stg.nb_profiles_per_sec}"
|
||||
)
|
||||
logger.debug(f"- stg.nb_profiles_per_sec {stg.nb_profiles_per_sec}")
|
||||
logger.debug(f"- stg.nb_cells {stg.nb_cells}")
|
||||
logger.debug(f"- stg.cell_size {stg.cell_size}")
|
||||
logger.debug(f"- stg.pulse_length {stg.pulse_length}")
|
||||
logger.debug(f"- stg.nb_pings_per_sec {stg.nb_pings_per_sec}")
|
||||
logger.debug(
|
||||
"- stg.nb_pings_averaged_per_profile "
|
||||
+ f"{stg.nb_pings_averaged_per_profile}"
|
||||
)
|
||||
logger.debug(f"- stg.nb_pings_averaged_per_profile {stg.nb_pings_averaged_per_profile}")
|
||||
logger.debug(f"- stg.gain_rx {stg.gain_rx}")
|
||||
logger.debug(f"- stg.gain_tx {stg.gain_tx}")
|
||||
|
||||
|
|
@ -384,8 +369,8 @@ class ReadTableForOpen:
|
|||
|
||||
it = iter(data)
|
||||
|
||||
time = np_f64_parse(next(it))
|
||||
depth = np_f64_parse(next(it))
|
||||
time = next(it)
|
||||
depth = next(it)
|
||||
BS = np_f64_parse(next(it))
|
||||
|
||||
if len(BS) == 0:
|
||||
|
|
@ -395,12 +380,12 @@ class ReadTableForOpen:
|
|||
stg.BS_noise_averaged_data.append(np.array([]))
|
||||
else:
|
||||
stg.time_noise.append(
|
||||
time.reshape(
|
||||
np_f64_parse(time).reshape(
|
||||
(stg.freq[i].shape[0], -1)
|
||||
)
|
||||
)
|
||||
stg.depth_noise.append(
|
||||
depth.reshape(
|
||||
np_f64_parse(depth).reshape(
|
||||
(stg.freq[i].shape[0], -1)
|
||||
)
|
||||
)
|
||||
|
|
@ -438,18 +423,10 @@ class ReadTableForOpen:
|
|||
for dest, resh in SNR_vars:
|
||||
SNR = np_f64_parse(next(it))
|
||||
|
||||
try:
|
||||
if len(SNR) != 0:
|
||||
dest.append(SNR.reshape(resh[i].shape))
|
||||
if len(SNR) == 0:
|
||||
dest.append(np.array([]))
|
||||
else:
|
||||
dest.append(np.array([]))
|
||||
except:
|
||||
logger.warning(
|
||||
"SQL: read_table_BS_raw_data_SNR: "
|
||||
+ "failed to reshape data from "
|
||||
+ f"{SNR.shape} to {resh[i].shape}"
|
||||
)
|
||||
dest.append(np.array([]))
|
||||
dest.append(SNR.reshape(resh[i].shape))
|
||||
|
||||
def read_table_BS_raw_data_rest(self, query, i):
|
||||
np_f64_parse = lambda d: np.frombuffer(d, dtype=np.float64)
|
||||
|
|
@ -509,34 +486,27 @@ class ReadTableForOpen:
|
|||
tmin_index, tmin_value, tmax_index, tmax_value,
|
||||
rmin_index, rmin_value, rmax_index, rmax_value,
|
||||
freq_bottom_detection_index, freq_bottom_detection_value,
|
||||
depth_bottom_detection_min,
|
||||
depth_bottom_detection_max,
|
||||
depth_bottom_detection_inverval,
|
||||
SNR_filter_value, Nb_cells_to_average_BS_signal
|
||||
FROM Settings
|
||||
WHERE (acoustic_data = {s})
|
||||
'''
|
||||
|
||||
data = self.execute(query3)
|
||||
it = iter(data[0])
|
||||
x = data[0]
|
||||
|
||||
acoustic_data = next(it)
|
||||
stg.temperature = [next(it)][0]
|
||||
stg.distance_from_ABS_to_free_surface.append(next(it))
|
||||
stg.tmin.append((next(it), next(it)))
|
||||
stg.tmax.append((next(it), next(it)))
|
||||
stg.rmin.append((next(it), next(it)))
|
||||
stg.rmax.append((next(it), next(it)))
|
||||
stg.freq_bottom_detection.append((next(it), next(it)))
|
||||
stg.depth_bottom_detection_min = next(it)
|
||||
stg.depth_bottom_detection_max = next(it)
|
||||
stg.depth_bottom_detection_interval = next(it)
|
||||
stg.SNR_filter_value.append(next(it))
|
||||
stg.Nb_cells_to_average_BS_signal.append(next(it))
|
||||
stg.temperature = [x[1]][0]
|
||||
stg.distance_from_ABS_to_free_surface.append(x[2])
|
||||
stg.tmin.append((x[3], x[4]))
|
||||
stg.tmax.append((x[5], x[6]))
|
||||
stg.rmin.append((x[7], x[8]))
|
||||
stg.rmax.append((x[9], x[10]))
|
||||
stg.freq_bottom_detection.append((x[11], x[12]))
|
||||
stg.SNR_filter_value.append(x[13])
|
||||
stg.Nb_cells_to_average_BS_signal.append(x[14])
|
||||
|
||||
logger.debug(f"stg.temperature: {stg.temperature}")
|
||||
logger.debug(f"stg.tmin: {stg.tmin}")
|
||||
logger.debug(f"stg.tmax: {stg.tmax}")
|
||||
logger.debug(f"stg.tmin: {stg.tmax}")
|
||||
logger.debug(f"stg.SNR_filter_value: {stg.SNR_filter_value}")
|
||||
|
||||
def read_table_sediment_file(self):
|
||||
|
|
@ -572,6 +542,7 @@ class ReadTableForOpen:
|
|||
+ list(stg.radius_grain_sand)
|
||||
)
|
||||
|
||||
@trace
|
||||
def read_table_table_sediment_data(self):
|
||||
np_f64_parse = lambda d: np.frombuffer(d, dtype=np.float64)
|
||||
|
||||
|
|
@ -629,68 +600,7 @@ class ReadTableForOpen:
|
|||
|
||||
logger.debug(f"fine: {stg.Ctot_fine}, sand: {stg.sample_sand}")
|
||||
|
||||
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)
|
||||
|
||||
|
|
@ -714,23 +624,11 @@ class ReadTableForOpen:
|
|||
stg.filename_calibration_file = next(it)
|
||||
stg.range_lin_interp = np_f64_parse(next(it))
|
||||
stg.M_profile_fine = np_f64_parse(next(it))
|
||||
stg.ks = np_f64_parse(next(it)).tolist()
|
||||
stg.sv = np_f64_parse(next(it)).tolist()
|
||||
stg.X_exponent = np_f64_parse(next(it)).tolist()
|
||||
stg.alpha_s = np_f64_parse(next(it)).tolist()
|
||||
stg.zeta = np_f64_parse(next(it)).tolist()
|
||||
stg.FCB = np_f64_parse(next(it)).tolist()
|
||||
stg.depth_real = np_f64_parse(next(it)).tolist()
|
||||
stg.lin_reg = np_f64_parse(next(it)).tolist()
|
||||
|
||||
def read_table_table_notes(self):
|
||||
np_f64_parse = lambda d: np.frombuffer(d, dtype=np.float64)
|
||||
|
||||
query = f'''
|
||||
SELECT notes
|
||||
FROM Notes
|
||||
'''
|
||||
|
||||
data = self.execute(query)
|
||||
if len(data) != 0:
|
||||
stg.notes = data[0][0]
|
||||
stg.ks = np_f64_parse(next(it))
|
||||
stg.sv = np_f64_parse(next(it))
|
||||
stg.X_exponent = np_f64_parse(next(it))
|
||||
stg.alpha_s = np_f64_parse(next(it))
|
||||
stg.zeta = np_f64_parse(next(it))
|
||||
stg.FCB = np_f64_parse(next(it))
|
||||
stg.depth_real = np_f64_parse(next(it))
|
||||
stg.lin_reg = np_f64_parse(next(it))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,469 @@
|
|||
# ============================================================================== #
|
||||
# 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()
|
||||
|
|
@ -29,18 +29,19 @@ import os
|
|||
class Logos():
|
||||
|
||||
def __init__(self):
|
||||
self.logo_AcouSed = os.path.join('logos', "AcouSed.png")
|
||||
|
||||
self.logo_INRAE = os.path.join('logos', "BlocMarque-INRAE-Inter.jpg")
|
||||
self.logo_AcouSed = (os.path.join('logos', "AcouSed.png"))
|
||||
|
||||
self.logo_OSR = os.path.join('logos', "OSR.png")
|
||||
self.logo_europe = os.path.join('logos', "Europe.png")
|
||||
self.logo_saone_rhone = os.path.join('logos', "plan_Rhone_Saone.png")
|
||||
self.logo_carnot = os.path.join('logos', "Carnot_EE.png")
|
||||
self.logo_INRAE = (os.path.join('logos', "BlocMarque-INRAE-Inter.jpg"))
|
||||
|
||||
self.logo_CNR = os.path.join('logos', "CNR.png")
|
||||
self.logo_EDF = os.path.join('logos', "EDF.png")
|
||||
self.logo_Ubertone = os.path.join('logos', "Ubertone.jpg")
|
||||
self.logo_OSR = (os.path.join('logos', "OSR.png"))
|
||||
self.logo_europe = (os.path.join('logos', "Europe.png"))
|
||||
self.logo_saone_rhone = (os.path.join('logos', "plan_Rhone_Saone.png"))
|
||||
self.logo_carnot = (os.path.join('logos', "Carnot_EE.png"))
|
||||
|
||||
self.logo_CNR = (os.path.join('logos', "CNR.png"))
|
||||
self.logo_EDF = (os.path.join('logos', "EDF.png"))
|
||||
self.logo_Ubertone = (os.path.join('logos', "Ubertone.jpg"))
|
||||
|
||||
logos_inst = Logos()
|
||||
|
||||
|
|
@ -48,6 +49,7 @@ logos_inst = Logos()
|
|||
class AboutWindow(QDialog):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
super().__init__()
|
||||
|
||||
self.setGeometry(400, 200, 350, 200)
|
||||
|
|
@ -69,12 +71,12 @@ class AboutWindow(QDialog):
|
|||
|
||||
self.label_acoused = QLabel()
|
||||
self.label_acoused.setText("Acoused 2.0")
|
||||
self.label_acoused.setFont(QFont("DejaVu Sans", 14))
|
||||
self.label_acoused.setFont(QFont("Ubuntu", 14))
|
||||
self.gridLayout.addWidget(self.label_acoused, 0, 1, 1, 1, Qt.AlignCenter)
|
||||
|
||||
self.label_date = QLabel()
|
||||
self.label_date.setText("2025.01.01")
|
||||
self.label_date.setFont(QFont("DejaVu Sans", 12))
|
||||
self.label_date.setFont(QFont("Ubuntu", 12))
|
||||
self.gridLayout.addWidget(self.label_date, 1, 1, 1, 1, Qt.AlignCenter)
|
||||
|
||||
self.label_logo_INRAE = QLabel()
|
||||
|
|
@ -300,3 +302,5 @@ class Authors(QDialog):
|
|||
# w = AboutWindow()
|
||||
# w.show()
|
||||
# sys.exit(app.exec_())
|
||||
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -121,18 +121,6 @@ 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):
|
||||
|
|
@ -163,3 +151,4 @@ class CheckableComboBox(QComboBox):
|
|||
# def itemChecked(self, index):
|
||||
# item = self.model().item(index, self.modelColumn())
|
||||
# return item.checkState() == Qt.Checked
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ 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
|
||||
|
|
@ -265,9 +266,7 @@ class Ui_MainWindow(object):
|
|||
self.centralwidget.addAction(self.actionDB_Browser_for_SQLite)
|
||||
|
||||
def save_as(self):
|
||||
db = CreateTableForSaveAs()
|
||||
db.save_as()
|
||||
|
||||
CreateTableForSaveAs()
|
||||
self.mainwindow.setWindowTitle(
|
||||
"AcouSed - " +
|
||||
stg.filename_save_as
|
||||
|
|
@ -275,8 +274,7 @@ class Ui_MainWindow(object):
|
|||
|
||||
def save(self):
|
||||
if stg.dirname_save_as:
|
||||
db = CreateTableForSaveAs()
|
||||
db.save()
|
||||
UpdateTableForSave()
|
||||
else:
|
||||
self.save_as()
|
||||
|
||||
|
|
@ -301,6 +299,7 @@ class Ui_MainWindow(object):
|
|||
msg_box.exec()
|
||||
|
||||
def about_window(self):
|
||||
print("about")
|
||||
aw = AboutWindow()
|
||||
aw.exec()
|
||||
|
||||
|
|
@ -313,6 +312,7 @@ class Ui_MainWindow(object):
|
|||
)
|
||||
|
||||
def open_doc_file(self, filename):
|
||||
print(self.current_file_path("filename.pdf"))
|
||||
QtGui.QDesktopServices.openUrl(
|
||||
QtCore.QUrl(
|
||||
f"file://{self.current_file_path(filename)}"
|
||||
|
|
@ -333,11 +333,15 @@ class Ui_MainWindow(object):
|
|||
name = QtWidgets.QFileDialog.getExistingDirectory(
|
||||
caption="Select Directory - Acoustic BS raw data Table"
|
||||
)
|
||||
print("name table to save ", name)
|
||||
|
||||
# --- Save the raw acoustic backscatter data from a
|
||||
# --- Dataframe to csv file ---
|
||||
|
||||
t0 = time.time()
|
||||
print("len(stg.BS_raw_data_reshape) ",
|
||||
len(stg.BS_raw_data_reshape))
|
||||
|
||||
if name:
|
||||
for i in range(len(stg.BS_raw_data_reshape)):
|
||||
header_list = []
|
||||
|
|
@ -387,7 +391,8 @@ class Ui_MainWindow(object):
|
|||
)
|
||||
|
||||
t1 = time.time() - t0
|
||||
logger.debug(f"Time duration export BS {t1}")
|
||||
print("time duration export BS ", t1)
|
||||
print("table of BS value Export finished")
|
||||
|
||||
def retranslateUi(self):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
import logging
|
||||
|
||||
from PyQt5.QtWidgets import (
|
||||
|
|
@ -7,7 +6,7 @@ from PyQt5.QtWidgets import (
|
|||
QSizePolicy, QFontComboBox, QColorDialog
|
||||
)
|
||||
from PyQt5.QtGui import QPixmap, QIcon, QFont
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
import settings as stg
|
||||
|
||||
|
|
@ -19,13 +18,13 @@ class NoteTab(QWidget):
|
|||
|
||||
''' This class generates a enhanced notepad in Note Tab '''
|
||||
|
||||
def _path_icon(self, icon):
|
||||
return os.path.join("icons", icon)
|
||||
|
||||
def __init__(self, widget_tab):
|
||||
super().__init__()
|
||||
|
||||
self.changed = False
|
||||
path_icon = "./icons/"
|
||||
|
||||
# FIXME: The note are disabled because there are never saved
|
||||
widget_tab.setEnabled(False)
|
||||
|
||||
self.verticalLayout_main_note_tab = QVBoxLayout(widget_tab)
|
||||
|
||||
|
|
@ -37,104 +36,96 @@ class NoteTab(QWidget):
|
|||
self.filename_text = ""
|
||||
|
||||
self.pushbutton_new_txt = QPushButton()
|
||||
self.icon_new_txt = QPixmap(self._path_icon("new_text.png"))
|
||||
self.icon_new_txt = QPixmap(path_icon + "new_text.png")
|
||||
self.pushbutton_new_txt.setIcon(QIcon(self.icon_new_txt))
|
||||
# self.pushbutton_new_txt.clicked.connect(self.new_text)
|
||||
self.horizontalLayout_toolbar.addWidget(self.pushbutton_new_txt)
|
||||
|
||||
self.pushbutton_save_txt = QPushButton()
|
||||
self.icon_save_txt = QPixmap(self._path_icon("save_txt.png"))
|
||||
self.icon_save_txt = QPixmap(path_icon + "save_txt.png")
|
||||
self.pushbutton_save_txt.setIcon(QIcon(self.icon_save_txt))
|
||||
# self.pushbutton_save_txt.clicked.connect(self.save_text)
|
||||
self.horizontalLayout_toolbar.addWidget(self.pushbutton_save_txt)
|
||||
|
||||
self.pushbutton_open_txt = QPushButton()
|
||||
self.icon_open_txt = QPixmap(self._path_icon("open_txt.png"))
|
||||
self.icon_open_txt = QPixmap(path_icon + "open_txt.png")
|
||||
self.pushbutton_open_txt.setIcon(QIcon(self.icon_open_txt))
|
||||
# self.pushbutton_open_txt.clicked.connect(self.open_text)
|
||||
self.horizontalLayout_toolbar.addWidget(self.pushbutton_open_txt)
|
||||
|
||||
self.fontbox = QFontComboBox()
|
||||
self.fontbox.currentFontChanged.connect(
|
||||
lambda font : self.textEdit.setCurrentFont(font)
|
||||
)
|
||||
self.fontbox.currentFontChanged.connect(lambda font : self.textEdit.setCurrentFont(font))
|
||||
self.horizontalLayout_toolbar.addWidget(self.fontbox)
|
||||
|
||||
self.fontSize = QSpinBox()
|
||||
self.fontSize.setSuffix("pt")
|
||||
self.fontSize.valueChanged.connect(
|
||||
lambda size: self.textEdit.setFontPointSize(size)
|
||||
)
|
||||
self.fontSize.valueChanged.connect(lambda size: self.textEdit.setFontPointSize(size))
|
||||
self.fontSize.setValue(14)
|
||||
self.horizontalLayout_toolbar.addWidget(self.fontSize)
|
||||
|
||||
self.fontColor = QPushButton()
|
||||
self.icon_fontColor = QPixmap(self._path_icon("font_color.png"))
|
||||
self.icon_fontColor = QPixmap(path_icon + "font_color.png")
|
||||
self.fontColor.setIcon(QIcon(self.icon_fontColor))
|
||||
# self.QAction(QIcon("couleur_police.png"), "Changer la couleur du texte", self)couleur_fond.png
|
||||
self.fontColor.clicked.connect(self.fontColorChanged)
|
||||
self.horizontalLayout_toolbar.addWidget(self.fontColor)
|
||||
|
||||
self.backColor = QPushButton()
|
||||
self.icon_backColor = QPixmap(self._path_icon("background_color.png"))
|
||||
self.icon_backColor = QPixmap(path_icon + "background_color.png")
|
||||
self.backColor.setIcon(QIcon(self.icon_backColor))
|
||||
self.backColor.clicked.connect(self.highlight)
|
||||
self.horizontalLayout_toolbar.addWidget(self.backColor)
|
||||
|
||||
self.boldAction = QPushButton()
|
||||
self.icon_boldAction = QPixmap(self._path_icon("bold.png"))
|
||||
self.icon_boldAction = QPixmap(path_icon + "bold.png")
|
||||
self.boldAction.setIcon(QIcon(self.icon_boldAction))
|
||||
self.boldAction.clicked.connect(self.bold)
|
||||
self.horizontalLayout_toolbar.addWidget(self.boldAction)
|
||||
|
||||
self.italicAction = QPushButton()
|
||||
self.icon_italicAction = QPixmap(self._path_icon("italic.png"))
|
||||
self.icon_italicAction = QPixmap(path_icon + "italic.png")
|
||||
self.italicAction.setIcon(QIcon(self.icon_italicAction))
|
||||
self.italicAction.clicked.connect(self.italic)
|
||||
self.horizontalLayout_toolbar.addWidget(self.italicAction)
|
||||
|
||||
self.underlineAction = QPushButton()
|
||||
self.icon_underlineAction = QPixmap(self._path_icon("underline.png"))
|
||||
self.icon_underlineAction = QPixmap(path_icon + "underline.png")
|
||||
self.underlineAction.setIcon(QIcon(self.icon_underlineAction))
|
||||
self.underlineAction.clicked.connect(self.underline)
|
||||
self.horizontalLayout_toolbar.addWidget(self.underlineAction)
|
||||
|
||||
self.strikeAction = QPushButton()
|
||||
self.icon_strikeAction = QPixmap(self._path_icon("strike.png"))
|
||||
self.icon_strikeAction = QPixmap(path_icon + "strike.png")
|
||||
self.strikeAction.setIcon(QIcon(self.icon_strikeAction))
|
||||
self.strikeAction.clicked.connect(self.strike)
|
||||
self.horizontalLayout_toolbar.addWidget(self.strikeAction)
|
||||
|
||||
self.alignLeftAction = QPushButton()
|
||||
self.icon_alignLeftAction = QPixmap(self._path_icon("left.png"))
|
||||
self.icon_alignLeftAction = QPixmap(path_icon + "left.png")
|
||||
self.alignLeftAction.setIcon(QIcon(self.icon_alignLeftAction))
|
||||
self.alignLeftAction.clicked.connect(self.alignLeft)
|
||||
self.horizontalLayout_toolbar.addWidget(self.alignLeftAction)
|
||||
|
||||
self.alignCenterAction = QPushButton()
|
||||
self.icon_alignCenterAction = QPixmap(self._path_icon("centre.png"))
|
||||
self.icon_alignCenterAction = QPixmap(path_icon + "centre.png")
|
||||
self.alignCenterAction.setIcon(QIcon(self.icon_alignCenterAction))
|
||||
self.alignCenterAction.clicked.connect(self.alignCenter)
|
||||
self.horizontalLayout_toolbar.addWidget(self.alignCenterAction)
|
||||
|
||||
self.alignRightAction = QPushButton()
|
||||
self.icon_alignRightAction = QPixmap(self._path_icon("right.png"))
|
||||
self.icon_alignRightAction = QPixmap(path_icon + "right.png")
|
||||
self.alignRightAction.setIcon(QIcon(self.icon_alignRightAction))
|
||||
self.alignRightAction.clicked.connect(self.alignRight)
|
||||
self.horizontalLayout_toolbar.addWidget(self.alignRightAction)
|
||||
|
||||
self.alignJustifyAction = QPushButton()
|
||||
self.icon_alignJustifyAction = QPixmap(self._path_icon("justify.png"))
|
||||
self.icon_alignJustifyAction = QPixmap(path_icon + "justify.png")
|
||||
self.alignJustifyAction.setIcon(QIcon(self.icon_alignJustifyAction))
|
||||
self.alignJustifyAction.clicked.connect(self.alignJustify)
|
||||
self.horizontalLayout_toolbar.addWidget(self.alignJustifyAction)
|
||||
|
||||
self.horizontalSpacerItem_toolbar_note_tab = QSpacerItem(
|
||||
500, 10, QSizePolicy.Expanding, QSizePolicy.Minimum
|
||||
)
|
||||
self.horizontalLayout_toolbar.addItem(
|
||||
self.horizontalSpacerItem_toolbar_note_tab
|
||||
)
|
||||
self.horizontalSpacerItem_toolbar_note_tab = QSpacerItem(500, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)
|
||||
self.horizontalLayout_toolbar.addItem(self.horizontalSpacerItem_toolbar_note_tab)
|
||||
|
||||
self.pushbutton_print_settings = QPushButton()
|
||||
self.pushbutton_print_settings.setText("EDIT SETTINGS")
|
||||
|
|
@ -143,39 +134,19 @@ class NoteTab(QWidget):
|
|||
|
||||
self.verticalLayout_main_note_tab.addWidget(self.textEdit)
|
||||
|
||||
self.textEdit.textChanged.connect(self.setTextChanged)
|
||||
|
||||
self._alarm = QTimer()
|
||||
self._alarm.timeout.connect(self.applyTextOnStg)
|
||||
self._alarm.start(1000)
|
||||
|
||||
## -------------------------------
|
||||
## ---------- Functions ----------
|
||||
## -------------------------------
|
||||
|
||||
@trace
|
||||
def full_update(self):
|
||||
self.blockSignals(True)
|
||||
self.textEdit.blockSignals(True)
|
||||
self._alarm.blockSignals(True)
|
||||
|
||||
logger.debug(f"{__name__}: Update")
|
||||
self.blockSignals(True)
|
||||
|
||||
self.applyStgOnText()
|
||||
# TODO: Update all widgets
|
||||
|
||||
self._alarm.blockSignals(False)
|
||||
self.textEdit.blockSignals(False)
|
||||
self.blockSignals(False)
|
||||
|
||||
def setTextChanged(self):
|
||||
self.changed = True
|
||||
|
||||
def applyTextOnStg(self):
|
||||
text = self.textEdit.toHtml()
|
||||
stg.notes = text
|
||||
|
||||
def applyStgOnText(self):
|
||||
text = self.textEdit.setText(stg.notes)
|
||||
|
||||
# def new_text(self):
|
||||
# window = self.ui_mainwindow.tab5
|
||||
# window.show()
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class PlotNoiseWindow(QDialog):
|
|||
|
||||
eval("self.ax" + str(i) + "[" + str(freq_ind) + "]" + ".text(1, .70, stg.freq_text[" + str(i) +
|
||||
"][" + str(freq_ind) + "]," +
|
||||
"fontsize=10, fontweight='bold', fontname='DejaVu Sans', c='black', alpha=0.5," +
|
||||
"fontsize=10, fontweight='bold', fontname='Ubuntu', c='black', alpha=0.5," +
|
||||
"horizontalalignment='right', verticalalignment='bottom'," +
|
||||
"transform=self.ax" + str(i) + "[" + str(freq_ind) + "].transAxes)")
|
||||
|
||||
|
|
@ -91,3 +91,4 @@ class PlotNoiseWindow(QDialog):
|
|||
|
||||
exec("self.verticalLayout_tab" + str(i) + ".addWidget(self.toolbar" + str(i) + ")")
|
||||
exec("self.verticalLayout_tab" + str(i) + ".addWidget(self.scroll" + str(i) + ")")
|
||||
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ class SampleDataTab(QWidget):
|
|||
super().__init__()
|
||||
|
||||
icon_folder = QIcon(os.path.join("icons", "folder.png"))
|
||||
self._setup_attrs()
|
||||
|
||||
### --- General layout of widgets ---
|
||||
|
||||
|
|
@ -258,11 +257,6 @@ class SampleDataTab(QWidget):
|
|||
|
||||
self.combobox_PSD_plot.currentTextChanged.connect(self.plot_PSD_fine_and_sand_sediments)
|
||||
|
||||
def _setup_attrs(self):
|
||||
self.figure_plot_sample_position_on_transect = None
|
||||
self.figure_total_concentration = None
|
||||
self.figure_plot_PSD = None
|
||||
|
||||
# -------------------- Functions for Sample Data Tab --------------------
|
||||
|
||||
def retranslate_data_sample_tab(self):
|
||||
|
|
@ -286,6 +280,7 @@ class SampleDataTab(QWidget):
|
|||
|
||||
self.groupbox_plot_PSD.setTitle(_translate("CONSTANT_STRING", cs.DISTRIBUTION_PLOT))
|
||||
|
||||
@trace
|
||||
def full_update(self):
|
||||
logger.debug(f"{__name__}: Update")
|
||||
self.blockSignals(True)
|
||||
|
|
@ -795,9 +790,6 @@ class SampleDataTab(QWidget):
|
|||
self.verticalLayout_groupbox_plot_transect\
|
||||
.removeWidget(self.canvas_plot_sample_position_on_transect)
|
||||
|
||||
if self.figure_plot_sample_position_on_transect is not None:
|
||||
self.figure_plot_sample_position_on_transect.clear()
|
||||
|
||||
fig, axis = plt.subplots(nrows=1, ncols=1, layout="constrained")
|
||||
|
||||
self.figure_plot_sample_position_on_transect = fig
|
||||
|
|
@ -1423,9 +1415,6 @@ class SampleDataTab(QWidget):
|
|||
self.verticalLayout_groupbox_plot_total_concentration.removeWidget(self.canvas_plot_total_concentration)
|
||||
self.verticalLayout_groupbox_plot_total_concentration.removeWidget(self.toolbar_plot_total_concentration)
|
||||
|
||||
if self.figure_total_concentration is not None:
|
||||
self.figure_total_concentration.clear()
|
||||
|
||||
self.figure_total_concentration, self.axis_total_concentration \
|
||||
= plt.subplots(nrows=1, ncols=1, layout="constrained")
|
||||
self.canvas_plot_total_concentration = FigureCanvas(self.figure_total_concentration)
|
||||
|
|
@ -1711,9 +1700,6 @@ class SampleDataTab(QWidget):
|
|||
self.verticalLayout_groupbox_plot_PSD.removeWidget(self.canvas_plot_PSD)
|
||||
self.verticalLayout_groupbox_plot_PSD.removeWidget(self.toolbar_plot_PSD)
|
||||
|
||||
if self.figure_plot_PSD is not None:
|
||||
self.figure_plot_PSD.clear()
|
||||
|
||||
self.figure_plot_PSD, self.axis_plot_PSD \
|
||||
= plt.subplots(nrows=1, ncols=2, layout="constrained")
|
||||
self.canvas_plot_PSD = FigureCanvas(self.figure_plot_PSD)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -75,7 +75,6 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
|
||||
self._setup_icons()
|
||||
self._setup_attrs()
|
||||
|
||||
### --- General layout of widgets ---
|
||||
|
||||
|
|
@ -431,13 +430,11 @@ class SignalProcessingTab(QWidget):
|
|||
self.widget_scrollArea_list_preprocessed_data.setLayout(self.verticalLayout_scrollArea_list_pre_processed_data)
|
||||
|
||||
# Add content to the widget (labels in this example)
|
||||
self.lineEdit_list_pre_processed_data = []
|
||||
for i in range(20):
|
||||
self.lineEdit_list_pre_processed_data.append(QLineEdit())
|
||||
self.verticalLayout_scrollArea_list_pre_processed_data.addWidget(
|
||||
self.lineEdit_list_pre_processed_data[i]
|
||||
)
|
||||
self.lineEdit_list_pre_processed_data[i].setDisabled(True)
|
||||
exec("self.lineEdit_list_pre_processed_data_" + str(i) + "= QLineEdit()")
|
||||
eval("self.verticalLayout_scrollArea_list_pre_processed_data.addWidget("
|
||||
"self.lineEdit_list_pre_processed_data_" + str(i) + ")")
|
||||
eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
|
||||
|
||||
|
||||
# Set the widget as the scroll area's widget
|
||||
|
|
@ -514,13 +511,7 @@ class SignalProcessingTab(QWidget):
|
|||
self.icon_clear = QIcon(path_icon("clear.png"))
|
||||
self.icon_apply = QIcon(path_icon("circle_green_arrow_right.png"))
|
||||
|
||||
def _setup_attrs(self):
|
||||
self.fig_profile_tail = None
|
||||
self.fig_noise = None
|
||||
self.fig_SNR = None
|
||||
self.fig_BS = None
|
||||
self.figure_profile = None
|
||||
|
||||
@trace
|
||||
def full_update(self):
|
||||
logger.debug(f"{__name__}: Update")
|
||||
self.blockSignals(True)
|
||||
|
|
@ -533,7 +524,7 @@ class SignalProcessingTab(QWidget):
|
|||
self.blockSignals(False)
|
||||
|
||||
def full_update_fill_text(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
self.lineEdit_profile_tail_value.setText(
|
||||
str(stg.noise_value[data_id])
|
||||
|
|
@ -548,6 +539,7 @@ class SignalProcessingTab(QWidget):
|
|||
)
|
||||
|
||||
def update_SignalPreprocessingTab(self):
|
||||
|
||||
""" The tab is updated in two cases :
|
||||
- the user remove a file (in the list widget) in the first tab (Acoustic data), so that the combobox
|
||||
of data to be processed is updated,
|
||||
|
|
@ -560,7 +552,7 @@ class SignalProcessingTab(QWidget):
|
|||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
else:
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
self.combobox_acoustic_data_choice.blockSignals(True)
|
||||
self.combobox_freq_noise_from_profile_tail.blockSignals(True)
|
||||
|
|
@ -593,7 +585,7 @@ class SignalProcessingTab(QWidget):
|
|||
self.combobox_acoustic_data_choice.blockSignals(False)
|
||||
|
||||
def _is_correct_shape(self, data):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
if stg.time_cross_section[data_id].shape != (0,):
|
||||
x_time = stg.time_cross_section[data_id]
|
||||
|
|
@ -620,57 +612,19 @@ class SignalProcessingTab(QWidget):
|
|||
return (y == depth_shape and z == time_shape)
|
||||
|
||||
def recompute(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
self.compute_average_profile_tail()
|
||||
|
||||
if stg.noise_method[data_id] == 0:
|
||||
if stg.filename_BS_noise_data[data_id] != "":
|
||||
if len(stg.BS_noise_raw_data) == 0:
|
||||
self.load_noise_data_and_compute_SNR()
|
||||
else:
|
||||
for i in range(self.combobox_acoustic_data_choice.count()):
|
||||
self.compute_noise(i)
|
||||
elif stg.noise_method[data_id] == 1:
|
||||
self.compute_noise_from_profile_tail_value()
|
||||
|
||||
self.remove_point_with_snr_filter()
|
||||
self.compute_averaged_BS_data()
|
||||
|
||||
@trace
|
||||
def compute_noise(self, data_id):
|
||||
if self._is_correct_shape(stg.BS_stream_bed):
|
||||
BS_data = stg.BS_stream_bed
|
||||
SNR_data = stg.SNR_stream_bed
|
||||
elif self._is_correct_shape(stg.BS_cross_section):
|
||||
BS_data = stg.BS_cross_section
|
||||
SNR_data = stg.SNR_cross_section
|
||||
else:
|
||||
BS_data = stg.BS_raw_data
|
||||
SNR_data = stg.SNR_raw_data
|
||||
|
||||
noise = np.zeros(BS_data[data_id].shape)
|
||||
for f, _ in enumerate(BS_data[data_id]):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1)
|
||||
)
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
|
||||
SNR_data[data_id] = (
|
||||
np.divide(
|
||||
(
|
||||
BS_data[data_id] - stg.BS_noise_averaged_data[data_id]
|
||||
) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2
|
||||
)
|
||||
)
|
||||
|
||||
self.combobox_frequency_profile.clear()
|
||||
self.combobox_frequency_profile.addItems(
|
||||
[f for f in stg.freq_text[data_id]]
|
||||
)
|
||||
|
||||
def replot(self):
|
||||
self.plot_averaged_profile_tail()
|
||||
self.plot_transect_with_SNR_data()
|
||||
|
|
@ -678,21 +632,19 @@ class SignalProcessingTab(QWidget):
|
|||
self.plot_pre_processed_profile()
|
||||
|
||||
def activate_list_of_pre_processed_data(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
|
||||
for i in range(self.combobox_acoustic_data_choice.count()):
|
||||
self.lineEdit_list_pre_processed_data[i].setDisabled(True)
|
||||
eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
|
||||
eval("self.lineEdit_list_pre_processed_data_" + str(
|
||||
self.combobox_acoustic_data_choice.currentIndex()) + ".setEnabled(True)")
|
||||
eval("self.lineEdit_list_pre_processed_data_" + str(
|
||||
self.combobox_acoustic_data_choice.currentIndex()) + ".returnPressed.connect(self.rename_preprocessed_data)")
|
||||
|
||||
self.lineEdit_list_pre_processed_data[data_id].setEnabled(True)
|
||||
self.lineEdit_list_pre_processed_data[data_id]\
|
||||
.returnPressed.connect(self.rename_preprocessed_data)
|
||||
|
||||
self.lineEdit_list_pre_processed_data[data_id]\
|
||||
.setText(stg.filename_BS_raw_data[data_id])
|
||||
eval("self.lineEdit_list_pre_processed_data_" + str(self.combobox_acoustic_data_choice.currentIndex()) +
|
||||
".setText(stg.filename_BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()])")
|
||||
|
||||
def rename_preprocessed_data(self):
|
||||
stg.data_preprocessed[data_id] = \
|
||||
self.lineEdit_list_pre_processed_data[data_id].text()
|
||||
exec("stg.data_preprocessed[self.combobox_acoustic_data_choice.currentIndex()] = "
|
||||
"self.lineEdit_list_pre_processed_data_" + str(self.combobox_acoustic_data_choice.currentIndex()) + ".text()")
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
|
|
@ -704,29 +656,18 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
def groupbox_download_noise_file_size_change(self):
|
||||
duration = 500
|
||||
self.animation_groupbox_download_noise_file = QPropertyAnimation(
|
||||
self.groupbox_download_noise_file, b"size"
|
||||
)
|
||||
self.animation_groupbox_download_noise_file = QPropertyAnimation(self.groupbox_download_noise_file, b"size")
|
||||
self.animation_groupbox_download_noise_file.setDuration(duration)
|
||||
|
||||
self.animation_groupbox_download_noise_file.setStartValue(
|
||||
QSize(
|
||||
self.groupbox_download_noise_file.width(),
|
||||
self.groupbox_download_noise_file.height()
|
||||
)
|
||||
)
|
||||
self.animation_groupbox_download_noise_file.setStartValue(QSize(self.groupbox_download_noise_file.width(),
|
||||
self.groupbox_download_noise_file.height()))
|
||||
|
||||
if self.groupbox_download_noise_file.isChecked():
|
||||
self.animation_groupbox_download_noise_file.setEndValue(
|
||||
QSize(
|
||||
self.groupbox_download_noise_file.width(),
|
||||
self.groupbox_download_noise_file.sizeHint().height()
|
||||
)
|
||||
)
|
||||
QSize(self.groupbox_download_noise_file.width(),
|
||||
self.groupbox_download_noise_file.sizeHint().height()))
|
||||
else:
|
||||
self.animation_groupbox_download_noise_file.setEndValue(
|
||||
QSize(self.groupbox_download_noise_file.width(), 25)
|
||||
)
|
||||
self.animation_groupbox_download_noise_file.setEndValue(QSize(self.groupbox_download_noise_file.width(), 25))
|
||||
|
||||
self.animation_groupbox_download_noise_file.start()
|
||||
|
||||
|
|
@ -738,35 +679,24 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
def groupbox_option_profile_tail_size_change(self):
|
||||
duration = 500
|
||||
self.animation_groupbox_option_profile_tail = QPropertyAnimation(
|
||||
self.groupbox_option_profile_tail, b"size"
|
||||
)
|
||||
self.animation_groupbox_option_profile_tail = QPropertyAnimation(self.groupbox_option_profile_tail, b"size")
|
||||
self.animation_groupbox_option_profile_tail.setDuration(duration)
|
||||
|
||||
self.animation_groupbox_option_profile_tail.setStartValue(
|
||||
QSize(
|
||||
self.groupbox_option_profile_tail.width(),
|
||||
self.groupbox_option_profile_tail.height()
|
||||
)
|
||||
)
|
||||
self.animation_groupbox_option_profile_tail.setStartValue(QSize(self.groupbox_option_profile_tail.width(),
|
||||
self.groupbox_option_profile_tail.height()))
|
||||
|
||||
if self.groupbox_option_profile_tail.isChecked():
|
||||
self.animation_groupbox_option_profile_tail.setEndValue(
|
||||
QSize(
|
||||
self.groupbox_option_profile_tail.width(),
|
||||
self.groupbox_option_profile_tail.sizeHint().height()
|
||||
)
|
||||
)
|
||||
QSize(self.groupbox_option_profile_tail.width(),
|
||||
self.groupbox_option_profile_tail.sizeHint().height()))
|
||||
else:
|
||||
self.animation_groupbox_option_profile_tail.setEndValue(
|
||||
QSize(self.groupbox_option_profile_tail.width(), 25)
|
||||
)
|
||||
self.animation_groupbox_option_profile_tail.setEndValue(QSize(self.groupbox_option_profile_tail.width(), 25))
|
||||
|
||||
self.animation_groupbox_option_profile_tail.start()
|
||||
|
||||
# ------------------------------------------------------
|
||||
def compute_average_profile_tail(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
freq_noise_id = self.combobox_freq_noise_from_profile_tail.currentIndex()
|
||||
|
||||
if ((float(self.lineEdit_val1.text()) == 0)
|
||||
|
|
@ -853,96 +783,79 @@ class SignalProcessingTab(QWidget):
|
|||
msgBox.exec()
|
||||
|
||||
else:
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
freq_noise_id = self.combobox_freq_noise_from_profile_tail.currentIndex()
|
||||
|
||||
if stg.BS_mean[data_id].shape == (0,):
|
||||
return
|
||||
if stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
|
||||
self.verticalLayout_groupbox_plot_profile_tail.removeWidget(self.canvas_profile_tail)
|
||||
|
||||
if self.fig_profile_tail is not None:
|
||||
self.fig_profile_tail.clear()
|
||||
|
||||
self.fig_profile_tail, self.axis_profile_tail = \
|
||||
plt.subplots(nrows=1, ncols=1, layout='constrained')
|
||||
self.fig_profile_tail, self.axis_profile_tail = plt.subplots(nrows=1, ncols=1, layout='constrained')
|
||||
self.canvas_profile_tail = FigureCanvas(self.fig_profile_tail)
|
||||
|
||||
self.verticalLayout_groupbox_plot_profile_tail.addWidget(self.canvas_profile_tail)
|
||||
|
||||
self.axis_profile_tail.plot(
|
||||
-stg.depth[data_id][freq_noise_id],
|
||||
stg.BS_mean[data_id][freq_noise_id],
|
||||
color="blue", linewidth=1
|
||||
)
|
||||
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
|
||||
stg.BS_mean[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq_noise_from_profile_tail.currentIndex()],
|
||||
color="blue", linewidth=1)
|
||||
self.axis_profile_tail.plot(
|
||||
-stg.depth[data_id][freq_noise_id],
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))
|
||||
* np.ones(stg.depth[data_id][freq_noise_id].shape[0]),
|
||||
linestyle='dashed', linewidth=2, color='red'
|
||||
)
|
||||
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
|
||||
self.combobox_freq_noise_from_profile_tail.currentIndex()],
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", ".")) *
|
||||
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
|
||||
self.combobox_freq_noise_from_profile_tail.currentIndex()].shape[0]),
|
||||
linestyle='dashed', linewidth=2, color='red')
|
||||
|
||||
self.axis_profile_tail.set_yscale('log')
|
||||
self.axis_profile_tail.tick_params(axis='both', labelsize=8)
|
||||
self.axis_profile_tail.text(
|
||||
.98, .03, "Depth (m)",
|
||||
fontsize=8, fontweight='bold',
|
||||
fontname="DejaVu Sans", c="black", alpha=0.9,
|
||||
horizontalalignment='right',
|
||||
verticalalignment='bottom', rotation='horizontal',
|
||||
transform=self.axis_profile_tail.transAxes
|
||||
)
|
||||
self.axis_profile_tail.text(
|
||||
.1, .45, "BS signal (v)",
|
||||
fontsize=8, fontweight='bold',
|
||||
fontname="DejaVu Sans", c="black", alpha=0.9,
|
||||
horizontalalignment='right',
|
||||
verticalalignment='bottom', rotation='vertical',
|
||||
transform=self.axis_profile_tail.transAxes
|
||||
)
|
||||
self.axis_profile_tail.text(
|
||||
.98, .85,
|
||||
stg.freq_text[data_id][freq_noise_id],
|
||||
fontsize=10, fontweight='bold',
|
||||
fontname="DejaVu Sans", c="black", alpha=0.5,
|
||||
self.axis_profile_tail.text(.98, .03, "Depth (m)",
|
||||
fontsize=8, fontweight='bold', fontname="DejaVu Sans", c="black", alpha=0.9,
|
||||
horizontalalignment='right', verticalalignment='bottom', rotation='horizontal',
|
||||
transform=self.axis_profile_tail.transAxes)
|
||||
self.axis_profile_tail.text(.1, .45, "BS signal (v)",
|
||||
fontsize=8, fontweight='bold', fontname="DejaVu Sans", c="black", alpha=0.9,
|
||||
horizontalalignment='right', verticalalignment='bottom', rotation='vertical',
|
||||
transform=self.axis_profile_tail.transAxes)
|
||||
self.axis_profile_tail.text(.98, .85,
|
||||
stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
|
||||
self.combobox_freq_noise_from_profile_tail.currentIndex()],
|
||||
fontsize=10, fontweight='bold', fontname="DejaVu Sans", c="black", alpha=0.5,
|
||||
horizontalalignment='right', verticalalignment='bottom',
|
||||
transform=self.axis_profile_tail.transAxes
|
||||
)
|
||||
transform=self.axis_profile_tail.transAxes)
|
||||
|
||||
self.fig_profile_tail.canvas.draw_idle()
|
||||
|
||||
# ------------------------------------------------------
|
||||
|
||||
def combobox_acoustic_data_choice_change_index(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
|
||||
self.combobox_frequency_profile.blockSignals(True)
|
||||
|
||||
self.compute_average_profile_tail()
|
||||
|
||||
logger.debug(f"stg.SNR_filter_value: {stg.SNR_filter_value}")
|
||||
|
||||
self.lineEdit_SNR_criterion.setText(
|
||||
str(stg.SNR_filter_value[data_id])
|
||||
str(stg.SNR_filter_value[
|
||||
self.combobox_acoustic_data_choice.currentIndex()
|
||||
])
|
||||
)
|
||||
|
||||
self.lineEdit_horizontal_average.setText(
|
||||
str(stg.Nb_cells_to_average_BS_signal[data_id])
|
||||
str(stg.Nb_cells_to_average_BS_signal[
|
||||
self.combobox_acoustic_data_choice.currentIndex()
|
||||
])
|
||||
)
|
||||
|
||||
self.combobox_frequency_profile.clear()
|
||||
self.combobox_frequency_profile.addItems(
|
||||
[f for f in stg.freq_text[data_id]]
|
||||
)
|
||||
[f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]])
|
||||
|
||||
self.recompute()
|
||||
self.replot()
|
||||
|
||||
if self.combobox_acoustic_data_choice.count() > 0:
|
||||
for i in range(self.combobox_acoustic_data_choice.count()):
|
||||
self.lineEdit_list_pre_processed_data[i].setDisabled(True)
|
||||
|
||||
self.lineEdit_list_pre_processed_data[data_id].setEnabled(True)
|
||||
for i in range(self.combobox_acoustic_data_choice.count()):
|
||||
eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
|
||||
#
|
||||
eval("self.lineEdit_list_pre_processed_data_" + str(
|
||||
self.combobox_acoustic_data_choice.currentIndex()) + ".setEnabled(True)")
|
||||
|
||||
self.combobox_frequency_profile.blockSignals(False)
|
||||
|
||||
|
|
@ -950,7 +863,7 @@ class SignalProcessingTab(QWidget):
|
|||
if len(stg.filename_BS_raw_data) == 0:
|
||||
pass
|
||||
else:
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
stg.BS_noise_raw_data[data_id] = np.array([])
|
||||
stg.BS_noise_averaged_data[data_id] = np.array([])
|
||||
|
|
@ -968,7 +881,7 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
stg.BS_stream_bed_pre_process_SNR[data_id] = np.array([])
|
||||
stg.BS_stream_bed_pre_process_average[data_id] = np.array([])
|
||||
|
||||
print("stg.noise_method[data_id]", stg.noise_method[data_id])
|
||||
if stg.noise_method[data_id] == 0:
|
||||
self.lineEdit_noise_file.clear()
|
||||
|
||||
|
|
@ -1089,65 +1002,67 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
|
||||
def load_noise_data_and_compute_SNR(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
stg.noise_method[data_id] = 0
|
||||
|
||||
noise_data = AcousticDataLoader(
|
||||
os.path.join(
|
||||
stg.path_BS_noise_data[data_id],
|
||||
stg.filename_BS_noise_data[data_id]
|
||||
)
|
||||
)
|
||||
noise_data = AcousticDataLoader(stg.path_BS_noise_data[data_id] +
|
||||
"/" +
|
||||
stg.filename_BS_noise_data[data_id])
|
||||
stg.BS_noise_raw_data[data_id] = noise_data._BS_raw_data
|
||||
|
||||
stg.time_noise[data_id] = noise_data._time
|
||||
stg.depth_noise[data_id] = noise_data._r
|
||||
|
||||
if stg.BS_stream_bed[data_id].shape != (0,):
|
||||
BS_data = stg.BS_stream_bed
|
||||
SNR_data = stg.SNR_stream_bed
|
||||
elif stg.BS_cross_section[data_id].shape != (0,):
|
||||
BS_data = stg.BS_cross_section
|
||||
SNR_data = stg.SNR_cross_section
|
||||
else:
|
||||
BS_data = stg.BS_raw_data
|
||||
SNR_data = stg.SNR_raw_data
|
||||
|
||||
noise = np.zeros(BS_data[data_id].shape)
|
||||
noise = np.zeros(stg.BS_stream_bed[data_id].shape)
|
||||
for f, _ in enumerate(noise_data._freq):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1)
|
||||
)
|
||||
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1))
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
SNR_data[data_id] = (
|
||||
np.divide(
|
||||
(
|
||||
BS_data[data_id] - stg.BS_noise_averaged_data[data_id]
|
||||
) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2
|
||||
)
|
||||
)
|
||||
stg.SNR_stream_bed[data_id] = (
|
||||
np.divide((stg.BS_stream_bed[data_id] -
|
||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
||||
|
||||
elif stg.BS_cross_section[data_id].shape != (0,):
|
||||
|
||||
noise = np.zeros(stg.BS_cross_section[data_id].shape)
|
||||
for f, _ in enumerate(noise_data._freq):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1))
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
stg.SNR_cross_section[data_id] = (
|
||||
np.divide((stg.BS_cross_section[data_id] -
|
||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
||||
# stg.SNR_reshape = np.reshape(stg.SNR_cross_section, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), order="F")
|
||||
|
||||
else:
|
||||
|
||||
noise = np.zeros(stg.BS_raw_data[data_id].shape)
|
||||
for f, _ in enumerate(noise_data._freq):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1))
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
stg.SNR_raw_data[data_id] = (
|
||||
np.divide((stg.BS_raw_data[data_id] -
|
||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
||||
|
||||
def open_plot_noise_window(self):
|
||||
pnw = PlotNoiseWindow()
|
||||
pnw.exec()
|
||||
|
||||
def compute_noise_from_profile_tail_value(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
stg.noise_method[data_id] = 1
|
||||
stg.noise_value[data_id] = (
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))
|
||||
)
|
||||
|
||||
self.compute_noise_from_profile_tail_value_compute()
|
||||
|
||||
@trace
|
||||
def compute_noise_from_profile_tail_value_compute(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
|
||||
if stg.time_cross_section[data_id].shape != (0,):
|
||||
stg.time_noise[data_id] = (
|
||||
stg.time_cross_section[data_id]
|
||||
|
|
@ -1167,38 +1082,48 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
# --- Compute noise from value and compute SNR ---
|
||||
if self._is_correct_shape(stg.BS_stream_bed):
|
||||
BS_data = stg.BS_stream_bed
|
||||
SNR_data = stg.SNR_stream_bed
|
||||
elif self._is_correct_shape(stg.BS_cross_section):
|
||||
BS_data = stg.BS_cross_section
|
||||
SNR_data = stg.SNR_cross_section
|
||||
else:
|
||||
BS_data = stg.BS_raw_data
|
||||
SNR_data = stg.SNR_raw_data
|
||||
|
||||
stg.BS_noise_raw_data[data_id] = np.array([])
|
||||
stg.BS_noise_raw_data[data_id] = (
|
||||
np.full(
|
||||
BS_data[data_id].shape,
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))
|
||||
)
|
||||
)
|
||||
np.full(stg.BS_stream_bed[data_id].shape,
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = (
|
||||
stg.BS_noise_raw_data[data_id]
|
||||
)
|
||||
SNR_data[data_id] = (
|
||||
np.divide(
|
||||
(
|
||||
BS_data[data_id] - stg.BS_noise_raw_data[data_id]
|
||||
) ** 2,
|
||||
stg.BS_noise_raw_data[data_id] ** 2
|
||||
)
|
||||
)
|
||||
stg.BS_noise_raw_data[data_id][:, :,
|
||||
:stg.BS_stream_bed[data_id].shape[2]])
|
||||
stg.SNR_stream_bed[data_id] = (
|
||||
np.divide((stg.BS_stream_bed[data_id]
|
||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
||||
stg.BS_noise_raw_data[data_id] ** 2))
|
||||
|
||||
elif self._is_correct_shape(stg.BS_cross_section):
|
||||
stg.BS_noise_raw_data[data_id] = (
|
||||
np.full(stg.BS_cross_section[data_id].shape,
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = (
|
||||
stg.BS_noise_raw_data[data_id][:, :,
|
||||
:stg.BS_cross_section[data_id].shape[2]])
|
||||
stg.SNR_cross_section[data_id] = (
|
||||
np.divide((stg.BS_cross_section[data_id]
|
||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
||||
stg.BS_noise_raw_data[data_id] ** 2)) #
|
||||
|
||||
else:
|
||||
|
||||
stg.BS_noise_raw_data[data_id] = (
|
||||
np.full(stg.BS_raw_data[data_id].shape,
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = (
|
||||
stg.BS_noise_raw_data[data_id])
|
||||
stg.SNR_raw_data[data_id] = (
|
||||
np.divide((stg.BS_raw_data[data_id]
|
||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
||||
stg.BS_noise_raw_data[data_id] ** 2))
|
||||
|
||||
self.combobox_frequency_profile.clear()
|
||||
self.combobox_frequency_profile.addItems(
|
||||
[f for f in stg.freq_text[data_id]]
|
||||
)
|
||||
[f for f in stg.freq_text[data_id]])
|
||||
|
||||
# --- Trigger graphic widgets ---
|
||||
|
||||
|
|
@ -1217,12 +1142,7 @@ class SignalProcessingTab(QWidget):
|
|||
def plot_noise(self):
|
||||
self.horizontalLayout_groupbox_plot_noise_data.removeWidget(self.canvas_noise)
|
||||
|
||||
if self.fig_noise is not None:
|
||||
self.fig_noise.clear()
|
||||
|
||||
self.fig_noise, self.axis_noise = plt.subplots(
|
||||
nrows=1, ncols=1, layout="constrained"
|
||||
)
|
||||
self.fig_noise, self.axis_noise = plt.subplots(nrows=1, ncols=1, layout="constrained")
|
||||
self.canvas_noise = FigureCanvas(self.fig_noise)
|
||||
|
||||
self.horizontalLayout_groupbox_plot_noise_data.addWidget(self.canvas_noise)
|
||||
|
|
@ -1263,16 +1183,13 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
# elif self.canvas_SNR == None:
|
||||
else:
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
if ((data_id != -1)
|
||||
and (stg.BS_noise_raw_data[data_id].shape != (0,))):
|
||||
self.verticalLayout_groupbox_plot_SNR.removeWidget(self.toolbar_SNR)
|
||||
self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR)
|
||||
|
||||
if self.fig_SNR is not None:
|
||||
self.fig_SNR.clear()
|
||||
|
||||
self.fig_SNR, self.axis_SNR = plt.subplots(
|
||||
nrows=stg.freq[data_id].shape[0], ncols=1,
|
||||
sharex=True, sharey=False, layout='constrained'
|
||||
|
|
@ -1392,7 +1309,7 @@ class SignalProcessingTab(QWidget):
|
|||
msgBox.exec()
|
||||
|
||||
else:
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
stg.SNR_filter_value[data_id] = (
|
||||
float(self.lineEdit_SNR_criterion.text().replace(",", ".")))
|
||||
|
|
@ -1439,7 +1356,7 @@ class SignalProcessingTab(QWidget):
|
|||
self.compute_averaged_BS_data()
|
||||
|
||||
def plot_pre_processed_BS_signal(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
self.lineEdit_horizontal_average.setText(
|
||||
str(stg.Nb_cells_to_average_BS_signal[data_id])
|
||||
|
|
@ -1453,9 +1370,6 @@ class SignalProcessingTab(QWidget):
|
|||
self.verticalLayout_groupbox_plot_pre_processed_data_2D_field\
|
||||
.removeWidget(self.scroll_BS)
|
||||
|
||||
if self.fig_BS is not None:
|
||||
self.fig_BS.clear()
|
||||
|
||||
self.fig_BS, self.axis_BS = plt.subplots(
|
||||
nrows=stg.freq[data_id].shape[0], ncols=1,
|
||||
sharex=True, sharey=False, layout="constrained"
|
||||
|
|
@ -1568,18 +1482,16 @@ class SignalProcessingTab(QWidget):
|
|||
.addWidget(self.scroll_BS)
|
||||
|
||||
def update_label_cells_sec(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
|
||||
print("Je change la valeur du moyennage")
|
||||
print(stg.nb_profiles_per_sec)
|
||||
print(stg.nb_profiles_per_sec[self.combobox_acoustic_data_choice.currentIndex()][0])
|
||||
print(self.combobox_acoustic_data_choice.currentIndex())
|
||||
self.label_cells_horizontal.clear()
|
||||
self.label_cells_horizontal.setText(
|
||||
"cells = +/- "
|
||||
+ str(
|
||||
(float(
|
||||
self.lineEdit_horizontal_average.text().replace(",", ".")
|
||||
) // 2)
|
||||
* (1 / stg.nb_profiles_per_sec[data_id][0])
|
||||
) + " sec"
|
||||
)
|
||||
"cells = +/- " +
|
||||
str((float(self.lineEdit_horizontal_average.text().replace(",", ".")) // 2) *
|
||||
(1 / stg.nb_profiles_per_sec[self.combobox_acoustic_data_choice.currentIndex()][0])) +
|
||||
" sec")
|
||||
|
||||
def compute_averaged_BS_data(self):
|
||||
if len(stg.filename_BS_raw_data) == 0:
|
||||
|
|
@ -1597,7 +1509,7 @@ class SignalProcessingTab(QWidget):
|
|||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
else:
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
n_average = 2 * int(float(self.lineEdit_horizontal_average.text().replace(",", "."))) + 1
|
||||
kernel_avg = np.ones(n_average)
|
||||
logger.debug(f"kernel_avg: {kernel_avg}")
|
||||
|
|
@ -1681,7 +1593,7 @@ class SignalProcessingTab(QWidget):
|
|||
)
|
||||
|
||||
def plot_pre_processed_profile(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
if ((data_id != -1) and
|
||||
(stg.BS_noise_raw_data[data_id].shape != (0,))):
|
||||
|
|
@ -1689,12 +1601,7 @@ class SignalProcessingTab(QWidget):
|
|||
self.verticalLayout_groupbox_plot_profile.removeWidget(self.toolbar_profile)
|
||||
self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_profile)
|
||||
|
||||
if self.figure_profile is not None:
|
||||
self.figure_profile.clear()
|
||||
|
||||
self.figure_profile, self.axis_profile = plt.subplots(
|
||||
nrows=1, ncols=1, layout="constrained"
|
||||
)
|
||||
self.figure_profile, self.axis_profile = plt.subplots(nrows=1, ncols=1, layout="constrained")
|
||||
self.canvas_profile = FigureCanvas(self.figure_profile)
|
||||
self.toolbar_profile = NavigationToolBar(self.canvas_profile, self)
|
||||
|
||||
|
|
@ -1913,7 +1820,7 @@ class SignalProcessingTab(QWidget):
|
|||
self.slider.setMaximum(10)
|
||||
|
||||
def update_plot_pre_processed_profile(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
if ((data_id != -1) and
|
||||
(stg.BS_noise_raw_data[data_id].shape != (0,))):
|
||||
|
|
|
|||
17
main.py
17
main.py
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
import sys
|
||||
import logging
|
||||
import traceback
|
||||
|
|
@ -34,12 +33,8 @@ logging.basicConfig(
|
|||
)
|
||||
|
||||
logger = logging.getLogger("acoused")
|
||||
|
||||
if os.getenv("ACOUSED_DEBUG") == "true":
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.debug("Set acoused at debug mode!")
|
||||
else:
|
||||
logger.setLevel(logging.INFO)
|
||||
#logger.setLevel(logging.INFO)
|
||||
|
||||
class MainApplication(QMainWindow):
|
||||
|
||||
|
|
@ -125,6 +120,16 @@ class MainApplication(QMainWindow):
|
|||
for tab in self.tabs:
|
||||
tab.full_update()
|
||||
|
||||
# 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.signal_processing_tab.combobox_acoustic_data_choice.addItems(stg.filename_BS_raw_data)
|
||||
|
||||
# self.sample_data_tab.fill_comboboxes_and_plot_transect()
|
||||
# self.sample_data_tab.lineEdit_fine_sediment.setText(stg.filename_fine)
|
||||
# self.sample_data_tab.lineEdit_fine_sediment.setToolTip(stg.path_fine)
|
||||
# self.sample_data_tab.fill_table_fine()
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print("sys.argv:", [arg for arg in sys.argv])
|
||||
# app = MainApplication(sys.argv)
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ user-defined extensions).")
|
|||
(home-page "https://github.com/python/typeshed")
|
||||
(synopsis "Typing stubs for psutil")
|
||||
(description "Typing stubs for psutil.")
|
||||
(license asl2.0)))
|
||||
(license #f)))
|
||||
|
||||
|
||||
(define-public python-qtrangeslider
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
@ECHO OFF
|
||||
|
||||
set ACOUSED_DEBUG=true
|
||||
|
||||
acoused.exe > error.txt 2>&1
|
||||
|
|
|
|||
20
settings.py
20
settings.py
|
|
@ -105,11 +105,11 @@ BS_stream_bed = [] # BS data (raw or cross_section) with detected b
|
|||
depth_bottom = [] # Depth value of th bottom : 1D array # List of arrays
|
||||
val_bottom = [] # Level of the BS signal on the bottom : 1D array # List of arrays
|
||||
ind_bottom = [] # Index of bottom in depth array : list of int # List of lists
|
||||
|
||||
freq_bottom_detection = [] # Frequency use to detect the bottom : (index, string) # List of tuple
|
||||
depth_bottom_detection_min = [] # Min value to detect bottom on the first vertical # List of float
|
||||
depth_bottom_detection_max = [] # Max value to detect bottom on the first vertical # List of float
|
||||
depth_bottom_detection_interval = [] # interval for searching area # List of float
|
||||
|
||||
# depth_bottom_detection_min = [] # Min value to detect bottom on the first vertical # List of float
|
||||
# depth_bottom_detection_max = [] # Max value to detect bottom on the first vertical # List of float
|
||||
# depth_bottom_detection_1st_int_area = [] # interval for searching area # List of float
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
# =========================================================
|
||||
|
|
@ -215,12 +215,6 @@ 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
|
||||
|
||||
|
|
@ -266,8 +260,6 @@ sand_sample_position = [] # Sand samples indexes position for time and dep
|
|||
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
|
||||
|
||||
# =========================================================
|
||||
# --- ACOUSTIC NOTES TAB ---
|
||||
# =========================================================
|
||||
|
||||
notes = ""
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue