From 06f09ef07eb68d9745f030cee2fefee7b1ec2d4b Mon Sep 17 00:00:00 2001 From: Mathias Sander Date: Fri, 22 Aug 2025 22:52:03 +0200 Subject: [PATCH] am --- eco/acquisition/scan.py | 18 ++++++++++++++++-- eco/utilities/utilities.py | 3 +-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/eco/acquisition/scan.py b/eco/acquisition/scan.py index e145e3c..651d5a2 100755 --- a/eco/acquisition/scan.py +++ b/eco/acquisition/scan.py @@ -10,7 +10,7 @@ from pathlib import Path import colorama from eco.elements.protocols import Adjustable -from eco.utilities.utilities import NumpyEncoder, foo_get_kwargs +from eco.utilities.utilities import NumpyEncoder, foo_get_kwargs, linlog_intervals from ..elements.adjustable import AdjustableMemory, DummyAdjustable from IPython import get_ipython from .daq_client import Daq @@ -1067,12 +1067,24 @@ class RunFilenameGenerator: def interpret_step_specification(spec): + """Create a list of step positions from a specification. + + Args: + spec (tuple/list): interable of different format: + - 3 numbers: start, end, N_intervals or interval size (int or float) + - 1 iterable of positions + - anchor positions with linear or logarithmic filled spaces. + i.e. odd number of elements, where every second element is an iterable ('lin',), interpreted as lin-log intervals + + Returns: + array: array of positions + """ # normal linear scan if len(spec) == 3 and all(isinstance(ta, Number) for ta in spec): start_pos, end_pos, N_intervals = spec if type(N_intervals) is float: print("Interval size defined as float, interpreting as interval size.") - positions = np.arange(start_pos, N_intervals, end_pos) + positions = np.arange(start_pos, end_pos+N_intervals, N_intervals) elif type(N_intervals) is int: print("Interval size defined as int, interpreting as number of intervals.") positions = np.linspace(start_pos, end_pos, N_intervals + 1) @@ -1084,6 +1096,8 @@ def interpret_step_specification(spec): ) positions = spec[0] return positions + elif len(spec)%2 and all([np.iterable(ts) for ts in spec[1::2]]): + return linlog_intervals(*spec) else: raise Exception( "Step position specification is not understood, should be 3 numbers or a list of positions." diff --git a/eco/utilities/utilities.py b/eco/utilities/utilities.py index aeb8fc2..f09bac3 100644 --- a/eco/utilities/utilities.py +++ b/eco/utilities/utilities.py @@ -179,8 +179,7 @@ def linlog_intervals(*args, verbose=True, plot=False): intlog = np.log10(tlims[0]+idef[1])-np.log10(tlims[0]) a.append(10**np.arange(np.log10(tlims[0]),np.log10(tlims[1]),intlog)) if verbose: - intervals = np.diff(np.log10(a[-1])) - + intervals = np.diff(a[-1]) print(f'From {tlims[0]:5g} to {a[-1][-1]:5g}: {len(a[-1])-1} logarithmic intervals between {np.min(intervals):5g} and {np.max(intervals):5g} in sizes.') if plot: plt.plot(np.arange(len(np.hstack(a))-len(a[-1]), len(np.hstack(a))),a[-1],'or',mfc='none')