contrast.motors package¶
Module contents¶
Provides the Motor base class and derived motor classes.
Does not automatically load hardware-specific submodules or classes as these might have special dependencies that aren’t available everywhere.
Submodules¶
contrast.motors.Motor module¶
- class contrast.motors.Motor.Motor(scaling=1.0, offset=0.0, dial_limits=(None, None), user_format='%.2f', dial_format='%.2f', **kwargs)[source]¶
Bases:
GadgetGeneral base class for motors.
Motors have dial and user positions, which are related by an offset and a scaling factor. The user position is supposed to be used in all macros and movements. The dial position is hard coded in the Motor subclass to closely reflect what the underlying device quotes.
user = dial * scaling + offset, dial = (user - offset) / scaling
The user position can be changed, which updates the offset but not the scaling. In the same way, limits on the user position are internally converted to dial limits, such that setting the user position leaves the dial limits unchanged.
- Parameters:
scaling – Scaling factor from dial to user position
offset – Offset from scaled dial to user position
dial_limits – Motor limits in dial positions
user_format – Format string for presenting user positions
dial_format – Format string for presenting dial positions
**kwargs – Passed on to base class constructor
- property dial_position¶
Override this property, which sets or gets the dial position.
- Return type:
float
- class contrast.motors.Motor.DummyMotor(velocity=None, dial_position=None, *args, **kwargs)[source]¶
Bases:
MotorDummy motor which can be harmlessly moved with a velocity of 1 / s.
- class contrast.motors.Motor.MotorBookmark(name, motors, positions=None)[source]¶
Bases:
objectA bookmark is a set of motor dial positions which together have some significance, for example a sample position or an attenuetor combination.
- Parameters:
name – Name given to the MotorBookmark
motors (list, tuple) – The motor instances to bookmark.
positions (list, tuple) – List of positions to bookmark.
- class contrast.motors.Motor.MotorMemorizer(filepath=None, **kwargs)[source]¶
Bases:
GadgetSaves or loads motor scaling, offsets, and limits, as well as any defined bookmarks to or from file.
- Parameters:
filepath (str) – Path to file where motor information will be dumped
**kwargs – Passed on to the base class
- class contrast.motors.Motor.Mv(*args)[source]¶
Bases:
objectThis class generates the macro `mv`
Move one or more motors.
mvr <motor1> <position1> <motor2> <position2> ...
- class contrast.motors.Motor.Mvd[source]¶
Bases:
objectThis class generates the macro `mvd`
Move one or more motors to an abolute dial position. Not implemented.
- class contrast.motors.Motor.Mvr(*args)[source]¶
Bases:
MvThis class generates the macro `mvr`
Move one or more motors relative to their current positions.
mvr <motor1> <position1> <motor2> <position2> ...
- class contrast.motors.Motor.Umv(*args)[source]¶
Bases:
MvThis class generates the macro `umv`
Like mv, but prints the current position while moving, and returns when the move is complete.
- class contrast.motors.Motor.Umvr(*args)[source]¶
-
This class generates the macro `umvr`
Like umv, but in positions relative to the current ones.
- class contrast.motors.Motor.Wm(*args)[source]¶
Bases:
objectThis class generates the macro `wm`
Print the positions of one or more motors.
wm <motor1> <motor2> ...
- class contrast.motors.Motor.WmS(*args)[source]¶
Bases:
WmThis class generates the macro `wms`
Silent ‘where motor’. Print the positions of one or more motors but do not print any output.
wms <motor1> <motor2> ...
- class contrast.motors.Motor.Wa[source]¶
Bases:
WmThis class generates the macro `wa`
Print the positions of all motors available at the current user level.
- class contrast.motors.Motor.LsM[source]¶
Bases:
objectThis class generates the macro `lsm`
List available motors.
- class contrast.motors.Motor.SetLim(*args)[source]¶
Bases:
objectThis class generates the macro `setlim`
Set limits on motors.
setlim <motor1> <lower 1> <upper 1> ...
Also saves new limits to all available
MotorMemorizerobjects.
- class contrast.motors.Motor.SetPos(*args)[source]¶
Bases:
objectThis class generates the macro `setpos`
Sets user position on motors.
setpos <motor1> <pos1> ...
Also saves new user positions to all available
MotorMemorizerobjects.
- class contrast.motors.Motor.BookmarkMacroBase(*args)[source]¶
Bases:
objectBase class for bookmark macros, which parses arguments into a list of MotorBookmark objects. If none are given, all bookmarks are included.
- class contrast.motors.Motor.LsBook(*args)[source]¶
Bases:
BookmarkMacroBaseThis class generates the macro `lsbook`
Lists the currently defined bookmarks or the contents of a specific bookmark.
lsbook [<bookmark name>]
- class contrast.motors.Motor.Bookmark(name, *args)[source]¶
Bases:
objectThis class generates the macro `bookmark`
Bookmarks the specified motors at their current dial positions.
bookmark <'bookmark name'> <motor 1> <motor 2> ...
Also saves existing bookmarks to all available
MotorMemorizerobjects.
- class contrast.motors.Motor.Restore(*args)[source]¶
Bases:
BookmarkMacroBaseThis class generates the macro `restore`
Restore a bookmarked position by moving all motors there.
- class contrast.motors.Motor.RmBook(*args)[source]¶
Bases:
BookmarkMacroBaseThis class generates the macro `rmbook`
Delete one or all bookmarks defined with the bookmark command.
rmbook [<bookmark 1> <bookmark 2> ...]
Also updates all available
MotorMemorizerinstances.
contrast.motors.PseudoMotor module¶
Provides base and example classes for pseudo motors, which are combinations of other motors.
- class contrast.motors.PseudoMotor.PseudoMotor(motors, dry_run=False, *args, **kwargs)[source]¶
Bases:
MotorPseudo motor base class.
Abstract base class for pseudo motors. The logic of pseudo motors needs some attention.
- Parameters:
motors – The underlying physical motors.
dry_run (bool) – Don’t move any physical motors, just print calculated positions.
- class contrast.motors.PseudoMotor.ExamplePseudoMotor(motors, dry_run=False, *args, **kwargs)[source]¶
Bases:
PseudoMotorExample pseudo motor which implements the difference between two motors.
Abstract base class for pseudo motors. The logic of pseudo motors needs some attention.
- Parameters:
motors – The underlying physical motors.
dry_run (bool) – Don’t move any physical motors, just print calculated positions.
contrast.motors.E727 module¶
Provides a Motor subclass for the PI E727 piezo driver.
contrast.motors.KukaMotor module¶
Provides a Motor interface to the MAX IV Kuka robot Tango device.
- class contrast.motors.KukaMotor.KukaRobot(tango_path, names=['gamma', 'delta', 'radius'])[source]¶
Bases:
objectManaging class which coordinates movements of the robot in polar coordinates. The manager’s role is to avoid trying to move more than one robot motor at a time, which would not be compatible with the controller.
This class owns three
KukaMotorinstances, which are returned on iteration:gamma, delta, radius = KukaRobot('path/to/device', names=['gamma, 'delta', 'radius'])
- Parameters:
tango_path (str) – Path to the underlying Tango device
names (list, tuple) – Names to assign to the three polar motors
- move_me(motor, pos)[source]¶
Method which makes sure that only one polar axis is moved at a time. For now, this is done by blocking until the device is standing still. Should perhaps be threaded or so, but works like this for scanning for example the two polar angles in a mesh.
- Parameters:
motor – Motor instance to move, typically
selffor the callingKukaMotor.pos (float) – Target position
contrast.motors.LC400 module¶
Provides a Motor subclass for the Npoint LC400 piezo driver, and a helper class for generating waveforms. Relies on the Tango server developed at MAX IV (available on request!):
https://gitlab.maxiv.lu.se/kits-maxiv/lib-maxiv-npoint-lc400
https://gitlab.maxiv.lu.se/kits-maxiv/dev-maxiv-npoint-lc400
- class contrast.motors.LC400.LC400Motor(device, axis, **kwargs)[source]¶
Bases:
MotorSingle axis on the LC400.
- Parameters:
device (str) – Path to the underlying Tango device.
axis – Axis number on the Tango controller
**kwargs – Passed on to the base class constructor
- class contrast.motors.LC400.LC400Waveform(axis, startpoint, endpoint, scanpoints, exposuretime, latencytime, accelerationtime, decelerationtime=None, startvelocity=None, endvelocity=None)[source]¶
Bases:
objectClass to generate waveform configs for the LC400 piezo controller. It generates a JSON string, that can be send to the LC400 Tango Server to configure the waveform.
contrast.motors.SmaractMotor module¶
Provides a Motor subclass for Smaract positioners. All numbers in
micrometers.
Controls these via a MAX IV Tango device, https://gitlab.maxiv.lu.se/kits-maxiv/dev-maxiv-mcs
- class contrast.motors.SmaractMotor.SmaractLinearMotor(device, axis, velocity=None, frequency=None, **kwargs)[source]¶
Bases:
MotorSingle Smaract motor axis.
- Parameters:
device (str) – Path to the MCS Tango device
axis (int) – Axis number on the controller
velocity (float) – Initialize velocity, defaults to None
**kwargs – Passed on to the
Motorbase class
- class contrast.motors.SmaractMotor.SmaractLinearMotor_MCS2(device, axis, velocity=None, acceleration=None, hold_time=None, **kwargs)[source]¶
Bases:
MotorSingle Smaract MCS2 motor axis.
- Parameters:
device (str) – Path to the MCS2 Tango device
axis (int) – Axis number on the controller
velocity (float) – Initialize velocity, defaults to None
acceleration (float) – Initialize acceleration, defaults to None
hold_time (float) – Initialize hold_time, defaults to None
**kwargs – Passed on to the
Motorbase class
contrast.motors.TangoAttributeMotor module¶
Provides a general Motor interface to any Tango attribute.
- class contrast.motors.TangoAttributeMotor.TangoAttributeMotor(device, attribute, force_read=True, **kwargs)[source]¶
Bases:
MotorMotor interface to any Tango attribute, so that anything can be scanned. These motors cannot be stopped and are never considered busy.
- Parameters:
device (str) – Path to the Tango device
attribute (str) – Name of the Tango attribute
**kwargs – Passed to the
Motorbase class
contrast.motors.TangoMotor module¶
Provides a Motor interface to standard Tango motors.