Useful Pylatus script snippets

Measure all LaB6 patterns at once

dists = [0, 100, 200, 300, 400, 500]
heights = [80, 0]

for d in dists:
    heights = heights[::-1]
    for h in heights:
        diffractometer.scan(filename=f'lab6_{d:03d}_{h:02d}',
                            pldistf=d, plvert=h, omega=0,
                            dOmega=100, nperiods=1,
                            exposure=10, nframes=1)

Measurements with the Cryostream

# from 300 K to 200 K with a step 10
# and from 200 K to 80 K with a step 1 K
temps = list(range(300, 200, -10)) + list(range(200, 79, -1))
for t in temps:
    # ramp with rate 360 K/hour
    cryostream.ramp(t, 360)
    cryostream.wait()
    # sometimes it's useful to wait for temperature stabilization
    diffractometer.sleep(120)
    # Folder pattern is like Sample1_100K
    diffractometer.scan(folder=f'Sample1_{t:03d}K')

Using the gas heat blower

# from 400.5 K to 500.5 K with a step 0.5
# and from 200 K to 80 K with a step 1 K.
# It is not possible to use range with float,
# Thus we import arange from numpy
from numpy import arange
temps = arange(400.5, 501, 0.5)
for t in temps:
    # ramp 10 C/min
    blower.ramp(t, 10)
    blower.wait()
    # Folder pattern is like Sample1_400.5C
    diffractometer.scan(folder=f'Sample1_{t:.2f}C')

Modulation Enhanced Diffraction snippet

import numpy as np

amax = 250  # max temperature amplitude
amin = 200  # min temperature amplitude
n = 50      # number of points
filename = 'name'
func = np.cos  # use cosine function

points = np.linspace(0, 2 * np.pi, n)
temps = (amax + amin) / 2 + func(points) * (amax - amin) / 2

for i, t in enumerate(temps):
    cryostream.ramp(t, 360)
    cryostream.wait()
    # nop=True means the filename pattern will be without _0001p
    # part, i.e. name_001.cbf instead of name_001_0001p.cbf
    diffractometer.scan(filename=f'{filename}_{i:03d}', nop=True)