Skip to content

Commit

Permalink
Merge #4759 #4770 #4779
Browse files Browse the repository at this point in the history
4759: Add ability to get parameter after set to dond r=jenshnielsen a=jenshnielsen

For some instruments it may be a good idea to get the value after setting it and store that in the dataset rather than relying on the instrument being able to set the exact value. 

This implements that by extending the Sweeps classes with a boolean. This could be extended to read a flag from the parameter giving the parameter a trait to indicate if it has been set


This is also a small step towards fixing #4695 since it will become possible to get the value of a parameter that one sets

To make this easier to demonstrate ManualParameters have been improved to log using the instrument logger

TODO 
- [x] Documentation (examples + docstrings)
- [x] Tests
- [x] release notes

4770: Add text-wrapping for extra-long plot titles r=jenshnielsen a=samantha-ho

This PR text-wraps long plot titles.

4779: Keithley calibration: adjust calibration date before saving new calibration r=astafan8 a=michieldemoor

When running the calibrate_keithley_smu_v method to calibrate a Keithley SMU, as documented [here](https://qcodes.github.io/Qcodes/examples/driver_examples/Qcodes%20example%20with%20Keithley%202600.html#Recalibration), the calibration gives the following error:

ERROR CODE: 5029

SMU A: Cannot save without changing cal adjustment date

SMU B: Cannot save without changing cal adjustment date

This PR addresses this error by changing the calibration adjustment date before saving the new calibration.

Co-authored-by: Jens H. Nielsen <Jens.Nielsen@microsoft.com>
Co-authored-by: Samantha Ho <samanthaho@microsoft.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: mdemoor <mdemoor@microsoft.com>
Co-authored-by: Mikhail Astafev <astafan8@gmail.com>
  • Loading branch information
6 people committed Oct 31, 2022
4 parents b7b65c1 + f57eadb + 4e2e254 + 5ca4325 commit 7efd78b
Show file tree
Hide file tree
Showing 11 changed files with 799 additions and 2,907 deletions.
2 changes: 2 additions & 0 deletions docs/changes/newsfragments/4759.improved
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The sweeps used by doNd has gained the ability to perform a get call after setting the parameter and storing
that value in the dataset rather than the value set.
1 change: 1 addition & 0 deletions docs/changes/newsfragments/4779.improved
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Keithley calibration: adjust calibration date before saving new calibration

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions qcodes/calibrations/keithley.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ def setup_dmm(dmm: Instrument) -> None:


def save_calibration(smu: Keithley_2600) -> None:
calibration_date = int(time.time())
for smu_channel in smu.channels:
smu.write(f"{smu_channel.channel}.cal.adjustdate = {calibration_date}")
smu.write(f"{smu_channel.channel}.cal.save()")


Expand Down
7 changes: 6 additions & 1 deletion qcodes/dataset/dond/do_nd.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ParameterSetEvent:
should_set: bool
delay: float
actions: ActionsT
get_after_set: bool


class _Sweeper:
Expand Down Expand Up @@ -228,6 +229,7 @@ def __getitem__(self, index: int) -> tuple[ParameterSetEvent, ...]:
should_set=should_set,
delay=sweep.delay,
actions=sweep.post_actions,
get_after_set=sweep.get_after_set,
)
parameter_set_events.append(event)
return tuple(parameter_set_events)
Expand Down Expand Up @@ -708,7 +710,10 @@ def dond(
act()
time.sleep(set_event.delay)

results[set_event.parameter] = set_event.new_value
if set_event.get_after_set:
results[set_event.parameter] = set_event.parameter()
else:
results[set_event.parameter] = set_event.new_value

meas_value_pair = call_params_meas()
for meas_param, value in meas_value_pair:
Expand Down
39 changes: 38 additions & 1 deletion qcodes/dataset/dond/sweeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ def post_actions(self) -> ActionsT:
"""
pass

@property
def get_after_set(self) -> bool:
"""
Should we perform a call to get on the parameter after setting it
and store that rather than the setpoint value in the dataset?
This defaults to False for backwards compatibility
but subclasses should overwrite this to implement if correctly.
"""
return False


class LinSweep(AbstractSweep[np.float64]):
"""
Expand All @@ -67,7 +78,10 @@ class LinSweep(AbstractSweep[np.float64]):
start: Sweep start value.
stop: Sweep end value.
num_points: Number of sweep points.
delay: Time in seconds between two consecutive sweep points
delay: Time in seconds between two consecutive sweep points.
post_actions: Actions to do after each sweep point.
get_after_set: Should we perform a get on the parameter after setting it
and store the value returned by get rather than the set value in the dataset.
"""

def __init__(
Expand All @@ -78,13 +92,15 @@ def __init__(
num_points: int,
delay: float = 0,
post_actions: ActionsT = (),
get_after_set: bool = False,
):
self._param = param
self._start = start
self._stop = stop
self._num_points = num_points
self._delay = delay
self._post_actions = post_actions
self._get_after_set = get_after_set

def get_setpoints(self) -> npt.NDArray[np.float64]:
"""
Expand All @@ -109,6 +125,10 @@ def num_points(self) -> int:
def post_actions(self) -> ActionsT:
return self._post_actions

@property
def get_after_set(self) -> bool:
return self._get_after_set


class LogSweep(AbstractSweep[np.float64]):
"""
Expand All @@ -120,6 +140,9 @@ class LogSweep(AbstractSweep[np.float64]):
stop: Sweep end value.
num_points: Number of sweep points.
delay: Time in seconds between two consecutive sweep points.
post_actions: Actions to do after each sweep point.
get_after_set: Should we perform a get on the parameter after setting it
and store the value returned by get rather than the set value in the dataset.
"""

def __init__(
Expand All @@ -130,13 +153,15 @@ def __init__(
num_points: int,
delay: float = 0,
post_actions: ActionsT = (),
get_after_set: bool = False,
):
self._param = param
self._start = start
self._stop = stop
self._num_points = num_points
self._delay = delay
self._post_actions = post_actions
self._get_after_set = get_after_set

def get_setpoints(self) -> npt.NDArray[np.float64]:
"""
Expand All @@ -161,6 +186,10 @@ def num_points(self) -> int:
def post_actions(self) -> ActionsT:
return self._post_actions

@property
def get_after_set(self) -> bool:
return self._get_after_set


class ArraySweep(AbstractSweep, Generic[T]):
"""
Expand All @@ -171,6 +200,8 @@ class ArraySweep(AbstractSweep, Generic[T]):
array: array with values to sweep.
delay: Time in seconds between two consecutive sweep points.
post_actions: Actions to do after each sweep point.
get_after_set: Should we perform a get on the parameter after setting it
and store the value returned by get rather than the set value in the dataset.
"""

def __init__(
Expand All @@ -179,11 +210,13 @@ def __init__(
array: Sequence[Any] | npt.NDArray[T],
delay: float = 0,
post_actions: ActionsT = (),
get_after_set: bool = False,
):
self._param = param
self._array = np.array(array)
self._delay = delay
self._post_actions = post_actions
self._get_after_set = get_after_set

def get_setpoints(self) -> npt.NDArray[T]:
return self._array
Expand All @@ -204,6 +237,10 @@ def num_points(self) -> int:
def post_actions(self) -> ActionsT:
return self._post_actions

@property
def get_after_set(self) -> bool:
return self._get_after_set


class TogetherSweep:
"""
Expand Down

0 comments on commit 7efd78b

Please sign in to comment.