layer-groupUsing the experiment queue

We recommend using the queue for long-running experiments that require no interaction.

The queue works like a compute cluster: you submit an experiment protocol, the chamber runs it when ready, and it uploads the data to a server for you to download.

circle-info

We store your experimental data for the entire duration of your contract.

Basic workflow

The API is very similar to that of the real-time experiments. You can find a complete example below.

1

Connect to the Remote Lab

First, open a connection to the remote lab (see also Quickstart)

import causalchamber.lab as lab

rlab = lab.Lab(credentials_file = 'path/to/file')
2

Create a new experiment protocol

Then, start a new protocol by specifying which chamber (chamber_id) and hardware configuration (config) you want it to run on

experiment = rlab.new_experiment(chamber_id, config)
3

Add instructions

Add instructions to the experiment protocol

experiment.set(target, value)

This sets the variable target to the given value, returning when the change has been made in the hardware. The above call returns None.

See the configuration docs for a list of variables and their valid / default values.

You can check which instructions are already in the protocol by calling experiment.instructions. Calling experiment.clear() will remove all instructions.

circle-info

You can also generate instructions directly from a pandas dataframe (see below).

4

Submit your experiment

Once you are ready, submit the experiment to the chamber's queue with

experiment.submit(tag='optional-tag')

This will return a experiment_id that uniquely identifies your experiment in the system.

To help you keep track of your experiments, you can also add an optional tag parameter with a string of your choice (alphanumeric characters and +-_:).

Monitoring your experiments

You can check on all your current and past experiments with

rlab.get_experiments(print_max=10) # 0 for no print, None to print all

Output

You can also query the details (incl. status) for an individual experiment with

Checking your position in the queue

You can check the position of your experiments in the queue by calling

Output

Cancelling a queued experiment

You can cancel an experiment before it runs (status = QUEUED ) by calling

Cancelling experiments that are already running will be available in a later version. For now, if you need to cancel a running experiment, please contact us at [email protected]envelope or through any of the support channels provided during onboarding.

Downloading the data

Once an experiment is finished (status=DONE), you can download the data by calling

where root specifies the directory where you want to store the data. Then, load the data into the desired format

A complete example

Let's submit an experiment to visualize the effect of Malus' law of polarizationarrow-up-right in the Light Tunnel Mk2. You can learn more about this effect in Appendix IV.2.1arrow-up-right of the original chambers paperarrow-up-right.

For our experiment, we will keep the light source fixed at a constant brightness and take measurements for random polarizer positions.

You can monitor the experiment with rlab.get_experiments() and load the measurements into a pandas dataframe once it's done.

Now we can plot the light intensity after both polarizers vs. their relative angle (see ir_3, pol_1, pol_2 in the configuration docsarrow-up-right). For comparison, we show the prediction from Malus' lawarrow-up-right in red.

Generating instructions from a pandas dataframe

To make things easier when creating experiments, you can also generate instructions from a pandas dataframe by calling experiment.from_df(...)arrow-up-right . For example, the above experiment can be rewritten as

You can find more details about how the function works (e.g., to customize the number of measurements per row) in its docstringarrow-up-right.

Last updated