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

Add scan arguments to snapshot

parent 833b2e09
No related branches found
No related tags found
No related merge requests found
from collections.abc import Sequence
from typing import Any, Dict, Optional
from qcodes import MultiParameter from qcodes import MultiParameter
import numpy as np import numpy as np
...@@ -144,10 +146,30 @@ def fast_scan1D_param(pulse_lib, gate, swing, n_pt, t_step, ...@@ -144,10 +146,30 @@ def fast_scan1D_param(pulse_lib, gate, swing, n_pt, t_step,
logger.info('Upload') logger.info('Upload')
my_seq.upload() my_seq.upload()
parameters = dict(
gate=gate,
swing=dict(label="swing", value=swing, unit="mV"),
n_pt=n_pt,
t_measure=dict(label="t_measure", value=t_step, unit="ns"),
biasT_corr=biasT_corr,
iq_mode=iq_mode,
acquisition_delay=dict(
label="acquisition_delay",
value=acquisition_delay_ns,
unit="ns"),
enabled_markers=enabled_markers,
pulse_gates={
name: dict(label=name, value=value, unit="mV")
for name, value in pulse_gates
},
line_margin=line_margin,
)
return _scan_parameter(pulse_lib, my_seq, t_step, return _scan_parameter(pulse_lib, my_seq, t_step,
(n_pt, ), (gate, ), (tuple(voltages_sp), ), (n_pt, ), (gate, ), (tuple(voltages_sp), ),
biasT_corr, channel_map=channel_map, biasT_corr, channel_map=channel_map,
reload_seq=reload_seq) reload_seq=reload_seq,
snapshot_extra={"parameters": parameters})
def fast_scan2D_param(pulse_lib, gate1, swing1, n_pt1, gate2, swing2, n_pt2, t_step, def fast_scan2D_param(pulse_lib, gate1, swing1, n_pt1, gate2, swing2, n_pt2, t_step,
...@@ -309,10 +331,33 @@ def fast_scan2D_param(pulse_lib, gate1, swing1, n_pt1, gate2, swing2, n_pt2, t_s ...@@ -309,10 +331,33 @@ def fast_scan2D_param(pulse_lib, gate1, swing1, n_pt1, gate2, swing2, n_pt2, t_s
logger.info('Seq upload') logger.info('Seq upload')
my_seq.upload() my_seq.upload()
parameters = dict(
gate1=gate1,
swing1=dict(label="swing1", value=swing1, unit="mV"),
n_pt1=n_pt1,
gate2=gate2,
swing2=dict(label="swing2", value=swing2, unit="mV"),
n_pt2=n_pt2,
t_measure=dict(label="t_measure", value=t_step, unit="ns"),
biasT_corr=biasT_corr,
iq_mode=iq_mode,
acquisition_delay=dict(
label="acquisition_delay",
value=acquisition_delay_ns,
unit="ns"),
enabled_markers=enabled_markers,
pulse_gates={
name: dict(label=name, value=value, unit="mV")
for name, value in pulse_gates
},
line_margin=line_margin,
)
return _scan_parameter(pulse_lib, my_seq, t_step, return _scan_parameter(pulse_lib, my_seq, t_step,
(n_pt2, n_pt1), (gate2, gate1), (n_pt2, n_pt1), (gate2, gate1),
(tuple(voltages2_sp), (tuple(voltages1_sp),)*n_pt2), (tuple(voltages2_sp), (tuple(voltages1_sp),)*n_pt2),
biasT_corr, channel_map, reload_seq=reload_seq) biasT_corr, channel_map, reload_seq=reload_seq,
snapshot_extra={"parameters": parameters})
def _get_channels(pulse_lib, channel_map, channels, iq_mode, iq_complex): def _get_channels(pulse_lib, channel_map, channels, iq_mode, iq_complex):
...@@ -339,7 +384,7 @@ def _get_channels(pulse_lib, channel_map, channels, iq_mode, iq_complex): ...@@ -339,7 +384,7 @@ def _get_channels(pulse_lib, channel_map, channels, iq_mode, iq_complex):
for postfix, func, unit in ch_funcs: for postfix, func, unit in ch_funcs:
channel_map[name+postfix] = (name, func, unit) channel_map[name+postfix] = (name, func, unit)
else: else:
channel_map[name] = (name, lambda x:x, 'mV') channel_map[name] = (name, None, 'mV')
return acq_channels, channel_map return acq_channels, channel_map
...@@ -349,7 +394,7 @@ class _scan_parameter(MultiParameter): ...@@ -349,7 +394,7 @@ class _scan_parameter(MultiParameter):
generator for the parameter f generator for the parameter f
""" """
def __init__(self, pulse_lib, my_seq, t_measure, shape, names, setpoint, def __init__(self, pulse_lib, my_seq, t_measure, shape, names, setpoint,
biasT_corr, channel_map, reload_seq): biasT_corr, channel_map, reload_seq, snapshot_extra):
""" """
args: args:
pulse_lib (pulselib): pulse library object pulse_lib (pulselib): pulse library object
...@@ -365,6 +410,7 @@ class _scan_parameter(MultiParameter): ...@@ -365,6 +410,7 @@ class _scan_parameter(MultiParameter):
reload_seq (bool): reload_seq (bool):
If True the sequence is uploaded for every scan. If True the sequence is uploaded for every scan.
This gives makes the scan a bit slower, but allows to sweep all pulse-lib settings. This gives makes the scan a bit slower, but allows to sweep all pulse-lib settings.
snapshot_extra (dict<str, any>): snapshot
""" """
self.my_seq = my_seq self.my_seq = my_seq
self.pulse_lib = pulse_lib self.pulse_lib = pulse_lib
...@@ -378,6 +424,16 @@ class _scan_parameter(MultiParameter): ...@@ -378,6 +424,16 @@ class _scan_parameter(MultiParameter):
units = tuple(unit for _, _, unit in channel_map.values()) units = tuple(unit for _, _, unit in channel_map.values())
n_out_ch = len(self.channel_names) n_out_ch = len(self.channel_names)
channel_map_snapshot = {}
for name, mapping in channel_map.items():
channel_map_snapshot[name] = {
"channel": mapping[0],
"func": getattr(mapping[1], "__name__", str(mapping[1])),
"unit": mapping[2],
}
snapshot_extra["parameters"]["channel_map"] = channel_map_snapshot
self._snapshot_extra = snapshot_extra
super().__init__( super().__init__(
name='fastScan', name='fastScan',
names=self.channel_names, names=self.channel_names,
...@@ -406,7 +462,10 @@ class _scan_parameter(MultiParameter): ...@@ -406,7 +462,10 @@ class _scan_parameter(MultiParameter):
for ch, func, _ in self.channel_map.values(): for ch, func, _ in self.channel_map.values():
# channel data already is in mV # channel data already is in mV
ch_data = raw_dict[ch] ch_data = raw_dict[ch]
data.append(func(ch_data)) if func is not None:
data.append(func(ch_data))
else:
data.append(ch_data)
# make sure that data is put in the right order. # make sure that data is put in the right order.
data_out = [np.zeros(self.shape, dtype=d.dtype) for d in data] data_out = [np.zeros(self.shape, dtype=d.dtype) for d in data]
...@@ -422,6 +481,14 @@ class _scan_parameter(MultiParameter): ...@@ -422,6 +481,14 @@ class _scan_parameter(MultiParameter):
return tuple(data_out) return tuple(data_out)
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
def stop(self): def stop(self):
if not self.my_seq is None and not self.pulse_lib is None: if not self.my_seq is None and not self.pulse_lib is None:
logger.info('stop: release memory') logger.info('stop: release memory')
......
...@@ -76,6 +76,15 @@ def read_channels(pulselib, t_measure, channels=None, sample_rate=None, iq_mode= ...@@ -76,6 +76,15 @@ def read_channels(pulselib, t_measure, channels=None, sample_rate=None, iq_mode=
sequence.set_acquisition(sample_rate=sample_rate) sequence.set_acquisition(sample_rate=sample_rate)
param = sequence.get_measurement_param(upload='auto', iq_mode=iq_mode) param = sequence.get_measurement_param(upload='auto', iq_mode=iq_mode)
parameters = dict(
t_measure=dict(label="t_measure", value=t_measure, unit="ns"),
iq_mode=iq_mode,
)
if sample_rate is not None:
parameters['sample_rate'] = dict(label="sample_rate", value=sample_rate, unit="Sa/s")
param.update_snapshot(snapshot_extra={"parameters": parameters})
return param return param
...@@ -138,4 +147,16 @@ def scan_resonator_frequency( ...@@ -138,4 +147,16 @@ def scan_resonator_frequency(
) )
param = sequence.get_measurement_param(upload='auto', iq_mode=iq_mode) param = sequence.get_measurement_param(upload='auto', iq_mode=iq_mode)
parameters = dict(
t_measure=dict(label="t_measure", value=t_measure, unit="ns"),
f_start=dict(label="f_start", value=f_start, unit="Hz"),
f_stop=dict(label="f_stop", value=f_stop, unit="Hz"),
f_step=dict(label="f_step", value=f_step, unit="Hz"),
iq_mode=iq_mode,
)
if average_repetitions:
parameters['average_repetitions'] = average_repetitions
parameters['n_rep'] = n_rep
param.update_snapshot(snapshot_extra={"parameters": parameters})
return param return param
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