Skip to content
Snippets Groups Projects
Commit 833b2e09 authored by Sander de Snoo's avatar Sander de Snoo
Browse files

Added update_snapshot() to MeasurementParameter to allow custom snapshot data

parent 6f3eca7b
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,7 @@ def iq_mode2func(iq_mode): ...@@ -6,7 +6,7 @@ def iq_mode2func(iq_mode):
list[Tuple[str, func[np.array]->np.array], str] list[Tuple[str, func[np.array]->np.array], str]
''' '''
func_map = { func_map = {
'Complex': [('', lambda x:x, 'mV')], 'Complex': [('', None, 'mV')],
'I': [('', np.real, 'mV')], 'I': [('', np.real, 'mV')],
'Q': [('', np.imag, 'mV')], 'Q': [('', np.imag, 'mV')],
'amplitude': [('', np.abs, 'mV')], 'amplitude': [('', np.abs, 'mV')],
......
from collections.abc import Sequence
from dataclasses import dataclass, field from dataclasses import dataclass, field
from typing import Tuple, List from typing import Any, Dict, List, Optional, Tuple
from numbers import Number from numbers import Number
import logging import logging
import numpy as np import numpy as np
...@@ -89,6 +90,10 @@ class MeasurementParameter(MultiParameter): ...@@ -89,6 +90,10 @@ class MeasurementParameter(MultiParameter):
self._mc = mc self._mc = mc
self._data_selection = data_selection self._data_selection = data_selection
self._derived_params = {} self._derived_params = {}
self._snapshot_extra = {}
def update_snapshot(self, snapshot_extra: Dict[str, Any]):
self._snapshot_extra.update(snapshot_extra)
def add_derived_param(self, name, func, label=None, unit='mV', def add_derived_param(self, name, func, label=None, unit='mV',
time_trace=False, time_trace=False,
...@@ -236,6 +241,14 @@ class MeasurementParameter(MultiParameter): ...@@ -236,6 +241,14 @@ class MeasurementParameter(MultiParameter):
return data return data
def snapshot_base(self,
update: Optional[bool] = True,
params_to_skip_update: Optional[Sequence[str]] = None
) -> Dict[Any, Any]:
snapshot = super().snapshot_base(update, params_to_skip_update)
snapshot.update(self._snapshot_extra)
return snapshot
class MeasurementConverter: class MeasurementConverter:
ALLOWED_RELATIVE_THRESHOLD_DEVIATION = 0.01 ALLOWED_RELATIVE_THRESHOLD_DEVIATION = 0.01
...@@ -489,7 +502,10 @@ class MeasurementConverter: ...@@ -489,7 +502,10 @@ class MeasurementConverter:
else: else:
funcs = iq_mode2func(selection.iq_mode) funcs = iq_mode2func(selection.iq_mode)
for _, func, _ in funcs: for _, func, _ in funcs:
data.append(func(raw)) if func is not None:
data.append(func(raw))
else:
data.append(raw)
if selection.states: if selection.states:
data += self._states data += self._states
if selection.values: if selection.values:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment