Python Input Variables

Meas. mode:
Scope
Eye
TDR
Package License:
L-RND
L-SNT

When FlexDCA starts a user-measurement script, FlexDCA passes to the script a dictionary (variables) that contains the input variables shown in the following table. Use variables[SrcData] to get the source input waveform data. Use variables[MeasData] to get a list of scalar measurement dictionaries. Each dictionary in the list contains the input variables describing a single measurement that is listed in FlexDCA's Results panel. Any variables that you defined with the <Variable> XML element are also included in a dictionary.

The following example starts by assigning the waveform data (Source) and the scalar measurement data (MeasData). Then, the script loops through the MeasData list to identify each of two measurement dictionaries: Peak-Peak, and Amplitude. Each dictionary is assigned to a descriptive variable from which each measurement's results variables can be accessed. As you can see, the measurement name value is compared to the name an expected measurement. To learn the name of each FlexDCA measurement, refer to To Confirm a Measurement Name in this topic.

def algorithm(variables): 
	Source = variables['Source']      # Source of the input waveform
	MeasData = variables['MeasData']  # A dictionary of dependent measurement results
	# Find measurement results in MeasData: 
	for meas in MeasData:
		if (meas['Source1'] == Source):
			if (meas['Name'] == 'Peak-Peak'):  # found Peak-Peak dictionary
				Vpp = meas   # Peak-Peak measurement dictionary
			elif (meas['Name'] == 'Amplitude'):  # found Amplitude dictionary
				Vamptd = meas   # Amplitude measurement dictionary
	    …
	    …

In your script, you can print the output variables to the Show Output window as demonstrated in Exercise 2 and explained in Troubleshooting Python scripts.

If your script uses a two-waveform input measurement, the input variables shown in this table will have a "2" character appended to the variable's name to distinguish the variable from each waveform. For example, SrcData becomes SrcData2 for the second waveform. The only exceptions are the except MeasData and SoftwareVersion variables.

Input Variables
Dictionary keys Type Description FlexDCA Modes
Scope TDR Eye
SrcData numpy.ndarray The input waveform in Oscilloscope and TDR/TDT mode where the waveform consists of y-data values. Values are in volts for electrical signals and Watts for optical signals.  
The input waveform in Eye/Mask mode 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 variable and value:
'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 variable and value: 'Source': 'Channel 1B'
SourceBw float The bandwidth of the input source. Example variable and value: 'SourceBw': 150000000000.0
TotalHits long The number of hits in eye database. The value is an unsigned long integer in Python 2. Example variable and value: 'TotalHits': 2809395L
XOrg float The time of the first x-axis value of the input waveform value of SrcData. Example variable and value: 'XOrg': 8.785e-11
XInc float The spacing of the x-axis input waveform values of SrcData. Example variable and value: 'XInc': 2.232e-13
XUnits string The X units associated with the input waveform. Example variable and value: 'XUnits': 'Second'
YOrg float The time of the first y-axis value of SrcData. Example variable and value: 'YOrg': -0.42711    
YInc float The spacing of the y-axis values of SrcData. Example variable and value: 'YInc': 0.0016430    
YUnits string The Y units associated with the input waveform. Example variable and value: 'YUnits': 'Volt'
BitRate float FlexDCA A.05.61 and below. Deprecated in FlexDCA A.05.62 and above. Use the recommended SymbolRate variable instead.
The current value of the 'Data Rate' control in the pattern lock tab of the trigger setup dialog. If pattern lock is not turned on, this value may not be correct. Example variable and value: 'BitRate': 9953280000.0
SymbolRate float Available FlexDCA A.05.62 and above.
The current value of the 'Symbol Rate' control in the pattern lock tab of the trigger setup dialog. If pattern lock is not turned on, this value may not be correct. Example variable and value: 'SymbolRate': 9953280000.0
PatLength integer The current value of the 'Pattern Length' control in the pattern lock tap of the trigger setup dialog. If pattern lock is not turned on, this value may not be correct. Example variable and value: 'PatLength': 127
SrcClipped bolean Set to True if the source data was clipped high or low; otherwise set to False. Example variable and value: '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 variable and value: 'ClipLow': -0.510869  
IsAvgComplete bolean Flag tells if waveform averaging is complete. Set to True if complete, otherwise False if not complete. Example variable and value: 'IsAvgComplete': True  
IsPeriodic bolean Flag tells if waveform is periodic. Set to True if complete, otherwise False if not complete. Example variable and value: 'IsPeriodic': False  
AvgAcqCount long The current value of the 'Number of Averages' control in the Averaging tab of the Acquistion dialog if averaging is enabled, otherwise its value is 1. The value is an unsigned long integer in Python 2. Example variable and value: '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.
TdrAmplitude float The current amplitude of the TDR waveform.
TdrPolarity string The current polarity of the TDR waveform.
TdrRiseTime float The current rise time of the TDR waveform.
DielectricConstant float The dielectric constant of the TDR waveform. (If horizontal units are defined in distance instead of time.)
VelocityFactor float The velocity factor of the TDR waveform.(If horizontal units are defined in distance instead of time.)
MeasData list of dictionaries Contains name, status, channel, result, and units for each input measurement.
SoftwareVersion string The FlexDCA software version that is being run.

