Sediment calibration tab is cleaned from useless commented lines and useless print
parent
d3234bff5d
commit
40d14a2ffb
|
|
@ -1,13 +1,33 @@
|
|||
import sys
|
||||
# ============================================================================== #
|
||||
# acoustic_data_tab.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 matplotlib.pyplot as plt
|
||||
import pandas as pd
|
||||
from PyQt5.QtWidgets import (QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox,
|
||||
QGridLayout, QLabel, QPushButton, QSpinBox, QDoubleSpinBox, QAbstractSpinBox, QSpacerItem,
|
||||
QSizePolicy, QSlider, QLineEdit, QDial, QFileDialog, QMessageBox, QFrame)
|
||||
from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox,
|
||||
QGridLayout, QLabel, QPushButton, QSlider, QLineEdit, QFileDialog, QMessageBox, QFrame)
|
||||
|
||||
from PyQt5.QtCore import QCoreApplication, Qt, QPropertyAnimation, QSize
|
||||
from PyQt5.QtGui import QStandardItemModel, QIcon, QPixmap, QFont
|
||||
from PyQt5.QtCore import Qt, QPropertyAnimation, QSize
|
||||
from PyQt5.QtGui import QIcon, QPixmap, QFont
|
||||
|
||||
import settings as stg
|
||||
|
||||
|
|
@ -24,14 +44,6 @@ from os import path
|
|||
from View.checkable_combobox import CheckableComboBox
|
||||
|
||||
from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration
|
||||
from settings import J_cross_section, alpha_s
|
||||
|
||||
|
||||
# from settings import depth_cross_section, BS_raw_data_pre_process_average, BS_raw_data_pre_process_SNR, BS_raw_data, \
|
||||
# path_calibration_file
|
||||
|
||||
|
||||
# from virtual_env.bin.odfimg import directory
|
||||
|
||||
|
||||
class SedimentCalibrationTab(QWidget):
|
||||
|
|
@ -323,9 +335,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.label_ks.setText("ks")
|
||||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_ks, 4, 0, 1, 1, Qt.AlignCenter)
|
||||
|
||||
# self.spinbox_ks_freq1 = QDoubleSpinBox()
|
||||
# self.spinbox_ks_freq1.setDecimals(8)
|
||||
# self.spinbox_ks_freq1.setSuffix(" m/kg^0.5")
|
||||
self.lineEdit_ks_freq1 = QLineEdit()
|
||||
self.lineEdit_ks_freq1.setMaximumWidth(100)
|
||||
self.lineEdit_ks_freq1.setText("0.00")
|
||||
|
|
@ -336,9 +345,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_ks_freq1_unit, 4, 2, 1, 1,
|
||||
Qt.AlignLeft)
|
||||
|
||||
# self.spinbox_ks_freq2 = QDoubleSpinBox()
|
||||
# self.spinbox_ks_freq2.setDecimals(8)
|
||||
# self.spinbox_ks_freq2.setSuffix(" m/kg^0.5")
|
||||
self.lineEdit_ks_freq2 = QLineEdit()
|
||||
self.lineEdit_ks_freq2.setMaximumWidth(100)
|
||||
self.lineEdit_ks_freq2.setText("0.00")
|
||||
|
|
@ -353,9 +359,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.label_sv.setText("sv")
|
||||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_sv, 5, 0, 1, 1, Qt.AlignCenter)
|
||||
|
||||
# self.spinbox_sv_freq1 = QDoubleSpinBox()
|
||||
# self.spinbox_sv_freq1.setDecimals(8)
|
||||
# self.spinbox_sv_freq1.setSuffix(" /m")
|
||||
self.lineEdit_sv_freq1 = QLineEdit()
|
||||
self.lineEdit_sv_freq1.setMaximumWidth(100)
|
||||
self.lineEdit_sv_freq1.setText("0.00")
|
||||
|
|
@ -365,9 +368,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.label_sv_freq1_unit.setText("m<sup>-1</sup>")
|
||||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_sv_freq1_unit, 5, 2, 1, 1)
|
||||
|
||||
# self.spinbox_sv_freq2 = QDoubleSpinBox()
|
||||
# self.spinbox_sv_freq2.setDecimals(8)
|
||||
# self.spinbox_sv_freq2.setSuffix(" /m")
|
||||
self.lineEdit_sv_freq2 = QLineEdit()
|
||||
self.lineEdit_sv_freq2.setMaximumWidth(100)
|
||||
self.lineEdit_sv_freq2.setText("0.00")
|
||||
|
|
@ -381,8 +381,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.label_X.setText("X")
|
||||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_X, 6, 0, 1, 1, Qt.AlignCenter)
|
||||
|
||||
# self.spinbox_X = QDoubleSpinBox()
|
||||
# self.spinbox_X.setDecimals(2)
|
||||
self.lineEdit_X = QLineEdit()
|
||||
self.lineEdit_X.setMaximumWidth(100)
|
||||
self.lineEdit_X.setText("0.00")
|
||||
|
|
@ -392,9 +390,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.label_alphas.setText("\u03B1s")
|
||||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_alphas, 7, 0, 1, 1, Qt.AlignCenter)
|
||||
|
||||
# self.spinbox_alphas_freq1 = QDoubleSpinBox()
|
||||
# self.spinbox_alphas_freq1.setDecimals(4)
|
||||
# self.spinbox_alphas_freq1.setSuffix(" /m")
|
||||
self.lineEdit_alphas_freq1 = QLineEdit()
|
||||
self.lineEdit_alphas_freq1.setMaximumWidth(100)
|
||||
self.lineEdit_alphas_freq1.setText("0.00")
|
||||
|
|
@ -404,9 +399,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.label_alphas_freq1_unit.setText("m<sup>-1</sup>")
|
||||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_alphas_freq1_unit, 7, 2, 1, 1, Qt.AlignLeft)
|
||||
|
||||
# self.spinbox_alphas_freq2 = QDoubleSpinBox()
|
||||
# self.spinbox_alphas_freq2.setDecimals(4)
|
||||
# self.spinbox_alphas_freq2.setSuffix(" /m")
|
||||
self.lineEdit_alphas_freq2 = QLineEdit()
|
||||
self.lineEdit_alphas_freq2.setMaximumWidth(100)
|
||||
self.lineEdit_alphas_freq2.setText("0.00")
|
||||
|
|
@ -420,9 +412,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.label_zeta.setText("\u03B6")
|
||||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_zeta, 8, 0, 1, 1, Qt.AlignCenter)
|
||||
|
||||
# self.spinbox_zeta_freq1 = QDoubleSpinBox()
|
||||
# self.spinbox_zeta_freq1.setDecimals(4)
|
||||
# self.spinbox_zeta_freq1.setSuffix(" /m")
|
||||
self.lineEdit_zeta_freq1 = QLineEdit()
|
||||
self.lineEdit_zeta_freq1.setMaximumWidth(100)
|
||||
self.lineEdit_zeta_freq1.setText("0.00")
|
||||
|
|
@ -433,9 +422,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.label_zeta_freq1_unit, 8, 2, 1, 1,
|
||||
Qt.AlignLeft)
|
||||
|
||||
# self.spinbox_zeta_freq2 = QDoubleSpinBox()
|
||||
# self.spinbox_zeta_freq2.setDecimals(4)
|
||||
# self.spinbox_zeta_freq2.setSuffix(" /m")
|
||||
self.lineEdit_zeta_freq2 = QLineEdit()
|
||||
self.lineEdit_zeta_freq2.setMaximumWidth(100)
|
||||
self.lineEdit_zeta_freq2.setText("0.00")
|
||||
|
|
@ -450,22 +436,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.pushbutton_save_calibration.setText("Save calibration")
|
||||
self.gridLayout_groupbox_sediment_calibration_parameter.addWidget(self.pushbutton_save_calibration,9, 5, 1, 1)
|
||||
|
||||
# self.groupbox_calibration_compute_size_change()
|
||||
|
||||
# self.animaiton_groupbox_compute = QPropertyAnimation(self.groupbox_sediment_calibration_compute, b"size")
|
||||
# self.animaiton_groupbox_compute.setStartValue(QSize(self.groupbox_sediment_calibration_compute.width(), 25))
|
||||
#
|
||||
# self.animaiton_groupbox_compute.start()
|
||||
|
||||
# setStartValue(QSize(self.groupbox_sediment_calibration_compute.width(),
|
||||
# self.groupbox_sediment_calibration_compute.height()))
|
||||
#
|
||||
# self.animaiton_groupbox_compute.setEndValue(
|
||||
# QSize(self.groupbox_sediment_calibration_compute.width(),
|
||||
# self.groupbox_sediment_calibration_compute.sizeHint().height()))
|
||||
# else:
|
||||
# self.animaiton_groupbox_compute.setEndValue(QSize(self.groupbox_sediment_calibration_compute.width(), 25))
|
||||
|
||||
# ++++++++++++++++++++
|
||||
# +++ Groupbox FCB +++
|
||||
|
||||
|
|
@ -814,7 +784,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
|
||||
print("totototototototoott")
|
||||
val_min = np.nanmin(
|
||||
stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(),
|
||||
:, :])
|
||||
|
|
@ -1066,8 +1035,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
|
||||
|
||||
# --- Plot samples ---
|
||||
print("stg.fine_sample_profile ", stg.fine_sample_profile)
|
||||
print("stg.sand_sample_target ", stg.sand_sample_target)
|
||||
|
||||
if (stg.fine_sample_profile) or (stg.sand_sample_target):
|
||||
|
||||
|
|
@ -1150,8 +1117,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.combobox_freq2.currentIndex(), :],
|
||||
color='red', linestyle="solid", linewidth=2))
|
||||
|
||||
# self.axis_BS.set_xticks([])
|
||||
# self.axis_BS.set_yticks([])
|
||||
self.axis_BS.set_xlabel("Time (sec)")
|
||||
self.axis_BS.set_ylabel("Depth (m)")
|
||||
self.fig_BS.canvas.draw_idle()
|
||||
|
|
@ -1159,13 +1124,11 @@ 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()]
|
||||
print(f"stg.fine_sample_profile : {stg.fine_sample_profile}")
|
||||
|
||||
# --- 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())]
|
||||
print(f"stg.sand_sample_target : {stg.sand_sample_target}")
|
||||
|
||||
# --- Find index in time (along acoustic recording) of sand sample target ---
|
||||
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
|
|
@ -1232,7 +1195,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
)
|
||||
|
||||
stg.sand_sample_target_indice = [(d1, t1), (d2, t2)]
|
||||
print("stg.sand_sample_target_indice ", stg.sand_sample_target_indice)
|
||||
|
||||
def summary_samples_choices(self):
|
||||
|
||||
|
|
@ -1260,17 +1222,9 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
for p in range(len(fine_data)):
|
||||
for q in range(len(fine_data[0])):
|
||||
# exec("fine_label[" + str(p) + "]_" + "stg.fine_sample_profile[" + str(p) + "][0]" + " = QLabel()")
|
||||
# eval("fine_label[" + str(p) + "]_" + "stg.fine_sample_profile[" + str(p) + "][0]" + ".setText(" + "fine_data[" + str(p) + "][" + str(q) + "])")
|
||||
# eval("self.gridLayout_groupbox_interpolate_info.addWidget(" + "fine_label[" + str(p) + "]_" + "stg.fine_sample_profile[" + str(p) + "], " + str(1+p) + ", " + str(q) + ", 1, 1)")
|
||||
print(f"self.gridLayout_groupbox_interpolate_info.addWidget(QLabel(fine_data[{p}][{q}]), {2 + p}, {q}, 1, 1, Qt.AlignCenter)")
|
||||
eval(f"self.gridLayout_groupbox_interpolate_info.addWidget(QLabel(fine_data[{p}][{q}]), {2 + p}, {q}, 1, 1, Qt.AlignCenter)")
|
||||
|
||||
# self.double_horizontal_line = QFrame()
|
||||
# self.double_horizontal_line.setFrameShape(QFrame.HLine)
|
||||
# self.double_horizontal_line.setFrameShadow(QFrame.Sunken)
|
||||
# self.double_horizontal_line.setLineWidth(1)
|
||||
# self.double_horizontal_line.setMidLineWidth(3)
|
||||
self.gridLayout_groupbox_interpolate_info.addWidget(self.double_horizontal_line, 2 + len(fine_data), 0, 1, 4, Qt.AlignCenter)
|
||||
|
||||
sand_head = ["Sample", "Depth (m)", "time", "Csand (g/L)"]
|
||||
|
|
@ -1363,8 +1317,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
)
|
||||
)
|
||||
|
||||
# print(f"range_lin_interp : {range_lin_interp}")
|
||||
# print(f"M_profile_fine : {M_profile_fine}")
|
||||
else:
|
||||
|
||||
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
|
|
@ -1405,118 +1357,12 @@ class SedimentCalibrationTab(QWidget):
|
|||
]
|
||||
))
|
||||
|
||||
print(f"1 M_profile_fine : {stg.M_profile_fine}")
|
||||
stg.range_lin_interp = stg.range_lin_interp
|
||||
stg.M_profile_fine = stg.M_profile_fine
|
||||
stg.M_profile_fine = stg.M_profile_fine[:stg.range_lin_interp.shape[0]]
|
||||
print(f"2 M_profile_fine : {stg.M_profile_fine}")
|
||||
|
||||
self.plot_profile_of_concentration_fine()
|
||||
|
||||
# def range_cells_function(self):
|
||||
# """ Computing the real cell size, that depends on the temperature """
|
||||
#
|
||||
# # defaut Aquascat cell size
|
||||
# aquascat_cell_size = stg.r[0, 1] - stg.r[0, 0]
|
||||
# # Pulse duration
|
||||
# tau = aquascat_cell_size * 2 / 1500 # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat
|
||||
# # Sound speed
|
||||
# cel = self.inv_hc.water_velocity(self.spinbox_temperature_water_attenuation.value())
|
||||
# # Real cell size
|
||||
# real_cell_size = cel * tau / 2 # voir fig 2.9
|
||||
#
|
||||
# # Converting to real cell profile
|
||||
# real_r = stg.r / aquascat_cell_size * real_cell_size # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1
|
||||
# # (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules
|
||||
#
|
||||
# # R with right shape (numpy array)
|
||||
# R_real = real_r # np.repeat(real_r, len(stg.freq), axis=1)
|
||||
#
|
||||
# return R_real
|
||||
|
||||
|
||||
# def compute_FCB(self):
|
||||
#
|
||||
# print(f"self.range_cells_function() : {self.range_cells_function()}")
|
||||
# print(f"self.range_cells_function() shape : {self.range_cells_function().shape}")
|
||||
# R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[1], axis=2)
|
||||
# print(f"R_real shape : {R_real.shape}")
|
||||
# if (stg.BS_stream_bed_pre_process_average.size == 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0):
|
||||
# stg.FCB = (np.log(stg.BS_stream_bed) + np.log(R_real) +
|
||||
# 2 * stg.water_attenuation * R_real)
|
||||
# elif stg.BS_stream_bed_pre_process_SNR.size == 0:
|
||||
# stg.FCB = (np.log(stg.BS_stream_bed_pre_process_average) + np.log(R_real) +
|
||||
# 2 * stg.water_attenuation * R_real)
|
||||
# else:
|
||||
# stg.FCB = (np.log(stg.BS_stream_bed_pre_process_SNR) + np.log(R_real) +
|
||||
# 2 * stg.water_attenuation * R_real)
|
||||
# self.plot_FCB()
|
||||
|
||||
# def fit_FCB_profile_with_linear_regression_and_compute_alphaS(self):
|
||||
#
|
||||
# if stg.FCB.size == 0:
|
||||
# msgBox = QMessageBox()
|
||||
# msgBox.setWindowTitle("Linear regression error")
|
||||
# msgBox.setIcon(QMessageBox.Warning)
|
||||
# msgBox.setText("Please compute FCB before")
|
||||
# msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
# msgBox.exec()
|
||||
# else:
|
||||
# try:
|
||||
# y0 = stg.FCB[self.combobox_frequency_compute_alphaS.currentIndex(), :, self.slider.value()]
|
||||
# y = y0[np.where(np.isnan(y0) == False)]
|
||||
#
|
||||
# x0 = stg.r[0, :].reshape(-1)
|
||||
# x = x0[np.where(np.isnan(y0) == False)]
|
||||
#
|
||||
# value1 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)
|
||||
# == np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)))
|
||||
# value2 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)
|
||||
# == np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)))
|
||||
#
|
||||
# # print(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2))
|
||||
# # # print("value1 ", value1[0][0])
|
||||
# # print(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2))
|
||||
# # print("value2 ", value2[0][0])
|
||||
#
|
||||
# # print("y limited ", y[value1[0][0]:value2[0][0]])
|
||||
#
|
||||
# lin_reg_compute = stats.linregress(x[value1[0][0]:value2[0][0]], y[value1[0][0]:value2[0][0]])
|
||||
# except ValueError:
|
||||
# msgBox = QMessageBox()
|
||||
# msgBox.setWindowTitle("Linear regression error")
|
||||
# msgBox.setIcon(QMessageBox.Warning)
|
||||
# msgBox.setText("Please check boundaries to fit a linear line")
|
||||
# msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
# msgBox.exec()
|
||||
# else:
|
||||
# stg.lin_reg = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
||||
# # print(f"y = {stg.lin_reg[0]}x + {stg.lin_reg[1]}")
|
||||
#
|
||||
# self.label_alphaS.clear()
|
||||
# self.label_alphaS.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m")
|
||||
#
|
||||
# # for i, value_freq in enumerate(stg.freq):
|
||||
# # for k, value_t in enumerate(stg.t):
|
||||
# # # print(f"indice i: {i}, indice k: {k}")
|
||||
# # # print(f"values of FCB: {stg.FCB[:, i, k]}")
|
||||
# # y = stg.FCB[:, i, k]
|
||||
# # # print("y : ", y)
|
||||
# # # print(f"values of FCB where FCB is not Nan {y[np.where(np.isnan(y) == False)]}")
|
||||
# # # print(f"values of r where FCB is not Nan {x[np.where(np.isnan(y) == False)]}")
|
||||
# # lin_reg_compute = stats.linregress(x[np.where(np.isnan(y) == False)], y[np.where(np.isnan(y) == False)])
|
||||
# # lin_reg_tuple = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
||||
# # stg.lin_reg.append(lin_reg_tuple)
|
||||
#
|
||||
# # print(f"y = {lin_reg.slope}x + {lin_reg.intercept}")
|
||||
#
|
||||
# # plt.figure()
|
||||
# # plt.plot(stg.r, stg.FCB[:, 0, 825], 'k-', stg.r, lin_reg.slope*stg.r + lin_reg.intercept, "b--")
|
||||
# # plt.show()
|
||||
#
|
||||
# # print("lin_reg length ", len(stg.lin_reg))
|
||||
# # print("lin_reg ", stg.lin_reg)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# --------------- Functions for sediment calibration ---------------
|
||||
# ------------------------------------------------------------------
|
||||
|
|
@ -1551,7 +1397,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.groupbox_sediment_calibration_import.setChecked(False)
|
||||
|
||||
def groupbox_calibration_compute_size_change(self):
|
||||
print("self.groupbox_sediment_calibration_compute.isChecked() ", self.groupbox_sediment_calibration_compute.isChecked())
|
||||
|
||||
duration = 500
|
||||
self.animaiton_groupbox_compute = QPropertyAnimation(self.groupbox_sediment_calibration_compute, b"size")
|
||||
|
|
@ -1561,12 +1406,10 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.groupbox_sediment_calibration_compute.height()))
|
||||
|
||||
if self.groupbox_sediment_calibration_compute.isChecked():
|
||||
print("Checked")
|
||||
self.animaiton_groupbox_compute.setEndValue(
|
||||
QSize(self.groupbox_sediment_calibration_compute.width(),
|
||||
self.groupbox_sediment_calibration_compute.sizeHint().height()))
|
||||
else:
|
||||
print("Non Checked")
|
||||
self.animaiton_groupbox_compute.setEndValue(QSize(self.groupbox_sediment_calibration_compute.width(), 25))
|
||||
|
||||
self.animaiton_groupbox_compute.start()
|
||||
|
|
@ -1631,9 +1474,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
# --- Read calibration file ---
|
||||
data = pd.read_csv(stg.path_calibration_file + "/" + stg.filename_calibration_file, header=0, index_col=0)
|
||||
print(data.head())
|
||||
print(data.iloc[0][0])
|
||||
print(type(data.iloc[0][0]))
|
||||
|
||||
# --- Fill spinboxes of calibration parameter ---
|
||||
self.label_temperature.clear()
|
||||
|
|
@ -1641,10 +1481,7 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
self.label_freq1.clear()
|
||||
self.label_freq1.setText(data.columns[0])
|
||||
print(stg.freq_text)
|
||||
print(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()])
|
||||
print(data.columns[0])
|
||||
print("index freq1 ", np.where(np.asarray(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]) == data.columns[0]))
|
||||
|
||||
index_freq1 = np.where(np.asarray(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]) ==
|
||||
data.columns[0])[0][0]
|
||||
stg.frequencies_for_calibration.clear()
|
||||
|
|
@ -1654,11 +1491,9 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
self.label_freq2.clear()
|
||||
self.label_freq2.setText(data.columns[1])
|
||||
print("index freq2 ",
|
||||
np.where(np.asarray(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]) == data.columns[1]))
|
||||
|
||||
index_freq2 = np.where(np.asarray(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]) ==
|
||||
data.columns[1])[0][0]
|
||||
# stg.frequencies_for_calibration.clear()
|
||||
stg.frequencies_for_calibration.append((stg.freq[self.combobox_acoustic_data_choice.currentIndex()][
|
||||
index_freq2],
|
||||
index_freq2))
|
||||
|
|
@ -1667,77 +1502,52 @@ class SedimentCalibrationTab(QWidget):
|
|||
stg.frequency_for_inversion = (stg.freq[self.combobox_acoustic_data_choice.currentIndex()][index_freq2],
|
||||
index_freq2)
|
||||
|
||||
# self.spinbox_ks_freq1.clear()
|
||||
# self.spinbox_ks_freq1.setValue()
|
||||
self.lineEdit_ks_freq1.clear()
|
||||
self.lineEdit_ks_freq1.setText(str("%.5f" % float(data.iloc[0][0])))
|
||||
|
||||
# self.spinbox_ks_freq2.clear()
|
||||
# self.spinbox_ks_freq2.setValue(float(data.iloc[0][1]))
|
||||
self.lineEdit_ks_freq2.clear()
|
||||
self.lineEdit_ks_freq2.setText(str("%.5f" % float(data.iloc[0][1])))
|
||||
|
||||
stg.ks.clear()
|
||||
# stg.ks = [self.spinbox_ks_freq1.value(), self.spinbox_ks_freq2.value()]
|
||||
stg.ks = [float(self.lineEdit_ks_freq1.text()), float(self.lineEdit_ks_freq2.text())]
|
||||
|
||||
# self.spinbox_sv_freq1.clear()
|
||||
# self.spinbox_sv_freq1.setValue(float(data.iloc[1][0]))
|
||||
self.lineEdit_sv_freq1.clear()
|
||||
self.lineEdit_sv_freq1.setText(str("%.5f" % float(data.iloc[1][0])))
|
||||
|
||||
# self.spinbox_sv_freq2.clear()
|
||||
# self.spinbox_sv_freq2.setValue(float(data.iloc[1][1]))
|
||||
self.lineEdit_sv_freq2.clear()
|
||||
self.lineEdit_sv_freq2.setText(str("%.5f" % float(data.iloc[1][1])))
|
||||
|
||||
stg.sv.clear()
|
||||
# stg.sv = [self.spinbox_sv_freq1.value(), self.spinbox_sv_freq2.value()]
|
||||
stg.sv = [float(self.lineEdit_sv_freq1.text()), float(self.lineEdit_sv_freq2.text())]
|
||||
|
||||
# self.spinbox_X.clear()
|
||||
# self.spinbox_X.setValue(float(data.iloc[2][0]))
|
||||
self.lineEdit_X.clear()
|
||||
self.lineEdit_X.setText(str("%.2f" % float(data.iloc[2][0])))
|
||||
|
||||
stg.X_exponent.clear()
|
||||
# stg.X_exponent.append(self.spinbox_X.value())
|
||||
stg.X_exponent.append(float(self.lineEdit_X.text()))
|
||||
|
||||
# self.spinbox_alphas_freq1.clear()
|
||||
# self.spinbox_alphas_freq1.setValue(float(data.iloc[3][0]))
|
||||
self.lineEdit_alphas_freq1.clear()
|
||||
self.lineEdit_alphas_freq1.setText(str("%.5f" % float(data.iloc[3][0])))
|
||||
|
||||
# self.spinbox_alphas_freq2.clear()
|
||||
# self.spinbox_alphas_freq2.setValue(float(data.iloc[3][1]))
|
||||
self.lineEdit_alphas_freq2.clear()
|
||||
self.lineEdit_alphas_freq2.setText(str("%.5f" % float(data.iloc[3][1])))
|
||||
|
||||
stg.alpha_s.clear()
|
||||
# stg.alpha_s = [self.spinbox_alphas_freq1.value(), self.spinbox_alphas_freq2.value()]
|
||||
stg.alpha_s = [float(self.lineEdit_alphas_freq1.text()), float(self.lineEdit_alphas_freq2.text())]
|
||||
|
||||
# self.spinbox_zeta_freq1.clear()
|
||||
# self.spinbox_zeta_freq1.setValue(float(data.iloc[4][0]))
|
||||
self.lineEdit_zeta_freq1.clear()
|
||||
self.lineEdit_zeta_freq1.setText(str("%.5f" % float(data.iloc[4][0])))
|
||||
|
||||
# self.spinbox_zeta_freq2.clear()
|
||||
# self.spinbox_zeta_freq2.setValue(float(data.iloc[4][1]))
|
||||
self.lineEdit_zeta_freq2.clear()
|
||||
self.lineEdit_zeta_freq2.setText(str("%.5f" % float(data.iloc[4][1])))
|
||||
|
||||
stg.zeta.clear()
|
||||
# stg.zeta = [self.spinbox_zeta_freq1.value(), self.spinbox_zeta_freq2.value()]
|
||||
stg.zeta = [float(self.lineEdit_zeta_freq1.text()), float(self.lineEdit_zeta_freq2.text())]
|
||||
|
||||
# self.compute_depth_2D()
|
||||
self.compute_kt2D_kt3D()
|
||||
self.compute_J_cross_section()
|
||||
|
||||
def compute_depth_2D(self):
|
||||
print("self.combobox_acoustic_data_choice.count() ", self.combobox_acoustic_data_choice.count())
|
||||
if self.combobox_acoustic_data_choice.count() > 0:
|
||||
|
||||
for k in range(self.combobox_acoustic_data_choice.count()):
|
||||
|
|
@ -1805,9 +1615,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
stg.time[k].shape[1],
|
||||
axis=1))
|
||||
|
||||
print("stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()].shape ",
|
||||
stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()].shape)
|
||||
|
||||
def function_pushbutton_compute_calibration(self):
|
||||
|
||||
self.label_temperature.clear()
|
||||
|
|
@ -1846,13 +1653,9 @@ class SedimentCalibrationTab(QWidget):
|
|||
print(f"ks for frequency of {stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex()]} : {ks_freq1} m/kg^0.5 \n")
|
||||
print(f"ks for frequency of {stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()]} : {ks_freq2} m/kg^0.5")
|
||||
|
||||
# self.spinbox_ks_freq1.clear()
|
||||
# self.spinbox_ks_freq1.setValue(ks_freq1)
|
||||
self.lineEdit_ks_freq1.clear()
|
||||
self.lineEdit_ks_freq1.setText(str("%.5f" % ks_freq1))
|
||||
|
||||
# self.spinbox_ks_freq2.clear()
|
||||
# self.spinbox_ks_freq2.setValue(ks_freq2)
|
||||
self.lineEdit_ks_freq2.clear()
|
||||
self.lineEdit_ks_freq2.setText(str("%.5f" % ks_freq2))
|
||||
|
||||
|
|
@ -1867,13 +1670,9 @@ class SedimentCalibrationTab(QWidget):
|
|||
print(f"sv for frequency of {stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq1.currentIndex()]} : {sv_freq1:.8f} /m \n")
|
||||
print(f"sv for frequency of {stg.freq[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex()]} : {sv_freq2:.8f} /m")
|
||||
|
||||
# self.spinbox_sv_freq1.clear()
|
||||
# self.spinbox_sv_freq1.setValue(sv_freq1)
|
||||
self.lineEdit_sv_freq1.clear()
|
||||
self.lineEdit_sv_freq1.setText(str("%.5f" % sv_freq1))
|
||||
|
||||
# self.spinbox_sv_freq2.clear()
|
||||
# self.spinbox_sv_freq2.setValue(sv_freq2)
|
||||
self.lineEdit_sv_freq2.clear()
|
||||
self.lineEdit_sv_freq2.setText(str("%.5f" % sv_freq2))
|
||||
|
||||
|
|
@ -1889,8 +1688,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
print(f"Exponent X = {X_exponent:.2f}\n")
|
||||
|
||||
# self.spinbox_X.clear()
|
||||
# self.spinbox_X.setValue(X_exponent)
|
||||
self.lineEdit_X.setText(str("%.2f" % X_exponent))
|
||||
|
||||
def compute_kt2D_kt3D(self):
|
||||
|
|
@ -1957,25 +1754,16 @@ class SedimentCalibrationTab(QWidget):
|
|||
stg.kt2D[i] = np.repeat(np.array([stg.kt_read]).transpose(), stg.time[i].shape[1], axis=1)
|
||||
stg.kt3D[i] = np.repeat(stg.kt2D[i][:, np.newaxis, :], stg.depth[i].shape[1], axis=1)
|
||||
|
||||
print('kt2D ', stg.kt2D)
|
||||
print('kt3D ', stg.kt3D)
|
||||
|
||||
def compute_J_cross_section(self):
|
||||
|
||||
for i in range(self.combobox_acoustic_data_choice.count()):
|
||||
|
||||
print('kt2D shape ', stg.kt2D[i].shape)
|
||||
print('kt3D shape ', stg.kt3D[i].shape)
|
||||
|
||||
J_cross_section_freq1 = np.array([])
|
||||
J_cross_section_freq2 = np.array([])
|
||||
|
||||
# --- Compute J ---
|
||||
if stg.BS_stream_bed_pre_process_average[i].shape != (0,):
|
||||
print("000000000000000000000000000000000")
|
||||
print(stg.BS_stream_bed_pre_process_average[i][stg.frequencies_for_calibration[0][1], :, :].shape,
|
||||
stg.depth_2D[i][stg.frequencies_for_calibration[0][1], :, :].shape,
|
||||
stg.kt3D[i][stg.frequencies_for_calibration[0][1], :, :].shape)
|
||||
|
||||
J_cross_section_freq1 = self.inv_hc.j_cross_section(
|
||||
BS=stg.BS_stream_bed_pre_process_average[i][
|
||||
stg.frequencies_for_calibration[0][1], :, :],
|
||||
|
|
@ -2110,9 +1898,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
stg.J_cross_section[i][0] = J_cross_section_freq1
|
||||
stg.J_cross_section[i][1] = J_cross_section_freq2
|
||||
|
||||
print(f"J_cross_section {str(i)} freq1 shape ", J_cross_section_freq1.shape, J_cross_section[i][0].shape)
|
||||
print(f"J_cross_section {str(i)} freq2 shape ", J_cross_section_freq2.shape, J_cross_section[i][1].shape)
|
||||
|
||||
def compute_alpha_s(self):
|
||||
|
||||
# --- Compute alpha_s ---
|
||||
|
|
@ -2161,13 +1946,9 @@ class SedimentCalibrationTab(QWidget):
|
|||
print(f"\u03B1s for frequency of freq1 : {alpha_s_freq1:.2f} /m \n")
|
||||
print(f"\u03B1s for frequency of freq2 : {alpha_s_freq2:.2f} /m")
|
||||
|
||||
# self.spinbox_alphas_freq1.clear()
|
||||
# self.spinbox_alphas_freq1.setValue(alpha_s_freq1)
|
||||
self.lineEdit_alphas_freq1.clear()
|
||||
self.lineEdit_alphas_freq1.setText(str("%.5f" % alpha_s_freq1))
|
||||
|
||||
# self.spinbox_alphas_freq2.clear()
|
||||
# self.spinbox_alphas_freq2.setValue(alpha_s_freq2)
|
||||
self.lineEdit_alphas_freq2.clear()
|
||||
self.lineEdit_alphas_freq2.setText(str("%.5f" % alpha_s_freq2))
|
||||
|
||||
|
|
@ -2229,13 +2010,9 @@ class SedimentCalibrationTab(QWidget):
|
|||
print(f"\u03B6 for frequency of freq1 : {zeta_freq1:.3f} /m \n")
|
||||
print(f"\u03B6 for frequency of freq2 : {zeta_freq2:.3f} /m")
|
||||
|
||||
# self.spinbox_zeta_freq1.clear()
|
||||
# self.spinbox_zeta_freq1.setValue(zeta_freq1)
|
||||
self.lineEdit_zeta_freq1.clear()
|
||||
self.lineEdit_zeta_freq1.setText(str("%.5f" % zeta_freq1))
|
||||
|
||||
# self.spinbox_zeta_freq2.clear()
|
||||
# self.spinbox_zeta_freq2.setValue(zeta_freq2)
|
||||
self.lineEdit_zeta_freq2.clear()
|
||||
self.lineEdit_zeta_freq2.setText(str("%.5f" % zeta_freq2))
|
||||
|
||||
|
|
@ -2248,8 +2025,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
directory=[stg.path_calibration_file if stg.path_calibration_file else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0],
|
||||
options=QFileDialog.DontUseNativeDialog)
|
||||
|
||||
print("dir_save_cal ", dir_save_cal)
|
||||
|
||||
if dir_save_cal:
|
||||
|
||||
stg.path_calibration_file = path.dirname(dir_save_cal)
|
||||
|
|
@ -2289,12 +2064,10 @@ class SedimentCalibrationTab(QWidget):
|
|||
aquascat_cell_size = []
|
||||
tau = []
|
||||
real_cell_size = []
|
||||
# stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = (
|
||||
# np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape))
|
||||
|
||||
stg.depth_real = np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)
|
||||
|
||||
for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]):
|
||||
print("f = ", f)
|
||||
# defaut Aquascat cell size
|
||||
aquascat_cell_size.append(
|
||||
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, 1] -
|
||||
|
|
@ -2303,27 +2076,19 @@ class SedimentCalibrationTab(QWidget):
|
|||
# Pulse duration
|
||||
tau.append(aquascat_cell_size[f] * 2 / 1500) # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat
|
||||
|
||||
print(stg.water_velocity)
|
||||
print(tau)
|
||||
# Real cell size
|
||||
real_cell_size.append(stg.water_velocity * tau[f] / 2) # voir fig 2.9
|
||||
|
||||
# Converting to real cell profile
|
||||
# stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][f, :] = \
|
||||
# (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :] /
|
||||
# aquascat_cell_size[f] * real_cell_size[f]) # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1
|
||||
stg.depth_real[f, :] = (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :]
|
||||
/ aquascat_cell_size[f] * real_cell_size[f])
|
||||
print("stg.depth_real ", stg.depth_real)
|
||||
# (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules
|
||||
|
||||
else:
|
||||
|
||||
aquascat_cell_size = []
|
||||
tau = []
|
||||
real_cell_size = []
|
||||
# stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = (
|
||||
# np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape))
|
||||
|
||||
stg.depth_real = (np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape))
|
||||
|
||||
for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]):
|
||||
|
|
@ -2340,57 +2105,23 @@ class SedimentCalibrationTab(QWidget):
|
|||
real_cell_size.append(stg.water_velocity * tau[f] / 2) # voir fig 2.9
|
||||
|
||||
# Converting to real cell profile
|
||||
# stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][f, :] = \
|
||||
# (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] /
|
||||
# aquascat_cell_size[f] * real_cell_size[f]) # (/ aquascat_cell_size) pour ramener BS.r entre 0 et 1
|
||||
# # (* real_cell_size) pour remettre les échelles spatiales sur la taille réelle des cellules
|
||||
|
||||
stg.depth_real[f, :] = (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] /
|
||||
aquascat_cell_size[f] * real_cell_size[f])
|
||||
|
||||
print("R_real 2D ", stg.depth_real.shape)
|
||||
|
||||
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
|
||||
# stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = (
|
||||
# np.repeat(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][:, :, np.newaxis],
|
||||
# stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
|
||||
stg.depth_real = \
|
||||
(np.repeat(stg.depth_real[:, :, np.newaxis],
|
||||
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
|
||||
|
||||
print("R_real 3D ", stg.depth_real.shape)
|
||||
|
||||
else:
|
||||
|
||||
# stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()] = (
|
||||
# np.repeat(stg.depth_real[self.combobox_acoustic_data_choice.currentIndex()][:, :, np.newaxis],
|
||||
# stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
|
||||
stg.depth_real = (
|
||||
np.repeat(stg.depth_real[:, :, np.newaxis],
|
||||
stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
|
||||
|
||||
print("R_real 3D ", stg.depth_real.shape)
|
||||
|
||||
def compute_FCB(self):
|
||||
# if stg.BS_stream_bed.size == 0:
|
||||
# msgBox = QMessageBox()
|
||||
# msgBox.setWindowTitle("FCB Error")
|
||||
# msgBox.setIcon(QMessageBox.Warning)
|
||||
# msgBox.setText("Load Backscatter data from acoustic data tab and compute water attenuation")
|
||||
# msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
# msgBox.exec()
|
||||
# else:
|
||||
|
||||
# R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[1], axis=2)
|
||||
# if (stg.BS_stream_bed_pre_process_average.size == 0) and (stg.BS_stream_bed_pre_process_SNR.size == 0):
|
||||
# stg.FCB = (np.log(stg.BS_stream_bed) + np.log(R_real) +
|
||||
# 2 * stg.water_attenuation * R_real)
|
||||
# elif stg.BS_stream_bed_pre_process_SNR.size == 0:
|
||||
# stg.FCB = (np.log(stg.BS_stream_bed_pre_process_average) + np.log(R_real) +
|
||||
# 2 * stg.water_attenuation * R_real)
|
||||
# else:
|
||||
# stg.FCB = (np.log(stg.BS_stream_bed_pre_process_SNR) + np.log(R_real) +
|
||||
# 2 * stg.water_attenuation * R_real)
|
||||
|
||||
self.combobox_frequency_FCB.clear()
|
||||
self.combobox_frequency_FCB.addItems(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()])
|
||||
|
|
@ -2417,13 +2148,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
|
||||
print("zzzzzzzzzzzzzzzzzzzzz")
|
||||
print(np.log(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()]).shape)
|
||||
print(np.log(stg.depth_real).shape)
|
||||
print(stg.water_attenuation)
|
||||
print(stg.depth_real.shape)
|
||||
print("zzzzzzzzzzzzzzzzzzzzz")
|
||||
|
||||
stg.FCB = \
|
||||
(np.log(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()]) +
|
||||
np.log(stg.depth_real) +
|
||||
|
|
@ -2451,13 +2175,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
|
||||
elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
|
||||
print("ttttttttttttttttttttttttt")
|
||||
print(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)
|
||||
print(stg.depth_real.shape)
|
||||
print(stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()])
|
||||
print(stg.depth_real.shape)
|
||||
print("ttttttttttttttttttttttttt")
|
||||
|
||||
stg.FCB = \
|
||||
(np.log(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()]) +
|
||||
np.log(stg.depth_real) +
|
||||
|
|
@ -2492,10 +2209,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.combobox_frequency_FCB.currentIndex()] *
|
||||
stg.depth_real)
|
||||
|
||||
print("FCB shape", stg.FCB.shape)
|
||||
print("FCB ", stg.FCB)
|
||||
|
||||
|
||||
self.plot_FCB()
|
||||
|
||||
def plot_FCB(self):
|
||||
|
|
@ -2547,10 +2260,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
horizontalalignment='right', verticalalignment='bottom',
|
||||
transform=self.axis_FCB.transAxes)
|
||||
|
||||
# if len(stg.lin_reg) != 0:
|
||||
# self.axis_FCB_profile[self.combobox_frequency_compute_alphaS.currentIndex()]. \
|
||||
# plot(stg.r[f, :], stg.lin_reg[0]*stg.r[f, :] + stg.lin_reg[1], linestyle="dashed", linewidth=1, color="b")
|
||||
|
||||
self.fig_FCB.supxlabel("Depth (m)")
|
||||
self.fig_FCB.supylabel("FCB")
|
||||
self.fig_FCB.canvas.draw_idle()
|
||||
|
|
@ -2660,15 +2369,11 @@ class SedimentCalibrationTab(QWidget):
|
|||
np.min(np.round(np.abs(x - float(self.lineEdit_FCB_from.text().replace(',','.'))), 2)))[0][0]
|
||||
value2 = np.where(np.round(np.abs(x - float(self.lineEdit_FCB_to.text().replace(',', '.'))), 2) ==
|
||||
np.min(np.round(np.abs(x - float(self.lineEdit_FCB_to.text().replace(',', '.'))), 2)))[0][0]
|
||||
print("value1 ", value1)
|
||||
print("value2 ", value2)
|
||||
|
||||
lin_reg_compute = linregress(x[value1:value2], y[value1:value2])
|
||||
print("lin_reg_compute ", lin_reg_compute)
|
||||
|
||||
stg.lin_reg.clear()
|
||||
stg.lin_reg = [lin_reg_compute.slope, lin_reg_compute.intercept]
|
||||
print("stg.lin_reg ", stg.lin_reg)
|
||||
|
||||
# --- Plot result of linear regression ---
|
||||
self.axis_FCB.plot(
|
||||
|
|
@ -2692,11 +2397,8 @@ class SedimentCalibrationTab(QWidget):
|
|||
np.min(np.round(np.abs(x - float(self.lineEdit_FCB_from.text().replace(',','.'))), 2)))[0][0]
|
||||
value2 = np.where(np.round(np.abs(x - float(self.lineEdit_FCB_to.text().replace(',', '.'))), 2) ==
|
||||
np.min(np.round(np.abs(x - float(self.lineEdit_FCB_to.text().replace(',', '.'))), 2)))[0][0]
|
||||
print("value1 ", value1)
|
||||
print("value2 ", value2)
|
||||
|
||||
lin_reg_compute = linregress(x[value1:value2], y[value1:value2])
|
||||
print("lin_reg_compute ", lin_reg_compute)
|
||||
|
||||
stg.lin_reg.clear()
|
||||
stg.lin_reg = [lin_reg_compute.slope, lin_reg_compute.intercept]
|
||||
|
|
@ -2717,69 +2419,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.label_alphaS_FCB.clear()
|
||||
self.label_alphaS_FCB.setText(f"α<sub>s</sub> = {-0.5*stg.lin_reg[0]:.4f} dB/m")
|
||||
|
||||
# if stg.FCB.size == 0:
|
||||
# msgBox = QMessageBox()
|
||||
# msgBox.setWindowTitle("Linear regression error")
|
||||
# msgBox.setIcon(QMessageBox.Warning)
|
||||
# msgBox.setText("Please compute FCB before")
|
||||
# msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
# msgBox.exec()
|
||||
# else:
|
||||
# try:
|
||||
# y0 = stg.FCB[self.combobox_frequency_compute_alphaS.currentIndex(), :, self.slider.value()]
|
||||
# y = y0[np.where(np.isnan(y0) == False)]
|
||||
#
|
||||
# x0 = stg.r[0, :].reshape(-1)
|
||||
# x = x0[np.where(np.isnan(y0) == False)]
|
||||
#
|
||||
# value1 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)
|
||||
# == np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)))
|
||||
# value2 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)
|
||||
# == np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)))
|
||||
#
|
||||
# # print(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2))
|
||||
# # # print("value1 ", value1[0][0])
|
||||
# # print(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2))
|
||||
# # print("value2 ", value2[0][0])
|
||||
#
|
||||
# # print("y limited ", y[value1[0][0]:value2[0][0]])
|
||||
#
|
||||
# lin_reg_compute = stats.linregress(x[value1[0][0]:value2[0][0]], y[value1[0][0]:value2[0][0]])
|
||||
# except ValueError:
|
||||
# msgBox = QMessageBox()
|
||||
# msgBox.setWindowTitle("Linear regression error")
|
||||
# msgBox.setIcon(QMessageBox.Warning)
|
||||
# msgBox.setText("Please check boundaries to fit a linear line")
|
||||
# msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
# msgBox.exec()
|
||||
# else:
|
||||
# stg.lin_reg = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
||||
# # print(f"y = {stg.lin_reg[0]}x + {stg.lin_reg[1]}")
|
||||
#
|
||||
# self.label_alphaS.clear()
|
||||
# self.label_alphaS.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m")
|
||||
#
|
||||
# # for i, value_freq in enumerate(stg.freq):
|
||||
# # for k, value_t in enumerate(stg.t):
|
||||
# # # print(f"indice i: {i}, indice k: {k}")
|
||||
# # # print(f"values of FCB: {stg.FCB[:, i, k]}")
|
||||
# # y = stg.FCB[:, i, k]
|
||||
# # # print("y : ", y)
|
||||
# # # print(f"values of FCB where FCB is not Nan {y[np.where(np.isnan(y) == False)]}")
|
||||
# # # print(f"values of r where FCB is not Nan {x[np.where(np.isnan(y) == False)]}")
|
||||
# # lin_reg_compute = stats.linregress(x[np.where(np.isnan(y) == False)], y[np.where(np.isnan(y) == False)])
|
||||
# # lin_reg_tuple = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
||||
# # stg.lin_reg.append(lin_reg_tuple)
|
||||
#
|
||||
# # print(f"y = {lin_reg.slope}x + {lin_reg.intercept}")
|
||||
#
|
||||
# # plt.figure()
|
||||
# # plt.plot(stg.r, stg.FCB[:, 0, 825], 'k-', stg.r, lin_reg.slope*stg.r + lin_reg.intercept, "b--")
|
||||
# # plt.show()
|
||||
#
|
||||
# # print("lin_reg length ", len(stg.lin_reg))
|
||||
# # print("lin_reg ", stg.lin_reg)
|
||||
|
||||
def slider_profile_number_to_begin_FCB(self):
|
||||
self.slider_FCB.setValue(int(self.slider_FCB.minimum()))
|
||||
self.update_lineEdit_by_moving_slider_FCB()
|
||||
|
|
|
|||
Loading…
Reference in New Issue