Skip to content

add function do2d_retrace #5780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 11, 2024
1 change: 1 addition & 0 deletions docs/changes/newsfragments/5780.new
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a do2d_retrace function
148 changes: 148 additions & 0 deletions src/qcodes/dataset/dond/do2d_retrace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
from __future__ import annotations

Check warning on line 1 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L1

Added line #L1 was not covered by tests

import logging
from collections.abc import Sequence
from typing import TYPE_CHECKING
from opentelemetry import trace

Check warning on line 6 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L3-L6

Added lines #L3 - L6 were not covered by tests

from qcodes import config
from qcodes.dataset.experiment_container import Experiment

Check warning on line 9 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L8-L9

Added lines #L8 - L9 were not covered by tests

from qcodes.dataset import (

Check warning on line 11 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L11

Added line #L11 was not covered by tests
DataSetDefinition,
LinSweeper,
datasaver_builder,
dond_into,
LinSweep,
)
from qcodes.parameters import ParameterBase

Check warning on line 18 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L18

Added line #L18 was not covered by tests

LOG = logging.getLogger(__name__)
TRACER = trace.get_tracer(__name__)

Check warning on line 21 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L20-L21

Added lines #L20 - L21 were not covered by tests


if TYPE_CHECKING:
from qcodes.dataset.descriptions.versioning.rundescribertypes import Shapes
from qcodes.dataset.dond.do_nd_utils import ActionsT
from qcodes.dataset.data_set_protocol import DataSetProtocol


@TRACER.start_as_current_span("qcodes.dataset.do2d")
def do2d_retrace(

Check warning on line 31 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L30-L31

Added lines #L30 - L31 were not covered by tests
param_set1: ParameterBase,
start1: float,
stop1: float,
num_points1: int,
delay1: float,
param_set2: ParameterBase,
start2: float,
stop2: float,
num_points2: int,
delay2: float,
*param_meas: ParameterBase,
enter_actions: ActionsT = (),
exit_actions: ActionsT = (),
before_inner_actions: ActionsT = (),
after_inner_actions: ActionsT = (),
measurement_name: str = "",
exp: Experiment | None = None,
additional_setpoints: Sequence[ParameterBase] = tuple(),
show_progress: bool | None = None,
) -> tuple[DataSetProtocol, DataSetProtocol]:
"""
Perform a 1D scan of ``param_set1`` from ``start1`` to ``stop1`` in
``num_points1`` and ``param_set2`` from ``start2`` to ``stop2`` in
``num_points2`` measuring param_meas at each step.

Args:
param_set1: The QCoDeS parameter to sweep over in the outer loop
start1: Starting point of sweep in outer loop
stop1: End point of sweep in the outer loop
num_points1: Number of points to measure in the outer loop
delay1: Delay after setting parameter in the outer loop
param_set2: The QCoDeS parameter to sweep over in the inner loop
start2: Starting point of sweep in inner loop
stop2: End point of sweep in the inner loop
num_points2: Number of points to measure in the inner loop
delay2: Delay after setting parameter before measurement is performed
param_meas: Parameter(s) to measure at each step or functions that
will be called at each step. The function should take no arguments.
The parameters and functions are called in the order they are
supplied.
enter_actions: A list of functions taking no arguments that will be
called before the measurements start
exit_actions: A list of functions taking no arguments that will be
called after the measurements ends
before_inner_actions: Actions executed before each run of the inner loop
after_inner_actions: Actions executed after each run of the inner loop
measurement_name: Name of the measurement. This will be passed down to
the dataset produced by the measurement. If not given, a default
value of 'results' is used for the dataset.
exp: The experiment to use for this measurement.
additional_setpoints: A list of setpoint parameters to be registered in
the measurement but not scanned.
show_progress: should a progress bar be displayed during the
measurement. If None the setting will be read from ``qcodesrc.json``

Returns:
The QCoDeS dataset.
"""

if show_progress is None:
show_progress = config.dataset.dond_show_progress

Check warning on line 92 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L91-L92

Added lines #L91 - L92 were not covered by tests

dataset_definition = [

Check warning on line 94 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L94

Added line #L94 was not covered by tests
DataSetDefinition(
name=measurement_name,
independent=[param_set1, param_set2],
dependent=param_meas,
experiment=exp,
),
DataSetDefinition(
name=f"retrace {measurement_name}",
independent=[param_set1, param_set2],
dependent=param_meas,
experiment=exp,
),
]

with datasaver_builder(dataset_definition) as datasavers:
for action in enter_actions:
action()
for _ in LinSweeper(param_set1, start1, stop1, num_points1, delay1):
sweep_up = LinSweep(

Check warning on line 113 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L109-L113

Added lines #L109 - L113 were not covered by tests
param_set2,
start2,
stop2,
num_points2,
delay2,
post_actions=after_inner_actions,
)
sweep_down = LinSweep(

Check warning on line 121 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L121

Added line #L121 was not covered by tests
param_set2,
stop2,
start2,
num_points2,
delay2,
post_actions=after_inner_actions,
)
for action in before_inner_actions:
action()
dond_into(

Check warning on line 131 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L129-L131

Added lines #L129 - L131 were not covered by tests
datasavers[0],
sweep_up,
*param_meas,
additional_setpoints=additional_setpoints,
)
for action in before_inner_actions:
action()
dond_into(

Check warning on line 139 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L137-L139

Added lines #L137 - L139 were not covered by tests
datasavers[1],
sweep_down,
*param_meas,
additional_setpoints=additional_setpoints,
)
for action in exit_actions:
action()
datasets = (datasavers[0].dataset, datasavers[1].dataset)
return datasets

Check warning on line 148 in src/qcodes/dataset/dond/do2d_retrace.py

View check run for this annotation

Codecov / codecov/patch

src/qcodes/dataset/dond/do2d_retrace.py#L145-L148

Added lines #L145 - L148 were not covered by tests
Loading