experimentor.lib package

Submodules

experimentor.lib.actuator module

actuator.py

Actuators are all the devices able to modify the experiment. For example a piezo stage is an actuator. The properties of the actuators are read-only; in principle one cannot change the port at which a specific sensor is plugged without re-generating the object. The actuator has a property called value, that can be accessed directly like so:

`python prop = {'name': 'Actuator 1'} a = Actuator(prop) a.value = Q_('1nm') print(a.value) `

Bear in mind that setting the value of an actuator triggers a communication with a real device. You have to be careful if there is something connected to it.

class experimentor.lib.actuator.Actuator(properties)[source]

Bases: object

device
make_ramp(ramp_properties)[source]

Sets the actuator to make a ramp if it is in its capabilities. Properties established all the properties that are needed for the ramp.

properties
value

The value of the device.

experimentor.lib.device module

device.py

Devices are connected to the computer. They control sensors and actuators. A device has to be able to set and read values. Setting complex devices such as a laser would require to define it as a device and its properties as sensors or actuators respectively.

Warning

If problems arise when adding new devices, tt is important to check :meth:initialize_driver . It was hardcoded which parameters are passed when initializing each device type.

Todo

Make flexible parameters when initializing the driver of the devices.

Section author: Aquiles Carattino

class experimentor.lib.device.Device(properties)[source]

Bases: object

Device is responsible for the communication with real devices. Device takes only one argument, a dictionary of properties, including the driver. Device has two properties, one called _properties that stores the initial properties passed to the device and is read-only. _params stores the parameters passed during execution; it doesn’t store a history, just the latest one.

add_driver(driver)[source]

Adds the driver of the device. It has to be initialized() :param driver: driver of any class. :return: Null

apply_value(actuator, value)[source]

Applies a given value to an actuator through the driver of the device. It is only a relay function left here to keep the hierarchical structure of the program, i.e. actuators communicate with devices, devices communicate with models and models with drivers.

Parameters:
  • actuator – instance of Actuator
  • value – A value to be set. Ideally a Quantity.
apply_values(values)[source]

Iterates over all values of a dictionary and sets the values of the driver to it. It is kept for legacy support but it is very important to switch to apply_value, passing an actuator.

Warning

This method can misbehave with the new standards of sensors and actuators in place since version 0.1.

Parameters:values – a dictionary of parameters and desired values for those parameters. The parameters should have units.
initialize_driver()[source]

Initializes the driver. There are 4 types of possible connections:

  • GPIB
  • USB
  • serial
  • daq

The first 3 are based on Lantz and its initialization routine, while daq was inherited from previous code and has a different initialization routine.

params
properties
read_value(sensor)[source]

Reads a value from a sensor. This method is just a relay to a model, in order to keep the structure of the program tidy.

experimentor.lib.fitgaussian module

experimentor.lib.fitgaussian.fitgaussian(data)[source]

Returns (height, x, y, width_x, width_y) the gaussian parameters of a 2D distribution found by a fit

experimentor.lib.fitgaussian.gaussian(height, center_x, center_y, width_x, width_y)[source]

Returns a gaussian function with the given parameters

experimentor.lib.fitgaussian.moments(data)[source]

Returns (height, x, y, width_x, width_y) the gaussian parameters of a 2D distribution by calculating its moments

experimentor.lib.log module

Logging Options

Standardizing logging options for experimentor.

copyright:Aquiles Carattino
license:MIT, see LICENSE for more details
experimentor.lib.log.get_logger(name='experimentor', level=10)[source]
experimentor.lib.log.get_mp_logger(level=10)[source]
experimentor.lib.log.log_to_file(filename, level=20, fmt=None)[source]
experimentor.lib.log.log_to_screen(logger, level=20, fmt=None)[source]

experimentor.lib.recursive_attributes module

Functions to get and set attributes of nested objects. These functions allow to do things like:

>>> rgetattr(obj, 'sub1.sub2.attr')

Taken from: https://stackoverflow.com/a/31174427/4467480

experimentor.lib.recursive_attributes.rgetattr(obj, attr, *args)[source]

Recursive get attribute of objects.

experimentor.lib.recursive_attributes.rsetattr(obj, attr, val)[source]

Iteratively gets attributes of objects until the last level and then sets its value.

experimentor.lib.sensor module

Sensor

Sensors are all the devices able to get a value from the experiment. For example a thermocouple is a sensor. The properties of the sensor are read-only; in principle one cannot change the port at which a specific sensor is plugged without re-generating the object.

Section author: Aquiles Carattino

class experimentor.lib.sensor.Sensor(properties)[source]

Bases: object

add_device(device)[source]

Adds the driver to the current sensor. In this context a driver is a class able to read the value from the device.

properties
value

Module contents