diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 32724d7..2b2be51 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -2314,83 +2314,41 @@ class AcousticDataTab(QWidget): ''' rmin and rmax are updated with double slider of depth ''' data_id = self.fileListWidget.currentRow() - stg.rmin[data_id] = (( - np.where( - np.abs( - np.round( - stg.depth[data_id][0, :], 2 - ) - float( - "".join( - findall( - "[.0-9]", - self.lineEdit_depth_max_limits.text() - ) - ) - ) - ) == np.nanmin( - np.abs( - np.round(stg.depth[data_id][0, :], 2) - - float( - "".join( - findall( - "[.0-9]", - self.lineEdit_depth_max_limits.text() - ) - ) - ) - ) - ) - )[0][0]+1, - float( - "".join( - findall( - "[.0-9]", - self.lineEdit_depth_max_limits.text() - ) + round_depth = np.round(stg.depth[data_id][0, :], 2) + depth_max = float( + "".join( + findall( + "[.0-9]", + self.lineEdit_depth_max_limits.text() ) ) + ) + depth_min = float( + "".join( + findall( + "[.0-9]", + self.lineEdit_depth_min_limits.text() + ) + ) + ) + + diff_max = np.abs(round_depth - depth_max) + diff_min = np.abs(round_depth - depth_min) + + stg.rmin[data_id] = (( + np.where(diff_max == np.nanmin(diff_max))[0][0]+1, + depth_max )) stg.rmax[data_id] = (( - np.where( - np.abs( - np.round( - stg.depth[data_id][0, :], 2 - ) - float( - "".join( - findall( - "[.0-9]", - self.lineEdit_depth_min_limits.text() - ) - ) - ) - ) == np.nanmin( - np.abs( - np.round(stg.depth[data_id][0, :], 2) - - float( - "".join( - findall( - "[.0-9]", - self.lineEdit_depth_min_limits.text() - ) - ) - ) - ) - ) - )[0][0], - float( - "".join( - findall( - "[.0-9]", - self.lineEdit_depth_min_limits.text() - ) - ) - ) + np.where(diff_min == np.nanmin(diff_min))[0][0], + depth_min )) stg.depth_cross_section[data_id] = ( - stg.depth[data_id][:, - stg.rmin[data_id][0]:stg.rmax[data_id][0]] + stg.depth[data_id][ + :, stg.rmin[data_id][0]:stg.rmax[data_id][0] + ] ) def compute_BS_cross_section(self):