MeasData Variable's Dictionaries

The MeasData variable is a list of dictionaries where each dictionary describes a FlexDCA measurement. For example,

'MeasData' = [
			{'Name': 'Amplitude', 'Status': 'Correct', 'Source1': 'Channel 1A', 'Result': 0.496241, 'Units':'Volt'},
			{'Name': 'Peak-Peak', 'Status': 'Correct', 'Source2': 'Channel 1B', 'Result': 0.514348, 'Units':'Volt'},
			....]

Dictionary keys return either string values (type unicode in Python 2) or float values. The string values are passed as Unicode. The tables at the end of this topic show example measurement name strings returned for a dictionary's 'Name' key. Use a dictionary's 'Name' key to:

  • Identify the measurement that a dictionary describes.
  • Learn the status of the found dictionary's measurement result using the 'Status' key.
  • Get the found dictionary's measurement result using the 'Result' key.

For example, you could identify a Rise Time and Fall Time measurements using the following code:

For meas in MeasData:  # loop through dictionaries
	if (meas['Name'] == 'Rise Time'):
		RiseTimeMeasurement = meas['Result']
	elif (meas['Name'] == 'Fall Time'):
		FallTimeMeasurement = meas['Result']

How do I handle Unicode symbols (Δ, δ, and μ) in a name string?

Three FlexDCA measurement names include Unicode symbols in their names: Δ Time, DI (δ-δ), and DJ (δ-δ). Also, names that have time or amplitude values in them may contain the μ symbol. For example, Eye mode's J4 measurement name could be J4 (RJ: 1.123μs) depending on the settings made at the time that the measurement was started in FlexDCA.

In Python 2, strings (the str type) is a sequence of 8-bit values while the unicode type is Unicode characters. Since the measurement string for the Δ Time, DI (δ-δ), and DJ (δ-δ) measurements contain Unicode symbols (chars beyond 255), you must do some extra work when performing comparisons to identify the a measurement dictionary. See also the note above for the situation when a 'μ' symbol can appear in a measurement name.

The following script includes three measurement that include a symbol and a fourth measurement that only includes ASCII (Rise Time). To identify measurement names for these measurements, "string" names of type unicode are used to directly compare with the 'Name' key's Unicode value.

This script:

  • Identifies dictionaries for Eye Mode's Rise Time, DJ (δ-δ), Δ Time, and JN measurements. Notice in lines 5, 6, and 7 that the symbols character is represented by Unicode character code shown in this topics sidebar.
  • Assigns each measurement's located dictionary to its own variable: RT, DJ, DeltaTime, and J4.
  • Returns the Δ Time measurement result to FlexDCA.
  • Prints each measurement result to the User Measurement Output dialog.

Alternately, you could do the comparison using byte strings (type str), but this involves encoding the Unicode measurement name from the dictionary into a byte string which just makes your code more difficult to read.

Copy

compare-unicode-names.py

