From cb46917101b6c2c79df9b45646e1ced34249b589 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Tue, 22 Apr 2025 15:54:23 +0200 Subject: [PATCH] Sediment calibration: Refacto 'compute_depth_2D' and add to 'full_update'. --- View/sediment_calibration_tab.py | 86 +++++++++++--------------------- 1 file changed, 30 insertions(+), 56 deletions(-) diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index f268ebc..76e158a 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -874,6 +874,7 @@ class SedimentCalibrationTab(QWidget): self._update_calibration() self.function_pushbutton_plot_sample() + self.compute_depth_2D() self.compute_kt2D_kt3D() self.compute_J_cross_section() @@ -1802,67 +1803,40 @@ class SedimentCalibrationTab(QWidget): self.compute_J_cross_section() def compute_depth_2D(self): - if self.combobox_acoustic_data_choice.count() > 0: - for k in range(self.combobox_acoustic_data_choice.count()): - while len(stg.depth_2D) <= k: - stg.depth_2D.append(np.array([])) + freq = self.combobox_freq1.currentIndex() - if stg.depth_cross_section[k].shape != (0,): - if stg.time_cross_section[k].shape != (0,): - stg.depth_2D[k] = ( - np.zeros((stg.freq[k].shape[0], - stg.depth_cross_section[k].shape[1], - stg.time_cross_section[k].shape[1]))) + for k in range(self.combobox_acoustic_data_choice.count()): + while len(stg.depth_2D) <= k: + stg.depth_2D.append(np.array([])) - for f, _ in enumerate(stg.freq[k]): - stg.depth_2D[k][f, :, :] = ( - np.repeat(np.transpose(stg.depth_cross_section[k] - [self.combobox_freq1.currentIndex()])[:, np.newaxis], - stg.time_cross_section[k].shape[1], - axis=1)) + if stg.depth_cross_section[k].shape != (0,): + depth_data = stg.depth_cross_section + elif stg.depth[k].shape != (0,): + depth_data = stg.depth - elif stg.time[k].shape != (0,): - stg.depth_2D[k] = ( - np.zeros((stg.freq[k].shape[0], - stg.depth_cross_section[k].shape[1], - stg.time[k].shape[1]))) + if stg.time_cross_section[k].shape != (0,): + time_data = stg.time_cross_section + elif stg.time[k].shape != (0,): + time_data = stg.time - for f, _ in enumerate(stg.freq[k]): - stg.depth_2D[k][f, :, :] = ( - np.repeat( - np.transpose(stg.depth_cross_section[k] - [self.combobox_freq1.currentIndex()])[:, np.newaxis], - stg.time[k].shape[1], - axis=1)) + stg.depth_2D[k] = ( + np.zeros(( + stg.freq[k].shape[0], + depth_data[k].shape[1], + time_data[k].shape[1] + )) + ) - elif stg.depth[k].shape != (0,): - if stg.time_cross_section[k].shape != (0,): - stg.depth_2D[k] = ( - np.zeros((stg.freq[k].shape[0], - stg.depth[k].shape[1], - stg.time_cross_section[k].shape[1]))) - - for f, _ in enumerate(stg.freq[k]): - stg.depth_2D[k][f, :, :] = ( - np.repeat( - np.transpose(stg.depth[k] - [self.combobox_freq1.currentIndex()])[:, np.newaxis], - stg.time_cross_section[k].shape[1], - axis=1)) - - elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.depth_2D[k] = ( - np.zeros((stg.freq[k].shape[0], - stg.depth[k].shape[1], - stg.time[k].shape[1]))) - - for f, _ in enumerate(stg.freq[k]): - stg.depth_2D[k][f, :, :] = ( - np.repeat( - np.transpose(stg.depth[k] - [self.combobox_freq1.currentIndex()])[:, np.newaxis], - stg.time[k].shape[1], - axis=1)) + for f, _ in enumerate(stg.freq[k]): + stg.depth_2D[k][f, :, :] = ( + np.repeat( + np.transpose( + depth_data[k][freq] + )[:, np.newaxis], + time_data[k].shape[1], + axis=1 + ) + ) def function_pushbutton_compute_calibration(self):