From 825b5aa9bb9660fc494974219f40923a8144a0fb Mon Sep 17 00:00:00 2001 From: brahim Date: Mon, 3 Jun 2024 15:26:09 +0200 Subject: [PATCH] A context menu is added. Update Table for Save action created. --- Model/update_table_for_save.py | 89 +++++ View/acoustic_data_tab.py | 633 ++++++++++++++++++--------------- View/mainwindow.py | 1 + 3 files changed, 427 insertions(+), 296 deletions(-) create mode 100644 Model/update_table_for_save.py diff --git a/Model/update_table_for_save.py b/Model/update_table_for_save.py new file mode 100644 index 0000000..bab7e21 --- /dev/null +++ b/Model/update_table_for_save.py @@ -0,0 +1,89 @@ +import numpy as np +from PyQt5.QtWidgets import QFileDialog, QApplication +import sqlite3 +import settings as stg +from os import chdir, getcwd +import time + + +class UpdateTableForSave: + + def __init__(self): + + start = time.time() + chdir(stg.dirname_save_as) + print("get cwd for save :", getcwd()) + print("stg.filename_save_as ", stg.filename_save_as) + self.update_table() + print(f"end : {time.time() - start} sec") + + def update_table(self): + + # Create a new database and open a database connection to allow sqlite3 to work with it. + cnx = sqlite3.connect(stg.filename_save_as + '.acd') + + # Create database cursor to execute SQL statements and fetch results from SQL queries. + cur = cnx.cursor() + + # -------------------------------------------------------------------------------------------------------------- + # --- Table BSRawData_i --- + start_table_BSRawData = time.time() + + # # --- Fill table BSRawData_i with data stg.depth_reshape --- + # + # for i in stg.acoustic_data: + # exec("query1 = '''ALTER TABLE BSRawData ADD COLUMN BS_cross_section BLOB''' ") + # + # exec("cur.execute(query1)") + # + # # Commit the transaction after executing INSERT. + # cnx.commit() + # + # for i in stg.acoustic_data: + # cur.execute(f"''' UPDATE BSRawData SET BS_cross_section = " + str(stg.BS_cross_section[i].tobytes()) + " WHERE acoustic_data =" + str(i) + " ''' ") + # + # # Commit the transaction after executing INSERT. + # cnx.commit() + # + # print(f"end : {time.time() - start_table_BSRawData} sec") + + if stg.BS_cross_section: + + cur.execute(''' DROP TABLE BSRawData ''') + print(f"end : {time.time() - start_table_BSRawData} sec") + + cur.execute('''CREATE TABLE BSRawData( + ID INTEGER PRIMARY KEY AUTOINCREMENT, + acoustic_data INTEGER, + time BLOB, + time_cross_section BLOB, + depth BLOB, + depth_cross_section BLOB, + BS_raw_data BLOB, + BS_cross_section BLOB)''') + + for i in stg.acoustic_data: + + cur.execute(''' INSERT into BSRawData(acoustic_data, time, time_cross_section, + depth, depth_cross_section, + BS_raw_data, BS_cross_section) + VALUES(?, ?, ?, ?, ?, ?, ?)''', + (stg.acoustic_data[i], stg.time[i].tobytes(), stg.time_cross_section[i].tobytes(), + stg.depth[i].tobytes(), stg.depth_cross_section[i].tobytes(), + stg.BS_raw_data[i].tobytes(), stg.BS_cross_section[i].tobytes())) + + cnx.commit() + + if stg.depth_bottom: + + pass + + + # Close database cursor + cur.close() + + # Close database connection + cnx.close() + + + diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 241932d..1b83d99 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -954,6 +954,9 @@ class AcousticDataTab(QWidget): self.max_selected_file = 1 # self.btnToggled() + plt.rcParams['figure.max_open_warning'] = 100 + print("plt.rcParams['figure.max_open_warning'] ", plt.rcParams['figure.max_open_warning']) + # -------------------------------------------------------------------------------------------------------------- # --- Connect signal of widget --- @@ -1689,8 +1692,20 @@ class AcousticDataTab(QWidget): self.tableView.setModel(self.tableModel) # --- Clear figure area for backscattered acoutsic signal recording --- - self.canvas_BS.figure.clear() - self.canvas_plot_profile.figure.clear() + # self.canvas_BS.figure.clear() + # self.fig_BS.clf() + # for ax in range(len(self.axis_BS)): + # self.axis_BS[ax].cla() + # print("axis BS : ", self.axis_BS) + # # self.axis_BS.tolist().clear() + # # print("clear axis BS : ", self.axis_BS) + # + # self.canvas_plot_profile.figure.clear() + # print("0 fig profile : ", self.fig_profile) + # self.fig_profile.delaxes(self.axis_profile) + # print("1 fig profile : ", self.fig_profile) + # # self.axis_profile.clear() + self.combobox_frequency_profile.clear() # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) # self.canvas_BS = FigureCanvas() @@ -1707,6 +1722,15 @@ class AcousticDataTab(QWidget): # self.canvas_plot_profile = FigureCanvas() # self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) + self.canvas_BS.figure.clear() + self.fig_BS.clf() + print("axis BS : ", self.axis_BS) + self.axis_BS.tolist().clear() + print("clear axis BS : ", self.axis_BS) + self.canvas_plot_profile.figure.clear() + self.fig_profile.clear() + self.axis_profile.clear() + self.slider.setValue(0) self.slider.setMaximum(10) @@ -1918,8 +1942,11 @@ class AcousticDataTab(QWidget): # self.label_tx.setText( # _translate("CONSTANT_STRING", cs.GAIN_TX) + ": " + ', '.join(map(str, stg.gain_tx[self.fileListWidget.currentRow()]))) - print("self.fileListWidget.count() ", self.fileListWidget.currentRow()) - if self.fileListWidget.count() > 0: + print("self.fileListWidget.currentItem() ", self.fileListWidget.currentItem()) + print("self.fileListWidget.currentRow ", self.fileListWidget.currentRow()) + print("self.fileListWidget.count() ", self.fileListWidget.count()) + + if self.fileListWidget.currentRow() != -1: self.label_date_acoustic_file.clear() self.label_date_acoustic_file.setText("Date: " + str(stg.date[self.fileListWidget.currentRow()])) @@ -2156,34 +2183,35 @@ class AcousticDataTab(QWidget): def fill_table(self): - if self.fileListWidget.count() == 1: + if self.fileListWidget.currentRow() != -1: - header_list = [] - for freq_ind, freq_value in enumerate(stg.freq_text[0]): - header_list.append("Time - " + freq_value) - header_list.append("Depth - " + freq_value) - header_list.append("BS - " + freq_value) - - if freq_ind == 0: - table_data = np.vstack((np.vstack((stg.time_reshape[0][:, freq_ind], - stg.depth_reshape[0][:, freq_ind])), - stg.BS_raw_data_reshape[0][:, freq_ind])) - else: - table_data = np.vstack((table_data, - np.vstack((np.vstack((stg.time_reshape[0][:, freq_ind], - stg.depth_reshape[0][:, freq_ind])), - stg.BS_raw_data_reshape[0][:, freq_ind])) - )) - - print(header_list) - print(table_data.shape) - - stg.DataFrame_acoustic = pd.DataFrame(data=table_data.transpose(), columns=header_list) - - else: + # header_list = [] + # for freq_ind, freq_value in enumerate(stg.freq_text[0]): + # header_list.append("Time - " + freq_value) + # header_list.append("Depth - " + freq_value) + # header_list.append("BS - " + freq_value) + # + # if freq_ind == 0: + # table_data = np.vstack((np.vstack((stg.time_reshape[0][:, freq_ind], + # stg.depth_reshape[0][:, freq_ind])), + # stg.BS_raw_data_reshape[0][:, freq_ind])) + # else: + # table_data = np.vstack((table_data, + # np.vstack((np.vstack((stg.time_reshape[0][:, freq_ind], + # stg.depth_reshape[0][:, freq_ind])), + # stg.BS_raw_data_reshape[0][:, freq_ind])) + # )) + # + # print("1 header_list ", header_list) + # print("1 table_data.shape ", table_data.shape) + # + # stg.DataFrame_acoustic = pd.DataFrame(data=table_data.transpose(), columns=header_list) + # + # else: header_list = [] header_list.clear() + table_data = np.array([[]]) for freq_ind, freq_value in enumerate(stg.freq_text[0]): header_list.append("Time - " + freq_value) header_list.append("Depth - " + freq_value) @@ -2201,10 +2229,11 @@ class AcousticDataTab(QWidget): stg.BS_raw_data_reshape[self.fileListWidget.currentRow()][:, freq_ind])) )) + stg.DataFrame_acoustic = pd.DataFrame(None) stg.DataFrame_acoustic = pd.DataFrame(data=table_data.transpose(), columns=header_list) - print(header_list) - print(table_data.shape) + print("2 header_list ", header_list) + print("2 table_data.shape", table_data.shape) # stg.DataFrame_acoustic = ( # pd.DataFrame(np.concatenate((stg.time_reshape[self.fileListWidget.currentRow()], # stg.BS_raw_data_reshape[self.fileListWidget.currentRow()]), axis=1), @@ -2284,114 +2313,116 @@ class AcousticDataTab(QWidget): # self.groupbox_xaxis_space.setDisabled(True) def compute_time(self): - if ((self.fileListWidget.count() == 1) and (len(stg.tmax) == 0)): + if self.fileListWidget.currentRow() != -1: - print("Config 1 : time") + if ((self.fileListWidget.count() == 1) and (len(stg.tmax) == 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 = [(tmin_indice, tmin_value)] + print("Config 1 : time") - 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)] + # --- 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)] - print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") + 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)] - # --- 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}") + print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") - # --- 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]) + # --- 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}") - # 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])) + # --- 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()) + print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) - elif len(stg.tmax) < self.fileListWidget.count(): + elif len(stg.tmax) < self.fileListWidget.count(): - print("Config 2 : time") + 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}") + # --- 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}") + 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}") + 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]]] + # --- 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]) + # --- 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])) + # 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()) + print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) - else: - print("-----------------") - print("Config 3 : time") - print("-----------------") + else: + print("-----------------") + print("Config 3 : time") + print("-----------------") - self.set_range_for_doubleRangeSlider_time() + 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]) + # --- 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()) + # 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): @@ -2441,63 +2472,65 @@ class AcousticDataTab(QWidget): # ) def compute_depth(self): - if ((self.fileListWidget.count() == 1) and (len(stg.rmax) == 0)): + if self.fileListWidget.currentRow() != -1: - # --- 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)] + if ((self.fileListWidget.count() == 1) and (len(stg.rmax) == 0)): - 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)] + # --- 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)] - # --- 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) + 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)] - elif len(stg.rmax) < self.fileListWidget.count(): + # --- 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) - # --- 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) + elif len(stg.rmax) < self.fileListWidget.count(): - 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) + # --- 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.append((rmin_indice, rmin_value)) - stg.rmax.append((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) - # --- 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) + stg.rmin.append((rmin_indice, rmin_value)) + stg.rmax.append((rmax_indice+1, rmax_value)) - else: + # --- 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) - self.set_range_for_doubleRangeSlider_depth() - print("Config 3 : 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], @@ -2536,46 +2569,50 @@ class AcousticDataTab(QWidget): print("rmax ", stg.rmax) def compute_BS_cross_section(self): - if (self.fileListWidget.count() == 1) and (len(stg.BS_cross_section) == 0): + if self.fileListWidget.currentRow() != -1: - print("Config 1 : BS_cross_section") + if (self.fileListWidget.count() == 1) and (len(stg.BS_cross_section) == 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]]] + print("Config 1 : BS_cross_section") - elif len(stg.BS_cross_section) < self.fileListWidget.count(): + 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("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]]] + elif len(stg.BS_cross_section) < self.fileListWidget.count(): - else: + 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("Config 3 : BS_cross_section") + else: - 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 3 : BS_cross_section") - print(f"BS_cross_section : {len(stg.BS_cross_section)}") - print(f"BS_cross_section shape : {stg.BS_cross_section[self.fileListWidget.currentRow()].shape}") + 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): - self.combobox_frequency_bathymetry.clear() - self.combobox_frequency_bathymetry.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]]) - self.combobox_frequency_profile.clear() - self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]]) + if self.fileListWidget.currentRow() != -1: + self.combobox_frequency_bathymetry.clear() + self.combobox_frequency_bathymetry.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]]) + self.combobox_frequency_profile.clear() + self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]]) def set_range_for_doubleRangeSlider_intg_area(self): - 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]) + 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])) + 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 --- @@ -2611,64 +2648,67 @@ class AcousticDataTab(QWidget): # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) # plt.close(self.fig_BS) - self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) - 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.canvas_BS = FigureCanvas(self.fig_BS) - # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_BS) + if self.fileListWidget.currentRow() != -1: - # self.scroll_BS = QScrollArea() - self.scroll_BS.setWidget(self.canvas_BS) - # self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) - # self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # # self.scroll_BS.setWidgetResizable(True) - # self.scroll_BS.setAlignment(Qt.AlignCenter) - self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) - for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): + 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.canvas_BS = FigureCanvas(self.fig_BS) + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.canvas_BS) - 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 + # self.scroll_BS = QScrollArea() + self.scroll_BS.setWidget(self.canvas_BS) + # self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) + # self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # # self.scroll_BS.setWidgetResizable(True) + # self.scroll_BS.setAlignment(Qt.AlignCenter) + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) - # print(f"freq = {f}") + for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): - 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, :, :], - # stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + 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 - 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, :, :]), - # np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]), - cmap='Blues') - 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) + # print(f"freq = {f}") - # --- Plot red solid line on transect to visualize position of plotted profile --- - # print("on the 2D field ", self.combobox_freq_choice.currentIndex()) - self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), - self.slider.value() - 1] * 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) + 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, :, :], + # stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - self.fig_BS.supxlabel('Time (sec)', fontsize=10) - self.fig_BS.supylabel('Depth (m)', fontsize=10) - cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right') - cbar.set_label(label='Acoustic backscatter signal (V)', rotation=270, labelpad=10) - self.fig_BS.canvas.draw_idle() - # plt.close(self.fig_BS) + 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, :, :]), + # np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]), + cmap='Blues') + 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.plot_profile() + # --- Plot red solid line on transect to visualize position of plotted profile --- + # print("on the 2D field ", self.combobox_freq_choice.currentIndex()) + self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( + stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), + self.slider.value() - 1] * 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) + + self.fig_BS.supxlabel('Time (sec)', fontsize=10) + self.fig_BS.supylabel('Depth (m)', fontsize=10) + cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right') + cbar.set_label(label='Acoustic backscatter signal (V)', rotation=270, labelpad=10) + self.fig_BS.canvas.draw_idle() + # plt.close(self.fig_BS) + + # self.plot_profile() def update_plot_backscattered_acoustic_signal_recording(self): @@ -2872,8 +2912,8 @@ class AcousticDataTab(QWidget): 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)) + # 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") @@ -2899,79 +2939,80 @@ class AcousticDataTab(QWidget): # plt.close(self.fig_BS) def plot_profile(self): + if self.fileListWidget.currentRow() != -1: - self.combobox_frequency_profile.setCurrentIndex(0) + self.combobox_frequency_profile.setCurrentIndex(0) - self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_profile) - self.combobox_frequency_profile.currentIndexChanged.connect( - self.update_plot_backscattered_acoustic_signal_recording) + self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_profile) + self.combobox_frequency_profile.currentIndexChanged.connect( + 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.BS_raw_data[self.fileListWidget.currentRow()].shape[2]) + self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) - self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) + self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) - # --- Figure to plot profiles --- - self.fig_profile, self.axis_profile = plt.subplots(nrows=1, ncols=1, layout="constrained") - self.canvas_plot_profile = FigureCanvas(self.fig_profile) - self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) + # --- Figure to plot profiles --- + self.fig_profile, self.axis_profile = plt.subplots(nrows=1, ncols=1, layout="constrained") + self.canvas_plot_profile = FigureCanvas(self.fig_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) - # for f, _ in enumerate(stg.freq[0]): + # 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] + 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.cla() - self.axis_profile.plot(stg.BS_cross_section[self.fileListWidget.currentRow()][ - self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[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) + # --- Profile plot --- + # self.axis_profile.cla() + self.axis_profile.plot(stg.BS_cross_section[self.fileListWidget.currentRow()][ + self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], + -stg.depth_cross_section[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) - # --- Plot bottom line --- + # --- 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 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) + 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(), - :])) + 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="Times New Roman", - 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="Times New Roman", + 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.supxlabel("Acoustic Backscatter Signal (V)") + self.fig_profile.supylabel("Depth (m)") - self.fig_profile.canvas.draw_idle() - # plt.close(self.fig_profile) + self.fig_profile.canvas.draw_idle() + # plt.close(self.fig_profile) - # self.plot_transect_with_BS_raw_data() + # self.plot_transect_with_BS_raw_data() - # self.slider.valueChanged.connect(self.update_plot_profile) - # self.slider.valueChanged.connect(self.update_xaxis_transect_with_BS_raw_data) - # self.combobox_frequency_profile.currentIndexChanged.connect(self.update_xaxis_transect_with_BS_raw_data) - # self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_profile) + # self.slider.valueChanged.connect(self.update_plot_profile) + # self.slider.valueChanged.connect(self.update_xaxis_transect_with_BS_raw_data) + # self.combobox_frequency_profile.currentIndexChanged.connect(self.update_xaxis_transect_with_BS_raw_data) + # self.combobox_frequency_profile.currentIndexChanged.connect(self.update_plot_profile) def update_plot_profile(self): # print("len(stg.BS_cross_section) ", len(stg.BS_cross_section)) diff --git a/View/mainwindow.py b/View/mainwindow.py index 029f6aa..df59067 100644 --- a/View/mainwindow.py +++ b/View/mainwindow.py @@ -174,6 +174,7 @@ class Ui_MainWindow(object): # --- Connect Action Open --- self.actionOpen.triggered.connect(self.open) + self.actionOpen.triggered.connect(lambda: print('tott')) # --- Connect Action DB_Browser_for_SQLite --- self.actionDB_Browser_for_SQLite.triggered.connect(self.db_browser_for_sqlite)