Pylatus Python scripting API

API Objects

Technical details

Pylatus is dynamically linked against a local version of Python, but only Python>=3.6 is supported. If you do not want to use any Python scripting in Pylatus, it should be compiled with -DNO_PYTHON=1.

Thus, Python in Pylatus is the same interpreter which is installed in your system and you can import any module which is installed for you system interpreter, i.e. this would work

import numpy as np

if you have numpy installed. Pylatus extends the system modules with a few objects specific for a typical diffraction experiment.

It is important to note that the Pylatus do not run the script immediately but creates a sequence of actions which can be inspected by user and run after.

API description

diffractometer

The main object which allows to script diffraction scan. Diffractometer script source code.

Instance methods:

diffractometer.scan(*, folder=None, filename=None, nperiods=None, nframes=None, exposure=None, dOmega=None, omega=None, phi=None, kappa=None, pldistf=None, pldistd=None, plrot=None, plvert=None, nop=False)

Makes a data collection sequence action. This method accepts only the keyword arguments. If an argument is not set, its value is taken from the main Pylatus window, from the “Set diffraction experiment” widget (excluding nop argument).

../_images/diffractometer_methods.svg

The method parameters are the following:

  • folder: string which specifies the directory where the data will be stored;

  • filename: string with file base name;

  • exposure: exposure time in seconds, float number;

  • nframes: number of frames, integer number;

  • nperiods: number of periods, integer number;

  • dOmega: angular step in degrees per image, float number. It is still called dOmega even if phi-scan is set (see issue #19);

  • omega: starting angle in degrees for omega axis when omega-scan is set or just omega position if phi-scan is set, float number;

  • phi: starting angle in degrees for phi axis when phi-scan is set or just phi position if omega-scan is set, float number;

  • kappa: kappa angle in degrees, float number;

  • pldistd: position of the detector inside the frame in mm, float number;

  • pldistf: position of the frame in mm, float number;

  • plrot: detector angle in degrees, float number;

  • plvert: vertical offset of the detector in mm, float number;

  • nop: bool, stands for no periods: if False the filename parameter will be extended with the period number, i.e. filename_0001p.cbf; if True just filename will be used, i.e. filename.cbf.

diffractometer.sleep(seconds)

Diffractometer does not do any action for a number of seconds.

diffractometer.setPhiScan()

Sets phi axis as the main scanning axis. In this case, the angular step will be called dPhi, since 2021-04-01 or dOmega for older version. Attention: if you switch omega and phi scans in the script, you HAVE TO specify both omega= and phi= parameters in the diffractometer.scan method.

diffractometer.setOmegaScan()

Sets omega axis as the main scanning axis. Attention: if you switch omega and phi scans in the script, you HAVE TO specify both omega= and phi= parameters in the diffractometer.scan method.

diffractometer.align()

Create a sequence action for the diffractometer auto alignment procedure. All the values must be set in the Guru option Autoscan before using this method.

Example of usage:

diffractometer.setOmegaScan()
diffractometer.scan(folder="omega_scan", phi=0, omega=-55, dOmega=1, nperiods=10)
diffractometer.setPhiScan()
diffractometer.scan(folder="phi_scan", phi=0, omega=-55, dPhi=1, nframes=5)


motor("name")

The object which allows to script individual motor motions. Motor script source code.

For move and moveRelative should be called in form:

motor("omega").move(0)

where "omega" sets the motor name, and 0 is the position. All motor connected to Pylatus in the Guru tab can be moved individually.

Instance methods:

.move(value)

Moves motor with name (string) absolutely to the position value (float number). The motor must be connected to Pylatus in the Guru tab.

.moveRelative(value)

Moves motor with name (string) relatively to the position value (float number). The motor must be connected to Pylatus in the Guru tab.

motor.wait()

Waits until all the moving motors reach desirable positions. It does not need a motor name.

Example of usage:

# move motors to the starting positions
motor('omega').move(0)
motor('phi').move(90)
motor('kappa').move(-55)
motor('gon1').move(-55)
# wait until all the motor reach starting positions
motor.wait()
# make a scan
diffractometer.scan()


cryostream

The object which operates the Cryostream gas blower. Cryostream script source code.

Instance methods:

cryostream.cool(temperature)

Cools the cryostream to the temperature as quick as possible. Temperature interval is from 80 K to 500 K (float).

cryostream.ramp(temperature, ramp_rate)

Ramps the cryostream to the temperature with the ramp rate of ramp_rate. Temperature interval is from 80 K to 500 K (float), ramp rate is from 1 to 360 K/hour.

cryostream.end(ramp_rate)

Ramps the cryostream to the room temperature the ramp rate ramp_rate and switches it off. Ramp rate is from 1 to 360 K/hour.

cryostream.wait()

Cryostream waits until it reaches the temperature specified by one of the previous commands.


blower

The object which operates the Eurotherm hot gas blower. Blower script source code.

Instance methods:

blower.ramp(temperature, ramp_rate)

Ramps the blower to the temperature with the ramp rate of ramp_rate. Temperature interval is from 20 C to 1000 C (float), ramp rate is from 1 to 1000 C/min.

blower.wait()

Blower waits until it reaches the temperature specified by the previous command.


lakeshore

The object which operates the Lakeshore temperature controller. Lakeshore script source code.

Instance methods:

lakeshore.setpoint(output, target)

Sets target temperature (in K) for the lakeshore at the output (usually 1 or 2).

lakeshore.range(output, range)

Sets the heater range at the output. range can be either one of the following values:

  • 0 - Off

  • 1 - Low

  • 2 - Medium

  • 3 - High

lakeshore.heater(output, value)

Sets the heater to manual value at the output. value is can be in the range from 0 to 100 %.

lakeshore.manual(output, value)

Alias for lakeshore.heater.

lakeshore.pid(output, p, i, d)

Sets p, i, d coefficients at the output.

lakeshore.wait()

Lakeshore waits for the temperature set with lakeshore.setpoint.


iseg

The object which operates the ISEG high voltage device. Iseg script source code.

Instance methods:

iseg.setVoltage(voltage, ramp_rate)

Sets the voltage value with the ramp_rate. Maximum voltage depends on the model (usually 2000 V). Ramp rate is from 2 to 255 V/s.

iseg.ramp()

Alias for iseg.setVoltage

iseg.wait()

Waits until the voltage is set by the previous command.


keithley

The object which operates the Keithley2200 voltage/current device. Keithley script source code.

Instance methods:

keithley.setVoltage(voltage)

Sets voltage value in V at the Keithley output.

keithley.setCurrent(current)

Sets current value in A at the Keithley output.

keithley.stop()

Switches off the Keithley output.