diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index f07bb6e..5db96da 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -1562,6 +1562,7 @@ class AcousticDataTab(QWidget): "stg.nb_profiles", "stg.nb_profiles_per_sec", "stg.nb_cells", "stg.cell_size", "stg.pulse_length", "stg.nb_pings_per_sec", "stg.nb_pings_averaged_per_profile", "stg.kt_read", "stg.kt_corrected", "stg.gain_rx", "stg.gain_tx", + "stg.filename_BS_raw_data", "stg.path_BS_raw_data", "stg.BS_raw_data", "stg.time", "stg.depth", "stg.BS_raw_data_reshape", "stg.time_reshape", "stg.depth_reshape"] @@ -1905,7 +1906,9 @@ class AcousticDataTab(QWidget): stg.SNR_stream_bed.append(np.array([])) stg.time_noise.append(np.array([])) stg.noise_method.append(0) + stg.noise_value.append(0) stg.SNR_filter_value.append(0) + stg.Nb_cells_to_average_BS_signal.append(0) stg.filename_BS_noise_data.append("") stg.path_BS_noise_data.append("") diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index d553196..8c74245 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -87,7 +87,6 @@ class SignalProcessingTab(QWidget): self.pushbutton_update = QPushButton() self.pushbutton_update.setIcon(self.icon_update) self.pushbutton_update.setMaximumWidth(40) - self.horizontalLayout_groupbox_data_to_be_processed.addWidget(self.pushbutton_update) self.verticalLayout_groupbox_study_data.addWidget(self.groupbox_data_to_be_processed) @@ -406,10 +405,10 @@ class SignalProcessingTab(QWidget): # --- Connect signal of widget --- - self.combobox_fileListWidget.ShowPopUpWindowSignal.connect(self.event_combobobx_fileListWidget) - # self.combobox_fileListWidget.currentIndexChanged.connect(self.combobox_fileListWidget_change_index) + self.pushbutton_update.clicked.connect(self.update_SignalPreprocessingTab) - # self.pushbutton_update.clicked.connect(self.update_SignalPreprocessingTab) + # self.combobox_fileListWidget.ShowPopUpWindowSignal.connect(self.event_combobobx_fileListWidget) + self.combobox_fileListWidget.currentIndexChanged.connect(self.combobox_fileListWidget_change_index) self.radiobutton_file.toggled.connect(self.onClicked_radiobutton_noise_data) self.radiobutton_profile_tail.toggled.connect(self.onClicked_radiobutton_noise_data) @@ -1047,8 +1046,10 @@ class SignalProcessingTab(QWidget): def event_combobobx_fileListWidget(self): print("self.combobox_fileListWidget.maxCount()", self.combobox_fileListWidget.maxCount()) print("self.combobox_fileListWidget.count()", self.combobox_fileListWidget.count()) + print("len(stg.filename_BS_noise_data ", len(stg.filename_BS_noise_data)) + self.combobox_fileListWidget.clear() - self.combobox_fileListWidget.addItem("") + # self.combobox_fileListWidget.addItem("") for i in range(len(stg.filename_BS_raw_data)): self.combobox_fileListWidget.addItem(stg.filename_BS_raw_data[i]) @@ -1072,56 +1073,128 @@ class SignalProcessingTab(QWidget): # stg.time_noise.append(np.array([])) # stg.noise_method.append(0) - if (stg.noise_method == 1) or (stg.noise_method == 0): - self.radiobutton_file.setChecked(True) - if stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1] != "": - self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1]) - self.radiobutton_profile_tail.setChecked(False) - self.radiobutton_value.setChecked(False) - elif stg.noise_method == 2: - self.radiobutton_file.setChecked(False) - self.radiobutton_profile_tail.setChecked(True) - self.radiobutton_value.setChecked(False) - elif stg.noise_method == 3: - self.radiobutton_file.setChecked(False) - self.radiobutton_profile_tail.setChecked(False) - self.radiobutton_value.setChecked(True) + # if (stg.noise_method == 1) or (stg.noise_method == 0): + # self.radiobutton_file.setChecked(True) + # if stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex()] != "": + # self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex()]) + # self.radiobutton_profile_tail.setChecked(False) + # self.radiobutton_value.setChecked(False) + # elif stg.noise_method == 2: + # self.radiobutton_file.setChecked(False) + # self.radiobutton_profile_tail.setChecked(True) + # self.radiobutton_value.setChecked(False) + # elif stg.noise_method == 3: + # self.radiobutton_file.setChecked(False) + # self.radiobutton_profile_tail.setChecked(False) + # self.radiobutton_value.setChecked(True) + # self.spinbox_compute_noise_from_value.setValue(stg.noise_value[self.combobox_fileListWidget.currentIndex()]) - def fill_combobox_fileListWidget(self): - self.combobox_fileListWidget.addItems([stg.filename_BS_raw_data]) + # self.combobox_fileListWidget.currentIndexChanged.connect(self.combobox_fileListWidget_change_index) + + # def fill_combobox_fileListWidget(self): + # self.combobox_fileListWidget.addItems([stg.filename_BS_raw_data]) def update_SignalPreprocessingTab(self): - self.combobox_fileListWidget.addItems([""] + stg.filename_BS_raw_data) + """ The tab is updated in two cases : + - the user remove a file (in the list widget) in the first tab (Acoustic data), so that the combobox + of data to be processed is updated, + - the user change the limits of one or all the records in the first tab (Acoustic data) """ + + print("filename BS_raw_data before clear ", stg.filename_BS_raw_data) + self.combobox_fileListWidget.clear() + print("filename BS_raw_data after clear ", stg.filename_BS_raw_data) + self.combobox_fileListWidget.addItems(stg.filename_BS_raw_data) + # self.combobox_fileListWidget.setCurrentIndex(0) + # self.combobox_fileListWidget.currentIndexChanged.connect(self.combobox_fileListWidget_change_index) + + # if self.combobox_fileListWidget.count() > 0: + # for c in range(self.combobox_frequency_profile.count()): + # + # if stg.SNR_stream_bed[c].shape != (0,): + # + # if stg.SNR_stream_bed[c] != stg.BS_stream_bed[c]: + # + # if stg.SNR_stream_bed[c].shape != (0,): + # stg.SNR_stream_bed[c] = ( + # stg.SNR_stream_bed[c][:, stg.BS_stream_bed[c].shape[1], stg.BS_stream_bed[c].shape[2]]) + # else: + # pass + # # continuer ici en calculant SNR_stream_bed si on a travailler avec raw data et qu'on revient sur le 1er onglet + # # pour couper ou rajouter la detection du fond. Du coup, il faudra recalculer le SNR stream bed ou cross section + # + # stg.BS_stream_bed_pre_process_SNR[c] = ( + # stg.SNR_stream_bed[c][:, stg.BS_stream_bed[c].shape[1], stg.BS_stream_bed[c].shape[2]]) + # + # if stg.BS_stream_bed_pre_process_SNR_average[c].shape != (0,): + # stg.BS_stream_bed_pre_process_SNR_average[c] = ( + # stg.BS_stream_bed_pre_process_SNR_average[c][:, stg.BS_stream_bed[c].shape[1],stg.BS_stream_bed[c].shape[2]]) + # + # elif stg.BS_stream_bed_pre_process_average[c].shape != (0,): + # stg.BS_stream_bed_pre_process_average[c] = ( + # stg.BS_stream_bed_pre_process_average[c][:, stg.BS_stream_bed[c].shape[1],stg.BS_stream_bed[c].shape[2]]) + # + # + # elif stg.BS_cross_section[c].shape != (0,): + # + # if stg.SNR_cross_section[c] != stg.BS_cross_section[c]: + # + # stg.SNR_cross_section[c] = ( + # stg.SNR_cross_section[c][:, stg.BS_cross_section[c].shape[1], stg.BS_cross_section[c].shape[2]]) + # + # stg.BS_cross_section_pre_process_SNR[c] = ( + # stg.SNR_cross_section[c][:, stg.BS_cross_section[c].shape[1], stg.BS_cross_section[c].shape[2]]) + # + # if stg.BS_cross_section_pre_process_SNR_average[c].shape != (0,): + # stg.BS_cross_section_pre_process_SNR_average[c] = ( + # stg.BS_cross_section_pre_process_SNR_average[c][:, stg.BS_cross_section[c].shape[1],stg.BS_cross_section[c].shape[2]]) + # + # elif stg.BS_cross_section_pre_process_average[c].shape != (0,): + # stg.BS_cross_section_pre_process_average[c] = ( + # stg.BS_cross_section_pre_process_average[c][:, stg.BS_cross_section[c].shape[1],stg.BS_cross_section[c].shape[2]]) + # + # elif stg.BS_raw_data[c].shape != (0,): + # + # if stg.SNR_cross_section[c] != stg.BS_cross_section[c]: + # + # stg.SNR_cross_section[c] = ( + # stg.SNR_cross_section[c][:, stg.BS_cross_section[c].shape[1], stg.BS_cross_section[c].shape[2]]) + # + # stg.BS_cross_section_pre_process_SNR[c] = ( + # stg.SNR_cross_section[c][:, stg.BS_cross_section[c].shape[1], stg.BS_cross_section[c].shape[2]]) + # + # if stg.BS_cross_section_pre_process_SNR_average[c].shape != (0,): + # stg.BS_cross_section_pre_process_SNR_average[c] = ( + # stg.BS_cross_section_pre_process_SNR_average[c][:, stg.BS_cross_section[c].shape[1],stg.BS_cross_section[c].shape[2]]) + # + # elif stg.BS_cross_section_pre_process_average[c].shape != (0,): + # stg.BS_cross_section_pre_process_average[c] = ( + # stg.BS_cross_section_pre_process_average[c][:, stg.BS_cross_section[c].shape[1],stg.BS_cross_section[c].shape[2]]) - # def combobox_fileListWidget_change_index(self): - # - # if stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): - # - # if stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] == 1: - # self.radiobutton_file.setVisible(True) - # self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1]) - # self.radiobutton_profile_tail.setVisible(False) - # self.radiobutton_value.setVisible(False) - # elif stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] == 2: - # self.radiobutton_file.setVisible(False) - # self.radiobutton_profile_tail.setVisible(True) - # self.radiobutton_value.setVisible(False) - # elif stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] == 3: - # self.radiobutton_file.setVisible(False) - # self.radiobutton_profile_tail.setVisible(False) - # self.radiobutton_value.setVisible(True) - # - # self.spinbox_SNR_criterion.setValue(stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex() - 1]) - # self.plot_transect_with_SNR_data() - # self.plot_BS_signal_filtered_with_SNR() - # - # self.plot_profile_and_position_on_transect_with_slider() - # - # else: - # - # self.clear_noise_data() + def combobox_fileListWidget_change_index(self): + + if (stg.noise_method[self.combobox_fileListWidget.currentIndex()] == 1)\ + or (stg.noise_method[self.combobox_fileListWidget.currentIndex()] == 0): + self.radiobutton_file.setChecked(True) + self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex()]) + self.radiobutton_profile_tail.setChecked(False) + self.radiobutton_value.setChecked(False) + elif stg.noise_method[self.combobox_fileListWidget.currentIndex()] == 2: + self.radiobutton_file.setChecked(False) + self.radiobutton_profile_tail.setChecked(True) + self.radiobutton_value.setChecked(False) + elif stg.noise_method[self.combobox_fileListWidget.currentIndex()] == 3: + self.radiobutton_file.setChecked(False) + self.radiobutton_profile_tail.setChecked(False) + self.radiobutton_value.setChecked(True) + self.spinbox_compute_noise_from_value.setValue(stg.noise_value[self.combobox_fileListWidget.currentIndex()]) + + self.spinbox_SNR_criterion.setValue(stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex()]) + self.plot_transect_with_SNR_data() + self.plot_BS_signal_filtered_with_SNR() + self.spinbox_average_horizontal.setValue(stg.Nb_cells_to_average_BS_signal[self.combobox_fileListWidget.currentIndex()]) + self.plot_profile_and_position_on_transect_with_slider() def onClicked_radiobutton_noise_data(self): # radiobutton = self.sender() @@ -1143,26 +1216,26 @@ class SignalProcessingTab(QWidget): def clear_noise_data(self): - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] = 0 - stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex() - 1] = 0 + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.time_noise[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.noise_method[self.combobox_fileListWidget.currentIndex()] = 0 + stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex()] = 0 - stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) - stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) - stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] = np.array([]) + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] = np.array([]) print("All is clear") @@ -1218,8 +1291,8 @@ class SignalProcessingTab(QWidget): name = path.basename(filename[0]) try: - stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1] = dir_name - stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1] = name + stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex()] = dir_name + stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex()] = name print("stg.path_BS_noise_data : ", stg.path_BS_noise_data) print("stg.filename_BS_noise_data : ", stg.filename_BS_noise_data) self.load_noise_data_and_compute_SNR() @@ -1234,8 +1307,8 @@ class SignalProcessingTab(QWidget): msgBox.exec() else: - self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1]) - self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1]) + self.lineEdit_noise_file.setText(stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex()]) + self.lineEdit_noise_file.setToolTip(stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex()]) # self.plot_noise() self.plot_transect_with_SNR_data() # self.combobox_freq_noise.addItems([f for f in stg.freq_text]) @@ -1243,91 +1316,91 @@ class SignalProcessingTab(QWidget): # self.spinbox_SNR_criterion.setValue(2) self.remove_point_with_snr_filter() - self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1]]) + self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex()]]) self.combobox_frequency_profile.currentIndexChanged.connect(self.plot_profile_and_position_on_transect_with_slider) - if stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): - self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]) else: - self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex()].shape[1]) - # if len(stg.BS_stream_bed) and stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape: + # if len(stg.BS_stream_bed) and stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape: # - # self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + # self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]) # - # elif (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[2] - # < stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape[2]): + # elif (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape[2] + # < stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape[2]): # - # self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + # self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]) # # else: # - # self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + # self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex()].shape[1]) self.compute_averaged_BS_data() self.plot_profile_and_position_on_transect_with_slider() - stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] = 1 + stg.noise_method[self.combobox_fileListWidget.currentIndex()] = 1 def load_noise_data_and_compute_SNR(self): - stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] = 1 + stg.noise_method[self.combobox_fileListWidget.currentIndex()] = 1 - noise_data = AcousticDataLoader(stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1] + + noise_data = AcousticDataLoader(stg.path_BS_noise_data[self.combobox_fileListWidget.currentIndex()] + "/" + - stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex() - 1]) - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = noise_data._BS_raw_data + stg.filename_BS_noise_data[self.combobox_fileListWidget.currentIndex()]) + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()] = noise_data._BS_raw_data # stg.date_noise = noise_data._date # stg.hour_noise = noise_data._hour - stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = noise_data._time + stg.time_noise[self.combobox_fileListWidget.currentIndex()] = noise_data._time # stg.time_snr_reshape = stg.time_reshape # print("len(stg.BS_cross_section) : ", len(stg.BS_cross_section)) # print("stg.BS_cross_section[0] : ", stg.BS_cross_section[0].shape) # print("len(stg.BS_stream_bed) : ", len(stg.BS_stream_bed)) - if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): print("Je suis dans stream bed") - noise = np.zeros(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape) + noise = np.zeros(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape) for f, _ in enumerate(noise_data._freq): noise[f, :, :] = np.mean( - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1)) - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise - stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.divide((stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] - - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :], axis=(0, 1)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] = noise + stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()] = ( + np.divide((stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()] - + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()]) ** 2, + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] ** 2)) - elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): print("Je suis dans cross section") - noise = np.zeros(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape) + noise = np.zeros(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape) for f, _ in enumerate(noise_data._freq): noise[f, :, :] = np.mean( - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1)) - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise - stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.divide((stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1] - - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :], axis=(0, 1)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] = noise + stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex()] = ( + np.divide((stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()] - + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()]) ** 2, + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] ** 2)) # stg.SNR_reshape = np.reshape(stg.SNR_cross_section, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), order="F") else: print("Je suis dans raw") - noise = np.zeros(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape) + noise = np.zeros(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape) for f, _ in enumerate(noise_data._freq): noise[f, :, :] = np.mean( - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], axis=(0, 1)) - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] = noise - stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.divide((stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1] - - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, - stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :], axis=(0, 1)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] = noise + stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex()] = ( + np.divide((stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()] - + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()]) ** 2, + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] ** 2)) @@ -1393,48 +1466,53 @@ class SignalProcessingTab(QWidget): def compute_noise_from_value(self): - stg.noise_method[self.combobox_fileListWidget.currentIndex() - 1] = 3 + stg.noise_method[self.combobox_fileListWidget.currentIndex()] = 3 + + stg.noise_value[self.combobox_fileListWidget.currentIndex()] = self.spinbox_compute_noise_from_value.value() + + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()] = ( + np.full(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape, + self.spinbox_compute_noise_from_value.value())) # --- Compute noise from value and compute SNR --- - if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.full(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape, - self.spinbox_compute_noise_from_value.value())) - stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.divide((stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1] - - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] = ( + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()][:, :, + :stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape[2]]) + stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()] = ( + np.divide((stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()] + - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()]) ** 2, + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()] ** 2)) - stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = ( - stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1]) + stg.time_noise[self.combobox_fileListWidget.currentIndex()] = ( + stg.time_cross_section[self.combobox_fileListWidget.currentIndex()]) - elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.full(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape, - self.spinbox_compute_noise_from_value.value())) - stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.divide((stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1] - - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] = ( + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()][:, :, + :stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape[2]]) + stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex()] = ( + np.divide((stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()] + - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()]) ** 2, + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()] ** 2)) - stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = ( - stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1]) + stg.time_noise[self.combobox_fileListWidget.currentIndex()] = ( + stg.time_cross_section[self.combobox_fileListWidget.currentIndex()]) else: - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.full(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape, - self.spinbox_compute_noise_from_value.value())) - stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1] = ( - np.divide((stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1] - - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1]) ** 2, - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1] ** 2)) + stg.BS_noise_averaged_data[self.combobox_fileListWidget.currentIndex()] = ( + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()]) + stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex()] = ( + np.divide((stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()] + - stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()]) ** 2, + stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()] ** 2)) - stg.time_noise[self.combobox_fileListWidget.currentIndex() - 1] = ( - stg.time[self.combobox_fileListWidget.currentIndex() - 1]) + stg.time_noise[self.combobox_fileListWidget.currentIndex()] = ( + stg.time[self.combobox_fileListWidget.currentIndex()]) # if len(stg.BS_stream_bed) == 0: # @@ -1469,24 +1547,24 @@ class SignalProcessingTab(QWidget): # --- Trigger graphic widgets --- - if stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex() - 1] == 0: + if stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex()] == 0: self.spinbox_SNR_criterion.setValue(0) else: - self.spinbox_SNR_criterion.setValue(stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex() - 1]) + self.spinbox_SNR_criterion.setValue(stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex()]) self.plot_transect_with_SNR_data() self.remove_point_with_snr_filter() self.combobox_frequency_profile.addItems( - [f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1]]) + [f for f in stg.freq_text[self.combobox_fileListWidget.currentIndex()]]) self.combobox_frequency_profile.currentIndexChanged.connect( self.plot_profile_and_position_on_transect_with_slider) - if stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): - self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + self.slider.setMaximum(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape[1]) else: - self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex() - 1].shape[1]) + self.slider.setMaximum(stg.time[self.combobox_fileListWidget.currentIndex()].shape[1]) self.compute_averaged_BS_data() self.plot_profile_and_position_on_transect_with_slider() @@ -1546,122 +1624,138 @@ class SignalProcessingTab(QWidget): # elif self.canvas_SNR == None: else: - self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq[self.combobox_fileListWidget.currentIndex() - 1].shape[0], ncols=1, sharex=True, sharey=False, layout='constrained') - self.canvas_SNR = FigureCanvas(self.fig_SNR) - # self.verticalLayout_groupbox_plot_Noise_SNR.addWidget(self.canvas_SNR) + if ((self.combobox_fileListWidget.currentIndex() != -1) + and (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,))): - # self.verticalLayout_groupbox_plot_SNR + self.fig_SNR, self.axis_SNR = plt.subplots(nrows=stg.freq[self.combobox_fileListWidget.currentIndex()].shape[0], ncols=1, sharex=True, sharey=False, layout='constrained') + self.canvas_SNR = FigureCanvas(self.fig_SNR) + # self.verticalLayout_groupbox_plot_Noise_SNR.addWidget(self.canvas_SNR) - # self.verticalLayout_groupbox_plot_Noise_SNR.removeWidget(self.scroll_SNR) - # self.scroll_SNR = QScrollArea() - self.scroll_SNR.setWidget(self.canvas_SNR) + # self.verticalLayout_groupbox_plot_SNR - self.navigationToolBar_SNR = NavigationToolBar(self.canvas_SNR, self.groupbox_plot_SNR) - # self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_SNR.setAlignment(Qt.AlignCenter) - # self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) + # self.verticalLayout_groupbox_plot_Noise_SNR.removeWidget(self.scroll_SNR) + # self.scroll_SNR = QScrollArea() + self.scroll_SNR.setWidget(self.canvas_SNR) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + self.navigationToolBar_SNR = NavigationToolBar(self.canvas_SNR, self.groupbox_plot_SNR) + # self.scroll_SNR.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_SNR.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_SNR.setAlignment(Qt.AlignCenter) + # self.verticalLayout_groupbox_plot_SNR.addWidget(self.scroll_SNR) - if stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :], - stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :]) + if stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): - print("0 plot SNR with SNR_stream_bed") - val_min = np.nanmin(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) - val_max = np.nanmax(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][0, :], + stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][0, :]) - if val_min == val_max: - levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - else: - if val_min == 0: - val_min = 1e-5 - if val_max > 1000: + print("0 plot SNR with SNR_stream_bed") + val_min = np.nanmin(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()][f, :, :]) + + if val_min == val_max: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) else: - levels = np.array([00.1, 1, 2, 10, 100, val_max]) + if val_min == 0: + val_min = 1e-5 + if val_max > 1000: + levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + else: + levels = np.array([00.1, 1, 2, 10, 100, val_max]) - bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - norm = BoundaryNorm(boundaries=bounds, ncolors=300) + bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + norm = BoundaryNorm(boundaries=bounds, ncolors=300) - cf = (self.axis_SNR[f].contourf(x, -y, - stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], - levels, cmap='gist_rainbow', - norm=norm)) + cf = (self.axis_SNR[f].contourf(x, -y, + stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()][f, :, :], + levels, cmap='gist_rainbow', + norm=norm)) - elif stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): - x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :], - stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][0, :]) + x, y = np.meshgrid(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][0, :], + stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][0, :]) - print("1 plot SNR with SNR_cross_section") - val_min = np.nanmin(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) - val_max = np.nanmax(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) - if val_min == val_max: - levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) - else: - if val_min == 0: - val_min = 1e-5 - if val_max > 1000: + print("1 plot SNR with SNR_cross_section") + val_min = np.nanmin(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex()][f, :, :]) + if val_min == val_max: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) else: - levels = np.array([00.1, 1, 2, 10, 100, val_max]) + if val_min == 0: + val_min = 1e-5 + if val_max > 1000: + levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + else: + levels = np.array([00.1, 1, 2, 10, 100, val_max]) - bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - norm = BoundaryNorm(boundaries=bounds, ncolors=300) + bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + norm = BoundaryNorm(boundaries=bounds, ncolors=300) - cf = (self.axis_SNR[f].contourf(x, -y, - stg.SNR_cross_section[ - self.combobox_fileListWidget.currentIndex() - 1][f, :, :], - levels, cmap='gist_rainbow', norm=norm)) + cf = (self.axis_SNR[f].contourf(x, -y, + stg.SNR_cross_section[ + self.combobox_fileListWidget.currentIndex()][f, :, :], + levels, cmap='gist_rainbow', norm=norm)) - else: - - x, y = np.meshgrid(stg.time[self.combobox_fileListWidget.currentIndex() - 1][0, :], - stg.depth[self.combobox_fileListWidget.currentIndex() - 1][0, :]) - - print("0 plot SNR with SNR_raw_data") - val_min = np.nanmin(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) - val_max = np.nanmax(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) - if val_min == val_max: - levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) else: - if val_min == 0: - val_min = 1e-5 - if val_max > 1000: + + x, y = np.meshgrid(stg.time[self.combobox_fileListWidget.currentIndex()][0, :], + stg.depth[self.combobox_fileListWidget.currentIndex()][0, :]) + + print("0 plot SNR with SNR_raw_data") + val_min = np.nanmin(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :]) + if val_min == val_max: levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) else: - levels = np.array([00.1, 1, 2, 10, 100, val_max]) + if val_min == 0: + val_min = 1e-5 + if val_max > 1000: + levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6]) + else: + levels = np.array([00.1, 1, 2, 10, 100, val_max]) - bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] - norm = BoundaryNorm(boundaries=bounds, ncolors=300) + bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2] + norm = BoundaryNorm(boundaries=bounds, ncolors=300) - cf = (self.axis_SNR[f].contourf(x, -y, - stg.SNR_raw_data[ - self.combobox_fileListWidget.currentIndex() - 1][f, :, :], - levels, cmap='gist_rainbow', norm=norm)) + print("self.combobox_fileListWidget.currentIndex() ", self.combobox_fileListWidget.currentIndex()) + print("x ", x.shape) + print("y ", y.shape) + print("stg.SNR_raw_data", stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex()].shape) + + cf = (self.axis_SNR[f].contourf(x, -y, + stg.SNR_raw_data[ + self.combobox_fileListWidget.currentIndex()][f, :, :], + levels, cmap='gist_rainbow', norm=norm)) - self.axis_SNR[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][f], - fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_SNR[f].transAxes) + self.axis_SNR[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex()][f], + fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_SNR[f].transAxes) - self.fig_SNR.supxlabel('Time (sec)', fontsize=10) - self.fig_SNR.supylabel('Depth (m)', fontsize=10) - cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right') - cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10) - cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$']) - self.fig_SNR.canvas.draw_idle() + self.fig_SNR.supxlabel('Time (sec)', fontsize=10) + self.fig_SNR.supylabel('Depth (m)', fontsize=10) + cbar = self.fig_SNR.colorbar(cf, ax=self.axis_SNR[:], shrink=1, location='right') + cbar.set_label(label='Signal to Noise Ratio', rotation=270, labelpad=10) + cbar.set_ticklabels(['0', '1', '2', '10', '100', r'10$^3$', r'10$^6$']) + self.fig_SNR.canvas.draw_idle() - # # --- 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(), 0] * np.ones( - # stg.r.shape[1]), - # -stg.r[self.combobox_frequency_profile.currentIndex(), :], - # color='red', linestyle="solid", linewidth=2) + # # --- 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(), 0] * np.ones( + # stg.r.shape[1]), + # -stg.r[self.combobox_frequency_profile.currentIndex(), :], + # color='red', linestyle="solid", linewidth=2) + + else: + + # self.canvas_SNR.figure.clear() + # self.fig_SNR.clf() + # self.axis_SNR.tolist().clear() + self.canvas_SNR = FigureCanvas() + self.scroll_SNR.setWidget(self.canvas_SNR) def remove_point_with_snr_filter(self): @@ -1675,35 +1769,35 @@ class SignalProcessingTab(QWidget): else: - stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex() - 1] = self.spinbox_SNR_criterion.value() + stg.SNR_filter_value[self.combobox_fileListWidget.currentIndex()] = self.spinbox_SNR_criterion.value() - if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): stg.BS_stream_bed_pre_process_SNR = deepcopy(stg.BS_stream_bed) # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) # stg.SNR_data_average = np.divide( # (stg.BS_stream_bed_pre_process_SNR - stg.Noise_data) ** 2, stg.Noise_data ** 2) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][ + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ f, - np.where(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[0], - np.where(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ + np.where(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()][f, :, :] < self.spinbox_SNR_criterion.value())[0], + np.where(stg.SNR_stream_bed[self.combobox_fileListWidget.currentIndex()][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ = np.nan - elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): stg.BS_cross_section_pre_process_SNR = deepcopy(stg.BS_cross_section) # stg.Noise_data = deepcopy(stg.BS_noise_averaged_data[:, :, :stg.t.shape[1]]) # stg.SNR_data_average = np.divide( # (stg.BS_stream_bed_pre_process_SNR - stg.Noise_data) ** 2, stg.Noise_data ** 2) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][ + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ f, - np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, + np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex()][f, :, :] < self.spinbox_SNR_criterion.value())[0], - np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :, + np.where(stg.SNR_cross_section[self.combobox_fileListWidget.currentIndex()][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ = np.nan @@ -1711,12 +1805,12 @@ class SignalProcessingTab(QWidget): stg.BS_raw_data_pre_process_SNR = deepcopy(stg.BS_raw_data) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][ + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][ f, - np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, + np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :] < self.spinbox_SNR_criterion.value())[0], - np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, :, + np.where(stg.SNR_raw_data[self.combobox_fileListWidget.currentIndex()][f, :, :] < self.spinbox_SNR_criterion.value())[1]] \ = np.nan @@ -1762,79 +1856,92 @@ class SignalProcessingTab(QWidget): # self.verticalLayout_groupbox_BS_SNR_filter.removeWidget(self.scroll_BS) - self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.combobox_fileListWidget.currentIndex() - 1].shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") - self.canvas_BS = FigureCanvas(self.fig_BS) - # self.verticalLayout_groupbox_plot_SNR.addWidget(self.canvas_SNR) + if ((self.combobox_fileListWidget.currentIndex() != -1) + and (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,))): - # self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR) - # self.scroll_BS = QScrollArea() - self.scroll_BS.setWidget(self.canvas_BS) - # self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) - # self.scroll_BS.setAlignment(Qt.AlignCenter) - # self.verticalLayout_groupbox_BS_SNR_filter.addWidget(self.scroll_BS) + self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.combobox_fileListWidget.currentIndex()].shape[0], ncols=1, sharex=True, sharey=False, layout="constrained") + self.canvas_BS = FigureCanvas(self.fig_BS) + # self.verticalLayout_groupbox_plot_SNR.addWidget(self.canvas_SNR) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): + # self.verticalLayout_groupbox_plot_SNR.removeWidget(self.scroll_SNR) + # self.scroll_BS = QScrollArea() + self.scroll_BS.setWidget(self.canvas_BS) + # self.scroll_BS.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_BS.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) + # self.scroll_BS.setAlignment(Qt.AlignCenter) + # self.verticalLayout_groupbox_BS_SNR_filter.addWidget(self.scroll_BS) - if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): - val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) - val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): - if val_min == 0: - val_min = 1e-5 + val_min = np.nanmin(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) - pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], - stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + if val_min == 0: + val_min = 1e-5 - self.axis_BS[f].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], - -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], - color='black', linewidth=1, linestyle="solid") + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + self.axis_BS[f].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth_bottom[self.combobox_fileListWidget.currentIndex()], + color='black', linewidth=1, linestyle="solid") - val_min = np.nanmin( - stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) - val_max = np.nanmax( - stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + elif stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): - if val_min == 0: - val_min = 1e-5 + val_min = np.nanmin( + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax( + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) - pcm = self.axis_BS[f].pcolormesh( - stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, :], - stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + if val_min == 0: + val_min = 1e-5 - else: + pcm = self.axis_BS[f].pcolormesh( + stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - val_min = np.nanmin( - stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) - val_max = np.nanmax( - stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, :, :]) + else: - if val_min == 0: - val_min = 1e-5 + val_min = np.nanmin( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) + val_max = np.nanmax( + stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, :, :]) - pcm = self.axis_BS[f].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex() - 1][f, :], - -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][f, :], - stg.BS_raw_data_pre_process_SNR[ - self.combobox_fileListWidget.currentIndex() - 1][f, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + if val_min == 0: + val_min = 1e-5 + + pcm = self.axis_BS[f].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex()][f, :], + -stg.depth[self.combobox_fileListWidget.currentIndex()][f, :], + stg.BS_raw_data_pre_process_SNR[ + self.combobox_fileListWidget.currentIndex()][f, :, :], + cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + + self.axis_BS[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex()][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) + 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() + + else: + + # self.canvas_BS.figure.clear() + # self.fig_BS.clf() + # self.axis_BS.tolist().clear() + self.canvas_BS = FigureCanvas() + self.scroll_BS.setWidget(self.canvas_BS) - self.axis_BS[f].text(1, .70, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][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) - 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() def compute_averaged_BS_data(self): @@ -1851,80 +1958,80 @@ class SignalProcessingTab(QWidget): kernel = np.ones(2*self.spinbox_average_horizontal.value()+1) print(kernel) - if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + if stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape != (0,): # --- Données pré-traitées avec SNR : BS stream bed pre process SNR -> BS stream bed pre process SNR average --- - if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): - # ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or - # (stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape))): + if stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # ((stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or + # (stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape))): stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1][f, i,:] \ - = convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i,:] \ + = convolve1d(stg.BS_stream_bed_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) print("1 - Je suis dans stg.BS_stream_bed_pre_process_SNR_average") # --- Données BS stream bed : BS stream bed -> BS stream bed pre process average --- else: - # elif ((stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or - # (stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1].shape)): + # elif ((stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape) or + # (stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()].shape)): stg.BS_stream_bed_pre_process_average = deepcopy(stg.BS_stream_bed) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): - stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ - = convolve1d(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ + = convolve1d(stg.BS_stream_bed[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) print("2 - Je suis dans stg.BS_stream_bed_pre_process_average") - elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): # --- Données pré-traitées avec SNR : BS cross section pre process SNR -> BS cross section pre process SNR average --- - if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): - # if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or - # (stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape)): + if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # if ((stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or + # (stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape)): stg.BS_cross_section_pre_process_SNR_average = deepcopy(stg.BS_cross_section_pre_process_SNR) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ - = convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ + = convolve1d(stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) print("3 - Je suis dans stg.BS_cross_section_pre_process_SNR_average") # --- Données BS section : BS cross section -> BS cross section pre process average --- else: - # elif ((stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or - # (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape)): + # elif ((stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape) or + # (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape)): stg.BS_cross_section_pre_process_average = deepcopy(stg.BS_cross_section) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): - stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ - = convolve1d(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ + = convolve1d(stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) print("4 - Je suis dans stg.BS_cross_section_pre_process_average") else: # --- Données pré-traitées avec SNR : BS raw data pre process SNR -> BS raw data pre process SNR average --- - if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): - # if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape) or - # (stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1].shape)): + if stg.BS_cross_section_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape != (0,): + # if ((stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape) or + # (stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()].shape)): stg.BS_raw_data_pre_process_SNR_average = deepcopy(stg.BS_raw_data_pre_process_SNR) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ - = convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ + = convolve1d(stg.BS_raw_data_pre_process_SNR[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) print("5 - Je suis dans stg.BS_raw_data_pre_process_SNR_average") # --- Données BS brutes : BS raw data -> BS raw data pre process average --- @@ -1933,20 +2040,20 @@ class SignalProcessingTab(QWidget): stg.BS_raw_data_pre_process_average = deepcopy(stg.BS_raw_data) - for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): - stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1][f, i,:] \ - = convolve1d(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1][f, i, :], weights=kernel) / len(kernel) + for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i,:] \ + = convolve1d(stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()][f, i, :], weights=kernel) / len(kernel) print("6 - Je suis dans stg.BS_raw_data_pre_process_average") - # if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape == - # stg.BS_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape): + # if (stg.BS_cross_section[self.combobox_fileListWidget.currentIndex()].shape == + # stg.BS_raw_data[self.combobox_fileListWidget.currentIndex()].shape): # # stg.BS_raw_data_pre_process_average = deepcopy(stg.BS_raw_data) # - # for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex() - 1]): - # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]): - # stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1][f, i, :] \ + # for f, _ in enumerate(stg.freq[self.combobox_fileListWidget.currentIndex()]): + # for i in range(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]): + # stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()][f, i, :] \ # = convolve1d(stg.BS_stream_bed_pre_process_SNR[f, i, :], weights=kernel) / len(kernel) # # stg.BS_stream_bed_pre_process_SNR_average = deepcopy(stg.BS_stream_bed_pre_process_SNR) @@ -2012,7 +2119,7 @@ class SignalProcessingTab(QWidget): self.label_profile_number.setText("Profile " + str(self.slider.value()) + " / " + str(self.slider.maximum())) if ((self.combobox_fileListWidget.currentIndex() != -1) and - (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,))): + (stg.BS_noise_raw_data[self.combobox_fileListWidget.currentIndex()].shape != (0,))): self.figure_profile, self.axis_profile = plt.subplots(nrows=2, ncols=1, layout="constrained") self.canvas_profile = FigureCanvas(self.figure_profile) @@ -2021,15 +2128,15 @@ class SignalProcessingTab(QWidget): self.axis_profile[0].cla() self.axis_profile[1].cla() - if stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + if stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) - self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex()], + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex()], fontsize=10, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, horizontalalignment='right', verticalalignment='bottom', @@ -2038,29 +2145,29 @@ class SignalProcessingTab(QWidget): # --- Plot transect with profile position --- self.axis_profile[1].cla() val_min = np.nanmin( - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], - stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], + stg.BS_stream_bed_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( - stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) - self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex()], fontsize=10, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, @@ -2070,32 +2177,32 @@ class SignalProcessingTab(QWidget): # --- Plot transect with profile position --- self.axis_profile[1].cla() val_min = np.nanmin( - stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_stream_bed_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], stg.BS_stream_bed_pre_process_average[ - self.combobox_fileListWidget.currentIndex() - 1] + self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) - self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex()], fontsize=10, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, @@ -2105,32 +2212,32 @@ class SignalProcessingTab(QWidget): # --- Plot transect with profile position --- self.axis_profile[1].cla() val_min = np.nanmin( - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_cross_section_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], stg.BS_cross_section_pre_process_SNR_average[ - self.combobox_fileListWidget.currentIndex() - 1] + self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( - stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) - self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex()], fontsize=10, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, @@ -2140,32 +2247,32 @@ class SignalProcessingTab(QWidget): # --- Plot transect with profile position --- self.axis_profile[1].cla() val_min = np.nanmin( - stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_cross_section_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], stg.BS_cross_section_pre_process_average[ - self.combobox_fileListWidget.currentIndex() - 1] + self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) - self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex()], fontsize=10, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, @@ -2175,32 +2282,32 @@ class SignalProcessingTab(QWidget): # --- Plot transect with profile position --- self.axis_profile[1].cla() val_min = np.nanmin( - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_raw_data_pre_process_SNR_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[1].pcolormesh(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth_cross_section[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], stg.BS_raw_data_pre_process_SNR_average[ - self.combobox_fileListWidget.currentIndex() - 1] + self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): + elif stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()].shape != (0,): # --- Plot profile --- self.axis_profile[0].plot( - stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, self.slider.value() - 1], - -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], linestyle='solid', color='k', linewidth=1) - self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[0].text(.95, .05, stg.freq_text[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex()], fontsize=10, fontweight='bold', fontname="Ubuntu", fontstyle="normal", c="black", alpha=0.2, @@ -2210,42 +2317,42 @@ class SignalProcessingTab(QWidget): # --- Plot transect with profile position --- self.axis_profile[1].cla() val_min = np.nanmin( - stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex() - 1] + stg.BS_raw_data_pre_process_average[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - self.axis_profile[1].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex() - 1][ + self.axis_profile[1].pcolormesh(stg.time[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], - -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][ + -stg.depth[self.combobox_fileListWidget.currentIndex()][ self.combobox_frequency_profile.currentIndex(), :], stg.BS_raw_data_pre_process_average[ - self.combobox_fileListWidget.currentIndex() - 1] + self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) self.axis_profile[1].plot( - stg.time[self.combobox_fileListWidget.currentIndex() - 1] + stg.time[self.combobox_fileListWidget.currentIndex()] [self.combobox_frequency_profile.currentIndex(), self.slider.value() - 1] * - np.ones(stg.depth[self.combobox_fileListWidget.currentIndex() - 1].shape[1]), - -stg.depth[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], + np.ones(stg.depth[self.combobox_fileListWidget.currentIndex()].shape[1]), + -stg.depth[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], color='red', linestyle="solid", linewidth=2) self.axis_profile[0].set_xlabel("Acoustic Backscatter Signal (V)") self.axis_profile[0].set_ylabel("Depth (m)") - if len(stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1]) != 0: - if stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1].shape != (0,): - self.axis_profile[1].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex() - 1][self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], + if len(stg.depth_bottom[self.combobox_fileListWidget.currentIndex()]) != 0: + if stg.time_cross_section[self.combobox_fileListWidget.currentIndex()].shape != (0,): + self.axis_profile[1].plot(stg.time_cross_section[self.combobox_fileListWidget.currentIndex()][self.combobox_frequency_profile.currentIndex(), :], + -stg.depth_bottom[self.combobox_fileListWidget.currentIndex()], color='black', linewidth=1, linestyle="solid") else: self.axis_profile[1].plot(stg.time[self.combobox_fileListWidget - 1][ self.combobox_frequency_profile.currentIndex(), :], - -stg.depth_bottom[self.combobox_fileListWidget.currentIndex() - 1], + -stg.depth_bottom[self.combobox_fileListWidget.currentIndex()], color='black', linewidth=1, linestyle="solid") self.axis_profile[1].set_xticks([]) @@ -2253,6 +2360,14 @@ class SignalProcessingTab(QWidget): self.figure_profile.canvas.draw_idle() + else: + + # self.canvas_profile.figure.clear() + # self.figure_profile.clf() + # self.axis_profile.tolist().clear() + self.canvas_profile = FigureCanvas() + self.scroll_profile.setWidget(self.canvas_profile) + # if stg.BS_stream_bed_pre_process_SNR_average.size != 0: # # # --- Plot profile --- diff --git a/settings.py b/settings.py index 7772c6f..726e4e9 100644 --- a/settings.py +++ b/settings.py @@ -23,7 +23,9 @@ BS_noise_raw_data = [] # BS noise raw data : BS signal listen BS_noise_averaged_data = [] # BS noise raw data averaged (array has the same shape than BS_raw_data shape) noise_method = [] +noise_value = [] SNR_filter_value = [] +Nb_cells_to_average_BS_signal = [] date = [] date_noise = []