acoused/View/acoustic_inversion_tab.py

3422 lines
197 KiB
Python

import sys
from PyQt5.QtWidgets import (QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox,
QGridLayout, QLabel, QPushButton, QSpinBox, QDoubleSpinBox, QAbstractSpinBox, QSpacerItem,
QSizePolicy, QSlider, QLineEdit, QMessageBox)
from PyQt5.QtCore import QCoreApplication, Qt, pyqtSignal
from PyQt5.QtGui import QStandardItemModel, QIcon, QPixmap
import numpy as np
from itertools import combinations
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm, BoundaryNorm, CSS4_COLORS
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolBar
import datetime
from scipy import stats
import Translation.constant_string as cs
from View.checkable_combobox import CheckableComboBox
import settings as stg
from View.show_popup_combobox import ComboBoxShowPopUpWindow
from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration
_translate = QCoreApplication.translate
def deleteItemsOfLayout(layout):
if layout is not None:
while layout.count():
item = layout.takeAt(0)
widget = item.widget()
if widget is not None:
widget.setParent(None)
else:
deleteItemsOfLayout(item.layout())
class AcousticInversionTab(QWidget):
''' This class generates the Acoustic Inversion Tab '''
def __init__(self, widget_tab):
super().__init__()
self.path_icon = "./icons/"
self.icon_folder = QIcon(self.path_icon + "folder.png")
self.icon_triangle_left = QIcon(self.path_icon + "triangle_left.png")
self.icon_triangle_left_to_begin = QIcon(self.path_icon + "triangle_left_to_begin.png")
self.icon_triangle_right = QIcon(self.path_icon + "triangle_right.png")
self.icon_triangle_right_to_end = QIcon(self.path_icon + "triangle_right_to_end.png")
self.icon_update = QIcon(self.path_icon + "update.png")
self.inv_hc = AcousticInversionMethodHighConcentration()
### --- General layout of widgets ---
self.verticalLayoutMain = QVBoxLayout(widget_tab)
self.horizontalLayout_Run_Inversion = QHBoxLayout()
self.verticalLayoutMain.addLayout(self.horizontalLayout_Run_Inversion)
self.horizontalLayoutTop = QHBoxLayout()
self.verticalLayoutMain.addLayout(self.horizontalLayoutTop, 5) # 1O units is 100% , 1 units is 10%
self.horizontalLayoutBottom = QHBoxLayout()
self.verticalLayoutMain.addLayout(self.horizontalLayoutBottom, 5)
### --- Combobox acoustic data choice + pushbutton Run Inversion ---
self.combobox_acoustic_data_choice = ComboBoxShowPopUpWindow()
self.combobox_acoustic_data_choice.setMaximumWidth(300)
self.horizontalLayout_Run_Inversion.addWidget(self.combobox_acoustic_data_choice)
self.pushbutton_run_inversion = QPushButton()
self.pushbutton_run_inversion.setText("RUN INVERSION")
self.pushbutton_run_inversion.setMaximumWidth(100)
self.horizontalLayout_Run_Inversion.addWidget(self.pushbutton_run_inversion)
### --- Layout of groupbox in the Top horizontal layout box
# Plot SSC 2D field | SSC vertical profile | Plot SSC graph sample vs inversion ===>>> FINE
self.groupbox_plot_SSC_fine = QGroupBox()
self.horizontalLayoutTop.addWidget(self.groupbox_plot_SSC_fine, 6)
self.groupbox_plot_SSC_fine_vertical_profile = QGroupBox()
# self.horizontalLayoutTop.addWidget(self.groupbox_plot_SSC_fine_vertical_profile, 3)
self.verticalLayout_groupbox_plot_SSC_fine_profile_and_slider = QVBoxLayout()
self.horizontalLayoutTop.addLayout(self.verticalLayout_groupbox_plot_SSC_fine_profile_and_slider, 3)
self.groupbox_plot_measured_vs_inverted_SSC_fine = QGroupBox()
# self.horizontalLayoutTop.addWidget(self.groupbox_plot_measured_vs_inverted_SSC_fine, 3)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine_and_combobox = QVBoxLayout()
self.horizontalLayoutTop.addLayout(self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine_and_combobox, 3)
### --- Layout of groupbox in the Bottom horizontal layout box
# Plot SSC 2D field | SSC vertical profile | Plot SSC graph sample vs inversion ===>>> SAND
self.groupbox_plot_SSC_sand = QGroupBox()
self.horizontalLayoutBottom.addWidget(self.groupbox_plot_SSC_sand, 6)
self.groupbox_plot_SSC_sand_vertical_profile = QGroupBox()
# self.horizontalLayoutBottom.addWidget(self.groupbox_plot_SSC_sand_vertical_profile, 3)
self.verticalLayout_groupbox_plot_SSC_sand_profile_and_slider = QVBoxLayout()
self.horizontalLayoutBottom.addLayout(self.verticalLayout_groupbox_plot_SSC_sand_profile_and_slider, 3)
self.groupbox_plot_measured_vs_inverted_SSC_sand = QGroupBox()
# self.horizontalLayoutBottom.addWidget(self.groupbox_plot_measured_vs_inverted_SSC_sand, 3)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand_and_combobox = QVBoxLayout()
self.horizontalLayoutBottom.addLayout(self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand_and_combobox,
3)
# =====================================================
# TOP HORIZONTAL BOX LAYOUT
# =====================================================
# +++++++++++++++++++++++++++++++++++++++
# | Group box SSC 2D Field FINE |
# +++++++++++++++++++++++++++++++++++++++
self.verticalLayout_groupbox_plot_SSC_fine = QVBoxLayout(self.groupbox_plot_SSC_fine)
self.canvas_SSC_fine = FigureCanvas()
self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine)
# +++++++++++++++++++++++++++++++++++++++++++++++
# | Group box SSC fine vertical profile |
# +++++++++++++++++++++++++++++++++++++++++++++++
self.verticalLayout_groupbox_plot_SSC_fine_profile_and_slider.addWidget(self.groupbox_plot_SSC_fine_vertical_profile)
self.verticalLayout_groupbox_plot_vertical_profile_fine = QVBoxLayout(
self.groupbox_plot_SSC_fine_vertical_profile)
self.canvas_profile_fine = FigureCanvas()
self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self)
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine)
self.horizontalLayout_slider_fine = QHBoxLayout()
# self.verticalLayout_groupbox_plot_vertical_profile_fine.addLayout(self.horizontalLayout_slider_fine)
self.verticalLayout_groupbox_plot_SSC_fine_profile_and_slider.addLayout(self.horizontalLayout_slider_fine)
self.pushbutton_left_to_begin_fine = QPushButton()
self.pushbutton_left_to_begin_fine.setIcon(self.icon_triangle_left_to_begin)
self.horizontalLayout_slider_fine.addWidget(self.pushbutton_left_to_begin_fine)
self.pushbutton_left_fine = QPushButton()
self.pushbutton_left_fine.setIcon(self.icon_triangle_left)
self.horizontalLayout_slider_fine.addWidget(self.pushbutton_left_fine)
self.lineEdit_slider_fine = QLineEdit()
self.lineEdit_slider_fine.setText("1")
self.lineEdit_slider_fine.setFixedWidth(50)
self.horizontalLayout_slider_fine.addWidget(self.lineEdit_slider_fine)
self.pushbutton_right_fine = QPushButton()
self.pushbutton_right_fine.setIcon(self.icon_triangle_right)
self.horizontalLayout_slider_fine.addWidget(self.pushbutton_right_fine)
self.pushbutton_right_to_end_fine = QPushButton()
self.pushbutton_right_to_end_fine.setIcon(self.icon_triangle_right_to_end)
self.horizontalLayout_slider_fine.addWidget(self.pushbutton_right_to_end_fine)
self.slider_fine = QSlider()
self.horizontalLayout_slider_fine.addWidget(self.slider_fine)
self.slider_fine.setOrientation(Qt.Horizontal)
self.slider_fine.setCursor(Qt.OpenHandCursor)
self.slider_fine.setMinimum(1)
self.slider_fine.setMaximum(10)
self.slider_fine.setTickInterval(1)
self.slider_fine.setValue(1)
# +++++++++++++++++++++++++++++++++++++++++++++++++++
# | Group box Measured VS Inverted SSC Fine |
# +++++++++++++++++++++++++++++++++++++++++++++++++++
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine_and_combobox.addWidget(
self.groupbox_plot_measured_vs_inverted_SSC_fine)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine = QVBoxLayout(
self.groupbox_plot_measured_vs_inverted_SSC_fine)
self.canvas_inverted_vs_measured_SSC_fine = FigureCanvas()
self.toolbar_inverted_vs_measured_SSC_fine = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_fine, self)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.toolbar_inverted_vs_measured_SSC_fine)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.canvas_inverted_vs_measured_SSC_fine)
self.horizontalLayout_combobox_fine_sample_choice = QHBoxLayout()
# self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addLayout(
# self.horizontalLayout_combobox_fine_sample_choice)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine_and_combobox.addLayout(
self.horizontalLayout_combobox_fine_sample_choice)
self.label_fine_sample_choice = QLabel()
self.label_fine_sample_choice.setText("Fine sample choice : ")
self.horizontalLayout_combobox_fine_sample_choice.addWidget(self.label_fine_sample_choice)
self.combobox_fine_sample_choice = CheckableComboBox()
self.horizontalLayout_combobox_fine_sample_choice.addWidget(self.combobox_fine_sample_choice)
self.pushbutton_plot_fine_sample_choice = QPushButton()
self.pushbutton_plot_fine_sample_choice.setIcon(self.icon_update)
self.pushbutton_plot_fine_sample_choice.setMaximumWidth(50)
self.horizontalLayout_combobox_fine_sample_choice.addWidget(self.pushbutton_plot_fine_sample_choice)
self.fine_sample_to_plot = []
# =====================================================
# BOTTOM HORIZONTAL BOX LAYOUT
# =====================================================
# ++++++++++++++++++++++++++++++++++++++
# | Group box SSC 2D Field SAND |
# ++++++++++++++++++++++++++++++++++++++
self.verticalLayout_groupbox_plot_SSC_sand = QVBoxLayout(self.groupbox_plot_SSC_sand)
self.canvas_SSC_sand = FigureCanvas()
self.toolbar_SSC_sand = NavigationToolBar(self.canvas_SSC_sand, self)
self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand)
self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand)
# +++++++++++++++++++++++++++++++++++++++++++++++
# | Group box SSC sand vertical profile |
# +++++++++++++++++++++++++++++++++++++++++++++++
self.verticalLayout_groupbox_plot_SSC_sand_profile_and_slider.addWidget(
self.groupbox_plot_SSC_sand_vertical_profile)
self.verticalLayout_groupbox_plot_vertical_profile_sand = QVBoxLayout(
self.groupbox_plot_SSC_sand_vertical_profile)
self.canvas_profile_sand = FigureCanvas()
self.toolbar_profile_sand = NavigationToolBar(self.canvas_profile_sand, self)
self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.toolbar_profile_sand)
self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.canvas_profile_sand)
self.horizontalLayout_slider_sand = QHBoxLayout()
# self.verticalLayout_groupbox_plot_vertical_profile_sand.addLayout(self.horizontalLayout_slider_sand)
self.verticalLayout_groupbox_plot_SSC_sand_profile_and_slider.addLayout(self.horizontalLayout_slider_sand)
self.pushbutton_left_to_begin_sand = QPushButton()
self.pushbutton_left_to_begin_sand.setIcon(self.icon_triangle_left_to_begin)
self.horizontalLayout_slider_sand.addWidget(self.pushbutton_left_to_begin_sand)
self.pushbutton_left_sand = QPushButton()
self.pushbutton_left_sand.setIcon(self.icon_triangle_left)
self.horizontalLayout_slider_sand.addWidget(self.pushbutton_left_sand)
self.lineEdit_slider_sand = QLineEdit()
self.lineEdit_slider_sand.setText("1")
self.lineEdit_slider_sand.setFixedWidth(50)
self.horizontalLayout_slider_sand.addWidget(self.lineEdit_slider_sand)
self.pushbutton_right_sand = QPushButton()
self.pushbutton_right_sand.setIcon(self.icon_triangle_right)
self.horizontalLayout_slider_sand.addWidget(self.pushbutton_right_sand)
self.pushbutton_right_to_end_sand = QPushButton()
self.pushbutton_right_to_end_sand.setIcon(self.icon_triangle_right_to_end)
self.horizontalLayout_slider_sand.addWidget(self.pushbutton_right_to_end_sand)
self.slider_sand = QSlider()
self.horizontalLayout_slider_sand.addWidget(self.slider_sand)
self.slider_sand.setOrientation(Qt.Horizontal)
self.slider_sand.setCursor(Qt.OpenHandCursor)
self.slider_sand.setMinimum(1)
self.slider_sand.setMaximum(10)
self.slider_sand.setTickInterval(1)
self.slider_sand.setValue(1)
# +++++++++++++++++++++++++++++++++++++++++++++++++++
# | Group box Measured VS Inverted SSC Sand |
# +++++++++++++++++++++++++++++++++++++++++++++++++++
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand_and_combobox.addWidget(
self.groupbox_plot_measured_vs_inverted_SSC_sand)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand = QVBoxLayout(
self.groupbox_plot_measured_vs_inverted_SSC_sand)
self.canvas_inverted_vs_measured_SSC_sand = FigureCanvas()
self.toolbar_inverted_vs_measured_SSC_sand = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_sand, self)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addWidget(
self.toolbar_inverted_vs_measured_SSC_sand)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addWidget(
self.canvas_inverted_vs_measured_SSC_sand)
self.horizontalLayout_combobox_sand_sample_choice = QHBoxLayout()
# self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addLayout(
# self.horizontalLayout_combobox_sand_sample_choice)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand_and_combobox.addLayout(
self.horizontalLayout_combobox_sand_sample_choice)
self.label_sand_sample_choice = QLabel()
self.label_sand_sample_choice.setText("Sand sample choice : ")
self.horizontalLayout_combobox_sand_sample_choice.addWidget(self.label_sand_sample_choice)
self.combobox_sand_sample_choice = CheckableComboBox()
self.horizontalLayout_combobox_sand_sample_choice.addWidget(self.combobox_sand_sample_choice)
self.pushbutton_plot_sand_sample_choice = QPushButton()
self.pushbutton_plot_sand_sample_choice.setIcon(self.icon_update)
self.pushbutton_plot_sand_sample_choice.setMaximumWidth(50)
self.horizontalLayout_combobox_sand_sample_choice.addWidget(self.pushbutton_plot_sand_sample_choice)
# ==============================================================================================================
# ---------------------------------------- Connect signal of widget --------------------------------------------
# ==============================================================================================================
self.combobox_acoustic_data_choice.ShowPopUpWindowSignal.connect(self.event_combobobx_acoustic_data_choice)
self.pushbutton_run_inversion.clicked.connect(self.function_run_inversion)
self.pushbutton_left_to_begin_fine.clicked.connect(self.slider_profile_number_to_begin_fine)
self.pushbutton_left_fine.clicked.connect(self.slider_profile_number_to_left_fine)
self.pushbutton_right_fine.clicked.connect(self.slider_profile_number_to_right_fine)
self.pushbutton_right_to_end_fine.clicked.connect(self.slider_profile_number_to_end_fine)
self.lineEdit_slider_fine.returnPressed.connect(self.profile_number_on_lineEdit_fine)
self.slider_fine.valueChanged.connect(self.update_lineEdit_by_moving_slider_fine)
self.slider_fine.valueChanged.connect(self.update_plot_SSC_fine_vertical_profile)
self.pushbutton_plot_fine_sample_choice.clicked.connect(self.plot_measured_vs_inverted_SSC_fine)
self.pushbutton_left_to_begin_sand.clicked.connect(self.slider_profile_number_to_begin_sand)
self.pushbutton_left_sand.clicked.connect(self.slider_profile_number_to_left_sand)
self.pushbutton_right_sand.clicked.connect(self.slider_profile_number_to_right_sand)
self.pushbutton_right_to_end_sand.clicked.connect(self.slider_profile_number_to_end_sand)
self.lineEdit_slider_sand.returnPressed.connect(self.profile_number_on_lineEdit_sand)
self.slider_sand.valueChanged.connect(self.update_lineEdit_by_moving_slider_sand)
self.slider_sand.valueChanged.connect(self.update_plot_SSC_sand_vertical_profile)
self.pushbutton_plot_sand_sample_choice.clicked.connect(self.plot_measured_vs_inverted_SSC_sand)
# ==================================================================================================================
# ------------------------------------ Functions for Acoustic Inversion Tab ----------------------------------------
# ==================================================================================================================
def event_combobobx_acoustic_data_choice(self):
print("(stg.filename_BS_noise_data ", (stg.filename_BS_noise_data))
self.combobox_acoustic_data_choice.clear()
# self.combobox_fileListWidget.addItem("")
for i in range(len(stg.filename_BS_raw_data)):
self.combobox_acoustic_data_choice.addItem(stg.filename_BS_raw_data[i])
self.combobox_acoustic_data_choice.currentIndexChanged.connect(self.combobox_acoustic_data_choice_currentIndexChanged)
def combobox_acoustic_data_choice_currentIndexChanged(self):
self.fill_combobox_fine_sample()
self.plot_SSC_fine()
self.plot_SSC_fine_vertical_profile()
self.plot_measured_vs_inverted_SSC_fine()
self.fill_combobox_sand_sample()
self.plot_SSC_sand()
self.plot_SSC_sand_vertical_profile()
self.plot_measured_vs_inverted_SSC_sand()
def function_run_inversion(self):
if (stg.alpha_s[0] < 0) or (stg.alpha_s[1] < 0):
msgBox = QMessageBox()
msgBox.setWindowTitle("Alpha computation error")
msgBox.setIconPixmap(
QPixmap(self.path_icon + "no_approved.png").scaledToHeight(32, Qt.SmoothTransformation))
msgBox.setText("Sediment sound attenuation is negative !")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec()
else:
self.compute_VBI()
self.compute_SSC_fine()
self.compute_SSC_sand()
self.fill_combobox_fine_sample()
self.plot_SSC_fine()
self.plot_SSC_fine_vertical_profile()
self.plot_measured_vs_inverted_SSC_fine()
self.fill_combobox_sand_sample()
self.plot_SSC_sand()
self.plot_SSC_sand_vertical_profile()
self.plot_measured_vs_inverted_SSC_sand()
def compute_VBI(self):
stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
print("compute VBI")
print(stg.frequencies_for_calibration[0][0],
stg.frequencies_for_calibration[1][0])
print(stg.frequency_for_inversion)
print(stg.zeta[0], stg.zeta[1])
print(stg.J_cross_section[0].shape, stg.J_cross_section[0].shape)
print(stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()].shape)
print(stg.alpha_s[0], stg.alpha_s[1])
print(stg.X_exponent[0])
stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.VBI_cross_section(
freq1=stg.frequencies_for_calibration[0][0],
freq2=stg.frequencies_for_calibration[1][0],
zeta_freq1=stg.zeta[0], zeta_freq2=stg.zeta[1],
j_cross_section_freq1=stg.J_cross_section[0], j_cross_section_freq2=stg.J_cross_section[1],
r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
water_attenuation_freq1=stg.alpha_s[0], water_attenuation_freq2=stg.alpha_s[1],
X=stg.X_exponent[0]
)
print("compute VBI end")
def compute_SSC_fine(self):
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
print("Compute SSC fine - start")
print(stg.zeta[1])
print(stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape)
# print(stg.VBI_cross_section.shape)
print(stg.frequencies_for_calibration[1][0])
print(stg.X_exponent[0])
print(stg.J_cross_section[1].shape)
print(stg.water_attenuation)
print(np.full(shape=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape,
fill_value=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]))
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_fine(
zeta=stg.zeta[1],
r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
VBI=stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()],
freq=stg.frequencies_for_calibration[1][0],
X=stg.X_exponent[0],
j_cross_section=stg.J_cross_section[1],
alpha_w=np.full(shape=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape,
fill_value=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
)
print("stg.SSC_fine ", stg.SSC_fine)
def compute_SSC_sand(self):
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
print("+++++++++++++++++++++")
print(stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)
print(stg.frequencies_for_calibration[1][0])
print(stg.X_exponent)
print(stg.ks[1])
print("+++++++++++++++++++++")
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_sand(
VBI=stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()],
freq=stg.frequencies_for_calibration[1][0],
X=stg.X_exponent,
ks=stg.ks[1])
print("stg.SSC_sand ", stg.SSC_sand)
def plot_SSC_fine(self):
if self.combobox_acoustic_data_choice.count() > 0:
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,):
self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine)
self.canvas_SSC_fine = FigureCanvas()
self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine)
elif stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine)
self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(nrows=1, ncols=1, layout="constrained")
self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine)
self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine)
val_min = np.nanmin(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()])
val_max = np.nanmax(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()])
print("ABS name ", stg.ABS_name)
if stg.ABS_name[0] == "Aquascat 1000R":
print("hey !")
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
print("hey hey !")
# print("time cross section ", stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1]])
# print("depth cross section ", stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1]])
# print(stg.frequency_for_inversion[1])
pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()],
cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud')
if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_SSC_fine.plot(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
color='black', linewidth=1, linestyle="solid")
self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_fine.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", color='r', linewidth=2)
print("o+o+o+o+o+o")
print(stg.frequency_for_inversion[1])
print([i for i, _ in stg.fine_sample_position])
# print([stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], i]
# for i, _ in stg.fine_sample_position])
print("o+o+o+o+o+o")
# self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot(
# [stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], i]
# for i, _ in stg.fine_sample_position],
# [-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], j]
# for _, j in stg.fine_sample_position],
# ls=" ", marker="o", ms=5, mec="k", mfc="k")
self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot(stg.time_fine, stg.depth_fine,
ls=" ", marker="o", ms=5, mec="k", mfc="k")
print(stg.time_fine)
print(stg.depth_fine)
print([f for _, f in stg.sample_fine])
for i, j in stg.sample_fine:
self.pcm_SSC_fine_meas_vs_inv_text = self.axis_SSC_fine.text(
stg.time_fine[j],
stg.depth_fine[j],
i)
else:
pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()],
cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud')
self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_fine.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[
1]].shape),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", color='r', linewidth=2)
if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_SSC_fine.plot(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
color='black', linewidth=1, linestyle="solid")
self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot(stg.time_fine, stg.depth_fine,
ls=" ", marker="o", ms=5, mec="k", mfc="k")
print(stg.time_fine)
print(stg.depth_fine)
print([f for _, f in stg.sample_fine])
for i, j in stg.sample_fine:
self.pcm_SSC_fine_meas_vs_inv_text = self.axis_SSC_fine.text(
stg.time_fine[j],
stg.depth_fine[j],
i)
# self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot(
# [stg.time[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], i]
# for i, _ in stg.fine_sample_position],
# [-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], j]
# for _, j in stg.fine_sample_position],
# ls=" ", marker="o", ms=5, mec="k", mfc="k")
cbar_SSC_fine = self.figure_SSC_fine.colorbar(pcm_SSC_fine, ax=self.axis_SSC_fine, shrink=1,
location='right')
cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15)
elif stg.ABS_name[0] == "UB-SediFlow":
pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(stg.t[0, :],
-stg.r[0, :],
stg.SSC_fine,
cmap='rainbow',
norm=LogNorm(vmin=1e-2, vmax=10),
shading='gouraud')
self.figure_SSC_fine.supxlabel("Time (sec)", fontsize=10)
self.figure_SSC_fine.supylabel("Depth (m)", fontsize=10)
self.figure_SSC_fine.canvas.draw_idle()
def plot_SSC_fine_vertical_profile(self):
if self.combobox_acoustic_data_choice.count() > 0:
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,):
self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.canvas_profile_fine)
self.canvas_profile_fine = FigureCanvas()
self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self)
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine)
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.slider_fine.setMaximum(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.canvas_profile_fine)
self.figure_vertical_profile_SSC_fine, self.axis_vertical_profile_SSC_fine = plt.subplots(
nrows=1, ncols=1, layout="constrained")
self.canvas_profile_fine = FigureCanvas(self.figure_vertical_profile_SSC_fine)
self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self)
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine)
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot(
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_fine.value() -1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", linewidth=1, color="k")
self.pcm_SSC_fine_vertical_line.set_data(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_fine.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim(
[-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
else:
self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot(
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_fine.value() -1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", linewidth=1, color="k")
self.pcm_SSC_fine_vertical_line.set_data(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], self.slider_fine.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim(
[-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
# self.axis_SSC_fine.plot([], [], )
self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)")
self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_fine.canvas.draw_idle()
def update_plot_SSC_fine_vertical_profile(self):
if stg.filename_BS_noise_data != []:
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.plot_fine.set_data(
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:,
self.slider_fine.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.pcm_SSC_fine_vertical_line.set_data(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_fine.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim(
[-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
else:
self.plot_fine.set_data(
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:,
self.slider_fine.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.pcm_SSC_fine_vertical_line.set_data(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], self.slider_fine.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim(
[-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)")
self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_fine.canvas.draw_idle()
def slider_profile_number_to_begin_fine(self):
self.slider_fine.setValue(int(self.slider_fine.minimum()))
self.lineEdit_slider_fine.setText(str(self.slider_fine.value()))
def slider_profile_number_to_right_fine(self):
self.slider_fine.setValue(int(self.slider_fine.value()) + 1)
self.lineEdit_slider_fine.setText(str(self.slider_fine.value()))
def slider_profile_number_to_left_fine(self):
self.slider_fine.setValue(int(self.slider_fine.value()) - 1)
self.lineEdit_slider_fine.setText(str(self.slider_fine.value()))
def slider_profile_number_to_end_fine(self):
self.slider_fine.setValue(int(self.slider_fine.maximum()))
self.lineEdit_slider_fine.setText(str(self.slider_fine.value()))
def profile_number_on_lineEdit_fine(self):
self.slider_fine.setValue(int(self.lineEdit_slider_fine.text()))
def update_lineEdit_by_moving_slider_fine(self):
self.lineEdit_slider_fine.setText(str(self.slider_fine.value()))
# --- Plot fine SSC : measured vs inverted ---
def fill_combobox_fine_sample(self):
print("stg.sample_fine ", stg.sample_fine)
self.combobox_fine_sample_choice.addItems([f for f, _ in stg.sample_fine])
# --- Get position (index, value) of sample in acoustic measurement space ---
if ((stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
print(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
print(stg.depth_fine)
for j in range(len(stg.time_fine)):
(stg.fine_sample_position.
append(
(
np.where(
np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[j])
==
np.nanmin(np.abs(stg.time_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[j]))
)[0][0],
np.where(
np.abs(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_fine[j]))
==
np.nanmin(np.abs(stg.depth_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_fine[j])))
)[0][0]
)
)
)
print("0 stg.fine_sample_position ", stg.fine_sample_position)
elif ((stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_fine)):
(stg.fine_sample_position.
append(
(
np.where(
np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[j])
==
np.nanmin(np.abs(stg.time_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[j]))
)[0][0],
np.where(
np.abs(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_fine[j]))
==
np.nanmin(np.abs(stg.depth[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_fine[j])))
)[0][0]
)
)
)
print("1 stg.fine_sample_position ", stg.fine_sample_position)
elif ((stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_fine)):
(stg.fine_sample_position.
append(
(
np.where(
np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[j])
==
np.nanmin(np.abs(stg.time[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[j]))
)[0][0],
np.where(
np.abs(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_fine[j]))
==
np.nanmin(np.abs(stg.depth_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_fine[j])))
)[0][0]
)
)
)
print("2 stg.fine_sample_position ", stg.fine_sample_position)
elif ((stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_fine)):
(stg.fine_sample_position.
append(
(
np.where(
np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[j])
==
np.nanmin(np.abs(stg.time[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[j]))
)[0][0],
np.where(
np.abs(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_fine[j]))
==
np.nanmin(np.abs(stg.depth[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_fine[j])))
)[0][0]
)
)
)
print("3 stg.fine_sample_position ", stg.fine_sample_position)
def plot_measured_vs_inverted_SSC_fine(self):
if self.combobox_acoustic_data_choice.count() > 0:
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,):
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.removeWidget(self.toolbar_inverted_vs_measured_SSC_fine)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.removeWidget(self.canvas_inverted_vs_measured_SSC_fine)
self.canvas_inverted_vs_measured_SSC_fine = FigureCanvas()
self.toolbar_inverted_vs_measured_SSC_fine = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_fine, self)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.toolbar_inverted_vs_measured_SSC_fine)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.canvas_inverted_vs_measured_SSC_fine)
else:
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.removeWidget(self.toolbar_inverted_vs_measured_SSC_fine)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.removeWidget(self.canvas_inverted_vs_measured_SSC_fine)
self.figure_measured_vs_inverted_fine, self.axis_measured_vs_inverted_fine = (
plt.subplots(nrows=1, ncols=1, layout="constrained"))
self.canvas_inverted_vs_measured_SSC_fine = FigureCanvas(self.figure_measured_vs_inverted_fine)
self.toolbar_inverted_vs_measured_SSC_fine = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_fine, self)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.toolbar_inverted_vs_measured_SSC_fine)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_fine.addWidget(self.canvas_inverted_vs_measured_SSC_fine)
print("self.combobox_fine_sample_choice.currentData() ", self.combobox_fine_sample_choice.currentData())
print("self.combobox_fine_sample_choice.currentIndex() ", self.combobox_fine_sample_choice.currentIndex())
print("///////////////////////////////////////////////////")
self.fine_sample_to_plot = [int(f[1:]) - 1 for f in self.combobox_fine_sample_choice.currentData()]
print("self.fine_sample_to_plot ", self.fine_sample_to_plot)
# for k in self.fine_sample_to_plot:
# print("stg.Ctot_fine[k] ", stg.Ctot_fine[k])
# print(stg.fine_sample_position[k][1])
# print(stg.fine_sample_position[k][0])
# print(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
# stg.fine_sample_position[k][1],
# stg.fine_sample_position[k][0]])
if self.fine_sample_to_plot:
self.axis_measured_vs_inverted_fine.plot(
[stg.Ctot_fine[k] for k in self.fine_sample_to_plot],
[stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
stg.fine_sample_position[k][1],
stg.fine_sample_position[k][0]] for k in self.fine_sample_to_plot],
ls=" ", marker='o', ms=5, mec='black', mfc="black"
)
self.axis_measured_vs_inverted_fine.plot(
[0, np.nanmax([np.nanmax([stg.Ctot_fine[c] for c in self.fine_sample_to_plot]),
np.nanmax([stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
stg.fine_sample_position[i][1],
stg.fine_sample_position[i][0]]
for i in self.fine_sample_to_plot]) ]) + 1],
[0, np.nanmax([np.nanmax([stg.Ctot_fine[c] for c in self.fine_sample_to_plot]),
np.nanmax([stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
stg.fine_sample_position[i][1],
stg.fine_sample_position[i][0]]
for i in self.fine_sample_to_plot])]) + 1],
ls="solid", linewidth=1, color="k"
)
# --- Display sample label on plot ---
for i in self.fine_sample_to_plot:
self.axis_measured_vs_inverted_fine.text(
stg.Ctot_fine[i],
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
stg.fine_sample_position[i][1],
stg.fine_sample_position[i][0]],
stg.sample_fine[i][0],
fontstyle="normal", fontweight="light", fontsize=10)
else:
self.axis_measured_vs_inverted_fine.plot(
[stg.Ctot_fine[k] for k in range(len(stg.sample_fine))],
[stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
stg.fine_sample_position[k][1],
stg.fine_sample_position[k][0]] for k in
range(len(stg.sample_fine))],
ls=" ", marker='o', ms=5, mec='black', mfc="black"
)
self.axis_measured_vs_inverted_fine.plot(
[0, np.nanmax([np.nanmax([stg.Ctot_fine[c] for c in range(len(stg.sample_fine))]),
np.nanmax([stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
stg.fine_sample_position[i][1],
stg.fine_sample_position[i][0]]
for i in range(len(stg.sample_fine))])]) + 1],
[0, np.nanmax([np.nanmax([stg.Ctot_fine[c] for c in range(len(stg.sample_fine))]),
np.nanmax([stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
stg.fine_sample_position[i][1],
stg.fine_sample_position[i][0]]
for i in range(len(stg.sample_fine))])]) + 1],
ls="solid", linewidth=1, color="k"
)
for j in range(len(stg.sample_fine)):
self.axis_measured_vs_inverted_fine.text(
stg.Ctot_fine[j],
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
stg.fine_sample_position[j][1],
stg.fine_sample_position[j][0]],
stg.sample_fine[j][0],
fontstyle="normal", fontweight="light", fontsize=10)
self.axis_measured_vs_inverted_fine.set_xlabel("Measured SSC fine (g/L)")
self.axis_measured_vs_inverted_fine.set_ylabel("Inverted SSC fine (g/L)")
self.figure_measured_vs_inverted_fine.canvas.draw_idle()
def update_plot_sample_position_on_concentration_field(self):
# --- Plot sample position on concentration field ---
# self.pcm_SSC_fine_meas_vs_inv.set_data(
# [stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1],
# stg.fine_sample_position[i][0]]
# for i in self.fine_sample_to_plot],
# [-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1],
# stg.fine_sample_position[j][1]]
# for j in self.fine_sample_to_plot]
# )
self.pcm_SSC_fine_meas_vs_inv.set_data([stg.time_fine[i] for i in self.fine_sample_to_plot],
[stg.depth_fine[j] for j in self.fine_sample_to_plot])
self.figure_SSC_fine.canvas.draw_idle()
for i in self.fine_sample_to_plot:
self.pcm_SSC_fine_meas_vs_inv_text.set_text(stg.sample_fine[i][0])
self.pcm_SSC_fine_meas_vs_inv_text.set_position(stg.time_fine[i], stg.depth_fine[i])
self.figure_SSC_fine.canvas.draw_idle()
def plot_SSC_sand(self):
if self.combobox_acoustic_data_choice.count() > 0:
if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,):
self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.toolbar_SSC_sand)
self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.canvas_SSC_sand)
self.canvas_SSC_sand = FigureCanvas()
self.toolbar_SSC_sand = NavigationToolBar(self.canvas_SSC_sand, self)
self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand)
self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand)
else:
self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.toolbar_SSC_sand)
self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.canvas_SSC_sand)
self.figure_SSC_sand, self.axis_SSC_sand = plt.subplots(nrows=1, ncols=1, layout="constrained")
self.canvas_SSC_sand = FigureCanvas(self.figure_SSC_sand)
self.toolbar_SSC_sand = NavigationToolBar(self.canvas_SSC_sand, self)
self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.toolbar_SSC_sand)
self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand)
val_min = np.nanmin(stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()])
val_max = np.nanmax(stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()])
print("ABS name ", stg.ABS_name)
if stg.ABS_name[0] == "Aquascat 1000R":
print("hey !")
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
print("hey hey !")
# print("time cross section ", stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1]])
# print("depth cross section ", stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1]])
# print(stg.frequency_for_inversion[1])
pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()],
cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=10), shading='gouraud')
if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_SSC_sand.plot(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
color='black', linewidth=1, linestyle="solid")
self.pcm_SSC_sand_vertical_line, = self.axis_SSC_sand.plot(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_sand.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[
1]].shape),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", color='r', linewidth=2)
print("o+o+o+o+o+o")
print(stg.frequency_for_inversion[1])
print([i for i, _ in stg.sand_sample_position])
# print([stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], i]
# for i, _ in stg.fine_sample_position])
print("o+o+o+o+o+o")
# self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot(
# [stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], i]
# for i, _ in stg.fine_sample_position],
# [-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], j]
# for _, j in stg.fine_sample_position],
# ls=" ", marker="o", ms=5, mec="k", mfc="k")
self.pcm_SSC_sand_meas_vs_inv, = self.axis_SSC_sand.plot(stg.time_sand, stg.depth_sand,
ls=" ", marker="o", ms=5, mec="k", mfc="k")
print(stg.time_sand)
print(stg.depth_sand)
print([f for _, f in stg.sample_sand])
for i, j in stg.sample_sand:
self.pcm_SSC_sand_meas_vs_inv_text = self.axis_SSC_sand.text(
stg.time_sand[j],
stg.depth_sand[j],
i)
else:
pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()],
cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=10), shading='gouraud')
if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_SSC_sand.plot(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
color='black', linewidth=1, linestyle="solid")
self.pcm_SSC_sand_vertical_line, = self.axis_SSC_sand.plot(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_sand.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[
1]].shape),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", color='r', linewidth=2)
# self.pcm_SSC_sand_meas_vs_inv, = self.axis_SSC_sand.plot(
# [stg.time[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], i]
# for i, _ in stg.sand_sample_position],
# [-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
# stg.frequency_for_inversion[1], j]
# for _, j in stg.sand_sample_position],
# ls=" ", marker="o", ms=5, mec="k", mfc="k")
self.pcm_SSC_sand_meas_vs_inv, = self.axis_SSC_sand.plot(stg.time_sand, stg.depth_sand,
ls=" ", marker="o", ms=5, mec="k", mfc="k")
print(stg.time_sand)
print(stg.depth_sand)
print([f for _, f in stg.sample_sand])
for i, j in stg.sample_sand:
self.pcm_SSC_sand_meas_vs_inv_text = self.axis_SSC_sand.text(
stg.time_sand[j],
stg.depth_sand[j],
i)
cbar_SSC_sand = self.figure_SSC_sand.colorbar(pcm_SSC_sand, ax=self.axis_SSC_sand, shrink=1,
location='right')
cbar_SSC_sand.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15)
elif stg.ABS_name[0] == "UB-SediFlow":
pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :],
-stg.r[0, :],
stg.SSC_sand,
cmap='rainbow',
norm=LogNorm(vmin=1e-2, vmax=10),
shading='gouraud')
self.figure_SSC_sand.supxlabel("Time (sec)", fontsize=10)
self.figure_SSC_sand.supylabel("Depth (m)", fontsize=10)
self.figure_SSC_sand.canvas.draw_idle()
def plot_SSC_sand_vertical_profile(self):
if self.combobox_acoustic_data_choice.count() > 0:
if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,):
self.verticalLayout_groupbox_plot_vertical_profile_sand.removeWidget(self.toolbar_profile_sand)
self.verticalLayout_groupbox_plot_vertical_profile_sand.removeWidget(self.canvas_profile_sand)
self.canvas_profile_sand = FigureCanvas()
self.toolbar_profile_sand = NavigationToolBar(self.canvas_profile_sand, self)
self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.toolbar_profile_sand)
self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.canvas_profile_sand)
if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.slider_sand.setMaximum(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
self.verticalLayout_groupbox_plot_vertical_profile_sand.removeWidget(self.toolbar_profile_sand)
self.verticalLayout_groupbox_plot_vertical_profile_sand.removeWidget(self.canvas_profile_sand)
self.figure_vertical_profile_SSC_sand, self.axis_vertical_profile_SSC_sand = plt.subplots(
nrows=1, ncols=1, layout="constrained")
self.canvas_profile_sand = FigureCanvas(self.figure_vertical_profile_SSC_sand)
self.toolbar_profile_sand = NavigationToolBar(self.canvas_profile_sand, self)
self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.toolbar_profile_sand)
self.verticalLayout_groupbox_plot_vertical_profile_sand.addWidget(self.canvas_profile_sand)
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.plot_sand , = self.axis_vertical_profile_SSC_sand.plot(
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_sand.value() -1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", linewidth=1, color="k")
self.pcm_SSC_sand_vertical_line.set_data(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_sand.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_sand.canvas.draw_idle()
self.axis_vertical_profile_SSC_sand.set_ylim(
[-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
else:
self.plot_sand , = self.axis_vertical_profile_SSC_sand.plot(
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_sand.value() -1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", linewidth=1, color="k")
self.pcm_SSC_sand_vertical_line.set_data(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], self.slider_sand.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_sand.canvas.draw_idle()
self.axis_vertical_profile_SSC_sand.set_ylim(
[-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
# self.axis_SSC_fine.plot([], [], )
self.axis_vertical_profile_SSC_sand.set_xlabel("Inverted Sand SSC (g/L)")
self.axis_vertical_profile_SSC_sand.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_sand.canvas.draw_idle()
def update_plot_SSC_sand_vertical_profile(self):
if stg.filename_BS_noise_data != []:
if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.plot_sand.set_data(
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][:,
self.slider_sand.value() - 1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.pcm_SSC_sand_vertical_line.set_data(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_sand.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_sand.canvas.draw_idle()
self.axis_vertical_profile_SSC_sand.set_ylim(
[-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
else:
self.plot_sand.set_data(
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][:,
self.slider_sand.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.pcm_SSC_sand_vertical_line.set_data(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], self.slider_sand.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_sand.canvas.draw_idle()
self.axis_vertical_profile_SSC_sand.set_ylim(
[-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
self.axis_vertical_profile_SSC_sand.set_xlabel("Inverted Sand SSC (g/L)")
self.axis_vertical_profile_SSC_sand.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_sand.canvas.draw_idle()
def slider_profile_number_to_begin_sand(self):
self.slider_sand.setValue(int(self.slider_sand.minimum()))
self.lineEdit_slider_sand.setText(str(self.slider_sand.value()))
def slider_profile_number_to_right_sand(self):
self.slider_sand.setValue(int(self.slider_sand.value()) + 1)
self.lineEdit_slider_sand.setText(str(self.slider_sand.value()))
def slider_profile_number_to_left_sand(self):
self.slider_sand.setValue(int(self.slider_sand.value()) - 1)
self.lineEdit_slider_sand.setText(str(self.slider_sand.value()))
def slider_profile_number_to_end_sand(self):
self.slider_sand.setValue(int(self.slider_sand.maximum()))
self.lineEdit_slider_sand.setText(str(self.slider_sand.value()))
def profile_number_on_lineEdit_sand(self):
self.slider_sand.setValue(int(self.lineEdit_slider_sand.text()))
def update_lineEdit_by_moving_slider_sand(self):
self.lineEdit_slider_sand.setText(str(self.slider_sand.value()))
# --- Plot sand SSC : measured vs inverted ---
def fill_combobox_sand_sample(self):
print("stg.sample_sand ", stg.sample_sand)
self.combobox_sand_sample_choice.addItems([f for f, _ in stg.sample_sand])
# --- Get position (index, value) of sample in acoustic measurement space ---
if ((stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
print(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
print(stg.depth_fine)
for j in range(len(stg.time_sand)):
(stg.sand_sample_position.
append(
(
np.where(
np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j])
==
np.nanmin(np.abs(stg.time_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j]))
)[0][0],
np.where(
np.abs(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))
==
np.nanmin(np.abs(stg.depth_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j])))
)[0][0]
)
)
)
print("0 stg.sand_sample_position ", stg.sand_sample_position)
elif ((stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_sand)):
(stg.sand_sample_position.
append(
(
np.where(
np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j])
==
np.nanmin(np.abs(stg.time_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j]))
)[0][0],
np.where(
np.abs(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))
==
np.nanmin(np.abs(stg.depth[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j])))
)[0][0]
)
)
)
print("1 stg.sand_sample_position ", stg.sand_sample_position)
elif ((stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_sand)):
(stg.sand_sample_position.
append(
(
np.where(
np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j])
==
np.nanmin(np.abs(stg.time[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j]))
)[0][0],
np.where(
np.abs(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))
==
np.nanmin(np.abs(stg.depth_cross_section[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j])))
)[0][0]
)
)
)
print("2 stg.sand_sample_position ", stg.sand_sample_position)
elif ((stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,)) and
(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,))):
for j in range(len(stg.time_sand)):
(stg.sand_sample_position.
append(
(
np.where(
np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j])
==
np.nanmin(np.abs(stg.time[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_sand[j]))
)[0][0],
np.where(
np.abs(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j]))
==
np.nanmin(np.abs(stg.depth[
self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - (-stg.depth_sand[j])))
)[0][0]
)
)
)
print("3 stg.sand_sample_position ", stg.sand_sample_position)
def plot_measured_vs_inverted_SSC_sand(self):
if self.combobox_acoustic_data_choice.count() > 0:
if stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,):
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget(
self.toolbar_inverted_vs_measured_SSC_sand)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget(
self.canvas_inverted_vs_measured_SSC_sand)
self.canvas_inverted_vs_measured_SSC_sand = FigureCanvas()
self.toolbar_inverted_vs_measured_SSC_sand = NavigationToolBar(
self.canvas_inverted_vs_measured_SSC_sand, self)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addWidget(
self.toolbar_inverted_vs_measured_SSC_sand)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addWidget(
self.canvas_inverted_vs_measured_SSC_sand)
else:
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget(
self.toolbar_inverted_vs_measured_SSC_sand)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.removeWidget(
self.canvas_inverted_vs_measured_SSC_sand)
self.figure_measured_vs_inverted_sand, self.axis_measured_vs_inverted_sand = (
plt.subplots(nrows=1, ncols=1, layout="constrained"))
self.canvas_inverted_vs_measured_SSC_sand = FigureCanvas(self.figure_measured_vs_inverted_sand)
self.toolbar_inverted_vs_measured_SSC_sand = NavigationToolBar(self.canvas_inverted_vs_measured_SSC_sand, self)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addWidget(
self.toolbar_inverted_vs_measured_SSC_sand)
self.verticalLayout_groupbox_plot_measured_vs_inverted_SSC_sand.addWidget(
self.canvas_inverted_vs_measured_SSC_sand)
print("self.combobox_sand_sample_choice.currentData() ", self.combobox_sand_sample_choice.currentData())
print("self.combobox_sand_sample_choice.currentIndex() ", self.combobox_sand_sample_choice.currentIndex())
print("///////////////////////////////////////////////////")
self.sand_sample_to_plot = [int(f[1:]) - 1 for f in self.combobox_sand_sample_choice.currentData()]
print("self.sand_sample_to_plot ", self.sand_sample_to_plot)
# for k in self.fine_sample_to_plot:
# print("stg.Ctot_fine[k] ", stg.Ctot_fine[k])
# print(stg.fine_sample_position[k][1])
# print(stg.fine_sample_position[k][0])
# print(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][
# stg.fine_sample_position[k][1],
# stg.fine_sample_position[k][0]])
if self.sand_sample_to_plot:
self.axis_measured_vs_inverted_sand.plot(
[stg.Ctot_sand[k] for k in self.sand_sample_to_plot],
[stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][
stg.sand_sample_position[k][1],
stg.sand_sample_position[k][0]] for k in
self.sand_sample_to_plot],
ls=" ", marker='o', ms=5, mec='black', mfc="black"
)
self.axis_measured_vs_inverted_sand.plot(
[0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in self.sand_sample_to_plot]),
np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][
stg.sand_sample_position[i][1],
stg.sand_sample_position[i][0]]
for i in self.sand_sample_to_plot])]) + 1],
[0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in self.sand_sample_to_plot]),
np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][
stg.sand_sample_position[i][1],
stg.sand_sample_position[i][0]]
for i in self.sand_sample_to_plot])]) + 1],
ls="solid", linewidth=1, color="k"
)
# --- Display sample label on plot ---
for i in self.sand_sample_to_plot:
self.axis_measured_vs_inverted_sand.text(
stg.Ctot_sand[i],
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][
stg.sand_sample_position[i][1],
stg.sand_sample_position[i][0]],
stg.sample_sand[i][0],
fontstyle="normal", fontweight="light", fontsize=10)
else:
self.axis_measured_vs_inverted_sand.plot(
[stg.Ctot_sand[k] for k in range(len(stg.sample_sand))],
[stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][
stg.sand_sample_position[k][1],
stg.sand_sample_position[k][0]] for k in
range(len(stg.sample_sand))],
ls=" ", marker='o', ms=5, mec='black', mfc="black"
)
self.axis_measured_vs_inverted_sand.plot(
[0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in range(len(stg.sample_sand))]),
np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][
stg.sand_sample_position[i][1],
stg.sand_sample_position[i][0]]
for i in range(len(stg.sample_sand))])]) + 1],
[0, np.nanmax([np.nanmax([stg.Ctot_sand[c] for c in range(len(stg.sample_sand))]),
np.nanmax([stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][
stg.sand_sample_position[i][1],
stg.sand_sample_position[i][0]]
for i in range(len(stg.sample_sand))])]) + 1],
ls="solid", linewidth=1, color="k"
)
for j in range(len(stg.sample_sand)):
self.axis_measured_vs_inverted_sand.text(
stg.Ctot_sand[j],
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()][
stg.sand_sample_position[j][1],
stg.sand_sample_position[j][0]],
stg.sample_sand[j][0],
fontstyle="normal", fontweight="light", fontsize=10)
self.axis_measured_vs_inverted_sand.set_xlabel("Measured SSC sand (g/L)")
self.axis_measured_vs_inverted_sand.set_ylabel("Inverted SSC sand (g/L)")
self.figure_measured_vs_inverted_sand.canvas.draw_idle()
# --------------------------------------------------------------------------------------------------------------
# ______ _______
# | | | | \
# | | | | \
# | | | | |
# | | | | /
# |______| |________ |________/
# COMMENT OLD CODE LINE FROM HERE ...
# ### --- Layout of groupbox in the Top horizontal layout box
#
# # Acoustic inversion Options | Acoustic inversion method Settings parameter
#
# self.groupbox_acoustic_inversion_options = QGroupBox()
# self.horizontalLayoutTop.addWidget(self.groupbox_acoustic_inversion_options, 3)
#
# self.groupbox_acoustic_inversion_settings_parameter = QGroupBox()
# self.horizontalLayoutTop.addWidget(self.groupbox_acoustic_inversion_settings_parameter, 7)
#
# ### --- Layout of groupbox in the Bottom horizontal layout box
#
# # Plot SSC 2D field | Plot SSC graph sample vs inversion
#
# self.groupbox_SSC_2D_field = QGroupBox()
# self.horizontalLayoutBottom.addWidget(self.groupbox_SSC_2D_field, 6)
#
# self.groupbox_SSC_profiles_or_measured_vs_inverted = QGroupBox()
# self.horizontalLayoutBottom.addWidget(self.groupbox_SSC_profiles_or_measured_vs_inverted, 4)
#
# # =====================================================
# # TOP HORIZONTAL BOX LAYOUT
# # =====================================================
#
# # +++++++++++++++++++++++++++++++++++++++++++++++
# # | Group box Acoustic inversion options |
# # +++++++++++++++++++++++++++++++++++++++++++++++
#
# self.gridLayout_groupbox_acoustic_inversion_options = QGridLayout(self.groupbox_acoustic_inversion_options)
#
# self.groupbox_acoustic_inversion_options.setTitle("Acoustic inversion option")
#
# self.label_acoustic_inversion_method_choice = QLabel()
# self.gridLayout_groupbox_acoustic_inversion_options.addWidget(
# self.label_acoustic_inversion_method_choice, 0, 0, 1, 1)
# self.label_acoustic_inversion_method_choice.setText("Acoustic inversion method : ")
#
# self.combobox_acoustic_inversion_method_choice = QComboBox()
# self.gridLayout_groupbox_acoustic_inversion_options.addWidget(
# self.combobox_acoustic_inversion_method_choice, 0, 1, 1, 1)
# self.combobox_acoustic_inversion_method_choice.addItems([" ", "Acoustic inversion method 1"])
# self.combobox_acoustic_inversion_method_choice.currentIndexChanged.connect(
# self.acoustic_inversion_method_choice)
# # self.combobox_acoustic_inversion_method_choice.currentIndexChanged.connect(self.test)
#
# self.groupbox_calibration_samples = QGroupBox()
# self.groupbox_calibration_samples.setTitle("Sample choice for calibration")
# self.gridLayout_groupbox_acoustic_inversion_options.addWidget(self.groupbox_calibration_samples, 1, 0, 1, 2)
#
# self.gridLayout_groupbox_calibration_samples = QGridLayout(self.groupbox_calibration_samples)
#
# self.label_frequency = QLabel()
# self.label_frequency.setText("Frequency :")
# self.gridLayout_groupbox_calibration_samples.addWidget(self.label_frequency, 0, 0, 1, 1)
#
# self.combobox_frequency = QComboBox()
# self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_frequency, 0, 1, 1, 1)
# self.combobox_frequency.currentIndexChanged.connect(self.update_plot_transect_with_sample_position)
#
# self.label_sand_sample_choice = QLabel()
# self.label_sand_sample_choice.setText("Sand sediments :")
# self.gridLayout_groupbox_calibration_samples.addWidget(self.label_sand_sample_choice, 0, 2, 1, 1)
#
# self.combobox_calibration_sand_sample = CheckableComboBox()
# self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_calibration_sand_sample, 0, 3, 1, 1)
# # self.combobox_calibration_sand_sample.currentData.connect(self.update_plot_transect_with_sample_position)
# self.combobox_calibration_sand_sample.currentIndexChanged.connect(
# self.update_plot_transect_with_sample_position)
# # self.combobox_calibration_sand_sample.currentIndexChanged.connect(self.sample_choice)
#
# self.label_fine_sample_choice = QLabel()
# self.label_fine_sample_choice.setText("Fine sediments :")
# self.gridLayout_groupbox_calibration_samples.addWidget(self.label_fine_sample_choice, 0, 4, 1, 1)
#
# self.combobox_calibration_fine_sample = CheckableComboBox()
# self.gridLayout_groupbox_calibration_samples.addWidget(self.combobox_calibration_fine_sample, 0, 5, 1, 1)
# # self.combobox_calibration_fine_sample.currentData.connect(self.update_plot_transect_with_sample_position)
# self.combobox_calibration_fine_sample.currentIndexChanged.connect(
# self.update_plot_transect_with_sample_position)
#
# # self.combobox_calibration_fine_sample.currentIndexChanged.connect(self.sample_choice)
#
# self.groupbox_plot_sample_position_on_transect = QGroupBox()
# self.gridLayout_groupbox_calibration_samples.addWidget(self.groupbox_plot_sample_position_on_transect, 1, 0, 1, 6)
# self.verticalLayout_groupbox_plot_sample_position_on_transect = QVBoxLayout(self.groupbox_plot_sample_position_on_transect)
#
# self.canvas_plot_sample_position_on_transect = None
# # self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.canvas_plot_sample_position_on_transect)
#
#
# # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# # | Group box Acoustic inversion method settings parameter |
# # +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# self.gridLayout_groupbox_acoustic_inversion_settings_parameter \
# = QGridLayout(self.groupbox_acoustic_inversion_settings_parameter)
#
# self.groupbox_acoustic_inversion_settings_parameter.setTitle("Acoustic inversion method settings parameter")
#
# self.groupbox_parameter = QGroupBox()
# self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.groupbox_parameter, 0, 0, 1, 2)
#
# self.gridLayout_groupbox_parameter = QGridLayout(self.groupbox_parameter)
#
# # self.label_temperature = QLabel()
# # self.label_temperature.setText("Temperature : ")
# # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.label_temperature, 0, 0, 1, 1)
# # self.gridLayout_groupbox_parameter.addWidget(self.label_temperature, 0, 0, 1, 1)
# # self.spinbox_temperature = QDoubleSpinBox()
# # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.spinbox_temperature, 0, 1, 1, 1)
# # self.gridLayout_groupbox_parameter.addWidget(self.spinbox_temperature, 0, 1, 1, 1)
# # self.spinbox_temperature.valueChanged.connect(self.temperature_value)
#
# self.label_frequencies_pairs_to_compute_VBI = QLabel()
# self.label_frequencies_pairs_to_compute_VBI.setText("Frequencies for VBI")
# self.gridLayout_groupbox_parameter.addWidget(
# self.label_frequencies_pairs_to_compute_VBI, 0, 1, 1, 1)
#
# # self.combobox_frequencies_VBI = QComboBox()
# # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(
# # self.combobox_frequencies_VBI, 1, 1, 1, 1)
# # self.combobox_frequencies_VBI.currentIndexChanged.connect(self.frequencies_pair_choice_to_compute_VBI)
#
# self.label_ks = QLabel()
# self.label_ks.setText("ks")
# self.gridLayout_groupbox_parameter.addWidget(self.label_ks, 0, 2, 1, 1)
#
# self.label_sv = QLabel()
# self.label_sv.setText("sv")
# self.gridLayout_groupbox_parameter.addWidget(self.label_sv, 0, 3, 1, 1)
#
# self.label_X = QLabel()
# self.label_X.setText("X")
# self.gridLayout_groupbox_parameter.addWidget(self.label_X, 0, 4, 1, 1)
#
# self.label_alphas = QLabel()
# self.label_alphas.setText("\u03B1s")
# self.gridLayout_groupbox_parameter.addWidget(self.label_alphas, 0, 5, 1, 1)
#
# self.label_zeta = QLabel()
# self.label_zeta.setText("\u03B6")
# self.gridLayout_groupbox_parameter.addWidget(self.label_zeta, 0, 6, 1, 1)
#
# self.label_freq1 = QLabel()
# self.label_freq1.setText("Frequency 1 : ")
# self.gridLayout_groupbox_parameter.addWidget(self.label_freq1, 1, 0, 1, 1)
#
# self.label_freq2 = QLabel()
# self.label_freq2.setText("Frequency 2 : ")
# self.gridLayout_groupbox_parameter.addWidget(self.label_freq2, 2, 0, 1, 1)
#
# self.combobox_freq1 = QComboBox()
# self.gridLayout_groupbox_parameter.addWidget(self.combobox_freq1, 1, 1, 1, 1)
#
# self.combobox_freq2 = QComboBox()
# self.gridLayout_groupbox_parameter.addWidget(self.combobox_freq2, 2, 1, 1, 1)
#
# self.spinbox_ks_freq1 = QDoubleSpinBox()
# self.spinbox_ks_freq1.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_ks_freq1, 1, 2, 1, 1)
#
# self.spinbox_ks_freq2 = QDoubleSpinBox()
# self.spinbox_ks_freq2.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_ks_freq2, 2, 2, 1, 1)
#
# self.spinbox_sv_freq1 = QDoubleSpinBox()
# self.spinbox_sv_freq1.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_sv_freq1, 1, 3, 1, 1)
#
# self.spinbox_sv_freq2 = QDoubleSpinBox()
# self.spinbox_sv_freq2.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_sv_freq2, 2, 3, 1, 1)
#
# self.spinbox_X = QDoubleSpinBox()
# self.spinbox_X.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_X, 1, 4, 1, 1)
#
# self.spinbox_alphas_freq1 = QDoubleSpinBox()
# self.spinbox_alphas_freq1.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_alphas_freq1, 1, 5, 1, 1)
#
# self.spinbox_alphas_freq2 = QDoubleSpinBox()
# self.spinbox_alphas_freq2.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_alphas_freq2, 2, 5, 1, 1)
#
# self.spinbox_zeta_freq1 = QDoubleSpinBox()
# self.spinbox_zeta_freq1.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_zeta_freq1, 1, 6, 1, 1)
#
# self.spinbox_zeta_freq2 = QDoubleSpinBox()
# self.spinbox_zeta_freq2.setDecimals(5)
# self.gridLayout_groupbox_parameter.addWidget(self.spinbox_zeta_freq2, 2, 6, 1, 1)
#
# # self.label_frequency_to_compute_SSC = QLabel()
# # self.label_frequency_to_compute_SSC.setText("frequencies for SSC : ")
# # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(
# # # self.label_frequency_to_compute_SSC, 2, 0, 1, 1)
# # self.gridLayout_groupbox_parameter.addWidget(self.label_frequency_to_compute_SSC, 3, 0, 1, 1)
#
# # self.combobox_frequency_SSC = QComboBox()
# # # self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(
# # # self.combobox_frequency_SSC, 2, 1, 1, 1)
# # self.gridLayout_groupbox_parameter.addWidget(self.combobox_frequency_SSC, 3, 1, 1, 1)
# # self.combobox_frequency_SSC.currentIndexChanged.connect(self.frequency_choice_to_compute_SSC)
#
# self.pushbutton_run = QPushButton()
# self.pushbutton_run.setText("RUN")
# self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.pushbutton_run, 1, 0, 1, 1)
# self.pushbutton_run.clicked.connect(self.compute_acoustic_inversion_method_high_concentration)
#
# self.pushbutton_plot = QPushButton()
# self.pushbutton_plot.setText("PLOT")
# self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.pushbutton_plot, 1, 1, 1, 1)
# self.pushbutton_plot.clicked.connect(self.plot_SSC_fine)
# self.pushbutton_plot.clicked.connect(self.plot_SSC_sand)
# # self.pushbutton_plot.clicked.connect(self.insert_slider_for_vertical_profile_figure_area)
# self.pushbutton_plot.clicked.connect(self.plot_inverted_SSC_sand_vertical_profile)
# # self.pushbutton_plot.clicked.connect(self.plot_inverted_SSC_vs_measured_SSC)
# # self.pushbutton_plot.clicked.connect(self.plot_inverted_SSC_vs_measured_SSC_OR_inverted_SSC_vertical_profile)
#
# # =====================================================
# # BOTTOM HORIZONTAL BOX LAYOUT
# # =====================================================
#
# # +++++++++++++++++++++++++++++++++++++++++++++++
# # | Group box SSC 2D field |
# # +++++++++++++++++++++++++++++++++++++++++++++++
#
# self.verticalLayout_groupbox_SSC_2D_field = QVBoxLayout(self.groupbox_SSC_2D_field)
# self.groupbox_SSC_2D_field.setTitle("Suspended Sediment Concentration 2D plot")
#
# self.groupbox_plot_SSC_sand = QGroupBox()
# self.verticalLayout_groupbox_plot_SSC_sand = QVBoxLayout(self.groupbox_plot_SSC_sand)
# self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.groupbox_plot_SSC_sand)
#
# self.figure_SSC_sand, self.axis_SSC_sand = plt.subplots(nrows=1, ncols=1, layout="constrained")
# self.canvas_SSC_sand = FigureCanvas(self.figure_SSC_sand)
# self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand)
#
# self.groupbox_plot_SSC_fine = QGroupBox()
# self.verticalLayout_groupbox_plot_SSC_fine = QVBoxLayout(self.groupbox_plot_SSC_fine)
# self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.groupbox_plot_SSC_fine)
#
# self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(nrows=1, ncols=1, layout="constrained")
# self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine)
# self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine)
#
# # +++++++++++++++++++++++++++++++++++++++++++++++
# # | Group box plot samples vs inversion |
# # +++++++++++++++++++++++++++++++++++++++++++++++
#
# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted = QVBoxLayout(self.groupbox_SSC_profiles_or_measured_vs_inverted)
# # self.groupbox_SSC_profiles_or_measured_vs_inverted.setTitle("Suspended Sediment Concentration : sample vs inversion")
#
# self.horizontalLayout_fig_choice = QHBoxLayout()
# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addLayout(self.horizontalLayout_fig_choice)
# self.spacerItem_fig_choice = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum)
# self.horizontalLayout_fig_choice.addSpacerItem(self.spacerItem_fig_choice)
# self.combobox_fig_choice = QComboBox()
# self.combobox_fig_choice.addItems([
# "Inverted SSC sand vertical profile",
# "Inverted SSC fine vertical profile",
# "Inverted SSC vs Measured SSC"])
# self.horizontalLayout_fig_choice.addWidget(self.combobox_fig_choice)
#
# # self.combobox_fig_choice.currentIndexChanged.connect(self.plot_inverted_SSC_fine_vertical_profile)
# # self.combobox_fig_choice.currentIndexChanged.connect(self.plot_inverted_SSC_sand_vertical_profile)
# # self.combobox_fig_choice.currentIndexChanged.connect(self.plot_inverted_SSC_vs_measured_SSC)
#
# # self.combobox_fig_choice.currentIndexChanged.connect(self.plot_inverted_SSC_vs_measured_SSC_OR_inverted_SSC_vertical_profile)
#
# # --- Figure, axis, canvas for Inverted SSC vs Measured SSC
# self.figure_SSC_measured_vs_inverted, self.axis_SSC_measured_vs_inverted = plt.subplots(nrows=1, ncols=1,
# layout="constrained")
# self.canvas_SSC_measured_vs_inverted = FigureCanvas(self.figure_SSC_measured_vs_inverted)
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(self.canvas_SSC_measured_vs_inverted)
#
# # --- Figure, axis, canvas for SSC sand vertical profile
# self.figure_SSC_sand_vertical_profile, self.axis_SSC_sand_vertical_profile = (
# plt.subplots(nrows=1, ncols=1, layout="constrained"))
# self.canvas_SSC_sand_vertical_profile = FigureCanvas(self.figure_SSC_sand_vertical_profile)
# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(
# self.canvas_SSC_sand_vertical_profile)
#
# # --- Figure, axis, canvas for SSC fine vertical profile
# # self.figure_SSC_fine_vertical_profile, self.axis_SSC_fine_vertical_profile = (
# # plt.subplots(nrows=1, ncols=1, layout="constrained"))
# # self.canvas_SSC_fine_vertical_profile = FigureCanvas(self.figure_SSC_fine_vertical_profile)
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(
# # self.canvas_SSC_fine_vertical_profile)
#
# # --- Slider for moving the profile ---
# self.horizontalLayout_slider = QHBoxLayout()
# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addLayout(self.horizontalLayout_slider)
#
# self.pushbutton_slider_left = QPushButton()
# self.pushbutton_slider_left.setIcon(self.icon_triangle_left)
# self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left)
#
# self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left)
#
# self.pushbutton_slider_right = QPushButton()
# self.pushbutton_slider_right.setIcon(self.icon_triangle_right)
# self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right)
#
# self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right)
#
# self.lineEdit_slider = QLineEdit()
# self.lineEdit_slider.setText("1")
# self.lineEdit_slider.setFixedWidth(50)
# self.horizontalLayout_slider.addWidget(self.lineEdit_slider)
#
# self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit)
#
# self.slider = QSlider()
# self.horizontalLayout_slider.addWidget(self.slider, 9)
#
# self.slider.setOrientation(Qt.Horizontal)
# self.slider.setCursor(Qt.OpenHandCursor)
# self.slider.setMinimum(1)
# self.slider.setMaximum(10)
# self.slider.setTickInterval(1)
# self.slider.setValue(1)
#
# self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider)
# self.slider.valueChanged.connect(self.plot_inverted_SSC_sand_vertical_profile)
# self.slider.valueChanged.connect(self.plot_SSC_sand)
#
# # self.verticalLayout_groupbox_sediment_concentration_2Dplot = QVBoxLayout(self.groupbox_sediment_concentration_2Dplot)
# #
# # self.figure_SSC_2Dplot, self.axis_SSC_2Dplot = plt.subplots(nrows=2, ncols=1)
# # self.canvas_sediments2DPlot = FigureCanvas(self.figure_SSC_2Dplot)
# # self.toolbar_concentration_2Dplot = NavigationToolBar(self.canvas_sediments2DPlot, self)
# # self.plot_SSC_fine()
# # self.plot_SSC_sand()
# # # self.verticalLayout_groupbox_sediment_concentration_2Dplot.addWidget(self.toolbar_concentration_2Dplot)
# # self.verticalLayout_groupbox_sediment_concentration_2Dplot.addWidget(self.canvas_sediments2DPlot)
# #
# # # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.canvas_sediments2DPlot)
# # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.groupbox_sediment_concentration_2Dplot, 7)
# #
# #
# # # self.groupbox_sediment_concentration_sample_vs_measurement.setTitle(
# # # "Suspended sediment concentration plot : acoustic inversion theory VS measurements")
# #
# # self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement = QVBoxLayout(
# # self.groupbox_sediment_concentration_sample_vs_measurement)
# #
# # self.figure_inverseSSC_vs_measuredSSC, self.axis_inverseSSC_vs_measuredSSC = plt.subplots(nrows=1, ncols=1)
# # self.canvas_InverseSSC_vs_MeasuredSSC = FigureCanvas(self.figure_inverseSSC_vs_measuredSSC)
# # self.toolbar_InverseSSC_vs_MeasuredSSC = NavigationToolBar(self.canvas_InverseSSC_vs_MeasuredSSC, self)
# # # self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement.addWidget(
# # # self.toolbar_InverseSSC_vs_MeasuredSSC)
# # self.verticalLayout_groupbox_sediment_concentration_sample_vs_measurement.addWidget(
# # self.canvas_InverseSSC_vs_MeasuredSSC, 3)
# # # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(self.canvas_InverseSSC_vs_MeasuredSSC)
# #
# # self.horizontalLayout_Bottom_acousticInversionTab.addWidget(
# # self.groupbox_sediment_concentration_sample_vs_measurement)
# #
# # self.verticalLayout_acoustic_inversion_tab.addLayout(self.horizontalLayout_Bottom_acousticInversionTab, 6)
# #
# # self.retranslate_acoustic_inversion_tab()
#
# # ----------------------------------------------------------------------------------------------------------------
# # -------------------- Functions --------------------
#
# # def retranslate_acoustic_inversion_tab(self):
# #
# # self.groupbox_AcousticInversionOption.setTitle(_translate("CONSTANT_STRING", cs.ACOUSTIC_INVERSION_OPTIONS))
# # self.groupbox_sediment_concentration_2Dplot.setTitle(_translate("CONSTANT_STRING", cs.FINE_AND_SAND_SEDIMENTS_CONCENTRATION_2D_FIELD))
# # self.groupbox_sediment_concentration_sample_vs_measurement.setTitle(_translate("CONSTANT_STRING", cs.SUSPENDED_SEDIMENT_CONCENTRATION_PLOT))
# def acoustic_inversion_method_choice(self):
# print("acoustic_inversion_method_choice")
# if self.combobox_acoustic_inversion_method_choice.currentIndex() == 1:
#
# self.plot_transect_with_sample_position()
#
# # --- add items in combobox of samples (sand and vertical fine) to calibrate acoustic inversion method ---
#
# # samples_vertical_line = np.split(stg.samples, np.where(np.diff(stg.sample_time) != 0)[0]+1)
#
# # self.combobox_calibration_sand_sample.addItem(" ")
# # for s in samples_vertical_line:
# # self.combobox_calibration_sand_sample.addItem(" - ".join([i for i in s]))
#
# self.combobox_frequency.addItems(stg.freq_text)
#
# self.combobox_calibration_sand_sample.addItems(stg.samples)
# # self.combobox_calibration_sand_sample.currentData.connect(self.update_plot_transect_with_sample_position)
#
# self.combobox_calibration_fine_sample.addItems(stg.samples)
# # self.combobox_calibration_fine_sample.currentData.connect(self.update_plot_transect_with_sample_position)
#
# self.combobox_freq1.addItems(stg.freq_text)
# self.combobox_freq2.addItems(stg.freq_text)
#
#
# # for i in range(len(samples_vertical_line)):
# # self.combobox_calibration_samples.setItemChecked(i, False)
#
# # --- add items in combobox of frequencies for VBI computation ---
# # self.combobox_frequencies_VBI.addItem(" ")
# # for k in combinations(stg.freq_text, 2):
# # self.combobox_frequencies_VBI.addItem(k[0] + " - " + k[1])
# # print(k)
# # for i in range(len(list(combinations(stg.freq_text, 2)))):
# # self.combobox_frequencies_VBI.setItemChecked(i, False)
#
# # print(f"stg.fine_sediment_columns length : {len(stg.fine_sediment_columns)}")
# # print(f"stg.fine_sediment_columns : {stg.fine_sediment_columns}")
# # print(f"stg.frac_vol_fine.shape : {stg.frac_vol_fine.shape}")
# # print(f"stg.frac_vol_fine : {stg.frac_vol_fine}")
#
# def plot_transect_with_sample_position(self):
# print("plot_transect_with_sample_position")
# if self.canvas_plot_sample_position_on_transect == None:
#
# self.verticalLayout_groupbox_plot_sample_position_on_transect.removeWidget(self.canvas_plot_sample_position_on_transect)
# self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \
# plt.subplots(nrows=1, ncols=1, layout="constrained")
# self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect)
# self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(self.canvas_plot_sample_position_on_transect)
#
# if stg.BS_stream_bed.size == 0:
#
# val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :])
# val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :])
# if val_min == 0:
# val_min = 1e-5
#
# self.axis_plot_sample_position_on_transect.pcolormesh(
# stg.t[stg.freq_bottom_detection, :],
# -stg.r[stg.freq_bottom_detection, :],
# stg.BS_cross_section[stg.freq_bottom_detection, :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# if stg.r_bottom.size != 0:
# self.axis_plot_sample_position_on_transect.plot(
# stg.t[stg.freq_bottom_detection, :],
# -stg.r_bottom, color='black', linewidth=1, linestyle="solid")
#
# else:
#
# val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :])
# val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :])
# if val_min == 0:
# val_min = 1e-5
#
# self.axis_plot_sample_position_on_transect.pcolormesh(
# stg.t[stg.freq_bottom_detection, :],
# -stg.r[stg.freq_bottom_detection, :],
# stg.BS_stream_bed[stg.freq_bottom_detection, :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# if stg.r_bottom.size != 0:
# self.axis_plot_sample_position_on_transect.plot(
# stg.t[stg.freq_bottom_detection, :], -stg.r_bottom,
# color='black', linewidth=1, linestyle="solid")
#
# self.axis_plot_sample_position_on_transect.set_xticks([])
# self.axis_plot_sample_position_on_transect.set_yticks([])
# self.figure_plot_sample_position_on_transect.canvas.draw_idle()
#
# def update_plot_transect_with_sample_position(self):
#
# # --- List selected sand and fine samples ---
# sand_position_list, fine_position_list = self.sample_choice()
#
# # --- Create canvas of Matplotlib figure ---
# if stg.BS_raw_data.size == 0:
#
# self.verticalLayout_groupbox_plot_sample_position_on_transect.removeWidget(
# self.canvas_plot_sample_position_on_transect)
# self.figure_plot_sample_position_on_transect, self.axis_plot_sample_position_on_transect = \
# plt.subplots(nrows=1, ncols=1, layout="constrained")
# self.canvas_plot_sample_position_on_transect = FigureCanvas(self.figure_plot_sample_position_on_transect)
# self.verticalLayout_groupbox_plot_sample_position_on_transect.addWidget(
# self.canvas_plot_sample_position_on_transect)
#
# if sand_position_list:
# self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list],
# stg.sample_depth[sand_position_list],
# marker="o", s=20)
#
# if fine_position_list:
# self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list],
# stg.sample_depth[fine_position_list],
# marker="o", s=14)
#
# self.axis_plot_sample_position_on_transect.set_xticks([])
# self.axis_plot_sample_position_on_transect.set_yticks([])
# self.figure_plot_sample_position_on_transect.canvas.draw_idle()
#
# elif stg.BS_stream_bed.size == 0:
#
# val_min = np.nanmin(stg.BS_cross_section[stg.freq_bottom_detection, :, :])
# val_max = np.nanmax(stg.BS_cross_section[stg.freq_bottom_detection, :, :])
# if val_min == 0:
# val_min = 1e-5
#
# self.axis_plot_sample_position_on_transect.pcolormesh(
# stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :],
# stg.BS_cross_section[self.combobox_frequency.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# if stg.r_bottom.size != 0:
# self.axis_plot_sample_position_on_transect.plot(
# stg.t[stg.freq_bottom_detection, :], -stg.r_bottom,
# color='black', linewidth=1, linestyle="solid")
#
# if sand_position_list:
# self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list],
# stg.sample_depth[sand_position_list],
# marker="o", s=20)
# # markeredgecolor='k', markerfacecolor='none')
#
# if fine_position_list:
# self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list],
# stg.sample_depth[fine_position_list],
# marker="o", s=14)
# # markeredgecolor='k', markerfacecolor='k')
#
# self.axis_plot_sample_position_on_transect.set_xticks([])
# self.axis_plot_sample_position_on_transect.set_yticks([])
# self.figure_plot_sample_position_on_transect.canvas.draw_idle()
#
# else:
#
# val_min = np.nanmin(stg.BS_stream_bed[stg.freq_bottom_detection, :, :])
# val_max = np.nanmax(stg.BS_stream_bed[stg.freq_bottom_detection, :, :])
# if val_min == 0:
# val_min = 1e-5
#
# self.axis_plot_sample_position_on_transect.pcolormesh(
# stg.t[stg.freq_bottom_detection, :], -stg.r[stg.freq_bottom_detection, :],
# stg.BS_stream_bed[self.combobox_frequency.currentIndex(), :, :],
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
#
# if stg.r_bottom.size != 0:
# self.axis_plot_sample_position_on_transect.plot(
# stg.t[stg.freq_bottom_detection, :], -stg.r_bottom, color='black', linewidth=1, linestyle="solid")
#
# if sand_position_list:
# self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[sand_position_list],
# stg.sample_depth[sand_position_list],
# marker="o", s=20)
#
# if fine_position_list:
# self.axis_plot_sample_position_on_transect.scatter(stg.sample_time[fine_position_list],
# stg.sample_depth[fine_position_list],
# marker="o", s=14)
#
# self.axis_plot_sample_position_on_transect.set_xticks([])
# self.axis_plot_sample_position_on_transect.set_yticks([])
# self.figure_plot_sample_position_on_transect.canvas.draw_idle()
#
# def sample_choice(self):
# # --- List selected sand samples ---
# sand_position_list = [int(s[1:])-1 for s in self.combobox_calibration_sand_sample.currentData()]
# print(f"sand_position_list : {sand_position_list}")
# # print(f"sand samples checked : {sand_samples_checked}")
#
# # --- List selected fine samples ---
# fine_position_list = [int(s[1:])-1 for s in self.combobox_calibration_fine_sample.currentData()]
# print(f"fine_position_list : {fine_position_list}")
# # print(f"fine samples checked : {fine_samples_checked}")
# return sand_position_list, fine_position_list
#
# def frequencies_pair_choice_to_compute_VBI(self):
# freq_combination = list(combinations(stg.freq, 2))
# frequencies_position = []
# # for i in range(self.combobox_frequencies_VBI.count()):
# # if self.combobox_frequencies_VBI.itemChecked(i):
# # frequencies_position.append(i)
# # elif (i in frequencies_position) and (not self.combobox_frequencies_VBI.itemChecked(i)):
# # frequencies_position.remove(i)
# frequencies_position.append(self.combobox_frequencies_VBI.currentIndex())
# print(f"frequencies_position : {frequencies_position}")
#
# if len(frequencies_position) != 0:
# # print(frequencies_position)
# # print(freq_combination[frequencies_position[0]][0], freq_combination[frequencies_position[0]][1])
# stg.frequencies_to_compute_VBI = (
# np.array([[int(np.where(stg.freq == freq_combination[frequencies_position[0]-1][0])[0][0]),
# freq_combination[frequencies_position[0]-1][0]],
# [int(np.where(stg.freq == freq_combination[frequencies_position[0]-1][1])[0][0]),
# freq_combination[frequencies_position[0]-1][1]]]))
# print(f"stg.frequencies_to_compute_VBI : {stg.frequencies_to_compute_VBI}")
#
# # --- add items in combobox of frequency for SSC computation ---
# # for k in range(stg.frequencies_to_compute_VBI.shape[0]+1):
# # self.combobox_frequency_SSC.removeItem(k)
# self.combobox_frequency_SSC.clear()
# for k in range(stg.frequencies_to_compute_VBI.shape[0]+1):
# if k == 0:
# self.combobox_frequency_SSC.addItem(" ")
# else:
# self.combobox_frequency_SSC.addItem(str(1e-6*stg.frequencies_to_compute_VBI[k-1, 1]) + " MHz")
# # for i in range(stg.frequencies_to_compute_VBI.shape[0]):
# # self.combobox_frequency_SSC.setItemChecked(i, False)
#
# print("frequencies to compute VBI", stg.frequencies_to_compute_VBI)
#
# def frequency_choice_to_compute_SSC(self):
# print(self.combobox_frequency_SSC.currentText())
# print(self.combobox_frequency_SSC.currentIndex())
# # print(self.combobox_frequency_SSC.itemChecked(index))
#
#
# # if self.combobox_frequency_SSC.itemChecked(index):
# # # itemChecked(index)): # currentIndex() == 0) or (self.combobox_frequency_SSC.currentIndex() == 1):
# # print(self.combobox_frequency_SSC.currentText())
# # print(stg.freq_text)
# # print(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText()))
#
# # stg.frequency_to_compute_SSC \
# # = np.array([int(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText())[0][0]),
# # stg.freq[int(np.where(np.array(stg.freq_text) == self.combobox_frequency_SSC.currentText())[0][0])]])
# #
# # print("stg.frequency_to_compute_SSC ", stg.frequency_to_compute_SSC)
#
# # def temperature_value(self):
# # stg.temperature = self.spinbox_temperature.value()
# # print(stg.temperature)
#
# def compute_sound_velocity(self):
# stg.water_velocity = self.inv_hc.water_velocity(stg.temperature)
# print("water velocity ", stg.water_velocity)
#
# # def compute_kt(self, freq_ind):
# #
# # # stg.kt_corrected = self.inv_hc.kt_corrected(stg.r[int(stg.frequency_to_compute_SSC[0]), :], stg.water_velocity,
# # # stg.gain_rx[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]],
# # # stg.gain_tx[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]],
# # # stg.kt[[int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])]])
# #
# # if stg.ABS_name == "Aquascat 1000R":
# # kt_corrected = self.inv_hc.kt_corrected(stg.r[0, :], stg.water_velocity,
# # stg.gain_rx[freq_ind], stg.gain_tx[freq_ind], stg.kt[0, freq_ind])
# # kt_corrected_2D = np.repeat(kt_corrected, stg.r.shape[1], axis=0)
# # print("kt 2D ", kt_corrected_2D)
# # print("kt 2D shape ", kt_corrected_2D.shape)
# # kt_corrected_3D = np.zeros((kt_corrected_2D.shape[1], kt_corrected_2D.shape[0], stg.t.shape[1]))
# # for k in range(kt_corrected_2D.shape[1]):
# # kt_corrected_3D[k, :, :] = np.repeat(kt_corrected_2D, stg.t.shape[1], axis=1)[:,
# # k * stg.t.shape[1]:(k + 1) * stg.t.shape[1]]
# # print("kt 3D ", kt_corrected_3D)
# # print("kt 3D shape ", kt_corrected_3D.shape)
# # elif stg.ABS_name == "UB-SediFlow":
# # stg.kt_corrected = np.array([[0.003, 0.006]])
# # print("kt ", stg.kt_corrected)
# # print("kt shape ", stg.kt_corrected.shape)
# # stg.kt_corrected_2D = np.array(np.repeat(stg.kt_corrected, stg.r.shape[1], axis=0))
# # print("kt 2D shape ", stg.kt_corrected_2D.shape)
# # stg.kt_corrected_3D = np.zeros((stg.kt_corrected_2D.shape[1], stg.kt_corrected_2D.shape[0], stg.t.shape[1]))
# # for k in range(stg.kt_corrected_2D.shape[1]):
# # stg.kt_corrected_3D[k, :, :] = np.repeat(stg.kt_corrected_2D, stg.t.shape[1], axis=1)[:,
# # k * stg.t.shape[1]:(k + 1) * stg.t.shape[1]]
# # print("kt corrected 3D zeros shape ", stg.kt_corrected_3D.shape)
# #
# # print("kt ", stg.kt_corrected)
# # # print("kt shape ", stg.kt_corrected.shape)
# #
# # # stg.kt_corrected_2D = np.repeat(stg.kt_corrected, stg.r.shape[1], axis=0)
# #
# # # stg.kt_corrected_3D = np.zeros((stg.kt_corrected_2D.shape[1], stg.kt_corrected_2D.shape[0], stg.t.shape[1]))
# # # print("stg.t.shape ", stg.t.shape)
# # # print("kt corrected 3D zeros shape ", stg.kt_corrected_3D.shape)
# # # for k in range(stg.kt_corrected_2D.shape[1]):
# # # stg.kt_corrected_3D[k, :, :] = np.repeat(stg.kt_corrected_2D, stg.t.shape[1], axis=1)[:, k*stg.t.shape[1]:(k+1)*stg.t.shape[1]]
# #
# # # print("kt 2D", np.repeat(stg.kt_corrected[:, :, np.newaxis], stg.t.shape[0], axis=2))
#
# def compute_J(self, freq_ind, kt):
# if stg.ABS_name == "Aquascat 1000R":
# print(f"stg.BS_stream_bed.shape : {stg.BS_stream_bed.shape}")
#
# if stg.BS_stream_bed.size != 0:
#
# if stg.BS_stream_bed_pre_process_SNR.size != 0:
# print("1/ stg.BS_stream_bed_pre_process_SNR")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_stream_bed_pre_process_SNR[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_SNR.shape[2]],
# kt[freq_ind, :, :]))
#
# elif stg.BS_stream_bed_pre_process_average.size != 0:
# print("2/ stg.BS_stream_bed_pre_process_average")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_stream_bed_pre_process_average[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_average.shape[2]],
# kt[freq_ind, :, :]))
#
# else:
# print("3/ stg.BS_stream_bed")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_stream_bed[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_stream_bed.shape[2]],
# kt[freq_ind, :, :]))
#
# elif stg.BS_cross_section.size != 0:
#
# if stg.BS_cross_section_pre_process_SNR.size != 0:
# print("1/ stg.BS_cross_section_pre_process_SNR")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_cross_section_pre_process_SNR[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_cross_section_pre_process_SNR.shape[2]],
# kt[freq_ind, :, :]))
#
# elif stg.BS_cross_section_pre_process_average.size != 0:
# print("2/ stg.BS_cross_section_pre_process_average")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(stg.BS_cross_section_pre_process_average[freq_ind, :, :],
# stg.r_2D[0, :, :stg.BS_cross_section_pre_process_average.shape[2]],
# kt[freq_ind, :, :]))
#
# else:
# print("3/ stg.BS_cross_section")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_cross_section[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_cross_section.shape[2]],
# kt[freq_ind, :, :]))
#
# elif stg.ABS_name == "UB-SediFlow":
#
# if stg.BS_stream_bed.size != 0:
#
# if stg.BS_stream_bed_pre_process_SNR.size != 0:
# print("1/ stg.BS_stream_bed_pre_process_SNR")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_stream_bed_pre_process_SNR[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_SNR.shape[2]],
# kt[freq_ind, :, :]))
#
# elif stg.BS_stream_bed_pre_process_average.size != 0:
# print("2/ stg.BS_stream_bed_pre_process_average")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_stream_bed_pre_process_average[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_stream_bed_pre_process_average.shape[2]],
# kt[freq_ind, :, :]))
#
#
#
# else:
# print("3/ stg.BS_stream_bed")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_stream_bed[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_stream_bed.shape[2]],
# kt[freq_ind, :, :]))
#
# elif stg.BS_cross_section.size != 0:
#
# if stg.BS_cross_section_pre_process_SNR.size != 0:
# print("2/ stg.BS_cross_section_pre_process_SNR")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_cross_section_pre_process_SNR[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_cross_section_pre_process_SNR.shape[2]],
# kt[freq_ind, :, :]))
#
# if stg.BS_cross_section_pre_process_average.size != 0:
# print("1/ stg.BS_cross_section_pre_process_average")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(stg.BS_cross_section_pre_process_average[freq_ind, :, :],
# stg.r_2D[freq_ind, :,
# :stg.BS_cross_section_pre_process_average.shape[2]],
# kt[freq_ind, :, :]))
#
#
#
# else:
# print("3/ stg.BS_cross_section")
# stg.J_cross_section = (
# self.inv_hc.j_cross_section(
# stg.BS_cross_section[freq_ind, :, :],
# stg.r_2D[freq_ind, :, :stg.BS_cross_section.shape[2]],
# kt[freq_ind, :, :]))
#
#
#
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_cross_section_pre_process_average[
# # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])],
# # :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_cross_section_pre_process_average.shape[2]],
# # stg.kt_corrected_3D))
#
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_cross_section_pre_process_SNR[
# # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])],
# # :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :,
# # :stg.BS_cross_section_pre_process_SNR.shape[2]],
# # stg.kt_corrected_3D))
#
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_cross_section[
# # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])],
# # :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :,
# # :stg.BS_cross_section.shape[2]],
# # stg.kt_corrected_3D))
#
# # stg.J_stream_bed = (
# # self.inv_hc.j_cross_section(
# # stg.BS_stream_bed_pre_process_average[
# # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])],
# # :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_stream_bed_pre_process_average.shape[2]],
# # stg.kt_corrected_3D))
#
#
# # stg.J_stream_bed = (
# # self.inv_hc.j_cross_section(
# # stg.BS_stream_bed_pre_process_SNR[
# # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])],
# # :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_stream_bed_pre_process_SNR.shape[2]],
# # stg.kt_corrected_3D))
#
# # stg.J_stream_bed = (
# # self.inv_hc.j_cross_section(
# # stg.BS_stream_bed[
# # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])],
# # :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :,
# # :stg.BS_stream_bed.shape[2]],
# # stg.kt_corrected_3D))
#
# # elif (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0):
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_data_section[[int(stg.frequencies_to_compute_VBI[0, 0]),
# # int(stg.frequencies_to_compute_VBI[1, 0])], :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section.shape[2]], stg.kt_corrected_3D))
# # elif (stg.BS_data_section_averaged.size != 0) and (stg.BS_data_section_SNR_filter.size == 0):
# # print("Je suis dans ce J")
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_data_section_averaged[[0, 2], :, :],
# # stg.r_2D[[0, 2], :, :stg.BS_data_section_averaged.shape[2]],
# # stg.kt_corrected_3D[[0, 1], :, :]))
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_data_section_averaged[[int(stg.frequencies_to_compute_VBI[0, 0]),
# # int(stg.frequencies_to_compute_VBI[1, 0])], :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_averaged.shape[2]], stg.kt_corrected_3D))
# # else:
# # print("stg.r_2D.shape ", stg.r_2D.shape)
# # print("stg.kt_corrected_3D.shape ", stg.kt_corrected_3D.shape)
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_data_section_SNR_filter[[int(stg.frequencies_to_compute_VBI[0, 0]),
# # int(stg.frequencies_to_compute_VBI[1, 0])], :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_SNR_filter.shape[2]], stg.kt_corrected_3D))
# #
# # print("J ", stg.J_cross_section)
# # print("J sahpe ", stg.J_cross_section.shape)
#
# # if stg.BS_data_section.size == 0:
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_data[
# # [int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0])],
# # :, :], stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data.shape[2]],
# # stg.kt_corrected_3D))
# # elif (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0):
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_data_section[[int(stg.frequencies_to_compute_VBI[0, 0]),
# # int(stg.frequencies_to_compute_VBI[1, 0])], :, :],
# # np.array([stg.r_2D[0, :, :stg.BS_data_section.shape[2]]]),
# # stg.kt_corrected_3D))
# # elif (stg.BS_data_section_averaged.size != 0) and (stg.BS_data_section_SNR_filter.size == 0):
# # print("Je suis dans ce J")
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_data_section_averaged[[0, 2], :, :],
# # stg.r_2D[[0, 2], :, :stg.BS_data_section_averaged.shape[2]],
# # stg.kt_corrected_3D[[0, 1], :, :]))
# # # stg.J_cross_section = (
# # # self.inv_hc.j_cross_section(
# # # stg.BS_data_section_averaged[[int(stg.frequencies_to_compute_VBI[0, 0]),
# # # int(stg.frequencies_to_compute_VBI[1, 0])], :, :],
# # # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_averaged.shape[2]], stg.kt_corrected_3D))
# # else:
# # print("stg.r_2D.shape ", stg.r_2D.shape)
# # print("stg.kt_corrected_3D.shape ", stg.kt_corrected_3D.shape)
# # stg.J_cross_section = (
# # self.inv_hc.j_cross_section(
# # stg.BS_data_section_SNR_filter[[int(stg.frequencies_to_compute_VBI[0, 0]),
# # int(stg.frequencies_to_compute_VBI[1, 0])], :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.BS_data_section_SNR_filter.shape[2]],
# # stg.kt_corrected_3D))
# #
# # print("J ", stg.J_cross_section)
# # print("J sahpe ", stg.J_cross_section.shape)
#
# return stg.J_cross_section
#
# # def compute_alpha_s(self, freq, freq_ind):
# # stg.sv = self.compute_sv(freq)
# # j_cross_section = self.compute_J(freq_ind)
# # stg.alpha_s = np.log(stg.sv / j_cross_section) / (4 * stg.sample_depth[10]) - stg.water_attenuation
# # return
#
# # def compute_zeta(self):
# # stg.zeta_freq1 = self.inv_hc.zeta(0, 2)
# # stg.zeta_freq2 = self.inv_hc.zeta()
# # # stg.zeta = self.inv_hc.zeta(int(stg.frequencies_to_compute_VBI[0, 0]), int(stg.frequencies_to_compute_VBI[1, 0]))
# # print("zeta ", stg.zeta)
#
# # def compute_X(self):
# # stg.X_exponent = self.inv_hc.X_exponent(2) #self.inv_hc.X_exponent(self.combobox_frequencies_VBI.currentIndex())
# # print("X ", stg.X_exponent)
#
# # def compute_VBI(self):
# # stg.VBI_cross_section = self.inv_hc.VBI_cross_section(3e5,
# # 1e6,
# # stg.zeta[0],
# # # zeta is already limited to the frequencies pairs so that we just need to select indices 0 and 1
# # stg.zeta[1],
# # stg.J_cross_section[0, :, :],
# # stg.J_cross_section[1, :, :],
# # stg.r_2D[0, :, :stg.t.shape[1]],
# # stg.water_attenuation[0],
# # stg.water_attenuation[1],
# # stg.X_exponent)
#
# # stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.frequencies_to_compute_VBI[0, 1], stg.frequencies_to_compute_VBI[1, 1],
# # stg.zeta[0], # zeta is already limited to the frequencies pairs so that we just need to select indices 0 and 1
# # stg.zeta[1],
# # stg.J_cross_section[0, :, :],
# # stg.J_cross_section[1, :, :],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.t.shape[1]],
# # stg.water_attenuation[0],
# # stg.water_attenuation[1],
# # stg.X_exponent)
# # print("VBI shape ", stg.VBI_cross_section.shape)
# # print(int(self.combobox_frequency_SSC.currentIndex()))
# # print(stg.zeta[int(self.combobox_frequency_SSC.currentIndex())])
#
# 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.value())
# # Real cell size
# real_cell_size = cel * tau / 2 # voir fig 2.9
#
# # Converting to real cell profile
# real_r = np.zeros((stg.freq.shape[0], stg.r.shape[1]))
# for i in range(stg.freq.shape[0]):
# real_r[i, :] = stg.r[i, :] / 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)
# print(f"R_real = {R_real.shape}")
#
# return R_real
#
# def compute_acoustic_inversion_method_high_concentration(self):
#
# # --- List selected sand and fine samples ---
# sand_position_list, fine_position_list = self.sample_choice()
#
# if stg.ABS_name == "Aquascat 1000R":
#
# freq1 = int(self.combobox_freq1.currentIndex()) # 0 = 300kHz et 1 = 500kHz
# freq2 = int(self.combobox_freq2.currentIndex()) # 2 = 1MHz
# print(f"freq1 = {freq1}, freq2 = {freq2}")
#
# stg.water_velocity = self.inv_hc.water_velocity(stg.temperature)
#
# alpha_w_freq1, alpha_w_freq2 = (self.inv_hc.water_attenuation(freq=stg.freq[freq1], T=stg.temperature),
# self.inv_hc.water_attenuation(freq=stg.freq[freq2], T=stg.temperature))
# print(f"alpha_w_freq1 = {alpha_w_freq1}, alpha_w_freq2 = {alpha_w_freq2}")
#
# self.compute_sound_velocity()
#
# # print("ks value : ", self.inv_hc.ks(a_s=stg.sand_sediment_columns[5:], rho_s=2500, freq=stg.freq[0], pdf=stg.frac_vol_sand[2, :]))
#
# # ks_freq1, ks_freq2 = (
# # self.inv_hc.ks(num_sample=2, freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[2, :]),
# # self.inv_hc.ks(num_sample=2, freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[2, :]))
# ks_freq1, ks_freq2 = (
# self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :]),
# self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :]))
# # 6 = V11 , 10 = V12 sur le notebook d'Adrien
# # ks_freq1, ks_freq2 = self.inv_hc.ks()[0], self.inv_hc.ks()[2]
# print(f"ks_freq1 = {ks_freq1}, ks_freq2 = {ks_freq2}")
#
# # f = self.inv_hc.form_factor_function_MoateThorne2012(np.log(np.logspace(-10, -2, 3000)), stg.freq[2])
# # fig, ax = plt.subplots(nrows=1, ncols=1)
# # ax.plot(list(range(len(np.log(np.logspace(-10, -2, 3000))))), f, color="k", ls="solid")
# # plt.show()
#
# # sv_freq1, sv_freq2 = (
# # self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[2]),
# # self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[2]))
# sv_freq1, sv_freq2 = (
# self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[sand_position_list[0]]),
# self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[sand_position_list[0]]))
# print(f"sv_freq1 = {sv_freq1}, sv_freq2 = {sv_freq2}")
#
# X_exponent = self.inv_hc.X_exponent(freq1=stg.freq[freq1], freq2=stg.freq[freq2], sv_freq1=sv_freq1, sv_freq2=sv_freq2)
# # X_exponent = self.inv_hc.X_exponent(ind=2)
# print(f"X_exponent = {X_exponent}")
#
# stg.kt = np.array([[0.04], [0.01838], [0.03267], [0.01376]])
# kt = np.array([])
# for i, v in enumerate(stg.kt):
# kt = np.append(kt, self.inv_hc.kt_corrected(r=stg.r[i, :],
# water_velocity=stg.water_velocity,
# RxGain=stg.gain_rx[i],
# TxGain=stg.gain_tx[i],
# kt_ref=stg.kt[i]))
# kt = np.reshape(kt, (len(kt), 1))
# print(f"kt = {kt}")
# kt2D = np.repeat(np.array(kt), stg.r.shape[1], axis=1)
# print(f"kt2D.shape = {kt2D.shape}")
# # print(f"kt2D = {kt2D}")
# kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2)
# print(f"kt3D.shape = {kt3D.shape}")
# # print(f"kt3D = {kt3D}")
#
# # kt_freq1, kt_freq2 = (
# # self.inv_hc.kt_corrected(r=stg.r[0, :], water_velocity=stg.water_velocity, RxGain=stg.gain_rx[0],
# # TxGain=stg.gain_tx[0], kt_ref=stg.kt[0]),
# # self.inv_hc.kt_corrected(r=stg.r[2, :], water_velocity=stg.water_velocity, RxGain=stg.gain_rx[2],
# # TxGain=stg.gain_tx[2], kt_ref=stg.kt[2]))
# # print(f"kt_freq1 = {kt_freq1}, kt_freq2 = {kt_freq2}")
# # kt2D_freq1 = np.full((stg.r.shape[1], stg.t.shape[1]), kt_freq1)
# # kt2D_freq2 = np.full((stg.r.shape[1], stg.t.shape[1]), kt_freq2)
# # print(f"kt2D_freq1 = {kt2D_freq1.shape}")
# # print(f"kt2D_freq2 = {kt2D_freq2.shape}")
# # kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2)
# # print(f"kt_3D = {kt3D.shape}")
# # print(f"kt_3D = {kt3D}")
#
# # kt_freq1, kt_freq2 = (
# # np.full((stg.r.shape[1], stg.t.shape[1]), stg.kt[0]),
# # np.full((stg.r.shape[1], stg.t.shape[1]), stg.kt[2]))
# # print(f"kt_freq1 = {kt_freq1.shape}, kt_freq2 = {kt_freq2.shape}")
#
# J_freq1, J_freq2 = self.compute_J(freq_ind=freq1, kt=kt3D), self.compute_J(freq_ind=freq2, kt=kt3D)
# print(f"J_freq1 = {J_freq1.shape}, J_freq2 = {J_freq2.shape}")
#
# # fig, ax = plt.subplots(nrows=1, ncols=1)
# # pcm = ax.pcolormesh(stg.t[0, :], stg.r[0, :], J_freq2, cmap='rainbow', shading='gouraud')
# # fig.colorbar(pcm, ax=ax, shrink=1, location='right')
# # plt.show()
#
# # print("***************************")
# # print(sv_freq1.shape)
# # print(J_freq1.shape)
# # print(np.repeat(stg.r[0, :][:, np.newaxis], stg.t.shape[1], axis=1).shape)
# # print(np.full((stg.r.shape[1], stg.t.shape[1]), alpha_w_freq1).shape)
# # print("***************************")
#
# r_sample_ind = []
# t_sample_ind = []
# for i in range(len(stg.sample_depth[fine_position_list])): #:3
# # for i in range(len(stg.sample_depth[:3])): #:3
# # print(-stg.sample_depth[i])
# # print(-stg.sample_time[i])
# r_sample_ind.append(np.where(np.abs(stg.r[0, :] - (-stg.sample_depth[i])) ==
# np.nanmin(np.abs(stg.r[0, :] - (-stg.sample_depth[i])))))
# # print(np.abs(stg.t[0, :] - (-stg.sample_time[i])))
# t_sample_ind.append(np.where(np.abs(stg.t[0, :] - (stg.sample_time[i])) ==
# np.nanmin(np.abs(stg.t[0, :] - (stg.sample_time[i])))))
# print(f"r_sample_ind = {r_sample_ind}")
# print(f"t_sample_ind = {t_sample_ind}")
# # print("J_freq1[r_sample_ind[1][0], t_sample_ind[1][0]] ", J_freq1[r_sample_ind[1][0], t_sample_ind[1][0]])
#
# # ind_r_min = int(ind_X_min_around_sample[p, k])
# # print(f"ind_r_min = {ind_r_min}")
# # ind_r_max = int(ind_X_max_around_sample[p, k])
# # print(f"ind_r_max = {ind_r_max}")
# # ind_t_min = int(ind_r_min_around_sample[p, k])
# # print(f"ind_t_min = {ind_t_min}")
# # ind_t_max = int(ind_r_max_around_sample[p, k])
# # print(f"ind_t_max = {ind_t_max}")
#
# # print(f"stg.BS freq1 = {stg.BS_stream_bed_pre_process_average[freq1, r_sample_ind[-1], t_sample_ind[-1]]}")
# # print(f"stg.BS freq2 = {stg.BS_stream_bed_pre_process_average[freq2, r_sample_ind[-1], t_sample_ind[-1]]}")
# #
# # print(f"J_freq1[r_sample_ind[-1], t_sample_ind[-1]] {J_freq1[r_sample_ind[-1], t_sample_ind[-1]]}")
# # print(f"J_freq2[r_sample_ind[-1], t_sample_ind[-1]] {J_freq2[r_sample_ind[-1], t_sample_ind[-1]]}")
# #
# # print(f"stg.r[0, r_sample_ind[-1]] {stg.r[2, r_sample_ind[-1]]}")
#
#
# alpha_s_freq1, alpha_s_freq2 = (
# self.inv_hc.alpha_s(sv=sv_freq1, j_cross_section=J_freq1[r_sample_ind[-1], t_sample_ind[-1]], depth=stg.r[freq1, r_sample_ind[-1]], alpha_w=alpha_w_freq1),
# self.inv_hc.alpha_s(sv=sv_freq2, j_cross_section=J_freq2[r_sample_ind[-1], t_sample_ind[-1]], depth=stg.r[freq2, r_sample_ind[-1]], alpha_w=alpha_w_freq2))
# print(f"alpha_s_freq1 = {alpha_s_freq1}, alpha_s_freq2 = {alpha_s_freq2}")
#
# # range_lin_interp, M_profile_fine = self.inv_hc.M_profile_SCC_fine_interpolated(
# # sample_depth=-stg.sample_depth[:3], #:3
# # M_profile=stg.Ctot_fine[:3], #:3
# # range_cells=stg.r[0, :],
# # r_bottom=stg.r_bottom[t_sample_ind[0][0]])
# range_lin_interp, M_profile_fine = self.inv_hc.M_profile_SCC_fine_interpolated(sample_depth=-stg.sample_depth[fine_position_list], #:3
# M_profile=stg.Ctot_fine[fine_position_list], #:3
# range_cells=stg.r[0, :],
# r_bottom=[stg.r_bottom[t_sample_ind[0][0]] if stg.r_bottom.size != 0 else stg.r_bottom])
# print(f"range_lin_interp : {range_lin_interp}")
# print(f"M_profile_fine : {M_profile_fine}")
#
# M_profile_fine = M_profile_fine[:len(range_lin_interp)]
# print(f"M_profile_fine : {M_profile_fine}")
#
#
# # print("----------------------")
# # print(f"r_sample_ind[-1][0] = {r_sample_ind[-1][0][0]}")
# # print(f"M_profile_fine[:r_sample_ind[-1][0]] = ", M_profile_fine[:r_sample_ind[-1][0][0]])
# # print(f"stg.r[0, r_sample_ind[-1][0]] = ", stg.r[0, r_sample_ind[-1][0][0]])
# # print("----------------------")
#
# zeta_freq1, zeta_freq2 = (self.inv_hc.zeta(alpha_s=alpha_s_freq1, r=stg.r[freq1, :], M_profile_fine=M_profile_fine),
# self.inv_hc.zeta(alpha_s=alpha_s_freq2, r=stg.r[freq2, :], M_profile_fine=M_profile_fine))
# # zeta_freq1, zeta_freq2 = (
# # self.inv_hc.zeta(r=stg.r[0, :r_sample_ind[-1][0][0]], M_profile_fine=M_profile_fine[:r_sample_ind[-1][0][0]]),
# # self.inv_hc.zeta(r=stg.r[0, :r_sample_ind[-1][0][0]], M_profile_fine=M_profile_fine[:r_sample_ind[-1][0][0]]))
# print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}")
# # plt.figure()
# # plt.plot(stg.r[0, :], Mprofile, 'b.', -stg.sample_depth[:3], stg.Ctot_fine[:3], 'ko')
# # plt.show()
#
# # --- Fill spinboxes with values of parameters ---
# self.spinbox_ks_freq1.setValue(ks_freq1)
# self.spinbox_ks_freq2.setValue(ks_freq2)
# self.spinbox_sv_freq1.setValue(sv_freq1)
# self.spinbox_sv_freq2.setValue(sv_freq2)
# self.spinbox_X.setValue(X_exponent)
# self.spinbox_alphas_freq1.setValue(alpha_s_freq1)
# self.spinbox_alphas_freq2.setValue(alpha_s_freq2)
# self.spinbox_zeta_freq1.setValue(zeta_freq1)
# self.spinbox_zeta_freq2.setValue(zeta_freq2)
#
# # fig, ax = plt.subplots(nrows=2, ncols=1)
# # pcm1 = ax[0].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq1,
# # cmap='rainbow', vmin=0, vmax=1e-5, shading='gouraud')
# # cbar1 = fig.colorbar(pcm1, ax=ax[0], shrink=1, location='right')
# # cbar1.set_label(label='J (/m', rotation=270, labelpad=15)
# # pcm2 = ax[1].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq2,
# # cmap='rainbow', vmin=0, vmax=1e-4, shading='gouraud')
# # cbar2 = fig.colorbar(pcm2, ax=ax[1], shrink=1, location='right')
# # cbar2.set_label(label='J (/m', rotation=270, labelpad=15)
# # fig.supxlabel("Time (sec)", fontsize=10)
# # fig.supylabel("Depth (m)", fontsize=10)
# # plt.show()
#
# stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.freq[freq1], stg.freq[freq2],
# zeta_freq1, zeta_freq2,
# J_freq1, J_freq2,
# stg.r_2D[freq1, :, :stg.t.shape[1]],
# alpha_w_freq1, alpha_w_freq2,
# X_exponent)
#
# stg.SSC_fine = self.inv_hc.SSC_fine(zeta_freq2, stg.r_2D[freq2, :, :stg.t.shape[1]],
# stg.VBI_cross_section, stg.freq[freq2], X_exponent, J_freq2,
# np.full(shape=(stg.r.shape[1], stg.t.shape[1]), fill_value=alpha_w_freq2))
#
# stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section, stg.freq[freq2], X_exponent, ks_freq2)
#
# elif stg.ABS_name == "UB-SediFlow":
#
# freq1 = int(self.combobox_freq1.currentIndex()) # 0 = 500kHz
# freq2 = int(self.combobox_freq2.currentIndex()) # 1 = 1MHz
#
# stg.water_velocity = self.inv_hc.water_velocity(stg.temperature)
#
# alpha_w_freq1, alpha_w_freq2 = (self.inv_hc.water_attenuation(freq=stg.freq[freq1], T=stg.temperature),
# self.inv_hc.water_attenuation(freq=stg.freq[freq2], T=stg.temperature))
# print(f"alpha_w_freq1 = {alpha_w_freq1}, alpha_w_freq2 = {alpha_w_freq2}")
#
# self.compute_sound_velocity()
#
# # ks_freq1, ks_freq2 = 0.11373812635175432, 0.35705575378038723
# # ks_freq1, ks_freq2 = (self.inv_hc.form_factor_function_MoateThorne2012(a=100e-6, freq=stg.freq[freq1])/np.sqrt(2500*100e-6),
# # self.inv_hc.form_factor_function_MoateThorne2012(a=100e-6, freq=stg.freq[freq2])/np.sqrt(2500*100e-6))
#
# ks_freq1, ks_freq2 = (
# self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :]),
# self.inv_hc.ks(num_sample=sand_position_list[0], freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[sand_position_list[0], :]))
# # ks_freq1 = 0.05261498026985425
# # ks_freq2 = 0.19303997854869764
# print(f"ks_freq1 = {ks_freq1}, ks_freq2 = {ks_freq2}")
#
# # Fine sediments 19/05/2021 15h11 - 15h42 (locale) = 13h10 - 13h42 (UTC) --> 6 samples
# # 52 to 428 / fixed at 234
# # 14h10 = position 766
# # Sand sediments 20/05/2021 12h04 - 12h20 (locale) = 10h04 - 10h20 (UTC) --> 2 samples
# # 777 to 972 / fixed at 777
#
# sv_freq1, sv_freq2 = (
# self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[sand_position_list[0]]),
# self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[sand_position_list[0]]))
# # sv_freq1 = 0.0004956686799986783
# # sv_freq2 = 0.006672171109602389
# print(f"sv_freq1 = {sv_freq1}, sv_freq2 = {sv_freq2}")
#
# X_exponent = self.inv_hc.X_exponent(freq1=stg.freq[freq1], freq2=stg.freq[freq2],
# sv_freq1=sv_freq1, sv_freq2=sv_freq2)
# # X_exponent = 3.750708280862506
# print(f"X_exponent = {X_exponent}")
#
# # stg.kt = np.array([[1.38e-3], [6.02e-4]]) # Values of kt for 500kHz and 1MHz
# stg.kt = np.array([[0.5], [0.5]])
#
# kt = stg.kt
# # kt = np.array([])
# # for i, v in enumerate(stg.kt):
# # kt = np.append(kt, self.inv_hc.kt_corrected(r=stg.r[i, :],
# # water_velocity=stg.water_velocity,
# # RxGain=0,
# # TxGain=0,
# # kt_ref=stg.kt[i]))
# # kt = np.reshape(kt, (len(kt), 1))
# print(f"kt = {kt}, kt.shape = {kt.shape}")
# kt2D = np.repeat(np.array(kt), stg.r.shape[1], axis=1)
# print(f"kt2D.shape = {kt2D.shape}")
# # print(f"kt2D = {kt2D}")
# kt3D = np.repeat(kt2D[:, :, np.newaxis], stg.t.shape[1], axis=2)
# print(f"kt3D.shape = {kt3D.shape}")
#
# J_freq1, J_freq2 = self.compute_J(freq_ind=freq1, kt=kt3D), self.compute_J(freq_ind=freq2, kt=kt3D)
# print(f"J_freq1 = {J_freq1.shape}, J_freq2 = {J_freq2.shape}")
#
# r_sample_ind = []
# t_sample_ind = []
# for i in range(len(stg.sample_depth[fine_position_list])):
# # print(-stg.sample_depth[i])
# # print(-stg.sample_time[i])
# r_sample_ind.append(np.where(np.abs(stg.r[freq1, :] - (-stg.sample_depth[i])) ==
# np.nanmin(np.abs(stg.r[freq1, :] - (-stg.sample_depth[i])))))
# # print(np.abs(stg.t[0, :] - (-stg.sample_time[i])))
# t_sample_ind.append(np.where(np.abs(stg.t[freq1, :] - (stg.sample_time[i])) ==
# np.nanmin(np.abs(stg.t[freq1, :] - (stg.sample_time[i])))))
# print(f"r_sample_ind = {r_sample_ind}")
# print(f"t_sample_ind = {t_sample_ind}")
#
# print(f"stg.BS freq1 = {stg.BS_cross_section[freq1, r_sample_ind[-1], t_sample_ind[-1]]}")
# print(f"stg.BS freq2 = {stg.BS_cross_section[freq2, r_sample_ind[-1], t_sample_ind[-1]]}")
#
# print(f"J_freq1[r_sample_ind[-1], t_sample_ind[-1]] : {J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]}")
# # print(f"J_freq1[r_sample_ind[-1]+-n, t_sample_ind[-1]+-n] : {J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]:t_sample_ind[-1][0][0]].mean(axis=0)}")
#
# # delta_t = 0
# alpha_s_freq1, alpha_s_freq2 = (
# self.inv_hc.alpha_s(sv=sv_freq1,
# j_cross_section=np.mean(J_freq1[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]),
# depth=stg.r[freq1, r_sample_ind[-1][0][0]], alpha_w=alpha_w_freq1),
# self.inv_hc.alpha_s(sv=sv_freq2,
# j_cross_section=np.mean(J_freq2[r_sample_ind[-1][0][0], t_sample_ind[-1][0][0]]),
# # j_cross_section=J_freq2[r_sample_ind[-1], t_sample_ind[-1]],
# depth=stg.r[freq2, r_sample_ind[-1][0][0]], alpha_w=alpha_w_freq2))
#
# # avec J (alpha_w = 0.03578217234512747)
# # alpha_s_freq1 = -0.12087339
# # alpha_s_freq2 = -0.01437704
#
# # avec log(J)
# # alpha_s_freq1 = -1.91967628
# # alpha_s_freq2 = -1.87942544
#
# # --- Calculation of alpha_s with FCB slope ---
#
# # R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[1], axis=2)
# # water_attenuation = np.full((2, stg.r.shape[1], stg.t.shape[1]), 1)
# # water_attenuation[0, :, :] = alpha_w_freq1*water_attenuation[0, :, :]
# # water_attenuation[1, :, :] = alpha_w_freq2*water_attenuation[1, :, :]
# # if stg.BS_stream_bed.size == 0:
# # stg.FCB = (np.log(stg.BS_cross_section[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) +
# # 2 * water_attenuation * R_real[[freq1, freq2], :, :])
# # elif (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[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) +
# # 2 * water_attenuation * R_real[[freq1, freq2], :, :])
# # elif stg.BS_stream_bed_pre_process_SNR.size == 0:
# # stg.FCB = (np.log(stg.BS_stream_bed_pre_process_average[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) +
# # 2 * water_attenuation * R_real[[freq1, freq2], :, :])
# # else:
# # stg.FCB = (np.log(stg.BS_stream_bed_pre_process_SNR[[freq1, freq2], :, :]) + np.log(R_real[[freq1, freq2], :, :]) +
# # 2 * water_attenuation * R_real[[freq1, freq2], :, :])
# #
# # print(f"FCB shape : {stg.FCB.shape}")
# #
# # y1 = stg.FCB[freq1, 5:138, t_sample_ind[-1][0][0]]
# # x1 = stg.r[freq1, 5:138]
# # lin_reg_compute1 = stats.linregress(x1, y1)
# #
# # y2 = stg.FCB[freq2, 5:138, t_sample_ind[-1][0][0]]
# # x2 = stg.r[freq2, 5:138]
# # lin_reg_compute2 = stats.linregress(x2, y2)
# #
# # print(f"lin_reg_compute1 : {lin_reg_compute1}")
# # print(f"lin_reg_compute2 : {lin_reg_compute2}")
# #
# # fig, ax = plt.subplots(nrows=1, ncols=2)
# # ax[0].plot(x1, y1, ls='solid', c='k')
# # ax[0].plot(x1, x1*lin_reg_compute1.slope + lin_reg_compute1.intercept, ls='dashed', c='b')
# # ax[0].set_xlabel("Distance from transducer (m)")
# # ax[0].set_ylabel("FCB")
# # ax[0].set_title("Frequency 500kHz")
# # ax[1].plot(x2, y2, ls='solid', c='k')
# # ax[1].plot(x2, x2*lin_reg_compute2.slope + lin_reg_compute2.intercept, ls='solid', c='r')
# # ax[1].set_xlabel("Distance from transducer (m)")
# # ax[1].set_ylabel("FCB")
# # ax[1].set_title("Frequency 1MHz")
# # plt.show()
# #
# # alpha_s_freq1 , alpha_s_freq2 = -0.5*lin_reg_compute1.slope, -0.5*lin_reg_compute2.slope
# # alpha_s_freq1 = 0.35107724188865586
# # alpha_s_freq2 = 0.37059368399238274
# print(f"alpha_s_freq1 = {alpha_s_freq1}, alpha_s_freq2 = {alpha_s_freq2}")
#
# range_lin_interp, M_profile_fine = self.inv_hc.M_profile_SCC_fine_interpolated(
# sample_depth=-stg.sample_depth[:],
# M_profile=stg.Ctot_fine[:],
# range_cells=stg.r[0, :],
# r_bottom=np.array([])) # stg.r_bottom[t_sample_ind[0][0]] is empty
# # M_profile_fine = M_profile_fine[:len(range_lin_interp)]
# # range_lin_interp, M_profile_fine = 3.2, 6.5
#
# print(f"range_lin_interp : {range_lin_interp}")
# print(f"M_profile_fine : {M_profile_fine}")
#
# # zeta_freq1, zeta_freq2 = (alpha_s_freq1 / (M_profile_fine[0]*(3.19127224 - 0.52102404)),
# # alpha_s_freq2 / (M_profile_fine[0]*(3.19127224 - 0.52102404)))
# zeta_freq1, zeta_freq2 = (
# self.inv_hc.zeta(alpha_s=alpha_s_freq1, r=stg.r[freq1, :], M_profile_fine=M_profile_fine),
# self.inv_hc.zeta(alpha_s=alpha_s_freq2, r=stg.r[freq2, :], M_profile_fine=M_profile_fine))
# # zeta_freq1, zeta_freq2 = zeta_freq1*1e-8, zeta_freq2*1e-8
# # zeta_freq1 = 0.06417348381928434
# # zeta_freq2 = 0.06774089842814904
# # zeta_freq1, zeta_freq2 = 0.03018602, 0.05496619
# print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}")
#
# # zeta_freq1, zeta_freq2 = 1e-10*self.inv_hc.zeta(ind=1), 1e1*self.inv_hc.zeta(ind=2)
# # print(f"zeta_freq1 = {zeta_freq1}, zeta_freq2 = {zeta_freq2}")
#
# # --- Fill spinboxes with values of parameters ---
# self.spinbox_ks_freq1.setValue(ks_freq1)
# self.spinbox_ks_freq2.setValue(ks_freq2)
# self.spinbox_sv_freq1.setValue(sv_freq1)
# self.spinbox_sv_freq2.setValue(sv_freq2)
# self.spinbox_X.setValue(X_exponent)
# self.spinbox_alphas_freq1.setValue(alpha_s_freq1)
# self.spinbox_alphas_freq2.setValue(alpha_s_freq2)
# self.spinbox_zeta_freq1.setValue(zeta_freq1)
# self.spinbox_zeta_freq2.setValue(zeta_freq2)
#
# # fig, ax = plt.subplots(nrows=2, ncols=1)
# # pcm1 = ax[0].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq1,
# # cmap='rainbow', shading='gouraud')
# # cbar1 = fig.colorbar(pcm1, ax=ax[0], shrink=1, location='right')
# # cbar1.set_label(label='J (/m', rotation=270, labelpad=15)
# # pcm2 = ax[1].pcolormesh(stg.t[0, :], -stg.r[0, :], J_freq2,
# # cmap='rainbow', shading='gouraud')
# # cbar2 = fig.colorbar(pcm2, ax=ax[1], shrink=1, location='right')
# # cbar2.set_label(label='J (/m', rotation=270, labelpad=15)
# # fig.supxlabel("Time (sec)", fontsize=10)
# # fig.supylabel("Depth (m)", fontsize=10)
# # plt.show()
#
# stg.VBI_cross_section = self.inv_hc.VBI_cross_section(stg.freq[freq1], stg.freq[freq2],
# zeta_freq1, zeta_freq2,
# J_freq1, J_freq2,
# stg.r_2D[freq2, :, :stg.t.shape[1]],
# alpha_w_freq1, alpha_w_freq2,
# X_exponent)
#
#
#
# stg.SSC_fine = self.inv_hc.SSC_fine(zeta_freq2, stg.r_2D[freq2, :, :stg.t.shape[1]],
# stg.VBI_cross_section, stg.freq[freq2], X_exponent, J_freq2,
# np.full(shape=(stg.r.shape[1], stg.t.shape[1]), fill_value=alpha_w_freq2))
# # stg.SSC_fine = self.inv_hc.SSC_fine(stg.zeta[int(self.combobox_frequency_SSC.currentIndex())],
# # stg.r_2D[int(stg.frequency_to_compute_SSC[0]), :, :stg.t.shape[1]],
# # stg.VBI_cross_section,
# # stg.frequency_to_compute_SSC[1],
# # stg.X_exponent,
# # stg.J_cross_section[self.combobox_frequency_SSC.currentIndex(), :, :])
# # print("SSC fine shape ", stg.SSC_fine.shape)
#
# stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section, stg.freq[freq2], X_exponent, ks_freq2)
# # stg.SSC_sand = self.inv_hc.SSC_sand(stg.VBI_cross_section,
# # stg.frequency_to_compute_SSC[1],
# # stg.X_exponent,
# # stg.ks)
#
# # print("SSC sand shape ", stg.SSC_sand.shape)
#
# # def plot_SSC_2D_fields(self):
# #
# # if self.canvas_SSC_2D_field == None:
# #
# # self.figure_SSC_2D_field, self.axis_SSC_2D_field = plt.subplots(nrows=2, ncols=1, layout="constrained")
# # self.canvas_SSC_2D_field = FigureCanvas(self.figure_SSC_2D_field)
# # self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field)
# #
# # self.plot_SSC_fine()
# # self.plot_SSC_sand()
# #
# # else:
# #
# # self.verticalLayout_groupbox_SSC_2D_field.removeWidget(self.canvas_SSC_2D_field)
# # self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field)
# #
# # self.plot_SSC_fine()
# # self.plot_SSC_sand()
#
# # def update_plot_SSC_fine_and_sand(self):
# # self.verticalLayout_groupbox_SSC_2D_field.removeWidget(self.canvas_SSC_2D_field)
# #
# # self.figure_SSC_2D_field, self.axis_SSC_2D_field = plt.subplots(nrows=2, ncols=1, layout="constrained")
# # self.canvas_SSC_2D_field = FigureCanvas(self.figure_SSC_2D_field)
# # self.verticalLayout_groupbox_SSC_2D_field.addWidget(self.canvas_SSC_2D_field)
# #
# # self.plot_SSC_fine()
# # self.plot_SSC_sand()
#
# # def plot_SSC_fine(self):
# #
# # self.slider.setMaximum(stg.t.shape[1])
# #
# # self.figure_SSC_fine.clf()
# # self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine)
# #
# # self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(nrows=1, ncols=1, layout="constrained")
# # self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine)
# # self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine)
# #
# # # val_min = 1e-2
# # # val_max = 15
# # val_min = np.nanmin(stg.SSC_fine)
# # val_max = np.nanmax(stg.SSC_fine)
# # # print('val_min fine = ', val_min)
# # # print('val_max fine =', val_max)
# # # print('val_min fine = ', np.nanmin(stg.VBI_cross_section))
# # # print('val_max fine =', np.nanmax(stg.VBI_cross_section))
# # # if val_min == 0:
# # # val_min = 0.5
# # # print('val_min update =', val_min)
# #
# # # pcm_SSC_fine = self.axis_SSC_2D_field[0].pcolormesh(stg.t[0, :],
# # # -stg.r[0, :],
# # # stg.SSC_fine,
# # # # np.log(stg.VBI_cross_section/1.1932980954310682e-27),
# # # # cmap='jet',
# # # # vmin=val_min, vmax=val_max)
# # # cmap = 'rainbow',
# # # norm=LogNorm(vmin=1e-1, vmax=15))
# # # # shading='gouraud')
# # if stg.ABS_name == "Aquascat 1000R":
# #
# # pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(stg.t[0, :],
# # -stg.r[0, :],
# # stg.SSC_fine,
# # cmap='rainbow',
# # norm=LogNorm(vmin=1e0, vmax=15),
# # shading='gouraud')
# #
# # cbar_SSC_fine = self.figure_SSC_fine.colorbar(pcm_SSC_fine, ax=self.axis_SSC_fine, shrink=1,
# # location='right')
# # cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15)
# #
# # elif stg.ABS_name == "UB-SediFlow":
# # pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(stg.t[0, :],
# # -stg.r[0, :],
# # stg.SSC_fine,
# # cmap='rainbow',
# # norm=LogNorm(vmin=1e-2, vmax=10),
# # shading='gouraud')
# #
# #
# # if stg.r_bottom.size != 0:
# # self.axis_SSC_fine.plot(stg.t[0, :],
# # -stg.r_bottom,
# # color='black', linewidth=1, linestyle="solid")
# # # self.axis_SSC_2D_field[0].plot(stg.t[int(stg.frequency_to_compute_SSC[0]), :],
# # # -stg.r_bottom,
# # # color='black', linewidth=1, linestyle="solid")
# #
# # if self.combobox_fig_choice.currentText() == "Inverted SSC fine vertical profile":
# # self.axis_SSC_fine.plot(stg.t[0, self.slider.value() - 1] * np.ones(stg.r.shape[1]),
# # -stg.r[0, :],
# # color='black', linestyle="solid", linewidth=2)
# #
# # self.figure_SSC_fine.supxlabel("Time (sec)", fontsize=10)
# # self.figure_SSC_fine.supylabel("Depth (m)", fontsize=10)
# # self.figure_SSC_fine.canvas.draw_idle()
# #
# # def plot_SSC_sand(self):
# #
# # self.slider.setMaximum(stg.t.shape[1])
# #
# # self.figure_SSC_sand.clf()
# # self.verticalLayout_groupbox_plot_SSC_sand.removeWidget(self.canvas_SSC_sand)
# #
# # self.figure_SSC_sand, self.axis_SSC_sand = plt.subplots(nrows=1, ncols=1, layout="constrained")
# # self.canvas_SSC_sand = FigureCanvas(self.figure_SSC_sand)
# # self.verticalLayout_groupbox_plot_SSC_sand.addWidget(self.canvas_SSC_sand)
# #
# # val_min = 1e-2
# # val_max = 2
# # val_min = np.nanmin(stg.SSC_sand)
# # val_max = np.nanmax(stg.SSC_sand)
# # # val_min = np.nanmin(np.log(stg.VBI_cross_section))
# # # val_max = np.nanmax(np.log(stg.VBI_cross_section))
# # # print('val_min sand = ', val_min)
# # # print('val_max sand =', val_max)
# # # print('val_min sand = ', np.nanmin(stg.VBI_cross_section))
# # # print('val_max sand = ', np.nanmax(stg.VBI_cross_section))
# # if val_min == 0:
# # val_min = 0.5
# # # print('val_min update =', val_min)
# #
# # # print(stg.SSC_sand)
# #
# # if stg.ABS_name == "Aquascat 1000R":
# #
# # pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :],
# # -stg.r[0, :],
# # (stg.SSC_sand),
# # cmap='rainbow',
# # # vmin=-60, vmax=-45)
# # # vmin=1e-2, vmax=10)
# # # vmin=val_min, vmax=val_max,
# # norm=LogNorm(vmin=1e-2, vmax=2),
# # shading='gouraud')
# #
# # cbar_SSC_sand = self.figure_SSC_sand.colorbar(pcm_SSC_sand, ax=self.axis_SSC_sand, shrink=1,
# # location='right')
# # cbar_SSC_sand.set_label(label='Sand SSC (g/L', rotation=270, labelpad=15)
# #
# # elif stg.ABS_name == "UB-SediFlow":
# # pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :],
# # -stg.r[0, 5:155],
# # (stg.SSC_sand[5:155, :]),
# # cmap="plasma",
# # # cmap='rainbow',
# # vmin=0, vmax=10,
# # # vmin=1e-2, vmax=10)
# # # vmin=val_min, vmax=val_max,
# # # norm=LogNorm(vmin=1e-2, vmax=1),
# # shading='gouraud')
# # # self.axis_SSC_2D_field[1].plot(stg.t[1, 52] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152],
# # # c='b', ls='solid', lw=2)
# # # self.axis_SSC_2D_field[1].plot(stg.t[1, ] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152],
# # # c='red', ls='solid', lw=2)
# # # self.axis_SSC_2D_field[1].plot(stg.t[1, 777] * np.ones(len(stg.r[1, 5:152])), -stg.r[1, 5:152],
# # # c='red', ls='solid', lw=2)
# #
# # # pcm_SSC_sand = self.axis_SSC_2D_field[1].pcolormesh(stg.t[int(stg.frequency_to_compute_SSC[0]), :],
# # # -stg.r[int(stg.frequency_to_compute_SSC[0]), :],
# # # stg.SSC_sand,
# # # cmap='rainbow',
# # # # vmin=val_min, vmax=val_max,
# # # norm=LogNorm(vmin=1e-2, vmax=2),
# # # shading='gouraud')
# #
# # if stg.r_bottom.size:
# # self.axis_SSC_sand.plot(stg.t[0, :],
# # -stg.r_bottom,
# # color='black', linewidth=1, linestyle="solid")
# # # self.axis_SSC_2D_field[1].plot(stg.t[int(stg.frequency_to_compute_SSC[0]), :],
# # # -stg.r_bottom,
# # # color='black', linewidth=1, linestyle="solid")
# #
# # if self.combobox_fig_choice.currentText() == "Inverted SSC sand vertical profile":
# # self.axis_SSC_sand.plot(stg.t[0, self.slider.value() - 1] * np.ones(stg.r.shape[1]),
# # -stg.r[0, :],
# # color='black', linestyle="solid", linewidth=2)
# #
# # self.figure_SSC_sand.supxlabel("Time (sec)", fontsize=10)
# # self.figure_SSC_sand.supylabel("Depth (m)", fontsize=10)
# # self.figure_SSC_sand.canvas.draw_idle()
#
# def plot_inverted_SSC_sand_vertical_profile(self):
#
# # self.combobox_fig_choice.setCurrentIndex(1)
#
# if self.combobox_fig_choice.currentText() == "Inverted SSC sand vertical profile":
#
# self.axis_SSC_sand_vertical_profile.cla()
#
# # --- Plot inverted SSC vertical profile ---
# self.axis_SSC_sand_vertical_profile.plot(stg.SSC_sand[:, self.slider.value()-1],
# -stg.r[self.combobox_freq2.currentIndex(), :],
# color='black', ls='solid')
#
# self.axis_SSC_sand_vertical_profile.set_xlabel('Sand concentration (g/l)', weight='bold')
# self.axis_SSC_sand_vertical_profile.set_ylabel('Depth (m)', weight='bold')
#
# self.axis_SSC_sand_vertical_profile.set_xlim(0, 10)
#
# self.figure_SSC_sand_vertical_profile.canvas.draw_idle()
#
# def plot_inverted_SSC_fine_vertical_profile(self):
#
# if self.combobox_fig_choice.currentText() == "Inverted SSC vs Measured SSC":
#
# self.axis_SSC_fine_vertical_profile.cla()
#
# # --- Plot inverted SSC vertical profile ---
# self.axis_SSC_fine_vertical_profile.plot(stg.r[self.combobox_freq2.currentIndex(), :],
# stg.SSC_sand[:, self.slider.value()-1],
# color='black', ls='solid')
#
# self.axis_SSC_fine_vertical_profile.set_xlabel('Sand concentration (g/l)', weight='bold')
# self.axis_SSC_fine_vertical_profile.set_ylabel('Depth (m)', weight='bold')
#
# self.figure_SSC_fine_vertical_profile.canvas.draw_idle()
#
# def plot_inverted_SSC_vs_measured_SSC(self):
#
# if self.combobox_fig_choice.currentText() == "Inverted SSC vs Measured SSC":
#
# self.figure_SSC_measured_vs_inverted.clf()
# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.canvas_SSC_measured_vs_inverted)
#
# self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(self.canvas_SSC_measured_vs_inverted)
#
# sample_depth_position = []
# for i in range(stg.sample_depth.shape[0]):
# sample_depth_position.append(
# np.where(np.abs(stg.r[0, :] + stg.sample_depth[i]) ==
# np.min(np.abs(stg.r[0, :] + stg.sample_depth[i])))[0][0])
#
# sample_time_position = []
# for j in range(stg.sample_time.shape[0]):
# sample_time_position.append(
# np.where(np.abs(stg.t[0, :] - stg.sample_time[j]) ==
# np.min(np.abs(stg.t[0, :] - stg.sample_time[j])))[0][0])
#
# # print("Ctot fine : ", stg.Ctot_fine)
# # print("SCC fine : ", stg.SSC_fine[sample_depth_position, sample_time_position])
# # print("Ctot sand : ", stg.Ctot_sand)
# # print("SCC sand : ", stg.SSC_sand[sample_depth_position, sample_time_position])
#
# self.axis_SSC_measured_vs_inverted.cla()
#
# self.axis_SSC_measured_vs_inverted.plot(stg.Ctot_fine, stg.SSC_fine[sample_depth_position, sample_time_position], ls=" ", marker='v', color='black', label='Fine SSC')
# self.axis_SSC_measured_vs_inverted.plot(stg.Ctot_sand,
# stg.SSC_sand[sample_depth_position, sample_time_position],
# ls=" ", marker='x', color='black', label='Sand SSC')
#
# self.axis_SSC_measured_vs_inverted.set_xscale('log')
# self.axis_SSC_measured_vs_inverted.set_yscale('log')
# self.axis_SSC_measured_vs_inverted.plot([0, 10], [0, 10], color='black', lw=1)
# self.axis_SSC_measured_vs_inverted.set_xlabel('Measured SSC (g/l)', weight='bold')
# self.axis_SSC_measured_vs_inverted.set_ylabel('Inverse SSC (g/l)', weight='bold')
# self.axis_SSC_measured_vs_inverted.legend()
#
# # def insert_slider_for_vertical_profile_figure_area(self):
# #
# # if ((self.combobox_fig_choice.currentText() == "Inverted SSC fine vertical profile") or
# # (self.combobox_fig_choice.currentText() == "Inverted SSC sand vertical profile")):
# #
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.canvas_SSC_measured_vs_inverted)
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(self.canvas_SSC_measured_vs_inverted)
# #
# # # --- Slider for moving the profile ---
# # self.horizontalLayout_slider = QHBoxLayout()
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addLayout(self.horizontalLayout_slider)
# #
# # self.pushbutton_slider_left = QPushButton()
# # self.pushbutton_slider_left.setIcon(self.icon_triangle_left)
# # self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left)
# #
# # self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left)
# #
# # self.pushbutton_slider_right = QPushButton()
# # self.pushbutton_slider_right.setIcon(self.icon_triangle_right)
# # self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right)
# #
# # self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right)
# #
# # self.lineEdit_slider = QLineEdit()
# # self.lineEdit_slider.setText("1")
# # self.lineEdit_slider.setFixedWidth(50)
# # self.horizontalLayout_slider.addWidget(self.lineEdit_slider)
# #
# # self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit)
# #
# # self.slider = QSlider()
# # self.horizontalLayout_slider.addWidget(self.slider, 9)
# #
# # self.slider.setOrientation(Qt.Horizontal)
# # self.slider.setCursor(Qt.OpenHandCursor)
# # self.slider.setMinimum(1)
# # self.slider.setMaximum(stg.t.shape[1])
# # self.slider.setTickInterval(1)
# # self.slider.setValue(1)
# #
# # self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider)
# #
# # self.slider.valueChanged.connect(self.plot_inverted_SSC_fine_vertical_profile)
# #
# # self.slider.valueChanged.connect(self.plot_SSC_sand)
# #
# # self.plot_inverted_SSC_fine_vertical_profile()
# # self.update_plot_SSC_fine_and_sand()
# #
# # elif self.combobox_fig_choice.currentText() == "Inverted SSC vs Measured SSC":
# #
# # self.figure_SSC_sand.clf()
# # self.figure_SSC_fine.clf()
# #
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.canvas_SSC_sand)
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.canvas_SSC_fine)
# #
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.pushbutton_slider_right)
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.pushbutton_slider_left)
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.lineEdit_slider)
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.removeWidget(self.slider)
# #
# # self.verticalLayout_groupbox_SSC_profiles_or_measured_vs_inverted.addWidget(self.canvas_SSC_measured_vs_inverted)
# #
# # self.figure_SSC_measured_vs_inverted.canvas.draw_idle()
#
#
#