Device classes

Cameras

A Camera can be set via the device-specific properties that can be set and read with Parameter.set() and Parameter.get(). Moreover, a camera provides means to

Camera triggering is specified by the trigger_source parameter, which can be one of

  • camera.trigger_sources.AUTO means the camera triggers itself automatically, the frames start being recorded right after the start_recording() call and stop being recorded by stop_recording()

  • Camera.trigger_sources.SOFTWARE means the camera needs to be triggered by the user by trigger(). This way you have complete programatic control over when is the camera triggered, example usage:

    camera.trigger_source = camera.trigger_sources.SOFTWARE
    start_recording(camera)
    trigger(camera)
    long_operation()
    # Here we get the frame from before the long operation
    grab(camera)
    
  • Camera.trigger_sources.EXTERNAL is a source when the camera is triggered by an external low-level signal (such as TTL). This source provides very precise triggering in terms of time synchronization with other devices

To setup and use a camera in a typical environment, you would do:

import numpy as np
from concert.devices.cameras.uca import Camera

camera = Camera('pco')
camera.trigger_source = camera.trigger_sources.SOFTWARE
camera.exposure_time = 0.2 * q.s
start_recording(camera)
trigger(camera)
data = grab(camera)
stop_recording(camera)

print("mean=%f, stddev=%f" % (np.mean(data), np.std(data)))

You can apply primitive operations to the frames obtained by Camera.grab() by setting up a Camera.convert attribute to some callable which takes just one argument which is the grabbed frame. The callable is applied to the frame and the converted one is returned by Camera.grab(). You can do:

import numpy as np
from concert.devices.cameras.dummy import Camera

camera = Camera()
camera.convert = np.fliplr
# The frame is left-right flipped
grab(camera)
class concert.devices.cameras.base.BufferedMixin(self)

Bases: concert.devices.base.Device

A camera that stores the frames in an internal buffer

class concert.devices.cameras.base.Camera(self)

Bases: concert.devices.base.Device

Base class for remotely controllable cameras.

frame-rate

Frame rate of acquisition in q.count per time unit.

await grab()

Return a NumPy array with data of the current frame.

async with recording()

A context manager for starting and stopping the camera.

In general it is used with the async with keyword like this:

async with camera.recording():
    frame = await camera.grab()
await start_recording()

Start recording frames.

await stop_recording()

Stop recording frames.

async for ... in stream()

Grab frames continuously yield them. This is an async generator.

await trigger()

Trigger a frame if possible.

exception concert.devices.cameras.base.CameraError

Bases: Exception

Camera specific errors.

class concert.devices.cameras.uca.Camera(self, name, params=None)

libuca-based camera.

All properties that are exported by the underlying camera are also visible.

await __ainit__(name, params=None)

Create a new libuca camera.

The name is passed to the uca plugin manager.

Raises

CameraError – In case camera name does not exist.

await grab(index=None)

Return a NumPy array with data of the current frame.

write(name, data)

Write NumPy array data for name.

class concert.devices.cameras.pco.Pco(self)

Pco camera implemented by libuca.

await __ainit__()

Create a new libuca camera.

The name is passed to the uca plugin manager.

Raises

CameraError – In case camera name does not exist.

async for ... in stream()

Grab frames continuously yield them. This is an async generator.

class concert.devices.cameras.pco.Dimax(self)

A pco.dimax camera implementation.

await start_recording()

Start recording frames.

class concert.devices.cameras.pco.PCO4000(self)

PCO.4000 camera implementation.

await __ainit__()

Create a new libuca camera.

The name is passed to the uca plugin manager.

Raises

CameraError – In case camera name does not exist.

await start_recording()

Start recording frames.

await stop_recording()

Stop recording frames.

class concert.devices.cameras.dummy.Camera(self, background=None, simulate=True)

A simple dummy camera.

await __ainit__(background=None, simulate=True)

background can be an array-like that will be used to generate the frame when calling grab. If simulate is True the final image intensity will be scaled based on exposure time and poisson noise will be added. If simulate is False, the background will be returned with no modifications to it.

Grippers

A gripper can grip and release objects.

class concert.devices.grippers.base.Gripper(self)

Bases: concert.devices.base.Device

Base gripper class.

await grip()

Grip an object.

await release()

Release an object.

I/O

class concert.devices.io.base.Signal(self)

