Skip to content

KeysightPna#

Controls a Keysight PNA vector network analyzer from Python. This class inherits from MeasmaticDevice.


property max_frequency#

Maximum frequency in Hz that the VNA supports.

Returns#

Type Description
float The maximum frequency in Hz.

Example#

vna = measmatic.get_device('device-vna')
print(vna.max_frequency)

property min_frequency#

Minimum frequency in Hz that the VNA supports.

Returns#

Type Description
float The minimum frequency in Hz.

Example#

vna = measmatic.get_device('device-vna')
print(vna.min_frequency)

property port_capabilities#

The S-parameters that this VNA can measure.

Returns#

Type Description
Any A .NET List of Atv.Framework.Mathematics.RF.NetworkElement, one entry per measurable S-parameter.

Example#

vna = measmatic.get_device('device-vna')
for s in vna.port_capabilities:
print(s)

property ports#

Number of test ports of the VNA, typically 2 or 4.

Returns#

Type Description
int The number of ports.

Example#

vna = measmatic.get_device('device-vna')
print(vna.ports)

method add_trace(s: Any, networkFormat: Any)#

Adds a measurement trace for the given S-parameter to the VNA display. Only S-parameters listed in port_capabilities are supported.

Parameters#

Name Description
s The S-parameter to measure, of type Atv.Framework.Mathematics.RF.NetworkElement.
networkFormat The display format of the trace, of type Atv.Framework.Mathematics.RF.NetworkElement.NetworkFormat.

Returns#

Type Description
str The name of the created trace.

Example#

from Atv.Framework.Mathematics.RF import NetworkElement
vna = measmatic.get_device('device-vna')
s21 = NetworkElement.Define('S21')
trace = vna.add_trace(s21, NetworkElement.NetworkFormat.LogMagPhase)

method clear_trace(s: Any)#

Deletes all traces that measure the given S-parameter.

Parameters#

Name Description
s The S-parameter whose traces are deleted, of type Atv.Framework.Mathematics.RF.NetworkElement.

Example#

from Atv.Framework.Mathematics.RF import NetworkElement
vna = measmatic.get_device('device-vna')
vna.clear_trace(NetworkElement.Define('S21'))

method clear_trace(name: str)#

Deletes the trace with the given name, including its second trace if the display format uses two traces.

Parameters#

Name Description
name The trace name as returned by add_trace.

Example#

from Atv.Framework.Mathematics.RF import NetworkElement
vna = measmatic.get_device('device-vna')
trace = vna.add_trace(NetworkElement.Define('S11'), NetworkElement.NetworkFormat.Smith)
vna.clear_trace(trace)

method clear_traces()#

Deletes all traces from the VNA.

Example#

vna = measmatic.get_device('device-vna')
vna.clear_traces()

method get_all_data()#

Reads the data of all S-parameters that currently have a trace on the VNA.

Returns#

Type Description
Any The measured data as Atv.Framework.Mathematics.RF.Network, containing the frequency axis and one sub network per S-parameter.

Example#

vna = measmatic.get_device('device-vna')
network = vna.get_all_data()

method get_available_traces()#

Returns the S-parameters for which a trace currently exists on the VNA.

Returns#

Type Description
Any An array of Atv.Framework.Mathematics.RF.NetworkElement, sorted and without duplicates.

Example#

vna = measmatic.get_device('device-vna')
traces = vna.get_available_traces()

method get_bandwidth()#

Reads the IF bandwidth (resolution bandwidth) of the VNA.

Returns#

Type Description
float The IF bandwidth in Hz.

Example#

vna = measmatic.get_device('device-vna')
bandwidth = vna.get_bandwidth()

method get_frequencies()#

Reads the frequency points of the current sweep.

Returns#

Type Description
Any The frequency axis as Atv.Framework.Mathematics.RF.Frequency, values in Hz.

Example#

vna = measmatic.get_device('device-vna')
frequencies = vna.get_frequencies()

method get_frequency_point_count()#

Reads the number of frequency points of the current sweep.

Returns#

Type Description
int The number of frequency points.

Example#

vna = measmatic.get_device('device-vna')
points = vna.get_frequency_point_count()

method get_is_calibrated()#

Checks whether the VNA has an active calibration.

Returns#

Type Description
bool True if a calibration is active, otherwise False.

Example#

