From c637066b4d3fd783cc9d9fb1ec6d01892c7a96fe Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Thu, 17 Nov 2022 18:35:37 +0100 Subject: [PATCH] handle scan values conversion inside Spreadsheet.add() --- slic/core/acquisition/spreadsheet.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/slic/core/acquisition/spreadsheet.py b/slic/core/acquisition/spreadsheet.py index 2bb22b9d..22fc049b 100644 --- a/slic/core/acquisition/spreadsheet.py +++ b/slic/core/acquisition/spreadsheet.py @@ -1,4 +1,5 @@ from functools import wraps +import numpy as np from stand.client import Client from slic.utils import typename @@ -33,17 +34,29 @@ class Spreadsheet: @printed_errors - def add(self, run, filename, n_pulses, scanned_adjs="", **kwargs): + def add(self, run, filename, n_pulses, scanned_adjs=None, scan_values=None, **kwargs): fixed = dict(run=run, filename=filename, n_pulses=n_pulses) - if scanned_adjs: + scan_info = {} + + if scanned_adjs is not None: scanned_adjs = [a.name for a in scanned_adjs] - scanned_adjs = " ".join(scanned_adjs) + scanned_adjs = ", ".join(scanned_adjs) + scan_info.update(scanned_adjs=scanned_adjs) + + if scan_values is not None: + vals = np.asarray(scan_values) + v_min = tuple(vals.min(axis=0)) + v_max = tuple(vals.max(axis=0)) + if len(v_min) == 1: v_min = v_min[0] + if len(v_max) == 1: v_max = v_max[0] + n_steps = len(vals) + scan_info.update(v_min=v_min, v_max=v_max, n_steps=n_steps) placeholders = {n: "" for n in self.placeholders} entries = self.get_adjs_values() - resp = self.client.add_row(**fixed, **placeholders, adjustables=scanned_adjs, **kwargs, **entries) + resp = self.client.add_row(**fixed, **placeholders, **scan_info, **kwargs, **entries) print(resp)