Bases: concert.devices.base.Device

Base device for binary signals, e.g. TTL trigger signals and similar.

await off()

Switch the signal off.

await on()

Switch the signal on.

await trigger(duration=10 * q.ms)

Generate a trigger signal of duration.

class concert.devices.io.base.IO(self)

Bases: concert.devices.base.Device

The IO device consists of ports which can be readable, writable or both.

property ports

Port IDs used by read_port() and write_port()

await read_port(port)

Read a port.

await write_port(port, value)

Write a value to the port.

class concert.devices.io.dummy.IO(self, port_value=0)

Dummy I/O device implementation.

Lightsources

class concert.devices.lightsources.base.LightSource(self)

Bases: concert.devices.base.Device

A base LightSource class.

class concert.devices.lightsources.dummy.LightSource(self)

A dummy light source

Monochromators

class concert.devices.monochromators.base.Monochromator(self)

Bases: concert.devices.base.Device

Monochromator device which is used to filter the beam in order to get a very narrow energy bandwidth.

energy

Monochromatic energy in electron volts.

wavelength

Monochromatic wavelength in meters.

class concert.devices.monochromators.doublemonochromator.Monochromator(self, motor_2)

Bases: concert.devices.monochromators.base.Monochromator

Base implementation of a monochromator with the ability to scan a second crystal/multilayer.

await __ainit__(motor_2)
Parameters

motor_2 (concert.devices.motors.base.RotationMotor) – Motor controlling the tilt of the second crystal or multilayer

get_last_tune_scan()

Shows a plot of the last tuning scan.

await scan_bragg_angle(diode, plot_callback=None, n_points=50, tune_range=<Quantity(0.025, 'degree')>, center_point=None)

Scans the second crystal or multilayer. After the scan, the motor is moved back to its initial position.

A scan can be shown afterwards with show_tune_scan(). To move the motor to the

maximum call select_maximum() and to go to the center of mass select_center_of_mass().

Parameters
  • diode (concert.devices.photodiodes.base.Diode) – Diode to measure the intensity

  • plot_callback – Function to plot the scanned intensity. Could be an instance of a PyplotViewer. If set to None the values of the scan are returned.

  • n_points (int) – Number of points, equally distributed between the current_angle - tune_range/2 and current_angle + tube_range/2

  • tune_range (q.deg) – Range to scan for maximum.

  • center_point (q.deg) – central point around which the scan is performed. If set to None the current position of the scanning motor is used.

await select_center_of_mass()

Moves bragg2 to the center of mass of the last tuning scan.

await select_maximum()

Moves bragg2 to the maximum of the last tuning scan.

class concert.devices.monochromators.dummy.Monochromator(self)

Monochromator class implementation.

class concert.devices.monochromators.dummy.DoubleMonochromator(self)

Double monochromator implementation

await __ainit__()
Parameters

motor_2 (concert.devices.motors.base.RotationMotor) – Motor controlling the tilt of the second crystal or multilayer

Motors

Linear

Linear motors are characterized by moving along a straight line.

class concert.devices.motors.base.LinearMotor(self)

Bases: concert.devices.motors.base._PositionMixin

One-dimensional linear motor.

position

Position of the motor in length units.

class concert.devices.motors.base.ContinuousLinearMotor(self)

Bases: concert.devices.motors.base.LinearMotor, concert.devices.motors.base._VelocityMixin

One-dimensional linear motor with adjustable velocity.

velocity

Current velocity in length per time unit.

class concert.devices.motors.dummy.LinearMotor(self, position=None, upper_hard_limit=None, lower_hard_limit=None)

A linear step motor dummy.

class concert.devices.motors.dummy.ContinuousLinearMotor(self, position=None, upper_hard_limit=None, lower_hard_limit=None)

A continuous linear motor dummy.

Rotational

Rotational motors are characterized by rotating around an axis.

class concert.devices.motors.base.RotationMotor(self)

Bases: concert.devices.motors.base._PositionMixin

One-dimensional rotational motor.

position

Position of the motor in angular units.

class concert.devices.motors.base.ContinuousRotationMotor(self)

Bases: concert.devices.motors.base.RotationMotor, concert.devices.motors.base._VelocityMixin

One-dimensional rotational motor with adjustable velocity.

velocity

Current velocity in angle per time unit.

