diff --git a/ETA.py b/ETA.py index f580f7e..9bd2774 100644 --- a/ETA.py +++ b/ETA.py @@ -442,7 +442,7 @@ else: if verbose: print( 'main ETA curved' ) - if not cache_file.exists(): + if not cache_file.exists() and not no_cache: if verbose: print( 'writing result in cache' ) with shelve.open( str( cache_file ) ) as cache: diff --git a/utils.py b/utils.py index d3f7ead..5162430 100644 --- a/utils.py +++ b/utils.py @@ -276,3 +276,16 @@ def retrieve_peaks( data , window_size = 5 , error_coef = 1.05 , max_window_size peaks = new_peaks window_size += 1 return peaks +def near_value( list_ , value ): + """ + return indexes of the list whith a value nearest of the given + one when crossing it + """ + change = np.where( np.diff( np.sign( list_ - value ) ) != 0 ) # sign change + index = change + ( + value - list_[ change ] + ) / ( + list_[ change + np.ones_like( change ) ] - list_[ change ] + ) # interpolation + index = np.append( index , np.where( list_ == value ) ) + return np.round( np.sort( index ) ).astype( int ) # triage