vna = measmatic.get_device('device-vna')
if not vna.get_is_calibrated():
vna.load_calibration('my_calibration')

method get_power()#

Reads the source output power of the VNA.

Returns#

Type Description
float The output power in dBm.

Example#

vna = measmatic.get_device('device-vna')
power = vna.get_power()

method get_sense_attenuation(port: int)#

Reads the receiver attenuation of the given port. Returns 0 if the VNA is not equipped with the receiver attenuator option.

Parameters#

Name Description
port The port number, starting at 1.

Returns#

Type Description
float The receiver attenuation in dB.

Example#

vna = measmatic.get_device('device-vna')
attenuation = vna.get_sense_attenuation(1)

method get_source_attenuation(port: int)#

Reads the source attenuation of the given port. Returns 0 if the VNA is not equipped with the source attenuator option.

Parameters#

Name Description
port The port number, starting at 1.

Returns#

Type Description
float The source attenuation in dB.

Example#

vna = measmatic.get_device('device-vna')
attenuation = vna.get_source_attenuation(1)

method get_start_frequency()#

Reads the start frequency of the sweep.

Returns#

Type Description
float The start frequency in Hz.

Example#

vna = measmatic.get_device('device-vna')
start = vna.get_start_frequency()

method get_stop_frequency()#

Reads the stop frequency of the sweep.

Returns#

Type Description
float The stop frequency in Hz.

Example#

vna = measmatic.get_device('device-vna')
stop = vna.get_stop_frequency()

method get_sweep_point_count()#

Reads the number of points of the sweep.

Returns#

Type Description
int The number of sweep points.

Example#

vna = measmatic.get_device('device-vna')
points = vna.get_sweep_point_count()

method get_sweep_type()#

Reads the sweep type of the VNA.

Returns#

Type Description
Any The sweep type as Atv.Framework.Devices.Enumerations.VnaSweepType (Linear, Logarithmic or Segmented).

Example#

vna = measmatic.get_device('device-vna')
sweep_type = vna.get_sweep_type()

method get_trace_data(s: Any)#

Reads the data of the trace that measures the given S-parameter.

Parameters#

Name Description
s The S-parameter to read, of type Atv.Framework.Mathematics.RF.NetworkElement. A trace for it must exist.

Returns#

Type Description
Any The complex measurement values as Atv.Framework.Mathematics.RF.SubNetwork, one value per sweep point.

Example#

from Atv.Framework.Mathematics.RF import NetworkElement
vna = measmatic.get_device('device-vna')
data = vna.get_trace_data(NetworkElement.Define('S21'))

method has_option(option: str)#

Checks whether an option is installed on the VNA.

Parameters#

Name Description
option Either the full option key including a dash (for example 'ZVA-K6') or only the abbreviation (for example 'B21').

Returns#

Type Description
bool True if the option is installed, otherwise False.

Example#

vna = measmatic.get_device('device-vna')
if vna.has_option('B21'):
vna.set_source_attenuation(1, 10.0)

method load_calibration(dataFile: str)#

Loads a calibration from a file on the VNA.

Parameters#

Name Description
dataFile The calibration file name, as seen by the VNA.

Example#

vna = measmatic.get_device('device-vna')
vna.load_calibration('my_calibration')

method output_off()#

Switches the RF output of the VNA off.

Example#

vna = measmatic.get_device('device-vna')
vna.output_off()

method output_on()#

Switches the RF output of the VNA on.

Example#

vna = measmatic.get_device('device-vna')
vna.output_on()

method reset()#

Resets the VNA to its default state and switches the RF output off.

Example#

vna = measmatic.get_device('device-vna')
vna.reset()

method set_average(average: int)#

Sets the number of sweeps that are averaged. A value of 1 or less switches averaging off.

Parameters#

Name Description
average The number of averages.

Example#

vna = measmatic.get_device('device-vna')
vna.set_average(16)

method set_bandwidth(bandwidth: float)#

Sets the IF bandwidth (resolution bandwidth) of the VNA. Values below 1 Hz are set to 1 Hz.

Parameters#

Name Description
bandwidth The IF bandwidth in Hz.

Example#

vna = measmatic.get_device('device-vna')
vna.set_bandwidth(1000.0)

method set_frequency_point_count(points: int)#

Sets the number of frequency points of the sweep. At least 2 points are required.

Parameters#

Name Description
points The number of frequency points.

Example#