class concert.devices.motors.dummy.RotationMotor(self, upper_hard_limit=None, lower_hard_limit=None)

A rotational step motor dummy.

class concert.devices.motors.dummy.ContinuousRotationMotor(self, position=None, upper_hard_limit=None, lower_hard_limit=None)

A continuous rotational step motor dummy.

Axes

An axis is a coordinate system axis which can realize either translation or rotation, depending by which type of motor it is realized.

class concert.devices.positioners.base.Axis(self, coordinate, motor, direction=1, position=None)

Bases: concert.base.AsyncObject

An axis represents a Euclidean axis along which one can translate or around which one can rotate. The axis coordinate is a string representing the Euclidean axis, i.e. ‘x’ or ‘y’ or ‘z’. Movement is realized by a motor. An additional position argument is necessary for calculatin more complicated motion types, e.g. rotation around arbitrary point in space. It is the local position with respect to a concert.devices.positioners.base.Positioner in which it is placed.

await get_position()

Get position asynchronously with respect to axis direction.

await set_position(position)

Set the position asynchronously with respect to axis direction.

Photodiodes

Photodiodes measure light intensity.

class concert.devices.photodiodes.base.PhotoDiode(self)

Bases: concert.devices.base.Device

Impementation of photo diode with V output signal

class concert.devices.photodiodes.dummy.PhotoDiode(self)

A dummy photo diode

Positioners

Positioner is a device consisting of more concert.devices.positioners.base.Axis instances which make it possible to specify a 3D position and orientation of some object.

class concert.devices.positioners.base.Positioner(self, axes, position=None)

Bases: concert.devices.base.Device

Combines more motors which move to form a complex motion. axes is a list of Axis instances. position is a 3D vector of coordinates specifying the global position of the positioner.

If a certain coordinate in the positioner is missing, then when we set the position or orientation we can specify the respective vector position to be zero or numpy.nan.

await back(value)

Move back by value.

await down(value)

Move down by value.

await forward(value)

Move forward by value.

await left(value)

Move left by value.

await move(position)

Move by specified position.

await right(value)

Move right by value.

await rotate(angles)

Rotate by angles.

await up(value)

Move up by value.

class concert.devices.positioners.dummy.Positioner(self, position=None)

A dummy positioner.

Imaging Positioners

Imaging positioner is a positioner capable of moving in x and y directions by the given amount of pixels.

class concert.devices.positioners.imaging.Positioner(self, axes, detector, position=None)

Bases: concert.devices.positioners.base.Positioner

A positioner which takes into account a detector with some pixel size. This way the user can specify the movement in pixels.

await move(position)

Move by specified position which can be given in meters or pixels.

class concert.devices.positioners.dummy.ImagingPositioner(self, detector=None, position=None)

A dummy imaging positioner.

Pumps

class concert.devices.pumps.base.Pump(self)

Bases: concert.devices.base.Device

A pumping device.

await start()

Start pumping.

await stop()

Stop pumping.

class concert.devices.pumps.dummy.Pump(self)

A dummy pump.

Sample changers

class concert.devices.samplechangers.base.SampleChanger(self)

Bases: concert.devices.base.Device

A device that moves samples in and out from the sample holder.

Scales

class concert.devices.scales.base.Scales(self)

Bases: concert.devices.base.Device

Base scales class.

class concert.devices.scales.base.TarableScales(self)

Bases: concert.devices.scales.base.Scales

Scales which can be tared.

await tare()

Tare the scales.

class concert.devices.scales.dummy.Scales(self)

A dummy scale.

Shutters

class concert.devices.shutters.base.Shutter(self)

Bases: concert.devices.base.Device

Shutter device class implementation.

await close()

Close the shutter.

await open()

Open the shutter.

class concert.devices.shutters.dummy.Shutter(self)

A dummy shutter that can be opened and closed.

Storage rings

class concert.devices.storagerings.base.StorageRing(self)

Bases: concert.devices.base.Device

Read-only access to storage ring information.

current

Ring current

energy

Ring energy

lifetime

Ring lifetime in hours

class concert.devices.storagerings.dummy.StorageRing(self)

A storage ring dummy.

X-ray tubes

class concert.devices.xraytubes.base.XRayTube(self)

Bases: concert.devices.base.Device

A base x-ray tube class.

await off()

Disables the x-ray tube.

await on()

Enables the x-ray tube.