From e75bdddab3d90b737e24843f2d8b1fde2f8c16a4 Mon Sep 17 00:00:00 2001 From: linarphy Date: Fri, 25 Aug 2023 17:25:33 +0200 Subject: [PATCH] Update find_point - Update default theshold - Update how it works --- function/utils.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/function/utils.py b/function/utils.py index 56b6c9f..59828db 100644 --- a/function/utils.py +++ b/function/utils.py @@ -65,7 +65,7 @@ def point( index_1 , index_2 , axis = 'x' ): return [ index_2 , index_1 ] return [ index_1 , index_2 ] -def find_point( list_ , index , axis = 'x' , threshold = 0.5 ): +def find_point( list_ , index , axis = 'x' , threshold = 0.95 ): """ find the index where to fill in a side """ @@ -80,22 +80,21 @@ def find_point( list_ , index , axis = 'x' , threshold = 0.5 ): if not isinstance( threshold , float ): raise ValueError( 'threshold must be a float, ' + type( threshold ) + ' given' ) - mean = np.mean( list_ ) ampl = np.max( list_ ) - np.min( list_ ) - if ampl < mean / 2: + if ampl < np.mean( list_ ) / 2: return [ point( index , 0 , axis ) ] else: points = [] - list_ = np.convolve( list_ , np.ones( 100 ) , 'same' ) + list_ = list_.copy() list_ -= np.min( list_ ) list_ /= np.max( list_ ) i , inside , size = 0 , False , 0 while i < len( list_ ): if list_[ i ] > threshold and not inside: - points.append( point( index , i , axis ) ) + points.append( point( index , i, axis ) ) inside = True size = 0 elif list_[ i ] < threshold and inside: