Python Measurement Variables

Input Variables

When Infiniium starts a user-measurement script, the following variables are passed to the script as key:value pairs in a dictionary. Any variables that you defined with the <Variable> XML element are also passed to the script. For example, your script will start with the function definition shown below. The input variables are passes in the variables dictionary. In the second line, the function uses the SrcData dictionary key to assign the value which is the input waveform to the SrcData variable.

def algorithm(variables):
    SrcData = variables['SrcData']
    …
    …

In your script, you can print the output variables to the Show Output window as demonstrated in Lesson 2 (see Lesson 2. Creating a "Show Vars" User Measurement Script) and explained in Python Measurement Troubleshooting.

Each input variable, except MeasurementData and SoftwareVersion, listed in the following table has two forms. The one listed is for a single input waveform or the waveform 1 of a dual-waveform input measurement. If a second input waveform exists, its variable has the digit "2" appended. For example, SrcData becomes SrcData2 for the second waveform.

Input Variables
Dictionary keys Type Description Data types
Wave Eye
SrcData numpy.ndarray The input waveform where the waveform consists of y-data values. Values are in volts for electrical signals and Watts for optical signals.  
The input data for an eye diagram is a database where the waveform consists of hits-per-pixel arranged in a two-dimensional array ([column][row]). The column index represents increasing time values starting from the waveform's displayed left side to its right side. The row index represents increasing amplitude values that are in volts for electrical signals and Watts for optical signals.  
Example key: value pair:
'SrcData': array([[0,0,0,…,0,0],
[0,0,0,…,0,0],
[0,0,0,…,0,0],
…
[0,0,0,…,0,0],
[0,0,0,…,0,0]], dtype=uint32)
Source string The source of the input waveform.
Example key: value pair: 'Source': 'Channel 2'
SourceBw float The bandwidth of the input source.
Example key: value pair: 'SourceBw': 150000000000.0
TotalHits long The number of hits in eye database. The value is an unsigned long integer in Python.
Example key: value pair: 'TotalHits': 2809395L
XOrg float The time of the first x-axis value of the input waveform value of SrcData.
Example key: value pair: 'XOrg': 8.785e-11
XInc float The spacing of the x-axis input waveform values of SrcData.
Example key: value pair: 'XInc': 2.232e-13
XUnits string The X units associated with the input waveform. Refer to Valid Measurement Units.
Example key: value pair: 'XUnits': 'Second'
YOrg float The time of the first y-axis value of SrcData.
Example key: value pair: 'YOrg': -0.42711
 
YInc float The spacing of the y-axis values of SrcData.
Example key: value pair: 'YInc': 0.0016430
 
YUnits string The Y units associated with the input waveform. Refer to Valid Measurement Units.
Example key: value pair: 'YUnits': 'Volt'
BitRate float The current value of the 'Data Rate' control.
Example key: value pair: 'BitRate': 9953280000.0
SymbolRate float The current value of the 'Symbol Rate' control.
Example key: value pair: 'SymbolRate': 9953280000.0
SrcClipped boolean Set to True if the source data was clipped high or low; otherwise set to False.
Example key: value pair: 'SrcClipped': True
 
ClipHigh float The maximum value that could be present in the source waveform. If SrcClipped is True, check to see which elements of SrcData are equal to ClipHigh to determine which elements were clipped.
Example key: value pair: 'ClipHigh': 0.51057
 
ClipLow float The minimum value that could be present in the source waveform. If SrcClipped is True, check to see which elements of SrcData are equal to ClipLow to determine which elements were clipped.
Example key: value pair: 'ClipLow': -0.510869
 
IsAvgComplete boolean Flag tells if waveform averaging is complete. Set to True if complete, otherwise False if not complete.
Example key: value pair: 'IsAvgComplete': True
 
AvgAcqCount long The current value of the 'Number of Averages' control in the Averaging tab of the Acquisition dialog if averaging is enabled, otherwise its value is 1. The value is an unsigned long integer in Python.
Example key: value pair: 'AvgAcqCount': 1L
 
Markers list of dictionaries Marker information if markers are on source waveform. If a marker is not on, it is not included in the list.
Example key: value pair:
'Markers': [
{'Status': 'Correct','Source': 'Channel 1','Name': 'X1,'Position': 1.01033e-10},
{'Status': 'Correct','Source': 'Channel 1','Name': 'X2,'Position': 1.28445e-10},
{'Status': 'Correct','Source': 'Channel 1','Name': 'X3,'Position': 1.50625e-10},
{'Status': 'Correct','Source': 'Channel 1','Name': 'X4,'Position': 1.78664e-10}]
MeasurementData list of dictionaries A list of dictionaries with one dictionary for each defined dependent measurement. Up to four dependent measurements can be defined.
Example key: value pair:
'MeasurementData':[
{'Name': 'Amplitude', 'Status': 'Correct', 'Source1': 'Channel 1', 'Result': 0.496241, 'Units':'Volt'},
{'Name': 'Peak-Peak', 'Status': 'Correct', 'Source2': 'Channel 2', 'Result': 0.514348, 'Units':'Volt'},
 ....]
YMiddle float The Y middle of the display of the input source.
YDispRange float The Y range of the display of the input source.
SoftwareVersion string The Infiniium software version that is being run.

Output Variables

This topic lists the variables whose values are returned to Infiniium when your script completes. The Result variable must be set in your script. The remaining variables may be returned, if needed. For Python scripts, these variables are returned in a dictionary.

Variables Output From Script
Variable Type Description
Variables that must be returned by your script
Result float The measured scalar result.
Optional variables that can be returned by your script
Units string Returns the measurement units of the result. Refer to Valid Measurement Units.
Status string Returns the status of the measurement result. The string can be 'Correct', 'Questionable', or 'Invalid'.
ErrorMsg string Returns an error message for the measurement. The error message is displayed in the oscilloscope message area.