vna = measmatic.get_device('device-vna')
vna.set_frequency_point_count(201)

method set_frequency_sweep(startFrequency: float, stopFrequency: float, points: int)#

Defines the sweep by start frequency, stop frequency and number of points.

Parameters#

Name Description
startFrequency The start frequency in Hz.
stopFrequency The stop frequency in Hz.
points The number of frequency points.

Example#

vna = measmatic.get_device('device-vna')
vna.set_frequency_sweep(1e9, 10e9, 201)

method set_frequency_sweep_center_span(centerFrequency: float, span: float, points: int)#

Defines the sweep by center frequency, span and number of points.

Parameters#

Name Description
centerFrequency The center frequency in Hz.
span The frequency span in Hz.
points The number of frequency points.

Example#

vna = measmatic.get_device('device-vna')
vna.set_frequency_sweep_center_span(5e9, 2e9, 201)

method set_frequency_sweep_from_calibration()#

Sets the sweep to the conditions of the loaded calibration. Not implemented for the Keysight PNA, calling it raises an error.

Example#

vna = measmatic.get_device('device-vna')
vna.load_calibration('my_calibration')
vna.set_frequency_sweep_from_calibration()

method set_frequency_sweep_start_stop(startFrequency: float, stopFrequency: float, points: int)#

Defines the sweep by start frequency, stop frequency and number of points.

Parameters#

Name Description
startFrequency The start frequency in Hz.
stopFrequency The stop frequency in Hz.
points The number of frequency points.

Example#

vna = measmatic.get_device('device-vna')
vna.set_frequency_sweep_start_stop(1e9, 10e9, 201)

method set_power(power: float)#

Sets the source output power of the VNA.

Parameters#

Name Description
power The output power in dBm.

Example#

vna = measmatic.get_device('device-vna')
vna.set_power(-10.0)

method set_sense_attenuation(port: int, dbm: float)#

Sets the receiver attenuation of the given port. Requires the receiver attenuator option, otherwise an error is raised.

Parameters#

Name Description
port The port number, starting at 1.
dbm The attenuation in dB.

Example#

vna = measmatic.get_device('device-vna')
vna.set_sense_attenuation(1, 10.0)

method set_source_attenuation(port: int, dbm: float)#

Sets the source attenuation of the given port. Requires the source attenuator option, otherwise an error is raised.

Parameters#

Name Description
port The port number, starting at 1.
dbm The attenuation in dB.

Example#

vna = measmatic.get_device('device-vna')
vna.set_source_attenuation(1, 10.0)

method set_source_attenuation_auto(port: int)#

Switches the source attenuation of the given port to automatic mode.

Parameters#

Name Description
port The port number, starting at 1.

Example#

vna = measmatic.get_device('device-vna')
vna.set_source_attenuation_auto(1)

method set_start_frequency(startFrequency: float)#

Sets the start frequency of the sweep. The value must be within min_frequency and max_frequency.

Parameters#

Name Description
startFrequency The start frequency in Hz.

Example#

vna = measmatic.get_device('device-vna')
vna.set_start_frequency(1e9)

method set_stop_frequency(stopFrequency: float)#

Sets the stop frequency of the sweep. The value must be within min_frequency and max_frequency.

Parameters#

Name Description
stopFrequency The stop frequency in Hz.

Example#

vna = measmatic.get_device('device-vna')
vna.set_stop_frequency(10e9)

method set_sweep_type(sweepType: Any)#

Sets the sweep type of the VNA. Only linear, logarithmic and segmented sweeps are supported.

Parameters#

Name Description
sweepType The sweep type, of type Atv.Framework.Devices.Enumerations.VnaSweepType.

Example#

vna = measmatic.get_device('device-vna')
from Atv.Framework.Devices.Enumerations import VnaSweepType
vna.set_sweep_type(VnaSweepType.Linear)

method trigger()#

Starts a sweep and waits until it has finished on the device side.

Example#

vna = measmatic.get_device('device-vna')
vna.trigger()
vna.wait_operation_completed(10000)

method wait_operation_completed(timeoutMs: int)#

Waits until the VNA has completed all pending operations. Raises an error if the VNA does not respond in time.

Parameters#

Name Description
timeoutMs The maximum time to wait in milliseconds.

Example#

vna = measmatic.get_device('device-vna')
vna.trigger()
vna.wait_operation_completed(10000)