mirror of
https://forgemia.inra.fr/theophile.terraz/acoused.git
synced 2026-10-30 03:10:40 +01:00
Implementation of SNR data from UBSediFlow ABS tool
This commit is contained in:
1 parent
92a0b5fa54
commit
426c68c880
3 files changed
+306
-71
No files matched your search
+195
-65
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user