diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index d78044c..f879ac7 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -971,7 +971,7 @@ class AcousticDataTab(QWidget): self.fileListWidget.itemSelectionChanged.connect(self.fill_table) self.fileListWidget.itemSelectionChanged.connect(self.compute_time) self.fileListWidget.itemSelectionChanged.connect(self.compute_depth) - self.fileListWidget.itemSelectionChanged.connect(self.compute_BS_cross_section) + # self.fileListWidget.itemSelectionChanged.connect(self.compute_BS_cross_section) self.fileListWidget.itemSelectionChanged.connect(self.update_frequency_combobox) self.fileListWidget.itemSelectionChanged.connect(self.plot_backscattered_acoustic_signal_recording) self.fileListWidget.itemSelectionChanged.connect(self.plot_profile) @@ -996,14 +996,14 @@ class AcousticDataTab(QWidget): # self.doubleRangeSlider_recording_time.lab .connect(self.print_value_doubleRangeSlider) self.pushbutton_apply_depth_limits.clicked.connect(self.set_rmin_rmax_for_doubleRangeSider_depth) - self.pushbutton_apply_depth_limits.clicked.connect(self.compute_depth) + # self.pushbutton_apply_depth_limits.clicked.connect(self.compute_depth) self.pushbutton_apply_depth_limits.clicked.connect(self.compute_BS_cross_section) self.pushbutton_apply_depth_limits.clicked.connect(self.update_plot_backscattered_acoustic_signal_recording) self.pushbutton_apply_depth_limits.clicked.connect(self.update_plot_profile) self.pushbutton_apply_depth_limits.clicked.connect(self.set_range_for_doubleRangeSlider_intg_area) self.pushbutton_apply_recording_time_limits.clicked.connect(self.set_tmin_tmax_for_doubleRangeSider_time) - self.pushbutton_apply_recording_time_limits.clicked.connect(self.compute_time) + # self.pushbutton_apply_recording_time_limits.clicked.connect(self.compute_time) self.pushbutton_apply_recording_time_limits.clicked.connect(self.compute_BS_cross_section) self.pushbutton_apply_recording_time_limits.clicked.connect(self.update_plot_backscattered_acoustic_signal_recording) self.pushbutton_apply_recording_time_limits.clicked.connect(self.update_plot_profile) @@ -1488,9 +1488,9 @@ class AcousticDataTab(QWidget): # _translate("CONSTANT_STRING", cs.HOUR) + ": " + str(stg.hour[self.fileListWidget.currentRow()])) self.fill_measurements_information_groupbox() self.fill_table() - self.set_range_for_doubleRangeSlider_time() - self.set_range_for_doubleRangeSlider_depth() - self.set_range_for_doubleRangeSlider_intg_area() + # self.set_range_for_doubleRangeSlider_time() + # self.set_range_for_doubleRangeSlider_depth() + # self.set_range_for_doubleRangeSlider_intg_area() self.plot_backscattered_acoustic_signal_recording() self.update_frequency_combobox() # self.combobox_frequency_bathymetry.clear() @@ -1847,6 +1847,8 @@ class AcousticDataTab(QWidget): # stg.gain_tx.append(acoustic_data._gain_tx) # stg.temperature.append(self.spinbox_temperature.value()) + # --- The acoustic variables are field with loaded data --- + stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) stg.BS_raw_data.append(acoustic_data._BS_raw_data) stg.BS_raw_data_reshape.append(acoustic_data.reshape_BS_raw_data()) @@ -1872,7 +1874,38 @@ class AcousticDataTab(QWidget): stg.gain_tx.append(acoustic_data._gain_tx) stg.temperature.append(self.spinbox_temperature.value()) - # if self.fileListWidget.count() == 0: + # --- The other acoustic variables lists are filled with empty object. --- + # --- They will be used for pre- and post-processing --- + + stg.BS_cross_section.append(np.array([])) + stg.depth_cross_section.append(np.array([])) + stg.time_cross_section.append(np.array([])) + + stg.tmin.append("") + stg.tmax.append("") + stg.rmin.append("") + stg.rmax.append("") + + stg.BS_stream_bed.append(np.array([])) + stg.depth_bottom.append([]) + stg.val_bottom.append([]) + stg.ind_bottom.append([]) + stg.freq_bottom_detection.append([]) + stg.depth_bottom_detection_1st_int_area.append([]) + + stg.BS_raw_data_pre_process_SNR.append(np.array([])) + stg.BS_raw_data_pre_process_average.append(np.array([])) + stg.BS_raw_data_pre_process_SNR_average.append(np.array([])) + + stg.BS_cross_section_pre_process_SNR.append(np.array([])) + stg.BS_cross_section_pre_process_average.append(np.array([])) + stg.BS_cross_section_pre_process_SNR_average.append(np.array([])) + + stg.BS_stream_bed_pre_process_SNR.append(np.array([])) + stg.BS_stream_bed_pre_process_average.append(np.array([])) + stg.BS_stream_bed_pre_process_SNR_average.append(np.array([])) + + # if self.fileListWidget.count() == 0: # # stg.ABS_name = [self.combobox_ABS_system_choice.currentText()] # stg.date = [acoustic_data._date] @@ -2365,127 +2398,191 @@ class AcousticDataTab(QWidget): # self.groupbox_xaxis_space.setDisabled(True) def compute_time(self): + ''' tmin and tmax are filled with min and max of time when data are uploaded and + double slider of time are updated with these values ''' + if self.fileListWidget.currentRow() != -1: + print("self.fileListWidget.currentRow() ", self.fileListWidget.currentRow()) - if ((self.fileListWidget.count() == 1) and (len(stg.tmax) == 0)): + # if stg.time_cross_section[self.fileListWidget.currentRow()].shape == (0,): - print("Config 1 : time") - - # --- tmim / tmax --- - tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # --- tmim / tmax --- + tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( stg.time[self.fileListWidget.currentRow()][0, :])) == np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] - tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) - stg.tmin = [(tmin_indice, tmin_value)] + tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + stg.tmin[self.fileListWidget.currentRow()] = (tmin_indice, tmin_value) - tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") + + tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( stg.time[self.fileListWidget.currentRow()][0, :])) == np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] - tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) - stg.tmax = [(tmax_indice+1, tmax_value)] + tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + stg.tmax[self.fileListWidget.currentRow()] = (tmax_indice + 1, tmax_value) - print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") - - # --- time_cross_section --- - stg.time_cross_section = [stg.time[self.fileListWidget.currentRow()][:, - stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] - print(f"t = {stg.time_cross_section}") - - # --- spinbox tmin / tmax --- - # self.spinbox_tmin.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) - # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) - - # self.doubleRangeSlider_recording_time.update() - # self.doubleRangeSlider_recording_time.setValue((0, 500)) - # (stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], - # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) + # else: + # + # # --- tmim / tmax --- + # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # stg.tmin[self.fileListWidget.currentRow()] = (tmin_indice, tmin_value) + # + # print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") + # + # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # stg.tmax[self.fileListWidget.currentRow()] = (tmax_indice + 1, tmax_value) - print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) + # print(f" tmax_indice = {tmax_indice} , tmax_value = {tmax_value}") + # + # print("stg.time ", stg.time[self.fileListWidget.currentRow()][:, 0:4499]) + # print("stg.tmin[self.fileListWidget.currentRow()][0] ", stg.tmin[self.fileListWidget.currentRow()][0]) + # print("stg.tmax[self.fileListWidget.currentRow()][0] ", stg.tmax[self.fileListWidget.currentRow()][0]) - elif len(stg.tmax) < self.fileListWidget.count(): + # --- time_cross_section --- + # stg.time_cross_section[self.fileListWidget.currentRow()] = \ + # stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]: + # stg.tmax[self.fileListWidget.currentRow()][0]] + # print(f"time cross section = {stg.time_cross_section[0].shape}") - print("Config 2 : time") + self.set_range_for_doubleRangeSlider_time() - # --- tmim / tmax --- - tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( - stg.time[self.fileListWidget.currentRow()][0, :])) == - np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( - stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] - tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) - print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") - - tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( - stg.time[self.fileListWidget.currentRow()][0, :])) == - np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( - stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] - tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) - print(f" tmax_indice = {tmax_indice} , tmax_value = {tmax_value}") - - print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") - stg.tmin.append((tmin_indice, tmin_value)) - stg.tmax.append((tmax_indice+1, tmax_value)) - print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") - - # --- time_cross_section --- - stg.time_cross_section = stg.time_cross_section + [stg.time[self.fileListWidget.currentRow()][:, - stg.tmin[self.fileListWidget.currentRow()][0]: - stg.tmax[self.fileListWidget.currentRow()][0]]] - - # --- spinbox tmin / tmax --- - # self.spinbox_tmin.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) - # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) - - # self.doubleRangeSlider_recording_time.setValue(value=( - # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], - # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) - - print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) - - else: - print("-----------------") - print("Config 3 : time") - print("-----------------") - - self.set_range_for_doubleRangeSlider_time() - - # --- spinbox tmin / tmax --- - # self.spinbox_tmin.setValue( - # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) - # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][ - # 0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) - - # print("tmin = ", stg.tmin) - # print("tmax = ", stg.tmax) - # print("list Widget : ", self.fileListWidget.currentRow()) - # print("stg.tmin[self.fileListWidget.currentRow()][0] ", stg.tmin[self.fileListWidget.currentRow()][0]) - # print("stg.tmax[self.fileListWidget.currentRow()][0] - 1 ", stg.tmax[self.fileListWidget.currentRow()][0]-1) - # - # print("time_cross_section min ", stg.time_cross_section[self.fileListWidget.currentRow()][ - # 0, stg.tmin[self.fileListWidget.currentRow()][0]]) - # print("time_cross_section max ", stg.time_cross_section[self.fileListWidget.currentRow()][ - # 0, stg.tmax[self.fileListWidget.currentRow()][0]]) - # # self.doubleRangeSlider_recording_time.setValue(value=(stg.tmin[self.fileListWidget.currentRow()][1], stg.tmax[self.fileListWidget.currentRow()][1])) - # - # self.doubleRangeSlider_recording_time.setValue(value=( - # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], - # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1] - # )) - # - # print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) + # if ((self.fileListWidget.count() == 1) and (len(stg.tmax) == 0)): + # + # print("Config 1 : time") + # + # # --- tmim / tmax --- + # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # stg.tmin = [(tmin_indice, tmin_value)] + # + # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # stg.tmax = [(tmax_indice+1, tmax_value)] + # + # print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") + # + # # --- time_cross_section --- + # stg.time_cross_section = [stg.time[self.fileListWidget.currentRow()][:, + # stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] + # print(f"t = {stg.time_cross_section}") + # + # # --- spinbox tmin / tmax --- + # # self.spinbox_tmin.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) + # # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) + # + # # self.doubleRangeSlider_recording_time.update() + # # self.doubleRangeSlider_recording_time.setValue((0, 500)) + # # (stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], + # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) + # + # + # print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) + # + # elif len(stg.tmax) < self.fileListWidget.count(): + # + # print("Config 2 : time") + # + # # --- tmim / tmax --- + # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") + # + # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # print(f" tmax_indice = {tmax_indice} , tmax_value = {tmax_value}") + # + # print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") + # stg.tmin.append((tmin_indice, tmin_value)) + # stg.tmax.append((tmax_indice+1, tmax_value)) + # print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") + # + # # --- time_cross_section --- + # stg.time_cross_section = stg.time_cross_section + [stg.time[self.fileListWidget.currentRow()][:, + # stg.tmin[self.fileListWidget.currentRow()][0]: + # stg.tmax[self.fileListWidget.currentRow()][0]]] + # + # # --- spinbox tmin / tmax --- + # # self.spinbox_tmin.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) + # # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) + # + # # self.doubleRangeSlider_recording_time.setValue(value=( + # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], + # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) + # + # print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) + # + # else: + # print("-----------------") + # print("Config 3 : time") + # print("-----------------") + # + # self.set_range_for_doubleRangeSlider_time() + # + # # --- spinbox tmin / tmax --- + # # self.spinbox_tmin.setValue( + # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) + # # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][ + # # 0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) + # + # # print("tmin = ", stg.tmin) + # # print("tmax = ", stg.tmax) + # # print("list Widget : ", self.fileListWidget.currentRow()) + # # print("stg.tmin[self.fileListWidget.currentRow()][0] ", stg.tmin[self.fileListWidget.currentRow()][0]) + # # print("stg.tmax[self.fileListWidget.currentRow()][0] - 1 ", stg.tmax[self.fileListWidget.currentRow()][0]-1) + # # + # # print("time_cross_section min ", stg.time_cross_section[self.fileListWidget.currentRow()][ + # # 0, stg.tmin[self.fileListWidget.currentRow()][0]]) + # # print("time_cross_section max ", stg.time_cross_section[self.fileListWidget.currentRow()][ + # # 0, stg.tmax[self.fileListWidget.currentRow()][0]]) + # # # self.doubleRangeSlider_recording_time.setValue(value=(stg.tmin[self.fileListWidget.currentRow()][1], stg.tmax[self.fileListWidget.currentRow()][1])) + # # + # # self.doubleRangeSlider_recording_time.setValue(value=( + # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], + # # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1] + # # )) + # # + # # print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) def set_range_for_doubleRangeSlider_time(self): self.doubleRangeSlider_recording_time.setRange(min=stg.time[self.fileListWidget.currentRow()][0, 0], max=stg.time[self.fileListWidget.currentRow()][0, -1]) - self.doubleRangeSlider_recording_time.setValue(value=(stg.time_cross_section[self.fileListWidget.currentRow()][0, 0], - stg.time_cross_section[self.fileListWidget.currentRow()][0, -1])) + if stg.time_cross_section[self.fileListWidget.currentRow()].shape == (0,): + self.doubleRangeSlider_recording_time.setValue(value=(stg.time[self.fileListWidget.currentRow()][0, 0], + stg.time[self.fileListWidget.currentRow()][0, -1])) + else: + self.doubleRangeSlider_recording_time.setValue(value=(stg.time_cross_section[self.fileListWidget.currentRow()][0, 0], + stg.time_cross_section[self.fileListWidget.currentRow()][0, -1])) + def set_tmin_tmax_for_doubleRangeSider_time(self): + ''' tmin and tmax are updated with double slider of time ''' + stg.tmin[self.fileListWidget.currentRow()] = (( np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], 2) - self.doubleRangeSlider_recording_time.value()[0]) == @@ -2503,10 +2600,6 @@ class AcousticDataTab(QWidget): )) print("tmax = ", stg.tmax) - stg.time_cross_section[self.fileListWidget.currentRow()] = ( - stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]] - ) - # def time_spin_box_value(self): # # if Qt.Key_Return: @@ -2524,76 +2617,157 @@ class AcousticDataTab(QWidget): # ) def compute_depth(self): + ''' rmin and rmax are filled with min and max of depth when data are uploaded and + double slider of depth are updated with these values ''' + + # if self.fileListWidget.currentRow() != -1: + # print("self.fileListWidget.currentRow() ", self.fileListWidget.currentRow()) + + # if stg.depth_cross_section[self.fileListWidget.currentRow()].shape == (0,): + # + # # --- tmim / tmax --- + # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # stg.tmin[self.fileListWidget.currentRow()] = (tmin_indice, tmin_value) + # + # print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") + # + # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # stg.tmax[self.fileListWidget.currentRow()] = (tmax_indice + 1, tmax_value) + # + # else: + # + # # --- tmim / tmax --- + # tmin_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmin_value = np.round(np.nanmin(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # stg.tmin[self.fileListWidget.currentRow()] = (tmin_indice, tmin_value) + # + # print(f" tmin_indice = {tmin_indice} , tmin_value = {tmin_value}") + # + # tmax_indice = np.where(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.time[self.fileListWidget.currentRow()][0, :]))))[0][0] + # tmax_value = np.round(np.nanmax(stg.time[self.fileListWidget.currentRow()][0, :]), 2) + # stg.tmax[self.fileListWidget.currentRow()] = (tmax_indice + 1, tmax_value) + if self.fileListWidget.currentRow() != -1: - if ((self.fileListWidget.count() == 1) and (len(stg.rmax) == 0)): + # --- rmim / rmax --- + rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( + stg.depth[self.fileListWidget.currentRow()][0, :])) == + np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( + stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] + rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) + stg.rmin[self.fileListWidget.currentRow()] = (rmin_indice, rmin_value) - # --- rmim / rmax --- - rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( - stg.depth[self.fileListWidget.currentRow()][0, :])) == - np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( - stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] - rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) - stg.rmin = [(rmin_indice, rmin_value)] + print(f" rmin_indice = {rmin_indice} , rmin_value = {rmin_value}") - rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( - stg.depth[self.fileListWidget.currentRow()][0, :])) == - np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( - stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] - rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) - stg.rmax = [(rmax_indice+1, rmax_value)] + rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( + stg.depth[self.fileListWidget.currentRow()][0, :])) == + np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( + stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] + rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) + stg.rmax[self.fileListWidget.currentRow()] = (rmax_indice + 1, rmax_value) - # --- depth_cross_section --- - stg.depth_cross_section = [stg.depth[self.fileListWidget.currentRow()][:, - stg.rmin[self.fileListWidget.currentRow()][0]: - stg.rmax[self.fileListWidget.currentRow()][0]]] - print("Config 1 : depth") - print("rmin ", stg.rmin) - print("rmax ", stg.rmax) + print(f" rmax_indice = {rmax_indice} , rmax_value = {rmax_value}") - elif len(stg.rmax) < self.fileListWidget.count(): + # # --- depth_cross_section --- + # + # stg.depth_cross_section[self.fileListWidget.currentRow()] = \ + # stg.depth[self.fileListWidget.currentRow()][:, stg.rmin[self.fileListWidget.currentRow()][0]: + # stg.rmax[self.fileListWidget.currentRow()][0]] - # --- rmim / rmax --- - rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( - stg.depth[self.fileListWidget.currentRow()][0, :])) == - np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( - stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] - rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) + # print(f"depth cross section = {stg.depth_cross_section}") - rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( - stg.depth[self.fileListWidget.currentRow()][0, :])) == - np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( - stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] - rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) + self.set_range_for_doubleRangeSlider_depth() - stg.rmin.append((rmin_indice, rmin_value)) - stg.rmax.append((rmax_indice+1, rmax_value)) - - # --- depth_cross_section --- - stg.depth_cross_section = stg.depth_cross_section + [stg.depth[self.fileListWidget.currentRow()][:, - stg.rmin[self.fileListWidget.currentRow()][0]: - stg.rmax[self.fileListWidget.currentRow()][0]]] - print("Config 2 : depth") - print("rmin ", stg.rmin) - print("rmax ", stg.rmax) - - else: - - self.set_range_for_doubleRangeSlider_depth() - print("Config 3 : depth") - print("rmin ", stg.rmin) - print("rmax ", stg.rmax) + # if ((self.fileListWidget.count() == 1) and (len(stg.rmax) == 0)): + # + # # --- rmim / rmax --- + # rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.depth[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] + # rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) + # stg.rmin = [(rmin_indice, rmin_value)] + # + # rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.depth[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] + # rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) + # stg.rmax = [(rmax_indice+1, rmax_value)] + # + # # --- depth_cross_section --- + # stg.depth_cross_section = [stg.depth[self.fileListWidget.currentRow()][:, + # stg.rmin[self.fileListWidget.currentRow()][0]: + # stg.rmax[self.fileListWidget.currentRow()][0]]] + # print("Config 1 : depth") + # print("rmin ", stg.rmin) + # print("rmax ", stg.rmax) + # + # elif len(stg.rmax) < self.fileListWidget.count(): + # + # # --- rmim / rmax --- + # rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.depth[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin( + # stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] + # rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) + # + # rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.depth[self.fileListWidget.currentRow()][0, :])) == + # np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax( + # stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0] + # rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2) + # + # stg.rmin.append((rmin_indice, rmin_value)) + # stg.rmax.append((rmax_indice+1, rmax_value)) + # + # # --- depth_cross_section --- + # stg.depth_cross_section = stg.depth_cross_section + [stg.depth[self.fileListWidget.currentRow()][:, + # stg.rmin[self.fileListWidget.currentRow()][0]: + # stg.rmax[self.fileListWidget.currentRow()][0]]] + # print("Config 2 : depth") + # print("rmin ", stg.rmin) + # print("rmax ", stg.rmax) + # + # else: + # + # self.set_range_for_doubleRangeSlider_depth() + # print("Config 3 : depth") + # print("rmin ", stg.rmin) + # print("rmax ", stg.rmax) def set_range_for_doubleRangeSlider_depth(self): self.doubleRangeSlider_depth.setRange(min=-stg.depth[self.fileListWidget.currentRow()][0, -1], max=-stg.depth[self.fileListWidget.currentRow()][0, 0]) - self.doubleRangeSlider_depth.setValue(value=(-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], - -stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0])) + if stg.depth_cross_section[self.fileListWidget.currentRow()].shape == (0,): + self.doubleRangeSlider_depth.setValue(value=(-stg.depth[self.fileListWidget.currentRow()][0, -1], + -stg.depth[self.fileListWidget.currentRow()][0, 0])) + else: + self.doubleRangeSlider_depth.setValue( + value=(-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], + -stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0])) - print("self.doubleRangeSlider_depth.value() ", self.doubleRangeSlider_depth.value()) + # print("self.doubleRangeSlider_depth.value() ", self.doubleRangeSlider_depth.value()) def set_rmin_rmax_for_doubleRangeSider_depth(self): + + ''' rmin and rmax are updated with double slider of depth ''' + stg.rmin[self.fileListWidget.currentRow()] = (( np.where(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :], 2) - -self.doubleRangeSlider_depth.value()[1]) == @@ -2616,40 +2790,58 @@ class AcousticDataTab(QWidget): stg.depth[self.fileListWidget.currentRow()][:, stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0]] ) - print("Config 4 : depth") - print("rmin ", stg.rmin) - print("rmax ", stg.rmax) + def compute_BS_cross_section(self): if self.fileListWidget.currentRow() != -1: - if (self.fileListWidget.count() == 1) and (len(stg.BS_cross_section) == 0): + # print("tmax for compute BS cross section = ", stg.tmax) - print("Config 1 : BS_cross_section") + stg.time_cross_section[self.fileListWidget.currentRow()] = ( + stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]: + stg.tmax[self.fileListWidget.currentRow()][0]] + ) - stg.BS_cross_section = [stg.BS_raw_data[self.fileListWidget.currentRow()][:, - stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], - stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] + stg.depth_cross_section[self.fileListWidget.currentRow()] = ( + stg.depth[self.fileListWidget.currentRow()][:, stg.rmin[self.fileListWidget.currentRow()][0]: + stg.rmax[self.fileListWidget.currentRow()][0]] + ) - elif len(stg.BS_cross_section) < self.fileListWidget.count(): + stg.BS_cross_section[self.fileListWidget.currentRow()] = ( + stg.BS_raw_data[self.fileListWidget.currentRow()] + [:, stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], + stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]) - print("Config 2 : BS_cross_section") - print("tmin for cross section ", stg.tmin) - stg.BS_cross_section = stg.BS_cross_section + [stg.BS_raw_data[self.fileListWidget.currentRow()][:, - stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], - stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] + # print(f"BS_cross_section : {len(stg.BS_cross_section)}") + # print(f"BS_cross_section shape : {stg.BS_cross_section[self.fileListWidget.currentRow()].shape}") - else: - - print("Config 3 : BS_cross_section") - - stg.BS_cross_section[self.fileListWidget.currentRow()] = ( - stg.BS_raw_data[self.fileListWidget.currentRow()] - [:, stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], - stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]) - - print(f"BS_cross_section : {len(stg.BS_cross_section)}") - print(f"BS_cross_section shape : {stg.BS_cross_section[self.fileListWidget.currentRow()].shape}") + # if (self.fileListWidget.count() == 1) and (len(stg.BS_cross_section) == 0): + # + # print("Config 1 : BS_cross_section") + # + # stg.BS_cross_section = [stg.BS_raw_data[self.fileListWidget.currentRow()][:, + # stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], + # stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] + # + # elif len(stg.BS_cross_section) < self.fileListWidget.count(): + # + # print("Config 2 : BS_cross_section") + # print("tmin for cross section ", stg.tmin) + # stg.BS_cross_section = stg.BS_cross_section + [stg.BS_raw_data[self.fileListWidget.currentRow()][:, + # stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], + # stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] + # + # else: + # + # print("Config 3 : BS_cross_section") + # + # stg.BS_cross_section[self.fileListWidget.currentRow()] = ( + # stg.BS_raw_data[self.fileListWidget.currentRow()] + # [:, stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0], + # stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]) + # + # print(f"BS_cross_section : {len(stg.BS_cross_section)}") + # print(f"BS_cross_section shape : {stg.BS_cross_section[self.fileListWidget.currentRow()].shape}") def update_frequency_combobox(self): if self.fileListWidget.currentRow() != -1: @@ -2660,11 +2852,25 @@ class AcousticDataTab(QWidget): def set_range_for_doubleRangeSlider_intg_area(self): if self.fileListWidget.currentRow() != -1: - self.doubleRangeSlider_intg_area.setRange(min=-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], - max=-stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0]) - self.doubleRangeSlider_intg_area.setValue(value=(-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], - -stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0])) + if stg.depth_cross_section[self.fileListWidget.currentRow()].shape == (0,): + self.doubleRangeSlider_intg_area.setRange( + min=-stg.depth[self.fileListWidget.currentRow()][0, -1], + max=-stg.depth[self.fileListWidget.currentRow()][0, 0]) + + self.doubleRangeSlider_intg_area.setValue( + value=(-stg.depth[self.fileListWidget.currentRow()][0, -1], + -stg.depth[self.fileListWidget.currentRow()][0, 0])) + + else: + + self.doubleRangeSlider_intg_area.setRange( + min=-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], + max=-stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0]) + + self.doubleRangeSlider_intg_area.setValue( + value=(-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1], + -stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0])) def plot_backscattered_acoustic_signal_recording(self): # --- Condition if table is not filled --- @@ -2775,221 +2981,345 @@ class AcousticDataTab(QWidget): msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() - # elif stg.BS_cross_section.size == 0: - # - # for f, _ in enumerate(stg.freq): - # - # self.axis_BS[f].cla() - # - # val_min = np.nanmin(stg.BS_raw_data[f, :, :]) - # val_max = np.nanmax(stg.BS_raw_data[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[f, int(stg.tmin[f]):int(stg.tmax[f])], - # -stg.depth[f, :], - # stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[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[f, int(stg.tmin[f]):int(stg.tmax[f])], - # -stg.depth[f, :], - # np.log(stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]), - # cmap='Blues') - # - # # --- Plot red solid line on transect to visualize position of plotted profile --- - # self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - # stg.time[self.combobox_frequency_profile.currentIndex(), self.slider.value()] * np.ones(stg.depth.shape[1]), - # -stg.depth[self.combobox_frequency_profile.currentIndex(), :], - # color='red', linestyle="solid", linewidth=2) - # - # self.axis_BS[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_BS[f].transAxes) - # - # self.fig_BS.supxlabel('Time (sec)', fontsize=10) - # self.fig_BS.supylabel('Depth (m)', fontsize=10) - # self.fig_BS.canvas.draw_idle() + else: - elif len(stg.BS_cross_section) != 0: + # print("stg.BS_cross_section[self.fileListWidget.currentRow()].shape ", stg.BS_cross_section[self.fileListWidget.currentRow()].shape) if len(self.axis_BS.tolist()) != stg.freq[self.fileListWidget.currentRow()].shape[0]: self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") - # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) - # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) - - # --- Backscatter acoustic signal is recorded for next tab --- - - # stg.BS_cross_section = np.array([[[]]]) - # stg.t = np.array([[]]) - - # stg.tmin[self.fileListWidget.currentRow()] = ( - # np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], - # 2) - self.spinbox_tmin.value()) == - # np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], - # 2) - self.spinbox_tmin.value())))[0][ - # 0] - # ) - # - # stg.tmax[self.fileListWidget.currentRow()] = ( - # np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], - # 2) - self.spinbox_tmax.value()) == - # np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], - # 2) - self.spinbox_tmax.value())))[0][ - # 0] - # ) - # - # print(f"Update tmin {stg.tmin}") - # print(f"Update tmax {stg.tmax}") - # - # if (self.fileListWidget.count() == 1) and (len(stg.BS_cross_section) == 0): - # stg.BS_cross_section = [stg.BS_raw_data[self.fileListWidget.currentRow()][:, :, - # int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]] - # elif (self.fileListWidget.count() > 1) and (len(stg.BS_cross_section) < self.fileListWidget.count()): - # stg.BS_cross_section = ( - # np.append(stg.BS_cross_section, - # stg.BS_raw_data[self.fileListWidget.currentRow()][:, :, - # int(stg.tmin[self.fileListWidget.currentRow()]):int( - # stg.tmax[self.fileListWidget.currentRow()])]) - # ) - # else: - # stg.BS_cross_section[self.fileListWidget.currentRow()] = ( - # stg.BS_raw_data[self.fileListWidget.currentRow()] - # [:, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]) - # - # - # if (self.fileListWidget.count() == 1) and (len(stg.t) == 0): - # stg.t = [stg.time[self.fileListWidget.currentRow()][:, - # int(stg.tmin[self.fileListWidget.currentRow()]):int( - # stg.tmax[self.fileListWidget.currentRow()])]] - # elif self.fileListWidget.count() > 1: - # stg.t = np.append(stg.t, - # stg.time[self.fileListWidget.currentRow()][:, - # int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]) - # else: - # stg.t[self.fileListWidget.currentRow()] = stg.time[self.fileListWidget.currentRow()][:, - # int(stg.tmin[self.fileListWidget.currentRow()]):int( - # stg.tmax[self.fileListWidget.currentRow()])] - # # stg.t = np.append(stg.t, np.array([stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) - # - # # print("stg.t[self.fileListWidget.currentRow()].shape() ", stg.t[self.fileListWidget.currentRow()].shape()) - # print("0/ stg.freq before plot : ", stg.freq) - # print("2/ stg.freq after plot : ", stg.freq[self.fileListWidget.currentRow()]) for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): - - # print(f"f = {f}") - - # stg.tmin[f] = np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][f, :], 2) - self.spinbox_tmin.value()) == - # np.nanmin(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmin.value())))[0][0] - # - # stg.tmax[f] = np.where(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmax.value()) == - # np.nanmin(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmax.value())))[0][0] - - # print("stg.tmin[f] ", stg.tmin[f]) - # print("stg.tmax[f] ", stg.tmax[f]) - # print("shape of BS_raw_data ", np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]).shape) - # print("BS_data shape ", stg.BS_cross_section.shape) - - # print(self.fileListWidget.count()) - # print(stg.BS_cross_section[self.fileListWidget.currentRow()].shape) - # if stg.BS_cross_section[self.fileListWidget.currentRow()].shape[2] == 0: - # if self.fileListWidget.count() == 1: - # stg.BS_cross_section = np.array( - # [stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]) - # else: - # stg.BS_cross_section[self.fileListWidget.currentRow()] = ( - # np.append(stg.BS_cross_section[self.fileListWidget.currentRow()], - # np.array([stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]), axis=0)) - - - # stg.BS_cross_section = np.stack(np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) - # stg.BS_cross_section = np.append(stg.BS_cross_section, np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=2) - # print("stg.BS_cross_section.shape ", stg.BS_cross_section.shape) - # print("stg.BS_cross_section.size ", stg.BS_cross_section.size) - # print("stg.time shape ", stg.time.shape) - # print("stg.t shape ", stg.t.shape) - # if stg.t[self.fileListWidget.currentRow()].shape[1] == 0: - # if self.fileListWidget.count() == 1: - # stg.t = np.array([stg.time[self.fileListWidget.currentRow()][f, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]) - # else: - # stg.t[self.fileListWidget.currentRow()] = np.append(stg.t[self.fileListWidget.currentRow()], - # np.array([stg.time[self.fileListWidget.currentRow()][f, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]), 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[self.fileListWidget.currentRow()].shape) - # print(f"stg.t : {stg.t}") - # stg.depth_2D = stg.depth_2D[:, 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]] - # print("stg.depth shape ", stg.depth_2D.shape) - - # print("self.combobox_frequency_profile.currentIndex() ", self.combobox_frequency_profile.currentIndex()) - # - # print("slider value = ", [ - # self.slider.value() - 1 if self.slider.value() - 1 <= stg.t.shape[1] - 1 else np.max( - # stg.t[self.fileListWidget.currentRow()].shape[1] - 1)][0]) - # - # print(stg.t[0, - # [self.slider.value() - 1 if self.slider.value() - 1 <= stg.t.shape[1] - 1 else np.max( - # stg.t.shape[1] - 1)][0]]) - - # print("self.axis_BS ", self.axis_BS) - # print(f"self.axis_BS[{f}] ", self.axis_BS[f]) self.axis_BS[f].cla() - 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 stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): - # print("stg.t[f, :].shape ", stg.t[f]) - # print("stg.depth[f, :].shape ", stg.depth[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, :, :]) + 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') + 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)) - # --- Plot river bottom line --- + 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') - if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): - if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): + # --- 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] - # 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()], + 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) + + # --- Plot river bottom line --- + if len(stg.depth_bottom[self.fileListWidget.currentRow()]) != 0: + self.axis_BS[f].plot(stg.time[self.fileListWidget.currentRow()][ + self.combobox_frequency_bathymetry.currentIndex(), :], + -stg.depth[self.fileListWidget.currentRow()], color='black', linewidth=1, linestyle="solid") - # --- 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] + else: - 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) + 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', - transform=self.axis_BS[f].transAxes) + fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_BS[f].transAxes) self.fig_BS.supxlabel('Time (sec)', fontsize=10) self.fig_BS.supylabel('Depth (m)', fontsize=10) self.fig_BS.canvas.draw_idle() - # self.fig_BS.canvas.flush_events() - # plt.close(self.fig_BS) + # self.fig_BS.canvas.flush_events() + # plt.close(self.fig_BS) + + + # # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) + # # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) + # + # # --- Backscatter acoustic signal is recorded for next tab --- + # + # # stg.BS_cross_section = np.array([[[]]]) + # # stg.t = np.array([[]]) + # + # # stg.tmin[self.fileListWidget.currentRow()] = ( + # # np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], + # # 2) - self.spinbox_tmin.value()) == + # # np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], + # # 2) - self.spinbox_tmin.value())))[0][ + # # 0] + # # ) + # # + # # stg.tmax[self.fileListWidget.currentRow()] = ( + # # np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], + # # 2) - self.spinbox_tmax.value()) == + # # np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], + # # 2) - self.spinbox_tmax.value())))[0][ + # # 0] + # # ) + # # + # # print(f"Update tmin {stg.tmin}") + # # print(f"Update tmax {stg.tmax}") + # # + # # if (self.fileListWidget.count() == 1) and (len(stg.BS_cross_section) == 0): + # # stg.BS_cross_section = [stg.BS_raw_data[self.fileListWidget.currentRow()][:, :, + # # int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]] + # # elif (self.fileListWidget.count() > 1) and (len(stg.BS_cross_section) < self.fileListWidget.count()): + # # stg.BS_cross_section = ( + # # np.append(stg.BS_cross_section, + # # stg.BS_raw_data[self.fileListWidget.currentRow()][:, :, + # # int(stg.tmin[self.fileListWidget.currentRow()]):int( + # # stg.tmax[self.fileListWidget.currentRow()])]) + # # ) + # # else: + # # stg.BS_cross_section[self.fileListWidget.currentRow()] = ( + # # stg.BS_raw_data[self.fileListWidget.currentRow()] + # # [:, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]) + # # + # # + # # if (self.fileListWidget.count() == 1) and (len(stg.t) == 0): + # # stg.t = [stg.time[self.fileListWidget.currentRow()][:, + # # int(stg.tmin[self.fileListWidget.currentRow()]):int( + # # stg.tmax[self.fileListWidget.currentRow()])]] + # # elif self.fileListWidget.count() > 1: + # # stg.t = np.append(stg.t, + # # stg.time[self.fileListWidget.currentRow()][:, + # # int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]) + # # else: + # # stg.t[self.fileListWidget.currentRow()] = stg.time[self.fileListWidget.currentRow()][:, + # # int(stg.tmin[self.fileListWidget.currentRow()]):int( + # # stg.tmax[self.fileListWidget.currentRow()])] + # # # stg.t = np.append(stg.t, np.array([stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) + # # + # # # print("stg.t[self.fileListWidget.currentRow()].shape() ", stg.t[self.fileListWidget.currentRow()].shape()) + # # print("0/ stg.freq before plot : ", stg.freq) + # # print("2/ stg.freq after plot : ", stg.freq[self.fileListWidget.currentRow()]) + # for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): + # + # # print(f"f = {f}") + # + # # stg.tmin[f] = np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][f, :], 2) - self.spinbox_tmin.value()) == + # # np.nanmin(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmin.value())))[0][0] + # # + # # stg.tmax[f] = np.where(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmax.value()) == + # # np.nanmin(np.abs(np.round(stg.time[f, :], 2) - self.spinbox_tmax.value())))[0][0] + # + # # print("stg.tmin[f] ", stg.tmin[f]) + # # print("stg.tmax[f] ", stg.tmax[f]) + # # print("shape of BS_raw_data ", np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]).shape) + # # print("BS_data shape ", stg.BS_cross_section.shape) + # + # # print(self.fileListWidget.count()) + # # print(stg.BS_cross_section[self.fileListWidget.currentRow()].shape) + # # if stg.BS_cross_section[self.fileListWidget.currentRow()].shape[2] == 0: + # # if self.fileListWidget.count() == 1: + # # stg.BS_cross_section = np.array( + # # [stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]) + # # else: + # # stg.BS_cross_section[self.fileListWidget.currentRow()] = ( + # # np.append(stg.BS_cross_section[self.fileListWidget.currentRow()], + # # np.array([stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]), axis=0)) + # + # + # # stg.BS_cross_section = np.stack(np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) + # # stg.BS_cross_section = np.append(stg.BS_cross_section, np.array([stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=2) + # # print("stg.BS_cross_section.shape ", stg.BS_cross_section.shape) + # # print("stg.BS_cross_section.size ", stg.BS_cross_section.size) + # # print("stg.time shape ", stg.time.shape) + # # print("stg.t shape ", stg.t.shape) + # # if stg.t[self.fileListWidget.currentRow()].shape[1] == 0: + # # if self.fileListWidget.count() == 1: + # # stg.t = np.array([stg.time[self.fileListWidget.currentRow()][f, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]) + # # else: + # # stg.t[self.fileListWidget.currentRow()] = np.append(stg.t[self.fileListWidget.currentRow()], + # # np.array([stg.time[self.fileListWidget.currentRow()][f, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]]), 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[self.fileListWidget.currentRow()].shape) + # # print(f"stg.t : {stg.t}") + # # stg.depth_2D = stg.depth_2D[:, 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]] + # # print("stg.depth shape ", stg.depth_2D.shape) + # + # # print("self.combobox_frequency_profile.currentIndex() ", self.combobox_frequency_profile.currentIndex()) + # # + # # print("slider value = ", [ + # # self.slider.value() - 1 if self.slider.value() - 1 <= stg.t.shape[1] - 1 else np.max( + # # stg.t[self.fileListWidget.currentRow()].shape[1] - 1)][0]) + # # + # # print(stg.t[0, + # # [self.slider.value() - 1 if self.slider.value() - 1 <= stg.t.shape[1] - 1 else np.max( + # # stg.t.shape[1] - 1)][0]]) + # + # # print("self.axis_BS ", self.axis_BS) + # # print(f"self.axis_BS[{f}] ", self.axis_BS[f]) + # self.axis_BS[f].cla() + # + # if stg.BS_cross_section[self.fileListWidget.currentRow()].shape == (0,): + # + # # print("stg.BS_cross_section[self.fileListWidget.currentRow()].shape ", + # # stg.BS_cross_section[self.fileListWidget.currentRow()].shape) + # + # val_min = np.nanmin(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) + # val_max = np.nanmax(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]) + # if val_min == 0: + # val_min = 1e-5 + # + # # print("stg.t[f, :].shape ", stg.t[f]) + # # print("stg.depth[f, :].shape ", stg.depth[f, :]) + # + # 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') + # + # # --- 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.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + # stg.time[self.fileListWidget.currentRow()][ + # 0, # self.combobox_frequency_profile.currentIndex(), + # 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) + # + # else: + # + # # print("stg.BS_cross_section[self.fileListWidget.currentRow()].shape ", + # # stg.BS_cross_section[self.fileListWidget.currentRow()].shape) + # + # 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 + # + # # print("stg.t[f, :].shape ", stg.t[f]) + # # print("stg.depth[f, :].shape ", stg.depth[f, :]) + # + # 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', + # transform=self.axis_BS[f].transAxes) + # + # self.fig_BS.supxlabel('Time (sec)', fontsize=10) + # self.fig_BS.supylabel('Depth (m)', fontsize=10) + # self.fig_BS.canvas.draw_idle() + # # self.fig_BS.canvas.flush_events() + # # plt.close(self.fig_BS) def plot_profile(self): if self.fileListWidget.currentRow() != -1: @@ -3001,7 +3331,7 @@ class AcousticDataTab(QWidget): self.update_plot_backscattered_acoustic_signal_recording) # self.slider.setMaximum(stg.BS_raw_data[self.fileListWidget.currentRow()].shape[2]) - self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) + self.slider.setMaximum(stg.time[self.fileListWidget.currentRow()].shape[1]) self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) @@ -3013,14 +3343,14 @@ class AcousticDataTab(QWidget): # for f, _ in enumerate(stg.freq[0]): 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.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.cla() - self.axis_profile.plot(stg.BS_cross_section[self.fileListWidget.currentRow()][ + self.axis_profile.plot(stg.BS_raw_data[self.fileListWidget.currentRow()][ self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :], + -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", @@ -3030,10 +3360,10 @@ class AcousticDataTab(QWidget): # --- Plot 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,): + # 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(), :, slider_value])], @@ -3042,13 +3372,13 @@ class AcousticDataTab(QWidget): 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(), + 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", + self.axis_profile.text(.95, 1 - position_x + 0.05, "River bed", fontsize=10, fontweight='normal', fontname="Times New Roman", fontstyle="italic", c="red", alpha=0.2, horizontalalignment='right', verticalalignment='bottom', @@ -3069,12 +3399,13 @@ class AcousticDataTab(QWidget): def update_plot_profile(self): # print("len(stg.BS_cross_section) ", len(stg.BS_cross_section)) - 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 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_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :], + -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", @@ -3089,7 +3420,7 @@ class AcousticDataTab(QWidget): # self.fig_profile.canvas.flush_events() # plt.close(self.fig_profile) - elif len(stg.BS_cross_section) != 0: + else: self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) @@ -3126,20 +3457,20 @@ class AcousticDataTab(QWidget): # 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) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): - if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): + 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(), :, 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]] / + 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", + 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', @@ -3617,28 +3948,34 @@ class AcousticDataTab(QWidget): # 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 ((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] + stg.depth_bottom[self.fileListWidget.currentRow()] = r_bottom - elif len(stg.depth_bottom) < self.fileListWidget.count(): + stg.val_bottom[self.fileListWidget.currentRow()] = val_bottom - stg.depth_bottom.append(r_bottom) + stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind - 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()]): @@ -3649,17 +3986,19 @@ class AcousticDataTab(QWidget): >= stg.depth_bottom[self.fileListWidget.currentRow()][k])[ 0], k] = np.nan - if ((self.fileListWidget.count() == 1) and (len(stg.BS_stream_bed) == 0)): + stg.BS_stream_bed[self.fileListWidget.currentRow()] = BS_stream_bed_copy - 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()]):