1104 lines
62 KiB
Python
1104 lines
62 KiB
Python
import sys
|
|
|
|
from PyQt5.QtWidgets import QWidget, QMainWindow, QApplication, QVBoxLayout, QHBoxLayout, QGroupBox, QComboBox, \
|
|
QGridLayout, QLabel, QPushButton, QSpinBox
|
|
from PyQt5.QtCore import QCoreApplication, Qt
|
|
from PyQt5.QtGui import QStandardItemModel
|
|
|
|
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 Translation.constant_string as cs
|
|
|
|
from View.checkable_combobox import CheckableComboBox
|
|
|
|
import settings as stg
|
|
|
|
from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration
|
|
|
|
_translate = QCoreApplication.translate
|
|
|
|
|
|
class AcousticInversionTab(QWidget):
|
|
|
|
''' This class generates the Acoustic Inversion Tab '''
|
|
|
|
def __init__(self, widget_tab):
|
|
super().__init__()
|
|
|
|
self.inv_hc = AcousticInversionMethodHighConcentration()
|
|
|
|
### --- General layout of widgets ---
|
|
|
|
self.verticalLayoutMain = QVBoxLayout(widget_tab)
|
|
|
|
self.horizontalLayoutTop = QHBoxLayout()
|
|
self.verticalLayoutMain.addLayout(self.horizontalLayoutTop, 4) # 1O units is 100% , 1 units is 10%
|
|
|
|
self.horizontalLayoutBottom = QHBoxLayout()
|
|
self.verticalLayoutMain.addLayout(self.horizontalLayoutBottom, 6)
|
|
|
|
### --- 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_sample_vs_inversion = QGroupBox()
|
|
self.horizontalLayoutBottom.addWidget(self.groupbox_SSC_sample_vs_inversion, 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.label_sample_choice = QLabel()
|
|
self.gridLayout_groupbox_acoustic_inversion_options.addWidget(self.label_sample_choice, 1, 0, 1, 1)
|
|
self.label_sample_choice.setText("Calibration samples : ")
|
|
|
|
self.combobox_calibration_samples = QComboBox()
|
|
self.gridLayout_groupbox_acoustic_inversion_options.addWidget(self.combobox_calibration_samples, 1, 1, 1, 1)
|
|
self.combobox_calibration_samples.currentIndexChanged.connect(self.sample_choice)
|
|
|
|
|
|
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
# | 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.label_temperature = QLabel()
|
|
self.label_temperature.setText("Temperature : ")
|
|
self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(self.label_temperature, 0, 0, 1, 1)
|
|
self.spinbox_temperature = QSpinBox()
|
|
self.gridLayout_groupbox_acoustic_inversion_settings_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_acoustic_inversion_settings_parameter.addWidget(
|
|
self.label_frequencies_pairs_to_compute_VBI, 1, 0, 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_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.combobox_frequency_SSC = QComboBox()
|
|
self.gridLayout_groupbox_acoustic_inversion_settings_parameter.addWidget(
|
|
self.combobox_frequency_SSC, 2, 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, 3, 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, 3, 1, 1, 1)
|
|
self.pushbutton_plot.clicked.connect(self.plot_SSC_2D_fields)
|
|
self.pushbutton_plot.clicked.connect(self.plot_SSC_inverse_VS_measured)
|
|
|
|
# =====================================================
|
|
# 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.canvas_SSC_2D_field = None
|
|
|
|
# +++++++++++++++++++++++++++++++++++++++++++++++
|
|
# | Group box plot samples vs inversion |
|
|
# +++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
self.verticalLayout_groupbox_SSC_sample_vs_inversion = QVBoxLayout(self.groupbox_SSC_sample_vs_inversion)
|
|
|
|
self.groupbox_SSC_sample_vs_inversion.setTitle("Suspended Sediment Concentration : sample vs inversion")
|
|
|
|
self.canvas_SSC_sample_vs_inversion = None
|
|
#
|
|
# 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):
|
|
if self.combobox_acoustic_inversion_method_choice.currentIndex() == 1:
|
|
|
|
# --- add items in combobox of samples 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_samples.addItem(" ")
|
|
for s in samples_vertical_line:
|
|
self.combobox_calibration_samples.addItem(" - ".join([i for i in s]))
|
|
|
|
# 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 sample_choice(self):
|
|
sample_position = []
|
|
# for i in range(self.combobox_calibration_samples.count()):
|
|
# if self.combobox_calibration_samples.itemChecked(i):
|
|
sample_position.append(self.combobox_calibration_samples.currentIndex())
|
|
# elif (i in sample_position) and (not self.combobox_calibration_samples.itemChecked(i)):
|
|
# sample_position.remove(i)
|
|
print(f"sample position : {sample_position}")
|
|
|
|
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_cross_section_averaged.size != 0:
|
|
print("1/ stg.BS_cross_section_averaged")
|
|
stg.J_cross_section = (
|
|
self.inv_hc.j_cross_section(stg.BS_cross_section_averaged[freq_ind, :, :],
|
|
stg.r_2D[0, :, :stg.BS_cross_section_averaged.shape[2]],
|
|
kt[freq_ind, :, :]))
|
|
# stg.J_cross_section = (
|
|
# self.inv_hc.j_cross_section(
|
|
# stg.BS_cross_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_cross_section_averaged.shape[2]],
|
|
# stg.kt_corrected_3D))
|
|
|
|
elif stg.BS_cross_section_SNR_filter.size != 0:
|
|
print("2/ stg.BS_cross_section_SNR_filter")
|
|
stg.J_cross_section = (
|
|
self.inv_hc.j_cross_section(
|
|
stg.BS_cross_section_SNR_filter[freq_ind, :, :],
|
|
stg.r_2D[freq_ind, :, :stg.BS_cross_section_SNR_filter.shape[2]],
|
|
kt[freq_ind, :, :]))
|
|
|
|
# stg.J_cross_section = (
|
|
# self.inv_hc.j_cross_section(
|
|
# stg.BS_cross_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_cross_section_SNR_filter.shape[2]],
|
|
# stg.kt_corrected_3D))
|
|
|
|
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[
|
|
# [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))
|
|
|
|
else:
|
|
|
|
if stg.BS_stream_bed_averaged.size != 0:
|
|
print("1/ stg.BS_stream_bed_averaged")
|
|
stg.J_cross_section = (
|
|
self.inv_hc.j_cross_section(
|
|
stg.BS_stream_bed_averaged[freq_ind, :, :],
|
|
stg.r_2D[freq_ind, :, :stg.BS_stream_bed_averaged.shape[2]],
|
|
kt[freq_ind, :, :]))
|
|
|
|
# stg.J_stream_bed = (
|
|
# self.inv_hc.j_cross_section(
|
|
# stg.BS_stream_bed_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_stream_bed_averaged.shape[2]],
|
|
# stg.kt_corrected_3D))
|
|
|
|
elif stg.BS_stream_bed_SNR_filter.size != 0:
|
|
print("2/ stg.BS_stream_bed_SNR_filter")
|
|
stg.J_cross_section = (
|
|
self.inv_hc.j_cross_section(
|
|
stg.BS_stream_bed_SNR_filter[freq_ind, :, :],
|
|
stg.r_2D[freq_ind, :, :stg.BS_stream_bed_SNR_filter.shape[2]],
|
|
kt[freq_ind, :, :]))
|
|
|
|
# stg.J_stream_bed = (
|
|
# self.inv_hc.j_cross_section(
|
|
# stg.BS_stream_bed_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_stream_bed_SNR_filter.shape[2]],
|
|
# stg.kt_corrected_3D))
|
|
|
|
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, :, :]))
|
|
|
|
# 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)
|
|
|
|
elif stg.ABS_name == "UB-SediFlow":
|
|
|
|
if stg.BS_stream_bed.size == 0:
|
|
|
|
if stg.BS_cross_section_averaged.size != 0:
|
|
print("1/ stg.BS_cross_section_averaged")
|
|
stg.J_cross_section = (
|
|
self.inv_hc.j_cross_section(stg.BS_cross_section_averaged[freq_ind, :, :],
|
|
stg.r_2D[0, :, :stg.BS_cross_section_averaged.shape[2]],
|
|
kt[freq_ind, :, :]))
|
|
|
|
elif stg.BS_cross_section_SNR_filter.size != 0:
|
|
print("2/ stg.BS_cross_section_SNR_filter")
|
|
stg.J_cross_section = (
|
|
self.inv_hc.j_cross_section(
|
|
stg.BS_cross_section_SNR_filter[freq_ind, :, :],
|
|
stg.r_2D[freq_ind, :, :stg.BS_cross_section_SNR_filter.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, :, :]))
|
|
|
|
else:
|
|
|
|
if stg.BS_stream_bed_averaged.size != 0:
|
|
print("1/ stg.BS_stream_bed_averaged")
|
|
stg.J_cross_section = (
|
|
self.inv_hc.j_cross_section(
|
|
stg.BS_stream_bed_averaged[freq_ind, :, :],
|
|
stg.r_2D[freq_ind, :, :stg.BS_stream_bed_averaged.shape[2]],
|
|
kt[freq_ind, :, :]))
|
|
|
|
elif stg.BS_stream_bed_SNR_filter.size != 0:
|
|
print("2/ stg.BS_stream_bed_SNR_filter")
|
|
stg.J_cross_section = (
|
|
self.inv_hc.j_cross_section(
|
|
stg.BS_stream_bed_SNR_filter[freq_ind, :, :],
|
|
stg.r_2D[freq_ind, :, :stg.BS_stream_bed_SNR_filter.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, :, :]))
|
|
|
|
|
|
# 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 compute_acoustic_inversion_method_high_concentration(self):
|
|
|
|
self.temperature_value()
|
|
|
|
if stg.ABS_name == "Aquascat 1000R":
|
|
|
|
freq1 = 0 # 0 = 300kHz et 1 = 500kHz
|
|
freq2 = 2 # 2 = 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()
|
|
|
|
# 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(freq=stg.freq[freq1], pdf=stg.frac_vol_sand_cumul[2, :]),
|
|
self.inv_hc.ks(freq=stg.freq[freq2], pdf=stg.frac_vol_sand_cumul[2, :]))
|
|
# 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]))
|
|
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[: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"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],
|
|
M_profile=stg.Ctot_fine[:3],
|
|
range_cells=stg.r[0, :],
|
|
r_bottom=stg.r_bottom[t_sample_ind[0][0]])
|
|
M_profile_fine = M_profile_fine[:len(range_lin_interp)]
|
|
|
|
print(f"range_lin_interp : {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()
|
|
|
|
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)
|
|
|
|
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 = 0 # 0 = 500kHz
|
|
freq2 = 1 # 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))
|
|
print(f"ks_freq1 = {ks_freq1}, ks_freq2 = {ks_freq2}")
|
|
|
|
sv_freq1, sv_freq2 = (
|
|
self.inv_hc.sv(ks=ks_freq1, M_sand=stg.Ctot_sand[-1]),
|
|
self.inv_hc.sv(ks=ks_freq2, M_sand=stg.Ctot_sand[-1]))
|
|
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([[1.38e-3], [6.02e-4]]) # Values of kt for 500kHz and 1MHz
|
|
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[:])):
|
|
# 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}")
|
|
|
|
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[:],
|
|
# M_profile=stg.Ctot_sand[:],
|
|
# 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, 1
|
|
|
|
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*(3.19127224 - 0.52102404)),
|
|
alpha_s_freq2 / (M_profile_fine*(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))
|
|
|
|
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}")
|
|
|
|
|
|
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)
|
|
# 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()
|
|
|
|
def plot_SSC_fine(self):
|
|
|
|
# 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_2D_field[0].pcolormesh(stg.t[0, :],
|
|
-stg.r[0, :],
|
|
stg.SSC_fine,
|
|
cmap='rainbow',
|
|
norm=LogNorm(vmin=1e-2, vmax=15),
|
|
shading='gouraud')
|
|
# pcm_SSC_fine = self.axis_SSC_2D_field[0].pcolormesh(stg.t[int(stg.frequency_to_compute_SSC[0]), :],
|
|
# -stg.r[int(stg.frequency_to_compute_SSC[0]), :],
|
|
# stg.SSC_fine,
|
|
# cmap='rainbow',
|
|
# norm=LogNorm(vmin=1e-2, vmax=15),
|
|
# shading='gouraud')
|
|
elif stg.ABS_name == "UB-SediFlow":
|
|
pcm_SSC_fine = self.axis_SSC_2D_field[0].pcolormesh(stg.t[0, :],
|
|
-stg.r[0, :],
|
|
stg.SSC_fine,
|
|
cmap='rainbow',
|
|
norm=LogNorm(vmin=1e-2, vmax=1),
|
|
shading='gouraud')
|
|
|
|
|
|
if stg.r_bottom.size != 0:
|
|
self.axis_SSC_2D_field[0].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")
|
|
|
|
self.figure_SSC_2D_field.supxlabel("Time (sec)", fontsize=10)
|
|
self.figure_SSC_2D_field.supylabel("Depth (m)", fontsize=10)
|
|
|
|
cbar_SSC_fine = self.figure_SSC_2D_field.colorbar(pcm_SSC_fine, ax=self.axis_SSC_2D_field[0], shrink=1, location='right')
|
|
cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15)
|
|
|
|
self.figure_SSC_2D_field.canvas.draw_idle()
|
|
|
|
def plot_SSC_sand(self):
|
|
|
|
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_2D_field[1].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')
|
|
|
|
elif stg.ABS_name == "UB-SediFlow":
|
|
pcm_SSC_sand = self.axis_SSC_2D_field[1].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=1),
|
|
shading='gouraud')
|
|
|
|
# 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_2D_field[1].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")
|
|
|
|
self.figure_SSC_2D_field.supxlabel("Time (sec)", fontsize=10)
|
|
self.figure_SSC_2D_field.supylabel("Depth (m)", fontsize=10)
|
|
|
|
cbar_SSC_sand = self.figure_SSC_2D_field.colorbar(pcm_SSC_sand, ax=self.axis_SSC_2D_field[1], shrink=1, location='right')
|
|
cbar_SSC_sand.set_label(label='Sand SSC (g/L', rotation=270, labelpad=15)
|
|
self.figure_SSC_2D_field.canvas.draw_idle()
|
|
|
|
def plot_SSC_inverse_VS_measured(self):
|
|
|
|
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])
|
|
|
|
if self.canvas_SSC_sample_vs_inversion == None:
|
|
|
|
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.figure_SSC_sample_vs_inversion, self.axis_SSC_sample_vs_inversion = plt.subplots(nrows=1, ncols=1, layout="constrained")
|
|
self.canvas_SSC_sample_vs_inversion = FigureCanvas(self.figure_SSC_sample_vs_inversion)
|
|
self.verticalLayout_groupbox_SSC_sample_vs_inversion.addWidget(self.canvas_SSC_sample_vs_inversion)
|
|
|
|
if stg.ABS_name == "Aquascat 1000R":
|
|
self.axis_SSC_sample_vs_inversion.plot(stg.Ctot_fine, stg.SSC_fine[sample_depth_position, sample_time_position], ls=" ", marker='v', color='black', label='Fine SSC')
|
|
self.axis_SSC_sample_vs_inversion.plot(stg.Ctot_sand,
|
|
stg.SSC_sand[sample_depth_position, sample_time_position],
|
|
ls=" ", marker='x', color='black', label='Sand SSC')
|
|
|
|
self.axis_SSC_sample_vs_inversion.set_xscale('log')
|
|
self.axis_SSC_sample_vs_inversion.set_yscale('log')
|
|
self.axis_SSC_sample_vs_inversion.plot([0, 10], [0, 10], color='black', lw=1)
|
|
self.axis_SSC_sample_vs_inversion.set_xlabel('Measured SSC (g/l)', weight='bold')
|
|
self.axis_SSC_sample_vs_inversion.set_ylabel('Inverse SSC (g/l)', weight='bold')
|
|
self.axis_SSC_sample_vs_inversion.legend()
|
|
|
|
elif stg.ABS_name == "UB-SediFlow":
|
|
# self.axis_SSC_sample_vs_inversion.plot(stg.Ctot_sand,
|
|
# stg.SSC_sand[sample_depth_position, sample_time_position],
|
|
# ls=" ", marker='x', color='black', label='Sand SSC')
|
|
|
|
# fig, ax = plt.subplots(nrows=2, ncols=10)
|
|
# for j in range(2):
|
|
# for i in range(10):
|
|
# ax[j, i].plot(stg.r[1, :145], stg.SSC_sand[:145, 750+j*10+i])
|
|
# plt.show()
|
|
# fig, ax = plt.subplots(nrows=1, ncols=1)
|
|
# for i in range(20):
|
|
# ax.plot(stg.r[1, :145], stg.SSC_sand[:145, 750+i])
|
|
# plt.show()
|
|
|
|
# self.axis_SSC_sample_vs_inversion.plot(stg.r[1, :145], stg.SSC_sand[:145, 40], color='blue', ls='solid')
|
|
self.axis_SSC_sample_vs_inversion.plot(stg.r[1, 2:145], stg.SSC_sand[2:145, 762],
|
|
color='red', ls='solid', marker='o', mec='k', mfc='k', ms=3)
|
|
self.axis_SSC_sample_vs_inversion.set_xlabel('Depth (m)', weight='bold')
|
|
self.axis_SSC_sample_vs_inversion.set_ylabel('Sand concentration (g/l)', weight='bold')
|
|
|
|
|
|
|
|
|
|
|
|
|