Bottom can be detected before (BS_raw_data) and after (BS_cross_section) change limits of the acoustic recording.

dev-brahim
brahim 2024-07-12 14:55:29 +02:00
parent 250fed45fc
commit ab9d3c026e
1 changed files with 475 additions and 322 deletions

View File

@ -3013,7 +3013,54 @@ class AcousticDataTab(QWidget):
for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]):
self.axis_BS[f].cla() self.axis_BS[f].cla()
if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): if stg.BS_cross_section[self.fileListWidget.currentRow()].shape != (0,):
val_min = np.nanmin(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :])
val_max = np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :])
if val_min == 0:
val_min = 1e-5
if self.combobox_ABS_system_choice.currentIndex() == 1:
pcm = self.axis_BS[f].pcolormesh(
stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(
stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :,
:]),
cmap='Blues')
# --- Plot red solid line on transect to visualize position of plotted profile ---
slider_value = \
[self.slider.value() - 1 if self.slider.value() - 1 <=
stg.time_cross_section[self.fileListWidget.currentRow()].shape[
1] - 1
else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0]
self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
stg.time_cross_section[self.fileListWidget.currentRow()][
0, # self.combobox_frequency_profile.currentIndex(),
slider_value] * np.ones(
stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1]),
-stg.depth_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :],
color='red', linestyle="solid", linewidth=2)
# --- Plot river bottom line ---
# if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()):
if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,):
# print("stg.depth_bottom ", stg.depth_bottom)
# print("len(stg.depth_bottom) ", len(stg.depth_bottom))
self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :],
-stg.depth_bottom[self.fileListWidget.currentRow()],
color='black', linewidth=1, linestyle="solid")
else:
val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
@ -3022,86 +3069,42 @@ class AcousticDataTab(QWidget):
if self.combobox_ABS_system_choice.currentIndex() == 1: if self.combobox_ABS_system_choice.currentIndex() == 1:
pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :], pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :],
-stg.depth[self.fileListWidget.currentRow()][f, -stg.depth[self.fileListWidget.currentRow()][f,
:], :],
stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, stg.BS_raw_data[self.fileListWidget.currentRow()][f, :,
:], :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif self.combobox_ABS_system_choice.currentIndex() == 2: elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :], pcm = self.axis_BS[f].pcolormesh(stg.time[self.fileListWidget.currentRow()][f, :],
-stg.depth[self.fileListWidget.currentRow()][f, -stg.depth[self.fileListWidget.currentRow()][f,
:], :],
np.log( np.log(
stg.BS_raw_data[self.fileListWidget.currentRow()][f, stg.BS_raw_data[self.fileListWidget.currentRow()][f,
:, :]), :, :]),
cmap='Blues') cmap='Blues')
# --- Plot red solid line on transect to visualize position of plotted profile --- # --- Plot red solid line on transect to visualize position of plotted profile ---
slider_value = \ slider_value = \
[self.slider.value() - 1 if self.slider.value() - 1 <= [self.slider.value() - 1 if self.slider.value() - 1 <=
stg.time[self.fileListWidget.currentRow()].shape[ stg.time[self.fileListWidget.currentRow()].shape[
1] - 1 1] - 1
else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0]
self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
stg.time[self.fileListWidget.currentRow()][0, slider_value] * stg.time[self.fileListWidget.currentRow()][0, slider_value] *
np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]), np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]),
-stg.depth[self.fileListWidget.currentRow()][ -stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :], self.combobox_frequency_profile.currentIndex(), :],
color='red', linestyle="solid", linewidth=2) color='red', linestyle="solid", linewidth=2)
# --- Plot river bottom line --- # --- Plot river bottom line ---
if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0: if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,):
self.axis_BS[f].plot(stg.time[self.fileListWidget.currentRow()][ self.axis_BS[f].plot(stg.time[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :], self.combobox_frequency_bathymetry.currentIndex(), :],
-stg.depth[self.fileListWidget.currentRow()], -stg.depth_bottom[self.fileListWidget.currentRow()],
color='black', linewidth=1, linestyle="solid") color='black', linewidth=1, linestyle="solid")
else:
val_min = np.nanmin(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :])
val_max = np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :])
if val_min == 0:
val_min = 1e-5
if self.combobox_ABS_system_choice.currentIndex() == 1:
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :,
:]),
cmap='Blues')
# --- Plot red solid line on transect to visualize position of plotted profile ---
slider_value = \
[self.slider.value() - 1 if self.slider.value() - 1 <=
stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1
else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0]
self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot(
stg.time_cross_section[self.fileListWidget.currentRow()][
0, # self.combobox_frequency_profile.currentIndex(),
slider_value] * np.ones(
stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1]),
-stg.depth_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :],
color='red', linestyle="solid", linewidth=2)
# --- Plot river bottom line ---
# if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()):
if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0:
# print("stg.depth_bottom ", stg.depth_bottom)
# print("len(stg.depth_bottom) ", len(stg.depth_bottom))
self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :],
-stg.depth_bottom[self.fileListWidget.currentRow()],
color='black', linewidth=1, linestyle="solid")
self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f], self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom', horizontalalignment='right', verticalalignment='bottom',
@ -3422,88 +3425,109 @@ class AcousticDataTab(QWidget):
# if (len(stg.BS_cross_section) == 0) and (len(stg.BS_raw_data) != 0): # if (len(stg.BS_cross_section) == 0) and (len(stg.BS_raw_data) != 0):
if self.fileListWidget.currentRow() != -1: if self.fileListWidget.currentRow() != -1:
if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): if stg.BS_cross_section[self.fileListWidget.currentRow()].shape != (0,):
self.axis_profile.cla() self.axis_profile.cla()
self.axis_profile.plot(stg.BS_raw_data[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
self.axis_profile.text(.95, .05, stg.freq_text[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()],
fontsize=10, fontweight='bold', fontname="Ubuntu",
fontstyle="normal", c="black", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes)
self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") # --- Set slider value ---
self.fig_profile.supylabel("Depth (m)") self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])
# self.fig_profile.canvas.draw() slider_value = [self.slider.value() - 1 if self.slider.value() - 1 <= stg.time_cross_section[
self.fig_profile.canvas.draw_idle() self.fileListWidget.currentRow()].shape[1] - 1
# self.fig_profile.canvas.flush_events() else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0]
# plt.close(self.fig_profile)
# --- Profile plot ---
self.axis_profile.plot(stg.BS_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :, slider_value],
-stg.depth_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1)
# --- Write frequency on graph ---
self.axis_profile.text(.95, .90, stg.freq_text[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex()],
fontsize=14, fontweight='bold', fontname="Ubuntu",
fontstyle="normal", c="black", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes)
# --- Plot bottom line ---
if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,):
self.axis_profile.plot([0,
np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
:, slider_value])],
-stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][
slider_value]] * np.ones(2),
linestyle='solid', color='r', linewidth=1)
position_x = (stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] /
np.nanmax(stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :]))
self.axis_profile.text(.95, 1 - position_x + 0.05, "River bed",
fontsize=10, fontweight='normal', fontname="Ubuntu",
fontstyle="italic", c="red", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes)
else: else:
self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])
slider_value = [self.slider.value() - 1 if self.slider.value() -1 <= stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1
else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1)][0]
self.axis_profile.cla() self.axis_profile.cla()
# --- Set slider value ---
self.slider.setMaximum(stg.time[self.fileListWidget.currentRow()].shape[1])
slider_value = [self.slider.value() - 1 if self.slider.value() - 1 <= stg.time[
self.fileListWidget.currentRow()].shape[1] - 1
else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0]
# --- Profile plot --- # --- Profile plot ---
self.axis_profile.plot(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :, slider_value], self.axis_profile.plot(stg.BS_raw_data[self.fileListWidget.currentRow()][
-stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :], self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1],
-stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :],
linestyle='solid', color='k', linewidth=1) linestyle='solid', color='k', linewidth=1)
# --- Plot upper limit line ---
# self.axis_profile.plot([0,
# stg.BS_cross_section[self.combobox_frequency_profile.currentIndex(),
# stg.ind_bottom[slider_value],
# slider_value]],
# -stg.
# )
# --- Plot lower limit line ---
# --- Write frequency on graph --- # --- Write frequency on graph ---
self.axis_profile.text(.95, .05, stg.freq_text[self.fileListWidget.currentRow()][
self.axis_profile.text(.95, .90, stg.freq_text[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()], self.combobox_frequency_profile.currentIndex()],
fontsize=14, fontweight='bold', fontname="Ubuntu", fontsize=10, fontweight='bold', fontname="Ubuntu",
fontstyle="normal", c="black", alpha=0.2, fontstyle="normal", c="black", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom', horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes) transform=self.axis_profile.transAxes)
# --- Plot bottom line --- # --- Plot bottom line ---
if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,):
# print("len(stg.depth_bottom) ", len(stg.depth_bottom))
# print("self.fileListWidget.currentRow() ", self.fileListWidget.count())
# if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()):
if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0:
self.axis_profile.plot([0, self.axis_profile.plot([0,
np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][
:, slider_value])], self.combobox_frequency_profile.currentIndex(),
-stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]]*np.ones(2), :, slider_value])],
linestyle='solid', color='r', linewidth=1) -stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][
slider_value]] * np.ones(2),
linestyle='solid', color='r', linewidth=1)
position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / position_x = (stg.depth[self.fileListWidget.currentRow()][
np.nanmax(stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :])) self.combobox_frequency_profile.currentIndex(),
stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] /
np.nanmax(stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_profile.currentIndex(), :]))
self.axis_profile.text(.95, 1-position_x + 0.05, "River bed", self.axis_profile.text(.95, 1 - position_x + 0.05, "River bed",
fontsize=10, fontweight='normal', fontname="Ubuntu", fontsize=10, fontweight='normal', fontname="Ubuntu",
fontstyle="italic", c="red", alpha=0.2, fontstyle="italic", c="red", alpha=0.2,
horizontalalignment='right', verticalalignment='bottom', horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_profile.transAxes) transform=self.axis_profile.transAxes)
self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)")
self.fig_profile.supylabel("Depth (m)") self.fig_profile.supylabel("Depth (m)")
# self.fig_profile.canvas.draw() self.fig_profile.canvas.draw_idle()
self.fig_profile.canvas.draw_idle() # self.fig_profile.canvas.flush_events()
# self.fig_profile.canvas.flush_events() # plt.close(self.fig_profile)
# plt.close(self.fig_profile)
def slide_profile_number_to_begin(self): def slide_profile_number_to_begin(self):
self.slider.setValue(int(self.slider.minimum())) self.slider.setValue(int(self.slider.minimum()))
@ -3842,39 +3866,35 @@ class AcousticDataTab(QWidget):
# #
# stg.freq_bottom_detection.append(self.combobox_frequency_bathymetry.currentIndex()) # stg.freq_bottom_detection.append(self.combobox_frequency_bathymetry.currentIndex())
if stg.depth_bottom == []: # if stg.depth_bottom == []:
stg.freq_bottom_detection = [np.array([])]*self.fileListWidget.count() # stg.freq_bottom_detection = [np.array([])]*self.fileListWidget.count()
stg.depth_bottom = [np.array([])]*self.fileListWidget.count() # stg.depth_bottom = [np.array([])]*self.fileListWidget.count()
stg.val_bottom = [np.array([])]*self.fileListWidget.count() # stg.val_bottom = [np.array([])]*self.fileListWidget.count()
stg.ind_bottom = [np.array([])]*self.fileListWidget.count() # stg.ind_bottom = [np.array([])]*self.fileListWidget.count()
# print("stg.freq_bottom_detection : ", stg.freq_bottom_detection) if stg.BS_cross_section[self.fileListWidget.currentRow()].shape != (0,):
# print("stg.depth_bottom : ", stg.depth_bottom)
# print("stg.val_bottom : ", stg.val_bottom)
# print("stg.ind_bottom : ", stg.ind_bottom)
stg.freq_bottom_detection[self.fileListWidget.currentRow()] = self.combobox_frequency_bathymetry.currentIndex() stg.freq_bottom_detection[self.fileListWidget.currentRow()] = self.combobox_frequency_bathymetry.currentIndex()
# Selecting the range in which we look for the bottom reflection # Selecting the range in which we look for the bottom reflection
# rmin = np.float32(self.doubleRangeSlider_intg_area.value()[0].text().replace(",", ".")) # rmin = np.float32(self.doubleRangeSlider_intg_area.value()[0].text().replace(",", "."))
# rmax = np.float32(self.doubleRangeSlider_intg_area.value()[1].text().replace(",", ".")) # rmax = np.float32(self.doubleRangeSlider_intg_area.value()[1].text().replace(",", "."))
rmin = -self.doubleRangeSlider_intg_area.value()[1] rmin = -self.doubleRangeSlider_intg_area.value()[1]
rmax = -self.doubleRangeSlider_intg_area.value()[0] rmax = -self.doubleRangeSlider_intg_area.value()[0]
print(f"rmin = {rmin}")
print(f"rmax = {rmax}")
# empty result arrays # empty result arrays
# r_bottom = np.zeros(stg.nb_profiles) # r_bottom = np.zeros(stg.nb_profiles)
# val_bottom = np.zeros(stg.nb_profiles) # val_bottom = np.zeros(stg.nb_profiles)
r_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) r_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])
val_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) val_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])
r_bottom_ind = []
r_bottom_ind = []
# print(f"r_bottom shape with zeros : {r_bottom.shape}") # print(f"r_bottom shape with zeros : {r_bottom.shape}")
BS_smooth = deepcopy(stg.BS_raw_data[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :, :]) BS_smooth = deepcopy(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :, :])
# print(f"BS_smooth shape : {BS_smooth.shape}") # print(f"BS_smooth shape : {BS_smooth.shape}")
for k in range(stg.time[self.fileListWidget.currentRow()].shape[1]): for k in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]):
BS_smooth[:, k] = savgol_filter(BS_smooth[:, k], 10, 2) BS_smooth[:, k] = savgol_filter(BS_smooth[:, k], 10, 2)
# fig1, ax1 = plt.subplots(nrows=1, ncols=1, layout="constrained") # fig1, ax1 = plt.subplots(nrows=1, ncols=1, layout="constrained")
# pcm1 = ax1.pcolormesh(stg.time[0, :], -stg.r[0, :], np.log(BS_smooth[:, :]), cmap='Blues') # pcm1 = ax1.pcolormesh(stg.time[0, :], -stg.r[0, :], np.log(BS_smooth[:, :]), cmap='Blues')
@ -3883,200 +3903,333 @@ class AcousticDataTab(QWidget):
# ----------- Detecting the bottom ------------- # ----------- Detecting the bottom -------------
# for d in range(stg.nb_profiles): # for d in range(stg.nb_profiles):
for d in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]): for d in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]):
# Index of the range where we look for the peak # Index of the range where we look for the peak
# print(f"self.combobox_freq_choice.currentIndex() : {self.combobox_freq_choice.currentIndex()}") # print(f"self.combobox_freq_choice.currentIndex() : {self.combobox_freq_choice.currentIndex()}")
# print(f"r = {stg.r}") # print(f"r = {stg.r}")
ind_min = np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][int(self.combobox_frequency_bathymetry.currentIndex()), :] >= rmin)[0][0] ind_min = np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][int(self.combobox_frequency_bathymetry.currentIndex()), :] >= rmin)[0][0]
ind_max = np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][int(self.combobox_frequency_bathymetry.currentIndex()), :] <= rmax)[0][-1] ind_max = np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][int(self.combobox_frequency_bathymetry.currentIndex()), :] <= rmax)[0][-1]
# print(f"ind_min : {ind_min}") # print(f"ind_min : {ind_min}")
# print(f"ind_max : {ind_max}") # print(f"ind_max : {ind_max}")
# Getting the peak # Getting the peak
try: try:
# val_bottom[d] = np.nanmax((stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d])) # val_bottom[d] = np.nanmax((stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d]))
val_bottom[d] = np.nanmax(BS_smooth[ind_min:ind_max, d]) val_bottom[d] = np.nanmax(BS_smooth[ind_min:ind_max, d])
# print('---------------------------------------------------') # print('---------------------------------------------------')
# print(f"d = {d}") # print(f"d = {d}")
# print("stg.BS_raw_data[ind_min:ind_max] : ", stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d]) # print("stg.BS_raw_data[ind_min:ind_max] : ", stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d])
except ValueError as e: except ValueError as e:
msgBox = QMessageBox() msgBox = QMessageBox()
msgBox.setWindowTitle("Detect bottom Error") msgBox.setWindowTitle("Detect bottom Error")
msgBox.setIcon(QMessageBox.Warning) msgBox.setIcon(QMessageBox.Warning)
msgBox.setText(f"1/ {e} : maximum value of section bottom is not found. \n " msgBox.setText(f"1/ {e} : maximum value of section bottom is not found. \n "
f"Please change parameter of algorithm") f"Please change parameter of algorithm")
msgBox.setStandardButtons(QMessageBox.Ok) msgBox.setStandardButtons(QMessageBox.Ok)
msgBox_return = msgBox.exec() msgBox_return = msgBox.exec()
if msgBox_return == msgBox.Ok: if msgBox_return == msgBox.Ok:
break #msgBox.close() break #msgBox.close()
else: else:
# Getting the range cell of the peak # Getting the range cell of the peak
# ind_bottom = np.where((stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d]) # ind_bottom = np.where((stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), ind_min:ind_max, d])
# == val_bottom[d])[0][0] # == val_bottom[d])[0][0]
ind_bottom = np.where((BS_smooth[ind_min:ind_max, d]) == val_bottom[d])[0][0] ind_bottom = np.where((BS_smooth[ind_min:ind_max, d]) == val_bottom[d])[0][0]
np.append(stg.ind_bottom, ind_bottom) np.append(stg.ind_bottom, ind_bottom)
r_bottom[d] = stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), ind_bottom + ind_min] r_bottom[d] = stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), ind_bottom + ind_min]
r_bottom_ind.append(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) # 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()) # rmin = r_bottom[d] - locale.atof(self.doublespinbox_next_cell.text())
# rmax = r_bottom[d] + locale.atof(self.doublespinbox_next_cell.text()) # rmax = r_bottom[d] + locale.atof(self.doublespinbox_next_cell.text())
rmin = r_bottom[d] - np.float32(self.spinbox_offset_next_cell.text().replace(",", ".")) rmin = r_bottom[d] - np.float32(self.spinbox_offset_next_cell.text().replace(",", "."))
rmax = r_bottom[d] + np.float32(self.spinbox_offset_next_cell.text().replace(",", ".")) rmax = r_bottom[d] + np.float32(self.spinbox_offset_next_cell.text().replace(",", "."))
# --- Plot vertical profile for bottom detection --- # --- Plot vertical profile for bottom detection ---
# n = 60 # n = 60
# t0 = 200 # t0 = 200
# t1 = np.where(np.abs(stg.time[0, :] - t0) == np.nanmin(np.abs(stg.time[0, :] - t0)))[0][0] # t1 = np.where(np.abs(stg.time[0, :] - t0) == np.nanmin(np.abs(stg.time[0, :] - t0)))[0][0]
# # print(np.abs(self._time[0, :] - 200)) # # print(np.abs(self._time[0, :] - 200))
# # print(f"x0 = {x0}") # # print(f"x0 = {x0}")
# r1 = 98 # r1 = 98
# r2 = 150 # r2 = 150
# fig2, ax2 = plt.subplots(nrows=1, ncols=n, layout="constrained") # fig2, ax2 = plt.subplots(nrows=1, ncols=n, layout="constrained")
# for i in range(n): # for i in range(n):
# ax2[i].plot(stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), r1:r2, t1 + i], # ax2[i].plot(stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), r1:r2, t1 + i],
# -stg.r[0, r1:r2], 'b') # -stg.r[0, r1:r2], 'b')
# ax2[i].plot(BS_smooth[r1:r2, t1 + i], -stg.r[0, r1:r2], 'r') # ax2[i].plot(BS_smooth[r1:r2, t1 + i], -stg.r[0, r1:r2], 'r')
# ax2[i].scatter(val_bottom[i], -r_bottom[i], marker="o", fc="black", s=12) # ax2[i].scatter(val_bottom[i], -r_bottom[i], marker="o", fc="black", s=12)
# ax2[i].set_xticks([]) # ax2[i].set_xticks([])
# if i != 0: # if i != 0:
# ax2[i].set_yticks([]) # ax2[i].set_yticks([])
# plt.show() # plt.show()
# print(f"r_bootom shape : {r_bottom.shape}") # print(f"r_bootom shape : {r_bottom.shape}")
BS_section_bottom = np.zeros((stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1], BS_section_bottom = np.zeros((stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1],
stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])) stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]))
for i in range(BS_section_bottom.shape[0]): for i in range(BS_section_bottom.shape[0]):
try: try:
# print(f"r_bottom_ind : {r_bottom_ind}") # print(f"r_bottom_ind : {r_bottom_ind}")
BS_section_bottom[r_bottom_ind[i]][i] = 1 BS_section_bottom[r_bottom_ind[i]][i] = 1
except IndexError as e: except IndexError as e:
msgBox = QMessageBox() msgBox = QMessageBox()
msgBox.setWindowTitle("Detect bottom Error") msgBox.setWindowTitle("Detect bottom Error")
msgBox.setIcon(QMessageBox.Warning) msgBox.setIcon(QMessageBox.Warning)
msgBox.setText(f"2/ {e} : maximum value of section bottom is not found. \n " msgBox.setText(f"2/ {e} : maximum value of section bottom is not found. \n "
f"Please change parameter of algorithm") f"Please change parameter of algorithm")
msgBox.setStandardButtons(QMessageBox.Ok) msgBox.setStandardButtons(QMessageBox.Ok)
msgBox_return = msgBox.exec() msgBox_return = msgBox.exec()
if msgBox_return == msgBox.Ok: if msgBox_return == msgBox.Ok:
break # msgBox.close() break # msgBox.close()
if BS_section_bottom.sum() > 2: if BS_section_bottom.sum() > 2:
# --- Record r_bottom for other tabs --- # --- Record r_bottom for other tabs ---
# stg.r_bottom = r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.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]] # 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]: # 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]] # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom
print("stg.depth_bottom", stg.depth_bottom) print("stg.depth_bottom", stg.depth_bottom)
stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom
print("stg.val_bottom", stg.val_bottom) print("stg.val_bottom", stg.val_bottom)
stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind
print("stg.ind_bottom", stg.ind_bottom) print("stg.ind_bottom", stg.ind_bottom)
# if ((self.fileListWidget.count() == 1) and (len(stg.depth_bottom) == 0)): # if ((self.fileListWidget.count() == 1) and (len(stg.depth_bottom) == 0)):
# stg.depth_bottom = [r_bottom]#[int(stg.tmin[self.combobox_freq_choice.currentIndex()]): # stg.depth_bottom = [r_bottom]#[int(stg.tmin[self.combobox_freq_choice.currentIndex()]):
# # int(stg.tmax[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()]): # stg.val_bottom = [val_bottom]#[int(stg.tmin[self.combobox_freq_choice.currentIndex()]):
# # int(stg.tmax[self.combobox_freq_choice.currentIndex()])] # # int(stg.tmax[self.combobox_freq_choice.currentIndex()])]
# stg.ind_bottom = [r_bottom_ind] # stg.ind_bottom = [r_bottom_ind]
# #
# elif len(stg.depth_bottom) < self.fileListWidget.count(): # elif len(stg.depth_bottom) < self.fileListWidget.count():
# #
# stg.depth_bottom.append(r_bottom) # stg.depth_bottom.append(r_bottom)
# #
# stg.val_bottom.append(val_bottom) # stg.val_bottom.append(val_bottom)
# #
# stg.ind_bottom.append(r_bottom_ind) # stg.ind_bottom.append(r_bottom_ind)
# #
# else: # else:
# #
# stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom # stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom
# #
# stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom # stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom
# #
# stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind # stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind
BS_stream_bed_copy = deepcopy(stg.BS_cross_section[self.fileListWidget.currentRow()]) BS_stream_bed_copy = deepcopy(stg.BS_cross_section[self.fileListWidget.currentRow()])
for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]):
for k, _ in enumerate(stg.depth_bottom[self.fileListWidget.currentRow()]): for k, _ in enumerate(stg.depth_bottom[self.fileListWidget.currentRow()]):
# print(k, np.where(stg.r >= stg.r_bottom[k])[0]) # print(k, np.where(stg.r >= stg.r_bottom[k])[0])
BS_stream_bed_copy[ BS_stream_bed_copy[
f, np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :] f, np.where(stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :]
>= stg.depth_bottom[self.fileListWidget.currentRow()][k])[ >= stg.depth_bottom[self.fileListWidget.currentRow()][k])[
0], k] = np.nan 0], k] = np.nan
stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy
# if ((self.fileListWidget.count() == 1) and (len(stg.BS_stream_bed) == 0)): # if ((self.fileListWidget.count() == 1) and (len(stg.BS_stream_bed) == 0)):
# #
# stg.BS_stream_bed = [BS_stream_bed_copy] # stg.BS_stream_bed = [BS_stream_bed_copy]
# #
# elif len(stg.BS_stream_bed) < self.fileListWidget.count(): # elif len(stg.BS_stream_bed) < self.fileListWidget.count():
# #
# stg.BS_stream_bed.append(BS_stream_bed_copy) # stg.BS_stream_bed.append(BS_stream_bed_copy)
# #
# else: # else:
# #
# stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy # stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy
# --- Plot transect BS with bathymetry --- # --- Plot transect BS with bathymetry ---
for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]):
self.axis_BS[f].cla() self.axis_BS[f].cla()
val_min = np.min(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) val_min = np.min(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
val_max = np.max(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) val_max = np.max(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
if val_min == 0: if val_min == 0:
val_min = 1e-5 val_min = 1e-5
# pcm = self.axis_BS[f].pcolormesh( # pcm = self.axis_BS[f].pcolormesh(
# stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: # 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]], # np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
# -stg.r, # -stg.r,
# (stg.BS_raw_data[:, f, # (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_tmin.value())[0][0]:
# np.where(np.round(stg.time, 2) == self.spinbox_tmax.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)) # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
if self.combobox_ABS_system_choice.currentIndex() == 1: if self.combobox_ABS_system_choice.currentIndex() == 1:
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :], pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :], stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif self.combobox_ABS_system_choice.currentIndex() == 2: elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :], pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :],
-stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :],
np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]), np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]),
cmap='Blues') cmap='Blues')
# self.axis_BS[f].plot( # self.axis_BS[f].plot(
# stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]: # 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]], # 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]: # - 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.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
# color='black', linewidth=1, linestyle="solid") # color='black', linewidth=1, linestyle="solid")
# print("stg.t[self.combobox_freq_choice.currentIndex(), :] : ", stg.t[self.combobox_freq_choice.currentIndex(), :].shape) # print("stg.t[self.combobox_freq_choice.currentIndex(), :] : ", stg.t[self.combobox_freq_choice.currentIndex(), :].shape)
# print("-stg.r_bottom : ", stg.r_bottom.shape) # print("-stg.r_bottom : ", stg.r_bottom.shape)
self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :], self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :],
-stg.depth_bottom[self.fileListWidget.currentRow()], -stg.depth_bottom[self.fileListWidget.currentRow()],
color='black', linewidth=1, linestyle="solid") color='black', linewidth=1, linestyle="solid")
self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f], self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
horizontalalignment='right', verticalalignment='bottom', horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_BS[f].transAxes) transform=self.axis_BS[f].transAxes)
# --- Update plot profile --- # --- Update plot profile ---
self.update_plot_profile() self.update_plot_profile()
self.fig_BS.canvas.draw_idle() self.fig_BS.canvas.draw_idle()
elif stg.BS_raw_data[self.fileListWidget.currentRow()].shape != (0,):
print("I'm here for bottom detection")
stg.freq_bottom_detection[
self.fileListWidget.currentRow()] = self.combobox_frequency_bathymetry.currentIndex()
# Selecting the range in which we look for the bottom reflection
rmin = -self.doubleRangeSlider_intg_area.value()[1]
rmax = -self.doubleRangeSlider_intg_area.value()[0]
# empty result arrays
r_bottom = np.zeros(stg.time[self.fileListWidget.currentRow()].shape[1])
val_bottom = np.zeros(stg.time[self.fileListWidget.currentRow()].shape[1])
r_bottom_ind = []
BS_smooth = deepcopy(stg.BS_raw_data[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :, :])
# print(f"BS_smooth shape : {BS_smooth.shape}")
for k in range(stg.time[self.fileListWidget.currentRow()].shape[1]):
BS_smooth[:, k] = savgol_filter(BS_smooth[:, k], 10, 2)
# ----------- Detecting the bottom -------------
for d in range(stg.time[self.fileListWidget.currentRow()].shape[1]):
# Index of the range where we look for the peak
ind_min = np.where(stg.depth[self.fileListWidget.currentRow()][
int(self.combobox_frequency_bathymetry.currentIndex()), :] >= rmin)[0][0]
ind_max = np.where(stg.depth[self.fileListWidget.currentRow()][
int(self.combobox_frequency_bathymetry.currentIndex()), :] <= rmax)[0][-1]
# Getting the peak
try:
val_bottom[d] = np.nanmax(BS_smooth[ind_min:ind_max, d])
except ValueError as e:
msgBox = QMessageBox()
msgBox.setWindowTitle("Detect bottom Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText(f"1/ {e} : maximum value of section bottom is not found. \n "
f"Please change parameter of algorithm")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox_return = msgBox.exec()
if msgBox_return == msgBox.Ok:
break # msgBox.close()
else:
# Getting the range cell of the peak
ind_bottom = np.where((BS_smooth[ind_min:ind_max, d]) == val_bottom[d])[0][0]
np.append(stg.ind_bottom, ind_bottom)
r_bottom[d] = stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.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] - np.float32(self.spinbox_offset_next_cell.text().replace(",", "."))
rmax = r_bottom[d] + np.float32(self.spinbox_offset_next_cell.text().replace(",", "."))
BS_section_bottom = np.zeros((stg.depth[self.fileListWidget.currentRow()].shape[1],
stg.time[self.fileListWidget.currentRow()].shape[1]))
for i in range(BS_section_bottom.shape[0]):
try:
BS_section_bottom[r_bottom_ind[i]][i] = 1
except IndexError as e:
msgBox = QMessageBox()
msgBox.setWindowTitle("Detect bottom Error")
msgBox.setIcon(QMessageBox.Warning)
msgBox.setText(f"2/ {e} : maximum value of section bottom is not found. \n "
f"Please change parameter of algorithm")
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox_return = msgBox.exec()
if msgBox_return == msgBox.Ok:
break # msgBox.close()
if BS_section_bottom.sum() > 2:
# --- Record r_bottom for other tabs ---
stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom
stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom
stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind
BS_stream_bed_copy = deepcopy(stg.BS_raw_data[self.fileListWidget.currentRow()])
for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]):
for k, _ in enumerate(stg.depth_bottom[self.fileListWidget.currentRow()]):
# print(k, np.where(stg.r >= stg.r_bottom[k])[0])
BS_stream_bed_copy[
f, np.where(stg.depth[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :]
>= stg.depth_bottom[self.fileListWidget.currentRow()][k])[
0], k] = np.nan
stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy
# --- Plot transect BS with bathymetry ---
for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]):
self.axis_BS[f].cla()
val_min = np.min(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
val_max = np.max(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :])
if val_min == 0:
val_min = 1e-5
if self.combobox_ABS_system_choice.currentIndex() == 1:
pcm = self.axis_BS[f].pcolormesh(
stg.time[self.fileListWidget.currentRow()][f, :],
-stg.depth[self.fileListWidget.currentRow()][f, :],
stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :],
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
elif self.combobox_ABS_system_choice.currentIndex() == 2:
pcm = self.axis_BS[f].pcolormesh(
stg.time[self.fileListWidget.currentRow()][f, :],
-stg.depth[self.fileListWidget.currentRow()][f, :],
np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]),
cmap='Blues')
self.axis_BS[f].plot(stg.time[self.fileListWidget.currentRow()][
self.combobox_frequency_bathymetry.currentIndex(), :],
-stg.depth_bottom[self.fileListWidget.currentRow()],
color='black', linewidth=1, linestyle="solid")
self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f],
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black",
alpha=0.5,
horizontalalignment='right', verticalalignment='bottom',
transform=self.axis_BS[f].transAxes)
# --- Update plot profile ---
self.update_plot_profile()
self.fig_BS.canvas.draw_idle()
# print("stg.freq_bottom_detection : ", stg.freq_bottom_detection) # print("stg.freq_bottom_detection : ", stg.freq_bottom_detection)
# print("stg.depth_bottom : ", stg.depth_bottom) # print("stg.depth_bottom : ", stg.depth_bottom)