Implementation of SNR data from UBSediFlow ABS tool
parent
92a0b5fa54
commit
426c68c880
|
|
@ -4,7 +4,7 @@ import numpy as np
|
|||
import pandas as pd
|
||||
import datetime
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.colors import LogNorm
|
||||
from matplotlib.colors import LogNorm, BoundaryNorm
|
||||
|
||||
from Model.udt_extract.raw_extract import raw_extract
|
||||
# raw_20210519_102332.udt raw_20210520_135452.udt raw_20210525_092759.udt raw_20210525_080454.udt
|
||||
|
|
@ -43,14 +43,17 @@ class AcousticDataLoaderUBSediFlow():
|
|||
self._freq = np.array([[]])
|
||||
self._r = np.array([[]])
|
||||
self._time = np.array([[]])
|
||||
self._time_snr = np.array([[]])
|
||||
self._BS_raw_data = np.array([[[]]])
|
||||
self._SNR_data = np.array([[[]]])
|
||||
time_len = []
|
||||
time_snr_len = []
|
||||
for config in param_us_dicts.keys():
|
||||
# print("-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x")
|
||||
# print(f"config : {config} \n")
|
||||
for channel in param_us_dicts[config].keys():
|
||||
print("-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x")
|
||||
print(f"channel : {channel} \n")
|
||||
# print("-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x")
|
||||
# print(f"channel : {channel} \n")
|
||||
print(data_us_dicts[config][channel].keys())
|
||||
# print(data_us_dicts[config][channel]['echo_avg_profile'])
|
||||
|
||||
|
|
@ -65,7 +68,7 @@ class AcousticDataLoaderUBSediFlow():
|
|||
else:
|
||||
self._r = np.append(self._r, [depth], axis=0)
|
||||
|
||||
# --- Time for each frequencies ---
|
||||
# --- BS Time for each frequencies ---
|
||||
time = [[(t - data_us_dicts[config][channel]['echo_avg_profile']['time'][0]).total_seconds()
|
||||
for t in data_us_dicts[config][channel]['echo_avg_profile']['time']]]
|
||||
time_len = np.append(time_len, len(time[0]))
|
||||
|
|
@ -93,20 +96,62 @@ class AcousticDataLoaderUBSediFlow():
|
|||
self._time = np.append(self._time, time, axis=0)
|
||||
# print(f"self._time.shape {self._time.shape}")
|
||||
|
||||
# --- US Backscatter raw signal ---
|
||||
# --- SNR Time for each frequencies ---
|
||||
time_snr = [[(t - data_us_dicts[config][channel]['snr_doppler_avg_profile']['time'][0]).total_seconds()
|
||||
for t in data_us_dicts[config][channel]['snr_doppler_avg_profile']['time']]]
|
||||
time_snr_len = np.append(time_snr_len, len(time_snr[0]))
|
||||
|
||||
if len(time_snr_len) == 1:
|
||||
# print(f"1 time length : {len(time[0])}")
|
||||
self._time_snr = np.array(time_snr)
|
||||
# print(f"self._time.shape {self._time.shape}")
|
||||
elif self._time_snr.shape[1] == len(time_snr[0]):
|
||||
# print(f"2 time length : {len(time[0])}")
|
||||
self._time_snr = np.append(self._time_snr, time_snr, axis=0)
|
||||
# print(f"self._time.shape {self._time.shape}")
|
||||
elif self._time_snr.shape[1] > len(time_snr[0]):
|
||||
# print(f"3 time length : {len(time[0])}")
|
||||
# print(f"self._time.shape {self._time.shape}")
|
||||
# print([int(np.min(time_len)) + int(i) - 1 for i in range(1, int(np.max(time_len))-int(np.min(time_len))+1)])
|
||||
self._time_snr = np.delete(self._time_snr,
|
||||
[int(np.min(time_snr_len)) + int(i) - 1 for i in
|
||||
range(1, int(np.max(time_snr_len)) - int(np.min(time_snr_len)) + 1)],
|
||||
axis=1)
|
||||
self._time_snr = np.append(self._time_snr, time_snr, axis=0)
|
||||
# print(f"self._time.shape {self._time.shape}")
|
||||
elif self._time_snr.shape[1] < len(time_snr[0]):
|
||||
# print(f"4 time length : {len(time[0])}")
|
||||
time_snr = time_snr[:int(np.max(time_snr_len)) - (int(np.max(time_snr_len)) - int(np.min(time_snr_len)))]
|
||||
self._time_snr = np.append(self._time_snr, time_snr, axis=0)
|
||||
# print(f"self._time.shape {self._time.shape}")
|
||||
|
||||
# --- US Backscatter raw signal + SNR data ---
|
||||
for f, freq in enumerate(self._freq):
|
||||
if f == 0:
|
||||
# print(data_us_dicts[config][channel]['echo_avg_profile']['data'])
|
||||
self._BS_raw_data = np.array([np.reshape(data_us_dicts[config][channel]['echo_avg_profile']['data'],
|
||||
(self._time.shape[1], self._r.shape[1])).transpose()])
|
||||
# print(self._BS_raw_data.shape)
|
||||
self._SNR_data = np.array(
|
||||
[np.reshape(np.abs(data_us_dicts[config][channel]['snr_doppler_avg_profile']['data']),
|
||||
(self._time.shape[1], self._r.shape[1])).transpose()])
|
||||
else:
|
||||
self._BS_raw_data = np.append(self._BS_raw_data,
|
||||
np.array([np.reshape(np.array(
|
||||
data_us_dicts[config][channel]['echo_avg_profile']['data']),
|
||||
(self._time.shape[1], self._r.shape[1])).transpose()]),
|
||||
axis=0)
|
||||
|
||||
self._SNR_data = np.append(self._SNR_data,
|
||||
np.array([np.reshape(np.array(
|
||||
np.abs(data_us_dicts[config][channel]['snr_doppler_avg_profile']['data'])),
|
||||
(self._time.shape[1], self._r.shape[1])).transpose()]),
|
||||
axis=0)
|
||||
# print(self._BS_raw_data.shape)
|
||||
|
||||
# --- US Backscatter raw signal ---
|
||||
|
||||
|
||||
# print(len(self._BS_raw_data))
|
||||
# print(self._BS_raw_data)
|
||||
|
||||
|
|
@ -121,6 +166,9 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# self._BS_raw_data = np.array(np.reshape(self._BS_raw_data, (len(self._freq), self._r.shape[1], self._time.shape[1])))
|
||||
print("self._BS_raw_data.shape ", self._BS_raw_data.shape)
|
||||
|
||||
print("self._SNR_data.shape ", self._SNR_data.shape)
|
||||
print(self._SNR_data)
|
||||
|
||||
# print("device_name ", device_name, "\n")
|
||||
|
||||
# print("time_begin ", time_begin, "\n")
|
||||
|
|
@ -168,17 +216,56 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# print(self._time[np.where(np.floor(self._time) == 175)])
|
||||
# print(np.where((self._time) == 155)[0][0])
|
||||
|
||||
# --- Plot Backscatter US data ---
|
||||
# fig, ax = plt.subplots(nrows=len(self._freq), ncols=1)
|
||||
# for f, freq in enumerate(self._freq):
|
||||
# # print(f"{f} : {freq} \n")
|
||||
# pcm = ax[f].pcolormesh(self._time[f, :], self._r[f, :], (self._BS_raw_data[f, :, :self._time.shape[1]]),
|
||||
# cmap='viridis',
|
||||
# norm=LogNorm(vmin=np.min(self._BS_raw_data[f, :, :]), vmax=np.max(self._BS_raw_data[f, :, :])), shading='gouraud') # )
|
||||
# norm=LogNorm(vmin=np.min(self._BS_raw_data[f, :, :]), vmax=np.max(self._BS_raw_data[f, :, :])), shading='gouraud')
|
||||
# # ax.pcolormesh(range(self._BS_raw_data.shape[2]), range(self._BS_raw_data.shape[0]), self._BS_raw_data[:, 1, :], cmap='viridis',
|
||||
# # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[:, 0, :]))) # , shading='gouraud')
|
||||
# fig.colorbar(pcm, ax=ax[:], shrink=1, location='right')
|
||||
# plt.show()
|
||||
|
||||
# --- Plot SNR data ---
|
||||
# fig_snr, ax_snr = plt.subplots(nrows=len(self._freq), ncols=1)
|
||||
#
|
||||
# x, y = np.meshgrid(self._time[0, :], self._r[0, :])
|
||||
#
|
||||
# for f, freq in enumerate(self._freq):
|
||||
#
|
||||
# val_min = np.nanmin(abs(self._SNR_data[f, :, :]))
|
||||
# print(f"val_min = {val_min}")
|
||||
# val_max = np.nanmax(self._SNR_data[f, :, :])
|
||||
# print(f"val_max = {val_max}")
|
||||
# if int(val_min) == 0:
|
||||
# val_min = 1e-5
|
||||
# if int(val_max) < 1000:
|
||||
# levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
||||
# bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2]
|
||||
# else:
|
||||
# levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
||||
# bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
||||
# norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
||||
#
|
||||
# print(f"levels = {levels}")
|
||||
# print(f"norm = {norm.boundaries}")
|
||||
#
|
||||
# cf = ax_snr[f].contourf(x, y, self._SNR_data[f, :, :])#, levels, cmap='gist_rainbow', norm=norm)
|
||||
#
|
||||
# ax_snr[f].text(1, .70, self._freq_text[f],
|
||||
# fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
# horizontalalignment='right', verticalalignment='bottom',
|
||||
# transform=ax_snr[f].transAxes)
|
||||
#
|
||||
# fig_snr.supxlabel('Time (sec)', fontsize=10)
|
||||
# fig_snr.supylabel('Depth (m)', fontsize=10)
|
||||
# cbar = fig_snr.colorbar(cf, ax=ax_snr[:], shrink=1, location='right')
|
||||
# cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10)
|
||||
# # cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$'])
|
||||
# plt.show()
|
||||
|
||||
# fig, ax = plt.subplots(nrows=1, ncols=1)
|
||||
# ax.plot(list(range(self._time.shape[1])), self._time[0, :])
|
||||
# # ax.set_ylim(2, 20)
|
||||
|
|
@ -197,6 +284,13 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# print(BS_raw_cross_section.shape)
|
||||
return BS_raw_cross_section
|
||||
|
||||
def reshape_SNR_data(self):
|
||||
SNR_data = np.reshape(self._SNR_data,
|
||||
(self._r.shape[1]*self._time.shape[1], len(self._freq)),
|
||||
order="F")
|
||||
# print(BS_raw_cross_section.shape)
|
||||
return SNR_data
|
||||
|
||||
def reshape_r(self):
|
||||
r = np.zeros((self._r.shape[1]*self._time.shape[1], len(self._freq)))
|
||||
for i, _ in enumerate(self._freq):
|
||||
|
|
@ -215,6 +309,13 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# print(t.shape)
|
||||
return t
|
||||
|
||||
def reshape_t_snr(self):
|
||||
t = np.zeros((self._r.shape[1]*self._time_snr.shape[1], len(self._freq)))
|
||||
for i, _ in enumerate(self._freq):
|
||||
t[:, i] = np.repeat(self._time_snr[i, :], self._r.shape[1])
|
||||
# print(t.shape)
|
||||
return t
|
||||
|
||||
# def concatenate_data(self):
|
||||
|
||||
# self.reshape_BS_raw_cross_section()
|
||||
|
|
|
|||
|
|
@ -783,6 +783,8 @@ class AcousticDataTab(QWidget):
|
|||
stg.BS_raw_data_reshape = acoustic_data.reshape_BS_raw_cross_section()
|
||||
stg.r_reshape = acoustic_data.reshape_r()
|
||||
stg.time_reshape = acoustic_data.reshape_t()
|
||||
stg.snr = acoustic_data._SNR_data
|
||||
stg.snr_reshape = acoustic_data.reshape_SNR_data()
|
||||
|
||||
def load_noise_data_and_compute_SNR(self):
|
||||
if self.combobox_ABS_system_choice.currentIndex() == 1:
|
||||
|
|
@ -804,13 +806,10 @@ class AcousticDataTab(QWidget):
|
|||
noise_data = AcousticDataLoaderUBSediFlow(stg.path_BS_noise_data + "/" + stg.filename_BS_noise_data)
|
||||
stg.date_noise = noise_data._date
|
||||
stg.hour_noise = noise_data._hour
|
||||
stg.time_snr = noise_data._time
|
||||
noise = np.zeros(stg.BS_raw_data.shape)
|
||||
for f in range(noise_data._freq.shape[0]):
|
||||
noise[:, f, :] = np.mean(noise_data._BS_raw_data[:, f, :], axis=(0, 1))
|
||||
stg.BS_noise_data = noise
|
||||
stg.snr = np.divide((stg.BS_raw_data - stg.BS_noise_data) ** 2, stg.BS_noise_data ** 2)
|
||||
stg.snr_reshape = np.reshape(stg.snr, (stg.r.shape[0] * stg.time.shape[0], stg.freq.shape[0]), order="F")
|
||||
stg.time_snr = noise_data._time_snr
|
||||
stg.time_snr_reshape = noise_data.reshape_t_snr()
|
||||
stg.snr = noise_data._SNR_data
|
||||
stg.snr_reshape = noise_data.reshape_SNR_data()
|
||||
|
||||
def fill_measurements_information_groupbox(self):
|
||||
if self.combobox_ABS_system_choice.currentIndex() == 1:
|
||||
|
|
@ -872,15 +871,17 @@ class AcousticDataTab(QWidget):
|
|||
elif self.combobox_ABS_system_choice.currentIndex() == 2:
|
||||
if ((self.lineEdit_acoustic_file.text()) and (self.lineEdit_noise_file.text())):
|
||||
stg.DataFrame_acoustic = pd.DataFrame(
|
||||
np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape, stg.snr_reshape), axis=1),
|
||||
columns=list(map(str, ["Time"] + ["BS - " + f for f in stg.freq_text] +
|
||||
np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape, stg.time_snr_reshape, stg.snr_reshape), axis=1),
|
||||
columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] +
|
||||
["BS - " + f for f in stg.freq_text] +
|
||||
["Time SNR - " + f for f in stg.freq_text] +
|
||||
["SNR - " + f for f in stg.freq_text])))
|
||||
self.tableModel = TableModel(stg.DataFrame_acoustic)
|
||||
self.tableView.setModel(self.tableModel)
|
||||
elif self.lineEdit_acoustic_file.text():
|
||||
stg.DataFrame_acoustic = pd.DataFrame(
|
||||
np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape), axis=1),
|
||||
columns=list(map(str, ["Time - " + f for f in stg.freq_text] + ["BS - " + f for f in stg.freq_text])))
|
||||
columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] + ["BS - " + f for f in stg.freq_text])))
|
||||
self.tableModel = TableModel(stg.DataFrame_acoustic)
|
||||
self.tableView.setModel(self.tableModel)
|
||||
else:
|
||||
|
|
@ -1105,42 +1106,92 @@ class AcousticDataTab(QWidget):
|
|||
# self.spinbox_tmin.setValue(np.min(noise_data._time_snr))
|
||||
# self.spinbox_tmax.setValue(np.round(np.max(noise_data._time_snr), 2))
|
||||
|
||||
x, y = np.meshgrid(
|
||||
if self.combobox_ABS_system_choice.currentIndex() == 1:
|
||||
|
||||
x, y = np.meshgrid(
|
||||
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||
stg.r)
|
||||
|
||||
for f in range(stg.freq.shape[0]):
|
||||
for f in range(stg.freq.shape[0]):
|
||||
|
||||
val_min = np.min(stg.snr[:, f, :])
|
||||
val_max = np.max(stg.snr[:, f, :])
|
||||
if val_min == 0:
|
||||
val_min = 1e-5
|
||||
if val_max > 1000:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
||||
else:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
||||
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
||||
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
||||
val_min = np.min(stg.snr[:, f, :])
|
||||
val_max = np.max(stg.snr[:, f, :])
|
||||
if val_min == 0:
|
||||
val_min = 1e-5
|
||||
if val_max > 1000:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
||||
else:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
||||
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
||||
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
||||
|
||||
cf = (self.axis_SNR[f].
|
||||
contourf(x, -y,
|
||||
stg.snr[:, f,
|
||||
np.where(np.round(stg.snr, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||
levels, cmap='gist_rainbow', norm=norm))
|
||||
cf = (self.axis_SNR[f].
|
||||
contourf(x, -y,
|
||||
stg.snr[:, f,
|
||||
np.where(np.round(stg.snr, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||
levels, cmap='gist_rainbow', norm=norm))
|
||||
|
||||
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
horizontalalignment='right', verticalalignment='bottom',
|
||||
transform=self.axis_SNR[f].transAxes)
|
||||
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
horizontalalignment='right', verticalalignment='bottom',
|
||||
transform=self.axis_SNR[f].transAxes)
|
||||
|
||||
self.fig_SNR.supxlabel('Time (sec)', fontsize=10)
|
||||
self.fig_SNR.supylabel('Depth (m)', fontsize=10)
|
||||
cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right')
|
||||
cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10)
|
||||
cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$'])
|
||||
self.fig_SNR.canvas.draw_idle()
|
||||
self.fig_SNR.supxlabel('Time (sec)', fontsize=10)
|
||||
self.fig_SNR.supylabel('Depth (m)', fontsize=10)
|
||||
cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right')
|
||||
cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10)
|
||||
cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$'])
|
||||
self.fig_SNR.canvas.draw_idle()
|
||||
|
||||
elif self.combobox_ABS_system_choice.currentIndex() == 2:
|
||||
|
||||
x = np.array([[[]]])
|
||||
y = np.array([[[]]])
|
||||
print(f"x : {x.shape}, y : {y.shape}")
|
||||
for f, freq in enumerate(stg.freq):
|
||||
|
||||
if x.shape[2] == 0:
|
||||
x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :])
|
||||
x = np.array([x])
|
||||
y = np.array([y])
|
||||
print(f"x : {x.shape}, y : {y.shape}")
|
||||
else:
|
||||
x0, y0 = np.meshgrid(stg.time_snr[f, :], stg.r[f, :])
|
||||
x = np.append(x, np.array([x0]), axis=0)
|
||||
y = np.append(y, np.array([y0]), axis=0)
|
||||
print(f"x : {x.shape}, y : {y.shape}")
|
||||
|
||||
val_min = np.nanmin(abs(stg.snr[f, :, :]))
|
||||
# print(f"val_min = {val_min}")
|
||||
val_max = np.nanmax(abs(stg.snr[f, :, :]))
|
||||
# print(f"val_max = {val_max}")
|
||||
if int(val_min) == 0:
|
||||
val_min = 1e-5
|
||||
if int(val_max) < 1000:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
||||
bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2]
|
||||
else:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
||||
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
||||
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
||||
|
||||
# print(f"levels = {levels}")
|
||||
# print(f"norm = {norm.boundaries}")
|
||||
|
||||
cf = self.axis_SNR[f].contourf(x[f, :, :], y[f, :, :], stg.snr[f, :, :])#, levels, cmap='gist_rainbow', norm=norm)
|
||||
|
||||
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
horizontalalignment='right', verticalalignment='bottom',
|
||||
transform=self.axis_SNR[f].transAxes)
|
||||
|
||||
self.fig_SNR.supxlabel('Time (sec)', fontsize=10)
|
||||
self.fig_SNR.supylabel('Depth (m)', fontsize=10)
|
||||
cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right')
|
||||
cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10)
|
||||
self.fig_SNR.canvas.draw_idle()
|
||||
|
||||
def update_xaxis_transect_with_SNR_data(self):
|
||||
|
||||
|
|
@ -1155,42 +1206,121 @@ class AcousticDataTab(QWidget):
|
|||
if ((self.canvas_BS != None) and (self.canvas_SNR != None)):
|
||||
|
||||
# --- Backscatter noise signal is recorded for next tab ---
|
||||
stg.Noise_data = stg.BS_noise_data[:, :, np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
|
||||
|
||||
stg.SNR_data = stg.snr[:, :, np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
|
||||
stg.tmin_snr = np.array([])
|
||||
stg.tmax_snr = np.array([])
|
||||
|
||||
x, y = np.meshgrid(
|
||||
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||
stg.r)
|
||||
stg.SNR_data = np.array([[[]]])
|
||||
stg.t_snr = np.array([[]])
|
||||
|
||||
x = np.array([[[]]])
|
||||
y = np.array([[[]]])
|
||||
print(f"x : {x.shape}, y : {y.shape}")
|
||||
for f in range(stg.freq.shape[0]):
|
||||
|
||||
if x.shape[2] == 0:
|
||||
x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :])
|
||||
x = np.array([x])
|
||||
y = np.array([y])
|
||||
print(f"x : {x.shape}, y : {y.shape}")
|
||||
else:
|
||||
x0, y0 = np.meshgrid(stg.time_snr[f, :], stg.r[f, :])
|
||||
x = np.append(x, np.array([x0]), axis=0)
|
||||
y = np.append(y, np.array([y0]), axis=0)
|
||||
print(f"x : {x.shape}, y : {y.shape}")
|
||||
|
||||
# print(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value()))
|
||||
# print(np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value()) ==
|
||||
# np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value())))[0][0])
|
||||
|
||||
stg.tmin_snr = (
|
||||
np.append(stg.tmin_snr,
|
||||
np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value()) ==
|
||||
np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmin.value())))[0][
|
||||
0])
|
||||
)
|
||||
|
||||
stg.tmax_snr = (
|
||||
np.append(stg.tmax_snr,
|
||||
np.where(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmax.value()) ==
|
||||
np.nanmin(np.abs(np.round(stg.time_snr[f, :], 2) - self.spinbox_tmax.value())))[0][
|
||||
0])
|
||||
)
|
||||
|
||||
print("stg.tmin[f] ", stg.tmin_snr[f])
|
||||
print("stg.tmax[f] ", stg.tmax_snr[f])
|
||||
|
||||
if stg.SNR_data.shape[2] == 0:
|
||||
stg.SNR_data = np.array([stg.snr[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]])
|
||||
else:
|
||||
stg.SNR_data = np.append(stg.SNR_data,
|
||||
np.array([stg.snr[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]),
|
||||
axis=0)
|
||||
|
||||
# stg.BS_data = np.stack(np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0)
|
||||
# stg.BS_data = np.append(stg.BS_data, np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=2)
|
||||
|
||||
if stg.t_snr.shape[1] == 0:
|
||||
stg.t_snr = np.array([stg.time_snr[f, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]])
|
||||
else:
|
||||
stg.t_snr = np.append(stg.t_snr, np.array([stg.time_snr[f, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]]), axis=0)
|
||||
# stg.t = np.append(stg.t, np.array([stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0)
|
||||
print("stg.t shape ", stg.t_snr.shape)
|
||||
|
||||
self.axis_SNR[f].cla()
|
||||
|
||||
val_min = np.min(stg.snr[:, f, :])
|
||||
val_max = np.max(stg.snr[:, f, :])
|
||||
if val_min == 0:
|
||||
val_min = 1e-5
|
||||
if val_max > 1000:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
||||
else:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
||||
if self.combobox_ABS_system_choice.currentIndex() == 1:
|
||||
|
||||
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
||||
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
||||
val_min = np.nanmin(stg.SNR_data[f, :, :])
|
||||
val_max = np.nanmax(stg.snr[f, :, :])
|
||||
if val_min == 0:
|
||||
val_min = 1e-5
|
||||
if val_max < 1000:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
||||
else:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
||||
|
||||
cf = self.axis_SNR[f].contourf(x, -y,
|
||||
stg.snr[:, f,
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||
levels, cmap='gist_rainbow', norm=norm)
|
||||
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
||||
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
||||
|
||||
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
horizontalalignment='right', verticalalignment='bottom',
|
||||
transform=self.axis_SNR[f].transAxes)
|
||||
cf = self.axis_SNR[f].contourf(x, -y,
|
||||
stg.snr[:, f,
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||
levels, cmap='gist_rainbow', norm=norm)
|
||||
|
||||
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
horizontalalignment='right', verticalalignment='bottom',
|
||||
transform=self.axis_SNR[f].transAxes)
|
||||
|
||||
elif self.combobox_ABS_system_choice.currentIndex() == 2:
|
||||
|
||||
val_min = np.nanmin(abs(stg.snr[f, :, :]))
|
||||
# print(f"val_min = {val_min}")
|
||||
val_max = np.nanmax(abs(stg.snr[f, :, :]))
|
||||
# print(f"val_max = {val_max}")
|
||||
if int(val_min) == 0:
|
||||
val_min = 1e-5
|
||||
if int(val_max) < 1000:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
||||
bounds = [00.1, 1, 2, 10, 100, 1000, 1e6, 1e6 * 1.2]
|
||||
else:
|
||||
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
||||
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
||||
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
||||
|
||||
# print(f"levels = {levels}")
|
||||
# print(f"norm = {norm.boundaries}")
|
||||
|
||||
cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])],
|
||||
y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])],
|
||||
stg.snr[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]) # , levels, cmap='gist_rainbow', norm=norm)
|
||||
|
||||
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
horizontalalignment='right', verticalalignment='bottom',
|
||||
transform=self.axis_SNR[f].transAxes)
|
||||
|
||||
self.fig_SNR.supxlabel('Distance from left bank (m)', fontsize=10)
|
||||
self.fig_SNR.supylabel('Depth (m)', fontsize=10)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ time_snr = np.array([])
|
|||
|
||||
# --- reshape raw data for table of values in Acoustic Data tab ---
|
||||
time_reshape = np.array([])
|
||||
time_snr_reshape = np.array([])
|
||||
r_reshape = np.array([])
|
||||
BS_raw_data_reshape = np.array([])
|
||||
snr_reshape = np.array([]) # snr is reshape to be included in table of values in acoustic data tab
|
||||
|
|
@ -45,12 +46,15 @@ DataFrame_acoustic = pd.DataFrame()
|
|||
|
||||
# --- Processed data in Acoustic Data Tab and used in Acoustic processing tab ---
|
||||
tmin = np.array([]) # minimum boundary of time (spin box tmin)
|
||||
tmin_snr = np.array([])
|
||||
tmax = np.array([]) # maximum boundary of time (spin box tmin)
|
||||
tmax_snr = np.array([])
|
||||
BS_data = np.array([]) # BS data limited with tmin and tmax values of spin box
|
||||
BS_data_section = np.array([]) # BS data in the section. Values NaN outside the bottom of the section are deleted
|
||||
Noise_data = np.array([]) # Noise_data = BS_noise_data[:, :, tmin:tmax]
|
||||
SNR_data = np.array([]) # SNR_data = snr[:, :, tmin:tmax]
|
||||
t = np.array([])
|
||||
t_snr = np.array([])
|
||||
r_bottom = np.array([])
|
||||
val_bottom = np.array([])
|
||||
ind_bottom = np.array([])
|
||||
|
|
|
|||
Loading…
Reference in New Issue