diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index 970241c..fd5a9a0 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -1509,13 +1509,35 @@ class SedimentCalibrationTab(QWidget): self.ax_Mfine.plot(stg.M_profile_fine, -stg.range_lin_interp, marker="*", mfc="b", mec="b", ms=8, ls="None") + def interpolate_data_validity_message_box(self): + msgBox = QMessageBox() + msgBox.setWindowTitle("Interpolate (step 2)") + msgBox.setIconPixmap( + QPixmap( + self._path_icon("no_approved.png") + ) + .scaledToHeight(32, Qt.SmoothTransformation) + ) + msgBox.setText( + "Please select and valid the sample data with" + + "click on 'sample plot' button" + ) + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() + + def interpolate_Mfine_profile(self): - data_choice = self.combobox_acoustic_data_choice.currentIndex() + # Variable 'stg.sand_sample_target_indice' is set only at + # 'plot sample' button click + if len(stg.sand_sample_target_indice) == 0: + self.interpolate_data_validity_message_box() + return + + data_choice = self.combobox_acoustic_data_choice\ + .currentIndex() if stg.depth_cross_section[data_choice].shape != (0,): - range_cells = stg.depth_cross_section[data_choice][ - self.combobox_freq2.currentIndex(), : - ] + depth_data = stg.depth_cross_section if stg.time_cross_section[data_choice].shape != (0,): time_data = stg.time_cross_section @@ -1523,17 +1545,31 @@ class SedimentCalibrationTab(QWidget): time_data = stg.time else: - range_cells=stg.depth[data_choice][ - self.combobox_freq2.currentIndex(), : - ] + depth_data = stg.depth if stg.time_cross_section[data_choice].shape != (0,): time_data = stg.time_cross_sectino else: time_data = stg.time - sample_depth = [-stg.depth_fine[k[1]] for k in stg.fine_sample_profile] - M_profile = [stg.Ctot_fine[k[1]] for k in stg.fine_sample_profile] + self.interpolate_Mfine_profile_compute( + data_choice, depth_data, time_data + ) + + def interpolate_Mfine_profile_compute(self, data_choice, depth_data, time_data): + range_cells=depth_data[data_choice][ + self.combobox_freq2.currentIndex(), : + ] + + sample_depth = [ + -stg.depth_fine[k[1]] + for k in stg.fine_sample_profile + ] + + M_profile = [ + stg.Ctot_fine[k[1]] + for k in stg.fine_sample_profile + ] r_bottom = stg.depth_bottom[data_choice][ np.where( @@ -1546,7 +1582,7 @@ class SedimentCalibrationTab(QWidget): np.abs( time_data[data_choice][ self.combobox_freq2.currentIndex(), : - ] + ] - stg.time_fine[stg.fine_sample_profile[-1][1]]) ) )[0][0] @@ -1571,7 +1607,9 @@ class SedimentCalibrationTab(QWidget): stg.range_lin_interp = stg.range_lin_interp stg.M_profile_fine = stg.M_profile_fine - stg.M_profile_fine = stg.M_profile_fine[:stg.range_lin_interp.shape[0]] + stg.M_profile_fine = stg.M_profile_fine[ + :stg.range_lin_interp.shape[0] + ] self.plot_profile_of_concentration_fine()