def algorithm(variables): 
    Source = variables['Source']      # Source of the input waveform
    MeasData = variables['MeasData']  # A list of measurement dictionaries 
    RISETIME = 'Rise Time'
    DELTAJIT = u'DJ (\u03b4 - \u03b4)'
    DELTATIME = u'\u0394 Time'
    JFOUR = u'J4 (RJ: 1.200\u03bcs)'
    for meas in MeasData:
        if (meas['Source1'] == Source):
            if (meas['Name'] == RISETIME):  # compare Unicode
                RT = meas
                print 'Rise Time Result: ', str(RT['Result'])
            elif (meas['Name'] == DELTAJIT):  # compare Unicode
                DJ = meas
                print 'DJ Result: ', str(DJ['Result'])
            elif meas['Name'] == DELTATIME:  # compare Unicode
                DeltaTime = meas
                print 'Delta Time Result: ', str(DeltaTime['Result'])
            elif meas['Name'] == JFOUR:  # compare Unicode
                J4 = meas
                print 'J4 Result: ', str(J4['Result'])
    return { 'Result': DeltaTime['Result'],
        'Status': 'Correct',
        'Units': 'second',
        'ValueFormat': 'Engineering',
        'Resolution': 0.01e-12,
        'ErrorMsg': ''}

Markers Variable's Dictionaries

The Markers variable is a list of dictionaries where each dictionary describes a waveform marker. For example,

