mjolnir.measurements.handler#
Stateful control of optical measurements.
Todo
quantify-core might be suitable to replace this.
Notes
DAC trigger output:
# Route external trigger 1 to internal trigger 1
dac.write('OUTP:TRIG1:SOUR INT1')
# Width 1 ms
dac.write('OUTP:TRIG1:WIDT 1e-3')
# Fire internal trigger 1 (triggers external trigger 1)
dac.write('TINT:SIGN: 1')
Classes
|
Handler for measurements using the CCD. |
|
The default measurement handler, which does nothing on the side. |
|
Handler for measurements with Laser+CCD. |
|
Abstract base class for specifying measurement protocols. |
|
Handler for measurements using the APDs and Time Tagger. |
- class mjolnir.measurements.handler.CcdMeasurementHandler(station, sample_name=None, experiment='optics', measure_leakage=True, critical_leakage=1e-07, measurement_nplc=1, measurement_count=1, database_location='~/experiments.db', single_track_settings=<factory>)[source]#
Bases:
DefaultMeasurementHandlerHandler for measurements using the CCD.
- Parameters:
- add_default_measures(sweeps, measures)[source]#
Add default parameters to measure to the set measures.
sweeps.leak_measuresis kept separate to be able to act conditioned on their value.- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- abstractmethod assert_background_acquired()[source]#
This method needs to be run after all parameters (possibly in parameter contexts) are set. Hence, it cannot be included in
run_assertions().
- property ccd: AndorIDus4xx#
- get_custom_metadata(sweeps, measures)[source]#
Extract custom metadata to be saved with the measurement.
- get_default_parameter_contexts(sweeps, measures)[source]#
Default parameter values for each measurement.
- Return type:
- initialize_ccd_buffered_acquisition(n_pts, exposure_time=1.0, preamp_gain=1.0, horizontal_shift_speed=0.1, vertical_shift_speed=None, delay=0.0, **_)[source]#
Set the CCD up for buffered acquisition. Unused.
- initialize_ccd_single_acquisition(exposure_time=1.0, preamp_gain=1.0, horizontal_shift_speed=0.1, vertical_shift_speed=None, read_mode='single track', acquisition_mode='accumulate', number_accumulations=2, number_kinetics=1, accumulation_cycle_time=0.0, kinetic_cycle_time=0.0, **_)[source]#
Set the CCD up for acquisition of a single buffer.
- Parameters:
- class mjolnir.measurements.handler.DefaultMeasurementHandler(station, sample_name=None, experiment='optics', measure_leakage=True, critical_leakage=1e-07, measurement_nplc=1, measurement_count=1, database_location='~/experiments.db')[source]#
Bases:
MeasurementHandlerThe default measurement handler, which does nothing on the side.
- Parameters:
- add_default_measures(sweeps, measures)[source]#
Add default parameters to measure to the set measures.
sweeps.leak_measuresis kept separate to be able to act conditioned on their value.- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- add_default_sweeps(sweeps, measures, **default_sweeps_kwargs)[source]#
Add default sweep to the list sweeps.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- get_custom_metadata(sweeps, measures)[source]#
Extract custom metadata to be saved with the measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- get_default_parameter_contexts(sweeps, measures)[source]#
Default parameter values for each measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- run_assertions(sweeps, measures)[source]#
Assert conditions necessary for the measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- class mjolnir.measurements.handler.LaserCcdMeasurementHandler(station, sample_name=None, experiment='optics', measure_leakage=True, critical_leakage=1e-07, measurement_nplc=1, measurement_count=1, database_location='~/experiments.db', single_track_settings=<factory>)[source]#
Bases:
CcdMeasurementHandlerHandler for measurements with Laser+CCD.
- Parameters:
- add_default_measures(sweeps, measures)[source]#
Add default parameters to measure to the set measures.
sweeps.leak_measuresis kept separate to be able to act conditioned on their value.- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- assert_background_acquired()[source]#
This method needs to be run after all parameters (possibly in parameter contexts) are set. Hence, it cannot be included in
run_assertions().
- get_default_parameter_contexts(sweeps, measures)[source]#
Default parameter values for each measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- run_assertions(sweeps, measures)[source]#
Assert conditions necessary for the measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- class mjolnir.measurements.handler.MeasurementHandler(station, sample_name=None, experiment='optics', measure_leakage=True, critical_leakage=1e-07, measurement_nplc=1, measurement_count=1, database_location='~/experiments.db')[source]#
Bases:
ABCAbstract base class for specifying measurement protocols.
Subclasses override methods of this class which get run at different points during
measure()andloop(). See those methods for documentation on when they are run and what they should do.- Parameters:
station (qcodes.station.Station) – The station hosting the logical instruments that control the experiment
sample_name (str | None) – A string identifier for the sample. Defaults to the name of a
TrapSamplethat is a member ofstation, if any.experiment (qcodes.dataset.experiment_container.Experiment | str) – A qcodes experiment. Defaults to “optics”.
measure_leakage (bool) – Automatically measure the leakage current if a QDAC channel is swept.
critical_leakage (float) – Current (in Ampere) that determines a critical leakage threshold above which sweeps are aborted.
measurement_nplc (int) – The number of power line cycles (PLC) to average currents over.
measurement_count (int) – The number of current samples taken.
database_location (str) – The location of the database. Defaults to the qcodes default.
- abstractmethod add_after_run(sweeps, measures)[source]#
Default actions to run after finishing the measurement.
- abstractmethod add_before_run(sweeps, measures)[source]#
Default actions to run before starting the measurement.
- abstractmethod add_default_measures(sweeps, measures)[source]#
Add default parameters to measure to the set measures.
sweeps.leak_measuresis kept separate to be able to act conditioned on their value.- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- abstractmethod add_default_sweeps(sweeps, measures, **default_sweeps_kwargs)[source]#
Add default sweep to the list sweeps.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- abstractmethod get_custom_metadata(sweeps, measures)[source]#
Extract custom metadata to be saved with the measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- abstractmethod get_default_parameter_contexts(sweeps, measures)[source]#
Default parameter values for each measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- get_leakage_measures(sweeps)[source]#
Qdac channel leakage measures conditional on the flag.
- Parameters:
sweeps (SweepList)
- Return type:
- get_leakage_parameter_contexts(sweeps)[source]#
Parses the
SweepListto find QDAC-II current parameters.- Parameters:
sweeps (SweepList)
- Return type:
- abstractmethod initialize(**initialization_settings)[source]#
Initialize instruments for the measurement.
- leakage_limit_exceeded(params)[source]#
Measures leakage on the QDAC channels underlying params and tests if the critical limit is exceeded.
Returns the boolean and the list of leakage currents.
- loop(datasaver, params_caller_context, sweeps, measures, *, i=0, show_progress=True)[source]#
The main measurement loop.
This function recurses into sweeps, measures measures at the lowest recursion level (the innermost loop), and saves the results into datasaver.
Sweeps can specify initialization procedures as well, see
sweeps.Measures can specify a live-plotting procedure that is passed current measurement data at every point, see
measures.- Parameters:
datasaver (DataSaver)
params_caller_context (Callable[[], list[tuple[ParameterBase, str | complex | integer | floating | complexfloating | ndarray[tuple[Any, ...], dtype[_ScalarT]] | Sequence[str | complex | integer | floating | complexfloating]]]])
sweeps (SweepList)
measures (MeasureSet)
i (int)
show_progress (bool)
- measure(sweeps=None, measures=None, *, add_before_run=(), add_after_run=(), parameter_contexts=None, return_to_start=True, preallocate_results=True, cya=False, live_plot=True, show_progress=True, threaded_acquisition=True, write_in_background=True, metadata=None, default_sweeps_kwargs=None, loop_kwargs=None, initialize_plotting_kwargs=None, **initialization_settings)[source]#
The measurement entrypoint.
This function takes care of all measurement set-up, tear-down, as well as running the actual measurement loop.
- Parameters:
sweeps (SweepList | SweepProtocol | None) – A
SweepListdefining the nD sweep to execute, or a single sweep implementing theSweepProtocol. IfNone, only whatever the subclass implementation ofadd_default_sweeps()adds is used.measures (MeasureSet | Measure | ParameterBase | None) – A
MeasureSetdefining the parameters to measure at each point of the sweep, or a singleParameterBaseorMeasureto get. IfNone, only whatever the subclass implementation ofadd_default_measures()adds is used.add_before_run (Sequence[tuple[Callable[[...], Any], Sequence[Any]]]) – A sequence of two-tuples (callable, args) to run before the measurement is started.
add_after_run (Sequence[tuple[Callable[[...], Any], Sequence[Any]]]) – A sequence of two-tuples (callable, args) to run before the measurement is started.
parameter_contexts (dict[ParameterBase, Any] | None) – A mapping of
Parameterto values that the parameters should be set to for the duration of the measurement.return_to_start (bool) – Set parameters to their value before the measurement after it is done.
preallocate_results (bool) – Preallocate measurement results in the database. Should normally only be set to a different value by subclasses.
live_plot (bool) – Run the
plot_callbackhooks each time a data point is taken. Individual measures can be excluded by setting theirlive_plotattribute to False.show_progress (bool) – Show a progress bar for the outermost sweep loop.
threaded_acquisition (bool) – Use
ThreadPoolParamsCallerto acquire data asynchronously.write_in_background (bool) – Write data to the db in a background thread.
metadata (tuple[str, Any] | Any | None) – Runtime metadata either as a tuple (tag, metadata) or just metadata.
default_sweeps_kwargs (dict[Any, Any] | None) – Kwargs that are passed on to
add_default_sweeps().loop_kwargs (dict[Any, Any] | None) – Kwargs that are passed on to
loop().initialize_plotting_kwargs (dict[Any, Any] | None) – Kwargs that are passed on to
initialize_plotting().**initialization_settings – Kwargs that are passed on to
initialize().
- Returns:
The
DataSetholding the measurement.- Return type:
dataset
- abstractmethod run_assertions(sweeps, measures)[source]#
Assert conditions necessary for the measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- property sample: TrapSample#
The logical instrument representing the current sample.
- class mjolnir.measurements.handler.TimeTaggerMeasurementHandler(station, sample_name=None, experiment='optics', measure_leakage=True, critical_leakage=1e-07, measurement_nplc=1, measurement_count=1, database_location='~/experiments.db', max_duration=datetime.timedelta(days=1))[source]#
Bases:
DefaultMeasurementHandlerHandler for measurements using the APDs and Time Tagger.
Measurements executed with
measure()by default get aTimeParametersweep that simply waits for a given interval for a certain number of times. Laser wavelength and power are automatically recalibrated at each interval.- Parameters:
- add_default_measures(sweeps, measures)[source]#
Add default parameters to measure to the set measures.
sweeps.leak_measuresis kept separate to be able to act conditioned on their value.- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- add_default_sweeps(sweeps, measures, update_interval, parameter_contexts)[source]#
Add default sweep to the list sweeps.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
update_interval (float)
parameter_contexts (dict[ParameterBase, Any])
- Return type:
- static clear_tagger_measurements(measures)[source]#
Clear all TimeTagger measurements.
- Parameters:
measures (MeasureSet)
- get_default_parameter_contexts(sweeps, measures)[source]#
Default parameter values for each measurement.
- Parameters:
sweeps (SweepList)
measures (MeasureSet)
- Return type:
- loop(datasaver, params_caller_context, sweeps, measures, *, i=0, show_progress=True, add_result_on_update=False)[source]#
Custom measurement loop for Time Tagger measurements.
Measurements can be gracefully terminated by sending a keyboard interrupt.
- Parameters:
datasaver (DataSaver)
params_caller_context (Callable[[], list[tuple[ParameterBase, str | complex | integer | floating | complexfloating | ndarray[tuple[Any, ...], dtype[_ScalarT]] | Sequence[str | complex | integer | floating | complexfloating]]]])
sweeps (SweepList)
measures (MeasureSet)
i (int)
show_progress (bool)
add_result_on_update (bool)
- max_duration: timedelta = datetime.timedelta(days=1)#
The maximum duration the default sweep will run for if not interrupted.
- measure(sweeps=None, measures=None, *, add_before_run=(), add_after_run=(), parameter_contexts=None, cya=False, live_plot=True, update_interval=10.0, add_result_on_update=False, show_progress=True, threaded_acquisition=True, write_in_background=True, metadata=None, initialize_plotting_kwargs=None, **initialization_settings)[source]#
The measurement entry point.
For most parameters, see the base method.
- Parameters:
update_interval (float) – Interval in seconds to wait before getting new data from the TimeTagger API, as well as updating the live plot, if active.
add_result_on_update (bool) – Add results obtained during each update interval to the DB. If False (the default), only the last value before the measurement is finished or aborted is added.
sweeps (SweepList | SweepProtocol | None)
measures (MeasureSet | Measure | ParameterBase | None)
add_before_run (Sequence[tuple[Callable[[...], Any], Sequence[Any]]])
add_after_run (Sequence[tuple[Callable[[...], Any], Sequence[Any]]])
parameter_contexts (dict[ParameterBase, Any] | None)
cya (bool)
live_plot (bool)
show_progress (bool)
threaded_acquisition (bool)
write_in_background (bool)
- Return type:
- register_tagger_measurements(measures)[source]#
Register a TimeTagger measurement with the
TimeTaggerSynchronizedMeasurementsobject to synchronize measurements.- Parameters:
measures (MeasureSet)
- property tagger: TimeTagger#
- unregister_tagger_measurements(measures)[source]#
Unregister TimeTagger measurements.
- Parameters:
measures (MeasureSet)