Python Measurement Scripts
To run a Python based user measurement, you must create a simple XML configuration file that identifies your measurement script. In addition to calling the script, the XML file populates the User Measurement Setup dialog.
The version of Python supported for user measurements is Python 2.7. Python 3 is not supported. You must modify the PC's PATH environment variable to include the path to the Python 2.7 executable. For example, C:\Anaconda on a PC and C:\Users\dca-admin\Anaconda on an DCA-X.
When a user measurement is run, FlexDCA performs the following tasks for each data acquisition:
- Passes the source waveform, standard variables and any custom variables to the Python script.
- Runs any required standard FlexDCA scalar measurements (dependents) as specified in XML file.
- Executes the script.
- The script returns a dictionary to FlexDCA that describes the measurement result and the result is displayed in the measurement results table. A number of standard output variables are also retrieved from the script.
In Oscilloscope and TDR modes, the source waveform is a one-dimensional NumPy array. In Eye mode, the source database is a two-dimensional NumPy array.
NumPy is a library for creating multidimensional arrays must be installed. To import NumPy into your Python script enter the following line:
import numpy as np