'Markers' = [
			{'Status': 'Correct','Source': 'Channel 1B','Name': 'X1,'Position': 1.01033e-10},
			{'Status': 'Correct','Source': 'Channel 1B','Name': 'X2,'Position': 1.28445e-10},
			....]

To confirm a measurement name, see how the name is shown in FlexDCA's Results panel.

In the following tables, blue colored name string text shown in brackets [text] and parenthesis (text) indicate measurement options.

Scope Mode Measurement Names 1
(Example Dictionary Values for "Name" Key)
Time Toolbar Measurements Amplitude Toolbar Measurements PAM Toolbar Measurements
On Toolbar meas['Name']
Key Value Examples
On Toolbar meas['Name']
Key Value Examples
On Toolbar meas['Name']
Key Value Examples
Rise Time Rise Time Overshoot Overshoot Linearity RLM (802.3 CL_94)
Fall Time Fall Time Average Power Avg[Disp] Levels Level 3
Level 2
Level 1
Level 0
Jitter Jitter[rms] OMA OMA Levels RMS Level 3 RMS
Level 2 RMS
Level 1 RMS
Level 0 RMS
Period Period Amplitude Amplitude
Δ Time ΔT[+1Up,-2Lo] Peak-Peak Amplitude Peak-Peak(1.0E-2)
Frequency Frequency RMS RMS[AC,Disp]
RMS[DC,Cyc]
+ Pulse Width + Pulse Average Average Power
- Pulse Width - Pulse Waveform Top Top
Duty Cycle Duty Cycle Waveform Base Base
Time at Max Time at Max Maximum Maximum
Time at Min Time at Min Minimum Minimum
Time at Edge Time[+1Mid]
Time[-1Lo]
Time[+1Up]
Preshoot Preshoot
Time at Amplitude Time[+1,0 W]
Time[-2,1.80 mV]
Time[+2,900 μV]
Amplitude at Time Ampl[16.10000 ns]
Phase Phase[+]
Phase[-]
Amplitude at Upper Ampl at Upper
Amplitude at Middle Ampl at Middle
Amplitude at Lower Ampl at Lower
Peak-Peak at Hit Ratio Peak-Peak

Blue text describes measurement options which are selected when a measurement is run. Multiple instances of a measurement can be run each having different options. Refer to the Results panel for the exact name.

Eye Mode Measurement Names 1
(Example Dictionary Values for "Name" Key)
Time Toolbar Measurements Adv Eye Toolbar Measurements PAM Toolbar Measurements
On Toolbar meas['Name']
Key Value Examples
On Toolbar meas['Name']
Key Value Examples
On Toolbar meas['Name']
Key Value Examples
Extinction Ratio Ext. Ratio TJ TJ (1.0E-12, RJ: 3fs)
TJ 2/3 (1.0E-12, RJ: 3fs)
TJ 1/2 (1.0E-12, RJ: 3fs)
TJ 0/1 (1.0E-12, RJ: 3fs)
TDECQ TDECQ
TDEC TDEC[OMA XP] DJ (δ - δ) DJ (δ - δ, RJ: 2fs)
DJ 2/3 (δ - δ, RJ: 2fs)
DJ 1/2 (δ - δ, RJ: 2fs)
DJ 0/1 (δ - δ, RJ: 2fs)
Ceq Noise Gain Ceq
Jitter Jitter[rms] RJ (rms) RJ (rms, fixed)
RJ 2/3 (rms, fixed)
RJ 1/2 (rms, fixed)
RJ 0/1 (rms, fixed)
Trans. Time Trans. Time (Slowest; 5,6)
OMA at Crossing OMA XP Jn J2 0/1 (RJ: 1fs)
J2 (RJ: 1fs)
Outer OMA Outer OMA
VECP VECP[OMA XP] TI TI 3 (1.0E-12, RN: μW)
TI 2 (1.0E-12, RN: mW)
TI 1 (1.0E-12, RN: μW)
TI 0 (1.0E-12, RN: mW)
PAM Overshoot Overshoot(1.0E-2)
Average Power Average Power DI (δ - δ) DI 3 (δ - δ, RN: μV)
DI 2 (δ - δ, RN: mV)
DI 1 (δ - δ, RN: μV)
DI 0 (δ - δ, RN: mV)
PAM Undershoot Undershoot(1.0E-2)
Rise Time Rise Time RN (rms) RN (rms, fixed)
RN 3 (rms, fixed)
RN 2 (rms, fixed)
RN 1 (rms, fixed)
RN 0 (rms, fixed)
Outer Extinction Ratio Outer ER
Fall Time Fall Time Linearity RLM (802.3 CL_94)
One Level One Level Noise Margin (rms) Noise Margin (rms)
Zero Level Zero Level Pk-Pk Amplitude Pk-Pk Power(1.0E-2)
Eye Height Eye Height[Ampl] Tx Power Excursion Power Excursion(1.0E-2)
Eye Width Eye Width[Time] Partial SER Partial SER (2/3 L)
Crossing % Crossing % Partial TDECQ Partial TDECQ (2/3 L)
Signal to Noise Ratio SNR Partial Noise Margin Noise Margin (2/3 L)
Duty Cycle Distortion DCD[Time] Levels Level 3
Bit Rate Bit Rate Levels RMS Level 2 RMS
Eye Amplitude Eye Ampl Levels Peak-Peak Level 3 Peak-Peak
Δ Time Δ Time Level Skews Level 2 Skew
Crossing Time Crossing Time Eye Levels Eye 1/2 Level
Database Peak Hits Database Peak Hits Eye Skews Eye 2/3 Skew
Vertical Eye Closure Eye 0/1 VEC
Eye Heights Eye 1/2 Height
Eye Widths Eye 2/3 Width

Blue text describes measurement options which are selected when a measurement is run. Multiple instances of a measurement can be run each having different options. Refer to the Results panel for the exact name.

TDR Mode Measurement Names
(Example Dictionary Values for "Name" Key)
Time Toolbar Measurements Amplitude Toolbar Measurements
On Toolbar meas['Name']
Key Value Examples
On Toolbar meas['Name']
Key Value Examples
Rise Time Rise Time Average Avg[Disp]
Fall Time Fall Time Maximum Maximum
Delta Time Δ Time Minimum Minimum
Time at Max Time at Max Amplitude at Time Ampl[1.60200 ns]
Time at Min Time at Min Excess Capacitance Excess C[Left]
Time at Amplitude Time[+1,0 V] Excess Inductance Excess L[Left]
Time at Edge Time[+1Mid]

Blue text describes measurement options which are selected when a measurement is run. Multiple instances of a measurement can be run each having different options. Refer to the Results panel for the exact name.