Skip to content
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

Feature/Measurement loop #4074

Open
wants to merge 167 commits into
base: main
Choose a base branch
from

Conversation

nulinspiratie
Copy link
Contributor

@nulinspiratie nulinspiratie commented Apr 4, 2022

This pull request introduces a new way of doing measurements, called the MeasurementLoop, that sits somewhere in between the current Measurement class and the do1d/do2d/dond functions. The key idea of this measurement scheme is to offer flexibility in measurements while having as much as possible be implicit.

The MeasurementLoop introduced here is ported from the UNSW fork Measurement class.

Although the basic functionality is working, this PR is still very much a work in progress, but I thought of starting the PR now. Is this something that could fit into QCoDeS?
Tagging @jenshnielsen @WilliamHPNielsen @RasmusBC59

Features

  • Implicit setpoints using Sweep class
  • Implicit registering of measurements the first time a parameter is measured
  • Allows execution of arbitrary python code in measurements
  • Masking of parameters/attributes within a loop/measurement
  • Sweep/measure values without needing it to be a parameter
  • Allows nested measurements.
    Nested measurements recognize that they are nested and attach themselves to the parent measurement.
    This enables functions that perform a measurement. If the function is called within a measurement, it becomes part of the larger measurement

Limitations

  • Currently incompatible with measurements without a predefined array shape (e.g. keep measuring until X).
    This can be implemented.

Illustrative example

from qcodes import ManualParameter
from qcodes.utils.dataset.doNd import LinSweep
from qcodes.dataset.measurement_loop import MeasurementLoop, Sweep

# Initialize parameters
# Note that we do not need to register them in the measurement
p1_set = ManualParameter('outer_sweep_parameter')
p2_set = ManualParameter('inner_sweep_parameter')
p1_get = ManualParameter('parameter_get')
p_sum_above_ten = ManualParameter('sum_above_ten')

with MeasurementLoop('test') as msmt:
   # We encapsulate the LinSweep in a Sweep
   # This registers the sweep as being a setpoint for everything measured inside
   # This sweep also automatically sets the parameter
   for val1 in Sweep(LinSweep(p1_set, 0, 1, 11)):
      for val2 in Sweep(LinSweep(p2_set, 0, 1, 11)):
         p1_get(val1+val2)
         
         # Measuring this parameter automatically recognizes that it is inside
         # a 2D loop and automatically attaches those setpoints
         # Note that we also here don't need to preregister p1_get
         msmt.measure(p1_get)
      
      # Also include measurement outside inner loop
      p_sum_above_ten(p1_get() > 10)
      msmt.measure(p_sum_above_ten)

To do items

  • convert notebook imports to public API
  • Populate __all__ of measurement_loop.py
  • Sweep should inherit from Abstract sweep
  • Add args to Sweep.execute()
  • add type hints to args and variables
  • Write docstring for functions

Additions in future PR's

  • Save arrays
  • Add handling of ArrayParameter
  • Save complex results
  • Add plot functionality to sweep.execute
  • add progress bar to Measurement loop
  • Add metadata to MeasurementLoop

Tests to add

  • Use Sweep in dond
  • Pass args to sweep.execute
  • Pass LinSweep to MeasurementLoop

nulinspiratie and others added 29 commits February 25, 2022 10:01
@jenshnielsen
Copy link
Collaborator

@nulinspiratie Thanks a lot, I am super busy this week but I promise to get back to this ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants