From 76c654046aaa8739848ea18bd4e4bd4ce444a814 Mon Sep 17 00:00:00 2001 From: brahim Date: Thu, 31 Oct 2024 13:33:28 +0100 Subject: [PATCH] Profile scrolling is done in time with the slider, and not with the number of the profile. That's for all tabs --- View/acoustic_data_tab.py | 27 +++++---- View/acoustic_inversion_tab.py | 94 ++++++++++++++++++++++++++------ View/sediment_calibration_tab.py | 38 +++++++++++-- View/signal_processing_tab.py | 39 ++++++++++--- 4 files changed, 155 insertions(+), 43 deletions(-) diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 1da0ac2..a5436ce 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -3959,37 +3959,42 @@ class AcousticDataTab(QWidget): def slide_profile_number_to_begin(self): self.slider.setValue(int(self.slider.minimum())) self.update_lineEdit_by_moving_slider() - # self.lineEdit_slider.setText(str(self.slider.value())) def slide_profile_number_to_right(self): self.slider.setValue(int(self.slider.value()) + 1) self.update_lineEdit_by_moving_slider() - # self.lineEdit_slider.setText(str(self.slider.value())) def slide_profile_number_to_left(self): self.slider.setValue(int(self.slider.value()) - 1) self.update_lineEdit_by_moving_slider() - # self.lineEdit_slider.setText(str(self.slider.value())) def slide_profile_number_to_end(self): self.slider.setValue(int(self.slider.maximum())) self.update_lineEdit_by_moving_slider() - # self.lineEdit_slider.setText(str(self.slider.value())) def profile_number_on_lineEdit(self): - self.slider.setValue( - int(np.where(np.abs(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()] - - float(self.lineEdit_slider.text().replace(",", "."))) == - np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()] - - float(self.lineEdit_slider.text().replace(",", ".")))))[0][0])) + if stg.time_cross_section[self.fileListWidget.currentRow()].shape != (0,): + self.slider.setValue( + int(np.where(np.abs(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()] - + float(self.lineEdit_slider.text().replace(",", "."))) == + np.nanmin(np.abs(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()] - + float(self.lineEdit_slider.text().replace(",", ".")))))[0][0])) + else: + self.slider.setValue( + int(np.where(np.abs(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()] - + float(self.lineEdit_slider.text().replace(",", "."))) == + np.nanmin(np.abs(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()] - + float(self.lineEdit_slider.text().replace(",", ".")))))[0][0])) def update_lineEdit_by_moving_slider(self): + print("min ", np.nanmin(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()])) + print("max ", np.nanmax(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()])) if stg.time_cross_section[self.fileListWidget.currentRow()].shape != (0,): self.lineEdit_slider.setText( - str(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), self.slider.value()])) + str(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), self.slider.value()-1])) else: self.lineEdit_slider.setText( - str(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), self.slider.value()])) + str(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), self.slider.value()-1])) # def plot_transect_with_SNR_data(self): # if not self.lineEdit_noise_file.text(): diff --git a/View/acoustic_inversion_tab.py b/View/acoustic_inversion_tab.py index 9c599fa..df2a4a3 100644 --- a/View/acoustic_inversion_tab.py +++ b/View/acoustic_inversion_tab.py @@ -76,15 +76,23 @@ class AcousticInversionTab(QWidget): ### --- Combobox acoustic data choice + pushbutton Run Inversion --- - self.combobox_acoustic_data_choice = ComboBoxShowPopUpWindow() + self.pushbutton_update_acoustic_data_choice = QPushButton() + self.pushbutton_update_acoustic_data_choice.setIcon(self.icon_update) + self.pushbutton_update_acoustic_data_choice.setMaximumWidth(50) + self.horizontalLayout_Run_Inversion.addWidget(self.pushbutton_update_acoustic_data_choice) + + self.combobox_acoustic_data_choice = QComboBox() self.combobox_acoustic_data_choice.setMaximumWidth(300) self.horizontalLayout_Run_Inversion.addWidget(self.combobox_acoustic_data_choice) self.pushbutton_run_inversion = QPushButton() self.pushbutton_run_inversion.setText("RUN INVERSION") - self.pushbutton_run_inversion.setMaximumWidth(100) + self.pushbutton_run_inversion.setMaximumWidth(110) self.horizontalLayout_Run_Inversion.addWidget(self.pushbutton_run_inversion) + self.spacerItem_RunInversion = QSpacerItem(1000, 10)#, QSizePolicy.Expanding, QSizePolicy.Minimum) + self.horizontalLayout_Run_Inversion.addSpacerItem(self.spacerItem_RunInversion) + ### --- Layout of groupbox in the Top horizontal layout box # Plot SSC 2D field | SSC vertical profile | Plot SSC graph sample vs inversion ===>>> FINE @@ -330,7 +338,7 @@ class AcousticInversionTab(QWidget): # ---------------------------------------- Connect signal of widget -------------------------------------------- # ============================================================================================================== - self.combobox_acoustic_data_choice.ShowPopUpWindowSignal.connect(self.event_combobobx_acoustic_data_choice) + self.pushbutton_update_acoustic_data_choice.clicked.connect(self.update_acoustic_data_choice) self.pushbutton_run_inversion.clicked.connect(self.function_run_inversion) @@ -358,7 +366,7 @@ class AcousticInversionTab(QWidget): # ------------------------------------ Functions for Acoustic Inversion Tab ---------------------------------------- # ================================================================================================================== - def event_combobobx_acoustic_data_choice(self): + def update_acoustic_data_choice(self): print("(stg.filename_BS_noise_data ", (stg.filename_BS_noise_data)) self.combobox_acoustic_data_choice.clear() @@ -788,25 +796,51 @@ class AcousticInversionTab(QWidget): def slider_profile_number_to_begin_fine(self): self.slider_fine.setValue(int(self.slider_fine.minimum())) - self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + self.update_lineEdit_by_moving_slider_fine() def slider_profile_number_to_right_fine(self): self.slider_fine.setValue(int(self.slider_fine.value()) + 1) - self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + self.update_lineEdit_by_moving_slider_fine() def slider_profile_number_to_left_fine(self): self.slider_fine.setValue(int(self.slider_fine.value()) - 1) - self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + self.update_lineEdit_by_moving_slider_fine() def slider_profile_number_to_end_fine(self): self.slider_fine.setValue(int(self.slider_fine.maximum())) - self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + self.update_lineEdit_by_moving_slider_fine() def profile_number_on_lineEdit_fine(self): - self.slider_fine.setValue(int(self.lineEdit_slider_fine.text())) + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.slider_fine.setValue( + int(np.where( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]] - + float(self.lineEdit_slider_fine.text().replace(",", "."))) == + np.nanmin( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]] - + float(self.lineEdit_slider_fine.text().replace(",", ".")))))[0][0])) + else: + self.slider_fine.setValue( + int(np.where( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]] - + float(self.lineEdit_slider_fine.text().replace(",", "."))) == + np.nanmin( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]] - + float(self.lineEdit_slider_fine.text().replace(",", ".")))))[0][0])) def update_lineEdit_by_moving_slider_fine(self): - self.lineEdit_slider_fine.setText(str(self.slider_fine.value())) + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.lineEdit_slider_fine.setText( + str(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1], self.slider_fine.value()])) + else: + self.lineEdit_slider_fine.setText( + str(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1], self.slider_fine.value()])) # --- Plot fine SSC : measured vs inverted --- @@ -1229,7 +1263,7 @@ class AcousticInversionTab(QWidget): cbar_SSC_sand = self.figure_SSC_sand.colorbar(pcm_SSC_sand, ax=self.axis_SSC_sand, shrink=1, location='right') - cbar_SSC_sand.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15) + cbar_SSC_sand.set_label(label='Sand SSC (g/L', rotation=270, labelpad=15) elif stg.ABS_name[0] == "UB-SediFlow": pcm_SSC_sand = self.axis_SSC_sand.pcolormesh(stg.t[0, :], @@ -1386,25 +1420,51 @@ class AcousticInversionTab(QWidget): def slider_profile_number_to_begin_sand(self): self.slider_sand.setValue(int(self.slider_sand.minimum())) - self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + self.update_lineEdit_by_moving_slider_sand() def slider_profile_number_to_right_sand(self): self.slider_sand.setValue(int(self.slider_sand.value()) + 1) - self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + self.update_lineEdit_by_moving_slider_sand() def slider_profile_number_to_left_sand(self): self.slider_sand.setValue(int(self.slider_sand.value()) - 1) - self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + self.update_lineEdit_by_moving_slider_sand() def slider_profile_number_to_end_sand(self): self.slider_sand.setValue(int(self.slider_sand.maximum())) - self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + self.update_lineEdit_by_moving_slider_sand() def profile_number_on_lineEdit_sand(self): - self.slider_sand.setValue(int(self.lineEdit_slider_sand.text())) + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.slider_sand.setValue( + int(np.where( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]] - + float(self.lineEdit_slider_sand.text().replace(",", "."))) == + np.nanmin( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]] - + float(self.lineEdit_slider_sand.text().replace(",", ".")))))[0][0])) + else: + self.slider_sand.setValue( + int(np.where( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]] - + float(self.lineEdit_slider_sand.text().replace(",", "."))) == + np.nanmin( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1]] - + float(self.lineEdit_slider_sand.text().replace(",", ".")))))[0][0])) def update_lineEdit_by_moving_slider_sand(self): - self.lineEdit_slider_sand.setText(str(self.slider_sand.value())) + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.lineEdit_slider_sand.setText( + str(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1], self.slider_sand.value()-1])) + else: + self.lineEdit_slider_sand.setText( + str(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.frequency_for_inversion[1], self.slider_sand.value()-1])) # --- Plot sand SSC : measured vs inverted --- diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index cd2b83a..b0358f8 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -2676,23 +2676,49 @@ class SedimentCalibrationTab(QWidget): def slider_profile_number_to_begin_FCB(self): self.slider_FCB.setValue(int(self.slider_FCB.minimum())) - self.lineEdit_slider_FCB.setText(str(self.slider_FCB.value())) + self.update_lineEdit_by_moving_slider_FCB() def slider_profile_number_to_right_FCB(self): self.slider_FCB.setValue(int(self.slider_FCB.value()) + 1) - self.lineEdit_slider_FCB.setText(str(self.slider_FCB.value())) + self.update_lineEdit_by_moving_slider_FCB() def slider_profile_number_to_left_FCB(self): self.slider_FCB.setValue(int(self.slider_FCB.value()) - 1) - self.lineEdit_slider_FCB.setText(str(self.slider_FCB.value())) + self.update_lineEdit_by_moving_slider_FCB() def slider_profile_number_to_end_FCB(self): self.slider_FCB.setValue(int(self.slider_FCB.maximum())) - self.lineEdit_slider_FCB.setText(str(self.slider_FCB.value())) + self.update_lineEdit_by_moving_slider_FCB() def profile_number_on_lineEdit_FCB(self): - self.slider_FCB.setValue(int(self.lineEdit_slider_FCB.text())) + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.slider_FCB.setValue( + int(np.where( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] - + float(self.lineEdit_slider_FCB.text().replace(",", "."))) == + np.nanmin( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] - + float(self.lineEdit_slider_FCB.text().replace(",", ".")))))[0][0])) + else: + self.slider_FCB.setValue( + int(np.where( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] - + float(self.lineEdit_slider_FCB.text().replace(",", "."))) == + np.nanmin( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex()] - + float(self.lineEdit_slider_FCB.text().replace(",", ".")))))[0][0])) def update_lineEdit_by_moving_slider_FCB(self): - self.lineEdit_slider_FCB.setText(str(self.slider_FCB.value())) + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.lineEdit_slider_FCB.setText( + str(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex(), self.slider_FCB.value()-1])) + else: + self.lineEdit_slider_FCB.setText( + str(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_FCB.currentIndex(), self.slider_FCB.value()-1])) diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index 2b518b1..b0bf889 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -3005,23 +3005,44 @@ class SignalProcessingTab(QWidget): def slide_profile_number_to_begin(self): self.slider.setValue(int(self.slider.minimum())) - self.lineEdit_slider.setText(str(self.slider.value())) + self.update_lineEdit_by_moving_slider() def slide_profile_number_to_right(self): self.slider.setValue(int(self.slider.value()) + 1) - self.lineEdit_slider.setText(str(self.slider.value())) - - def profile_number_on_lineEdit(self): - self.slider.setValue(int(self.lineEdit_slider.text())) + self.update_lineEdit_by_moving_slider() def slide_profile_number_to_left(self): self.slider.setValue(int(self.slider.value()) - 1) - self.lineEdit_slider.setText(str(self.slider.value())) + self.update_lineEdit_by_moving_slider() def slide_profile_number_to_end(self): self.slider.setValue(int(self.slider.maximum())) - self.lineEdit_slider.setText(str(self.slider.value())) + self.update_lineEdit_by_moving_slider() + + def profile_number_on_lineEdit(self): + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.slider.setValue( + int(np.where( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()] - + float(self.lineEdit_slider.text().replace(",", "."))) == + np.nanmin( + np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()] - + float(self.lineEdit_slider.text().replace(",", ".")))))[0][0])) + else: + self.slider.setValue( + int(np.where( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()] - + float(self.lineEdit_slider.text().replace(",", "."))) == + np.nanmin( + np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_frequency_profile.currentIndex()] - + float(self.lineEdit_slider.text().replace(",", ".")))))[0][0])) def update_lineEdit_by_moving_slider(self): - self.lineEdit_slider.setText(str(self.slider.value())) - + if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.lineEdit_slider.setText( + str(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value()-1])) + else: + self.lineEdit_slider.setText( + str(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + self.combobox_frequency_profile.currentIndex(), self.slider.value()-1]))