Call Python

Commands:

.python.init %% activate python engine .python.deinit %% close python engine .python.exec(<string>) %% execute Python line .python.get(<string>) %% get variable from Python .exp.python %% bring current experiment to Python as a variable X in TDMS format .pulse.command.pattern.PYTHON= 'Python script' %% execute a script and bring the variable p as a shape

32 bit version is compatible with 32-bit Python 3.8.10. Path to Python DLL should be specified in Options>Directories and Files>Python directory.

To pass Python strings through the script engine, one must substitute single apostrophes (') with back apostrophe (`). Some windows do automatic conversion.

Example:

.python.init %% activate python engine .python.exec('a=6') %% execute Python line .python.get('a') %% get variable from Python .python.deinit %% close python engine .puls.awg.shape.PYTHON='p = [array(`d`, [0.0]*200) for _ in range(5)]'

Python in experiment

NEW: Variables in experiment engine can have python definitions. Assuming there is an array 'matrix' defined as matrix = np.linspace(10e6, 45e6, 50) the experiment variable can be defined like below. idx is an automatic variable defining axis index.

Example:

py: Frequency = matrix[idx]