From ab9d3c026ef72a233d69d81b4a1c6f3677f7e171 Mon Sep 17 00:00:00 2001 From: brahim Date: Fri, 12 Jul 2024 14:55:29 +0200 Subject: [PATCH] Bottom can be detected before (BS_raw_data) and after (BS_cross_section) change limits of the acoustic recording. --- View/acoustic_data_tab.py | 797 +++++++++++++++++++++++--------------- 1 file changed, 475 insertions(+), 322 deletions(-) diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 5bf0834..c63e2ae 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -3013,7 +3013,54 @@ class AcousticDataTab(QWidget): for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): 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_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: 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)) + -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') + -stg.depth[self.fileListWidget.currentRow()][f, + :], + np.log( + stg.BS_raw_data[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[self.fileListWidget.currentRow()].shape[ - 1] - 1 - else np.max(stg.time[self.fileListWidget.currentRow()].shape[1] - 1)][0] + [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] self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - stg.time[self.fileListWidget.currentRow()][0, slider_value] * - np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]), - -stg.depth[self.fileListWidget.currentRow()][ - self.combobox_frequency_profile.currentIndex(), :], - color='red', linestyle="solid", linewidth=2) + stg.time[self.fileListWidget.currentRow()][0, slider_value] * + np.ones(stg.depth[self.fileListWidget.currentRow()].shape[1]), + -stg.depth[self.fileListWidget.currentRow()][ + self.combobox_frequency_profile.currentIndex(), :], + color='red', linestyle="solid", linewidth=2) # --- 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.combobox_frequency_bathymetry.currentIndex(), :], - -stg.depth[self.fileListWidget.currentRow()], + -stg.depth_bottom[self.fileListWidget.currentRow()], 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], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, 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 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.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)") - self.fig_profile.supylabel("Depth (m)") - # self.fig_profile.canvas.draw() - self.fig_profile.canvas.draw_idle() - # self.fig_profile.canvas.flush_events() - # plt.close(self.fig_profile) + # --- Set slider value --- + 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] + + # --- 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: - 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() + # --- 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 --- - 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(), :], + 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) - # --- 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 --- - - 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) + 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) # --- Plot bottom line --- - - # 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: - + 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) + np.nanmax(stg.BS_raw_data[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(), :])) + 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) + 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) - self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") - self.fig_profile.supylabel("Depth (m)") - # self.fig_profile.canvas.draw() - self.fig_profile.canvas.draw_idle() - # self.fig_profile.canvas.flush_events() - # plt.close(self.fig_profile) + self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") + self.fig_profile.supylabel("Depth (m)") + self.fig_profile.canvas.draw_idle() + # self.fig_profile.canvas.flush_events() + # plt.close(self.fig_profile) def slide_profile_number_to_begin(self): self.slider.setValue(int(self.slider.minimum())) @@ -3842,39 +3866,35 @@ class AcousticDataTab(QWidget): # # stg.freq_bottom_detection.append(self.combobox_frequency_bathymetry.currentIndex()) - if stg.depth_bottom == []: - stg.freq_bottom_detection = [np.array([])]*self.fileListWidget.count() - stg.depth_bottom = [np.array([])]*self.fileListWidget.count() - stg.val_bottom = [np.array([])]*self.fileListWidget.count() - stg.ind_bottom = [np.array([])]*self.fileListWidget.count() + # if stg.depth_bottom == []: + # stg.freq_bottom_detection = [np.array([])]*self.fileListWidget.count() + # stg.depth_bottom = [np.array([])]*self.fileListWidget.count() + # stg.val_bottom = [np.array([])]*self.fileListWidget.count() + # stg.ind_bottom = [np.array([])]*self.fileListWidget.count() - # print("stg.freq_bottom_detection : ", stg.freq_bottom_detection) - # print("stg.depth_bottom : ", stg.depth_bottom) - # print("stg.val_bottom : ", stg.val_bottom) - # print("stg.ind_bottom : ", stg.ind_bottom) + if stg.BS_cross_section[self.fileListWidget.currentRow()].shape != (0,): - 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 # rmin = np.float32(self.doubleRangeSlider_intg_area.value()[0].text().replace(",", ".")) # rmax = np.float32(self.doubleRangeSlider_intg_area.value()[1].text().replace(",", ".")) - rmin = -self.doubleRangeSlider_intg_area.value()[1] - rmax = -self.doubleRangeSlider_intg_area.value()[0] - print(f"rmin = {rmin}") - print(f"rmax = {rmax}") + rmin = -self.doubleRangeSlider_intg_area.value()[1] + rmax = -self.doubleRangeSlider_intg_area.value()[0] # empty result arrays # r_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]) - val_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) - r_bottom_ind = [] + 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]) + + r_bottom_ind = [] # 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(), :, :]) - # 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) + BS_smooth = deepcopy(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :, :]) + # print(f"BS_smooth shape : {BS_smooth.shape}") + for k in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]): + BS_smooth[:, k] = savgol_filter(BS_smooth[:, k], 10, 2) # 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') @@ -3883,200 +3903,333 @@ class AcousticDataTab(QWidget): # ----------- Detecting the bottom ------------- # for d in range(stg.nb_profiles): - for d in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]): - # Index of the range where we look for the peak - # print(f"self.combobox_freq_choice.currentIndex() : {self.combobox_freq_choice.currentIndex()}") - # 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_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_max : {ind_max}") + for d in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]): + # Index of the range where we look for the peak + # print(f"self.combobox_freq_choice.currentIndex() : {self.combobox_freq_choice.currentIndex()}") + # 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_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_max : {ind_max}") - # Getting the peak - 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(BS_smooth[ind_min:ind_max, d]) - # print('---------------------------------------------------') - # 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]) - 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((stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), 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) + # Getting the peak + 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(BS_smooth[ind_min:ind_max, d]) + # print('---------------------------------------------------') + # 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]) + 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((stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), 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) - 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) - # 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()) - 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(",", ".")) + 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) + # 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()) + 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(",", ".")) - # --- Plot vertical profile for bottom detection --- - # n = 60 - # t0 = 200 - # 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(f"x0 = {x0}") - # r1 = 98 - # r2 = 150 - # fig2, ax2 = plt.subplots(nrows=1, ncols=n, layout="constrained") - # for i in range(n): - # ax2[i].plot(stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), r1:r2, t1 + i], - # -stg.r[0, r1:r2], 'b') - # 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].set_xticks([]) - # if i != 0: - # ax2[i].set_yticks([]) - # plt.show() + # --- Plot vertical profile for bottom detection --- + # n = 60 + # t0 = 200 + # 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(f"x0 = {x0}") + # r1 = 98 + # r2 = 150 + # fig2, ax2 = plt.subplots(nrows=1, ncols=n, layout="constrained") + # for i in range(n): + # ax2[i].plot(stg.BS_raw_data[self.combobox_freq_choice.currentIndex(), r1:r2, t1 + i], + # -stg.r[0, r1:r2], 'b') + # 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].set_xticks([]) + # if i != 0: + # ax2[i].set_yticks([]) + # plt.show() - # print(f"r_bootom shape : {r_bottom.shape}") - BS_section_bottom = np.zeros((stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1], - stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])) + # print(f"r_bootom shape : {r_bottom.shape}") + BS_section_bottom = np.zeros((stg.depth_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]): - try: - # print(f"r_bottom_ind : {r_bottom_ind}") - 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() + for i in range(BS_section_bottom.shape[0]): + try: + # print(f"r_bottom_ind : {r_bottom_ind}") + 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.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]] + 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.depth_bottom[self.fileListWidget.currentRow()] = r_bottom - print("stg.depth_bottom", stg.depth_bottom) + stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom + print("stg.depth_bottom", stg.depth_bottom) - stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom - print("stg.val_bottom", stg.val_bottom) + stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom + print("stg.val_bottom", stg.val_bottom) - stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind - print("stg.ind_bottom", stg.ind_bottom) + stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind + print("stg.ind_bottom", stg.ind_bottom) - # if ((self.fileListWidget.count() == 1) and (len(stg.depth_bottom) == 0)): - # stg.depth_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()])] - # stg.ind_bottom = [r_bottom_ind] - # - # elif len(stg.depth_bottom) < self.fileListWidget.count(): - # - # stg.depth_bottom.append(r_bottom) - # - # stg.val_bottom.append(val_bottom) - # - # stg.ind_bottom.append(r_bottom_ind) - # - # else: - # - # 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 + # if ((self.fileListWidget.count() == 1) and (len(stg.depth_bottom) == 0)): + # stg.depth_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()])] + # stg.ind_bottom = [r_bottom_ind] + # + # elif len(stg.depth_bottom) < self.fileListWidget.count(): + # + # stg.depth_bottom.append(r_bottom) + # + # stg.val_bottom.append(val_bottom) + # + # stg.ind_bottom.append(r_bottom_ind) + # + # else: + # + # 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_cross_section[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_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :] - >= stg.depth_bottom[self.fileListWidget.currentRow()][k])[ - 0], k] = np.nan + BS_stream_bed_copy = deepcopy(stg.BS_cross_section[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_cross_section[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 + stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy - # if ((self.fileListWidget.count() == 1) and (len(stg.BS_stream_bed) == 0)): - # - # stg.BS_stream_bed = [BS_stream_bed_copy] - # - # elif len(stg.BS_stream_bed) < self.fileListWidget.count(): - # - # stg.BS_stream_bed.append(BS_stream_bed_copy) - # - # else: - # - # stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy + # if ((self.fileListWidget.count() == 1) and (len(stg.BS_stream_bed) == 0)): + # + # stg.BS_stream_bed = [BS_stream_bed_copy] + # + # elif len(stg.BS_stream_bed) < self.fileListWidget.count(): + # + # stg.BS_stream_bed.append(BS_stream_bed_copy) + # + # else: + # + # 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() + # --- 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 + 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 - # 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)) - 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') + 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') - # 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.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") - # print("stg.t[self.combobox_freq_choice.currentIndex(), :] : ", stg.t[self.combobox_freq_choice.currentIndex(), :].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(), :], - -stg.depth_bottom[self.fileListWidget.currentRow()], - color='black', linewidth=1, linestyle="solid") + # print("stg.t[self.combobox_freq_choice.currentIndex(), :] : ", stg.t[self.combobox_freq_choice.currentIndex(), :].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(), :], + -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) + 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() + # --- 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.depth_bottom : ", stg.depth_bottom)