SNR is computed from Aquascat data and implemented following UBSediFlow array layout for acoustic data tab.

dev-brahim
brahim 2023-10-13 14:20:08 +02:00
parent 0e4899da9c
commit bdf900a9bb
1 changed files with 248 additions and 177 deletions

View File

@ -681,6 +681,9 @@ class AcousticDataTab(QWidget):
self.WindowNoiseLevelTailAveragedProfile().show()
def open_dialog_box(self):
print(self.combobox_ABS_system_choice.currentText())
print(self.sender().objectName())
# --- Open dialog box + choice directory and select file ---
if self.combobox_ABS_system_choice.currentIndex() == 0:
msgBox = QMessageBox()
@ -695,7 +698,7 @@ class AcousticDataTab(QWidget):
"Aquascat file (*.aqa)")
dir_name = path.dirname(filename[0])
name = path.basename(filename[0])
print(dir_name, name)
elif self.combobox_ABS_system_choice.currentIndex() == 2:
filename = QFileDialog.getOpenFileName(self, "Open file", "", "UBSediFlow file (*.udt)")
dir_name = path.dirname(filename[0])
@ -710,7 +713,9 @@ class AcousticDataTab(QWidget):
stg.path_BS_raw_data = dir_name
stg.filename_BS_raw_data = name
self.load_BS_acoustic_raw_data()
print("0 Je suis sur la donnée BS")
except ValueError as e:
print("1 Je suis sur la donnée BS")
msgBox = QMessageBox()
msgBox.setWindowTitle("Download Error")
msgBox.setIcon(QMessageBox.Warning)
@ -731,8 +736,12 @@ class AcousticDataTab(QWidget):
try:
stg.path_BS_noise_data = dir_name
stg.filename_BS_noise_data = name
print("dir_name ", stg.path_BS_noise_data)
print("filename ", stg.filename_BS_noise_data)
self.load_noise_data_and_compute_SNR()
print("0 je suis sur la donnée SNR")
except ValueError as e:
print("1 je suis sur la donnée SNR")
msgBox = QMessageBox()
msgBox.setWindowTitle("Download Error")
msgBox.setIcon(QMessageBox.Warning)
@ -793,13 +802,15 @@ class AcousticDataTab(QWidget):
# stg.BS_noise_data = noise_data._BS_raw_data
stg.date_noise = noise_data._date
stg.hour_noise = noise_data._hour
stg.time_snr = noise_data._time
stg.time_snr = stg.time
stg.time_snr_reshape = stg.time_reshape
print(stg.time_snr.shape)
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))
for f, _ in enumerate(noise_data._freq):
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.snr_reshape = np.reshape(stg.snr, (stg.r.shape[1] * stg.time.shape[1], stg.freq.shape[0]), order="F")
elif self.combobox_ABS_system_choice.currentIndex() == 2:
@ -1106,92 +1117,98 @@ 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))
if self.combobox_ABS_system_choice.currentIndex() == 1:
# 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]):
#
# 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))
#
# 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()
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)
# elif self.combobox_ABS_system_choice.currentIndex() == 2:
for f in range(stg.freq.shape[0]):
x = np.array([[[]]])
y = np.array([[[]]])
print(f"x : {x.shape}, y : {y.shape}")
for f, freq in enumerate(stg.freq):
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 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)
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))
# print(f"levels = {levels}")
# print(f"norm = {norm.boundaries}")
if self.combobox_ABS_system_choice.currentIndex() == 1:
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[f, :, :], -y[f, :, :],
stg.snr[f, :, :], levels, cmap='gist_rainbow', norm=norm)
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}")
elif self.combobox_ABS_system_choice.currentIndex() == 2:
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.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()
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):
@ -1216,7 +1233,7 @@ class AcousticDataTab(QWidget):
x = np.array([[[]]])
y = np.array([[[]]])
print(f"x : {x.shape}, y : {y.shape}")
for f in range(stg.freq.shape[0]):
for f, _ in enumerate(stg.freq):
if x.shape[2] == 0:
x, y = np.meshgrid(stg.time_snr[f, :], stg.r[f, :])
@ -1269,62 +1286,71 @@ class AcousticDataTab(QWidget):
self.axis_SNR[f].cla()
# if self.combobox_ABS_system_choice.currentIndex() == 1:
#
# 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])
#
# 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.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}")
if self.combobox_ABS_system_choice.currentIndex() == 1:
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])
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.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)
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)
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)
-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.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)
self.fig_SNR.canvas.draw_idle()
self.fig_SNR.supxlabel('Distance from left bank (m)', fontsize=10)
self.fig_SNR.supylabel('Depth (m)', fontsize=10)
self.fig_SNR.canvas.draw_idle()
def detect_bottom(self):
if self.lineEdit_acoustic_file.text() == "":
@ -1371,11 +1397,12 @@ class AcousticDataTab(QWidget):
# ----------- Detecting the bottom -------------
for d in range(stg.nb_profiles):
# Index of the range where we look for the peak
ind_min = np.where(stg.r >= rmin)[0][0]
ind_max = np.where(stg.r <= rmax)[0][-1]
ind_min = np.where(stg.r[int(self.combobox_freq_choice.currentIndex()), :] >= rmin)[0][0]
ind_max = np.where(stg.r[int(self.combobox_freq_choice.currentIndex()), :] <= rmax)[0][-1]
# Getting the peak
try:
val_bottom[d] = np.nanmax(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d])
val_bottom[d] = np.nanmax(stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d])
except ValueError as e:
msgBox = QMessageBox()
msgBox.setWindowTitle("Detect bottom Error")
@ -1388,17 +1415,17 @@ class AcousticDataTab(QWidget):
break #msgBox.close()
else:
# Getting the range cell of the peak
ind_bottom = np.where(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d]
ind_bottom = np.where(stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d]
== val_bottom[d])[0][0]
np.append(stg.ind_bottom, ind_bottom)
r_bottom[d] = stg.r[ind_bottom + ind_min]
r_bottom[d] = stg.r[self.combobox_freq_choice.currentIndex(), ind_bottom + ind_min]
r_bottom_ind.append(ind_bottom + ind_min)
# Updating the range where we will look for the peak (in the next cell)
rmin = r_bottom[d] - locale.atof(self.doublespinbox_next_cell.text())
rmax = r_bottom[d] + locale.atof(self.doublespinbox_next_cell.text())
BS_section_bottom = np.zeros((stg.r.shape[0], stg.time.shape[0]))
BS_section_bottom = np.zeros((stg.r.shape[1], stg.time.shape[1]))
for i in range(BS_section_bottom.shape[0]):
try:
@ -1416,35 +1443,45 @@ class AcousticDataTab(QWidget):
if BS_section_bottom.sum() > 2:
# --- Record r_bottom for other tabs ---
stg.r_bottom = r_bottom[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.val_bottom = val_bottom[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_bottom = r_bottom[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.val_bottom = val_bottom[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_bottom = r_bottom[int(stg.tmin[self.combobox_freq_choice.currentIndex()]):
int(stg.tmax[self.combobox_freq_choice.currentIndex()])]
stg.val_bottom = val_bottom[int(stg.tmin[self.combobox_freq_choice.currentIndex()]):
int(stg.tmax[self.combobox_freq_choice.currentIndex()])]
# --- Plot transect BS with bathymetry ---
for f in range(stg.freq.shape[0]):
for f, _ in enumerate(stg.freq):
self.axis_BS[f].cla()
val_min = np.min(stg.BS_raw_data[:, f, :])
val_max = np.max(stg.BS_raw_data[:, f, :])
val_min = np.min(stg.BS_raw_data[f, :, :])
val_max = np.max(stg.BS_raw_data[f, :, :])
if val_min == 0:
val_min = 1e-5
pcm = self.axis_BS[f].pcolormesh(
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.BS_raw_data[:, 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]]),
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
# pcm = self.axis_BS[f].pcolormesh(
# 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.BS_raw_data[:, 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]]),
# cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
self.axis_BS[f].plot(
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]],
- r_bottom[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]],
color='black', linewidth=1, linestyle="solid")
pcm = self.axis_BS[f].pcolormesh(stg.t[f, :], -stg.r[f, :], stg.BS_data[f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
# self.axis_BS[f].plot(
# 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]],
# - r_bottom[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]],
# color='black', linewidth=1, linestyle="solid")
self.axis_BS[f].plot(stg.t[self.combobox_freq_choice.currentIndex(), :], -stg.r_bottom,
color='black', linewidth=1, linestyle="solid")
self.axis_BS[f].text(1, .70, stg.freq_text[f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
@ -1455,47 +1492,80 @@ class AcousticDataTab(QWidget):
# --- Plot transect SNR with bathymetry ---
if self.canvas_SNR != None:
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)
# 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)
x = np.array([[[]]])
y = np.array([[[]]])
print(f"x : {x.shape}, y : {y.shape}")
for f, _ 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}")
for f in range(stg.freq.shape[0]):
self.axis_SNR[f].cla()
val_min = np.min(stg.snr[:, f, :])
val_max = np.max(stg.snr[:, f, :])
val_min = abs(np.nanmin(stg.snr[f, :, :]))
val_max = abs(np.nanmax(stg.snr[f, :, :]))
if val_min == 0:
val_min = 1e-5
if val_max > 1000:
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.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) # , shading='gouraud')
# 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) # , shading='gouraud')
if self.combobox_ABS_system_choice.currentIndex() == 1:
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)
elif self.combobox_ABS_system_choice.currentIndex() == 2:
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.axis_SNR[f].plot(
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]],
- r_bottom[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]],
self.axis_SNR[f].plot(stg.t[self.combobox_freq_choice.currentIndex(), :], -stg.r_bottom,
color='black', linewidth=1, linestyle="solid")
# self.axis_SNR[f].plot(
# 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]],
# - r_bottom[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]],
# + np.min(r_bottom[np.where(np.round(noise_data._time, 2) == self.spinbox_tmin.value())[0][0]:
# np.where(np.round(noise_data._time, 2) == self.spinbox_tmax.value())[0][0]]),
# np.max(self._model.r_bottom_cross_section) - self._model.r_bottom_cross_section + np.min(self._model.r_bottom_cross_section),
color='black', linewidth=1, linestyle="solid")
# color='black', linewidth=1, linestyle="solid")
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
@ -1504,6 +1574,7 @@ class AcousticDataTab(QWidget):
self.fig_SNR.canvas.draw_idle()
# else:
#
# acoustic_data = self.load_BS_acoustic_raw_data()