Useful Pylatus script snippets ========================================= .. toctree:: :maxdepth: 2 :caption: Contents: Measure all LaB\ :sub:`6`\ patterns at once ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python 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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python # 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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python # from 400.5 K to 500.5 K with a step 0.5 # 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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python 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) Measure the full sphere with Arinax micro-kappa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: python dir = 'test' runs = { 'run0': {'akappa': 0, 'aphi': 0, 'prhor': -44.5813, 'samtx': 1.6822, 'samty': 0.8764}, 'run1': {'akappa': 90, 'aphi': 0, 'prhor': -44.3563, 'samtx': 1.9445, 'samty': 1.3063}, 'run2': {'akappa': 90, 'aphi': 90, 'prhor': -44.3064, 'samtx': 1.8516, 'samty': 0.7455}, 'run3': {'akappa': 90, 'aphi': 180, 'prhor': -44.6463, 'samtx': 1.3820, 'samty': 0.8077}, } for r in runs: motors = runs[r] for m in motors: motor(m).move(motors[m]) motor('omega').move(0) motor.wait() diffractometer.scan(folder=f'{dir}/{r}', kappa=motors['akappa'], phi=motors['aphi'])