Experiments subpackage

An experiment is what a user (i.e., a scientist) wants to perform in order to record data. This requires as a minimum a setup to connect to. Usually, it involves as well a kind of display presenting the data during recording, and one or several saver to store the obtained data in a persistent manner. The base class for experiments is eprcontrol.experiments.Experiment. Every experiment should inherit from this class.

To test the interplay with other classes, eprcontrol.experiments.DummyExperiment can be used. This class creates a set of testdata that get copied row-wise into the data attribute, mimicking a real experiment.

General usage

The eprcontrol.experiments.Experiment class is the heart of the eprcontrol toolbox. A general usage may look like the following:

experiment = eprcontrol.experiments.Experiment;
experiment.run()

Of course, in a real setting one would like to connect an instance of eprcontrol.displays.Display to present the data during their recording, as well as a list of different saver as instances of class eprcontrol.saver.Saver.

Classes

class eprcontrol.experiments.DummyExperiment

Bases: eprcontrol.experiments.Experiment

Dummy experiment to test display components and alike.

This “experiment” simply creates a set of two-dimensional testdata and copies the testdata row-wise to the data, waiting in between for a given time delay_time.

number_of_rows

y dimension of the (test)data

default: 300

Type

scalar

add_noise

add noise to the (test)data?

For creating noise, the rand() function is used.

default: true

Type

Boolean

noise_amplitude

noise amplitude relative to the amplitude of the (test)data

Amplitudes are peak-to-peak amplitudes

default: 0.1

Type

scalar

delay_time

How long (in s) to wait between “recording” adjacent traces

default: 0.05

Type

scalar

Example

To run the experiment, simply use these lines:

experiment = eprcontrol.experiments.DummyExperiment()
experiment.run()
create_testdata()

Create testdata using peaks() function

As peaks() always returns a quadratic matrix, testdata gets reshaped to have 5000 columns (i.e., points in x direction).

class eprcontrol.experiments.Experiment

Bases: handle

Base class for an experiment.

Each experiment has a setup, i.e. an object of class eprcontrol.setups.Setup, as well as a list of savers, each of class eprcontrol.saver.Saver.

kind

kind of experiment, e.g. “TREPR experiment”

Type

string

parameters

parameters specific to the actual experiment

Type

struct

setup

setup used to perform the experiment

Type

eprcontrol.setups.Setup

settings

parameters for different components of the setup used for the experiment.

The dict needs to be organised according to the general names of the components on its first level, e.g., “digitizer”, …

These settings will be automatically applied to the corresponding components.

Type

dict

saver

list of classes of type eprcontrol.saver.Saver

Type

cell array

data

actual data obtained during the experiment

This property is set observable, hence issuing the “PostSet” event after each change. Thus, you can create listeners listening to this event, e.g., classes of type eprcontrol.displays.Display used to display the data obtained during the experiment.

Type

matrix

Note

The difference between the parameters and settings structs is that parameters are the variables of the experiment itself (e.g., field range for an EPR experiment), and the settings refer to the parameters applied to the settup and its underlying components (e.g., channel settings for the digitizer).

run()

Run an experiment

This method will connect to the setup, set the respective parameters and afterwards run the experiment. In any case, even if the user hits Ctrl + C, the experiment will leave the setup in a clean and disconnected state and save the data obtained so far.

Note

A note to developers: The method run() cannot be changed in derived classes. All details for running the experiment should hence go into the protected method run_experiment().

set_properties(parameters)

Assign values to properties

If the “parameters” structure contains a field that corresponds to a property of the class, set this property to the corresponding value of the struct.

In case of the property being an object, this object will be tested for having a “set_properties” method itself and in this case, this method will be called with the respective value of the struct (that may in those cases be a struct itself). Thus, cascaded setting of properties is possible.

Parameters

parameters (struct) – Structure with fields (keys) corresponding to the properties of the class. Only those properties will be set.

Note

This functionality will eventually perhaps allow to create derived classes for concrete types of components by simply defining their properties in a configuration file.

class eprcontrol.experiments.TreprExperiment

Bases: eprcontrol.experiments.Experiment

TREPR experiment yielding 2D data (B_0, time)

parameters

parameters necessary to run the experiment

A complete struct may look like the following:

parameters = struct( ...
    'magnetic_field', struct( ...
        'start', 3410, ...
        'step', 1, ...
        'end', 3510 ...
    ) ...
);
Type

struct

settings

parameters for components of the setup used for the experiment

A complete struct may look like the following:

settings = struct( ...
    'digitizer', struct( ...
        'accumulations', 20 ...
    ) ...
);
Type

struct

wait_for_field

initial delay to wait for magnetic field to settle

Time in seconds

Type

scalar

current_field

current magnetic field position

Magnetic field value in G

Type

scalar

magnetic_field_axis

values of the magnetic field axis

Type

vector

time_axis

values of the time axis

Type

vector