Skip to content

Keysight Network Analyzer

Bases: VisaDriver

Source code in driverlib/keysight/keysight_na.py
11
12
def __init__(self, resource_location: str):
    super().__init__(resource_location, "\n")

idn property

idn

Retrieve the identification string.

Returns:

Name Type Description
str str

The identification string of the device.

close

close()

Close the connection to the device.

Source code in driverlib/visa_driver.py
114
115
116
def close(self):
    """Close the connection to the device."""
    self.rm.close()

get_error

get_error()

Retrieve the error message from the device.

Returns:

Name Type Description
str

The error message.

Source code in driverlib/visa_driver.py
127
128
129
130
131
132
133
def get_error(self):
    """Retrieve the error message from the device.

    Returns:
        str: The error message.
    """
    return self.ask("SYST:ERR?")

print_error

print_error()

Print eventual errors occurred.

Source code in driverlib/visa_driver.py
135
136
137
def print_error(self):
    """Print eventual errors occurred."""
    print(f"Errors: {self.get_error()}", end="")

reset

reset()

Reset instrument to factory default state. Does not clear volatile memory.

Source code in driverlib/visa_driver.py
139
140
141
142
def reset(self):
    """Reset instrument to factory default state. Does not clear volatile memory."""
    self.write("*RST")
    self.write("*WAI")

clear

clear()

Clear event register, error queue -when power is cycled-.

Source code in driverlib/visa_driver.py
144
145
146
147
def clear(self):
    """Clear event register, error queue -when power is cycled-."""
    self.write("*CLS")
    self.write("*WAI")

lookup_resources

lookup_resources()

Look for all the available resources.

Source code in driverlib/visa_driver.py
149
150
151
152
153
154
155
156
157
158
159
160
def lookup_resources(self):
    """Look for all the available resources."""
    instruments = self.rm.list_resources()
    print(f"Found {len(instruments)} instruments:")
    for location in instruments:
        try:
            with OpenResource(self.rm, location, self.endline) as instr:
                idn = instr.query("*IDN?")
        except VisaIOError:
            idn = None

        print(f"Resource named: {idn if idn else 'Unable to determine'} @ '{location}'")

get_output

get_output()

Query the output state of the signal generator.

Returns:

Name Type Description
bool bool

True if the output is enabled, False otherwise.

Source code in driverlib/keysight/keysight_na.py
119
120
121
122
123
124
125
def get_output(self) -> bool:
    """Query the output state of the signal generator.

    Returns:
        bool: True if the output is enabled, False otherwise.
    """
    return bool(int(self.ask("OUTP?")))

set_output

set_output(value)

Set the output state of the signal generator.

Parameters:

Name Type Description Default
value bool | ON | OFF | 0 | 1

The desired output state. True to enable the output, False to disable it.

required
Source code in driverlib/keysight/keysight_na.py
127
128
129
130
131
132
133
134
135
136
def set_output(self, value):
    """Set the output state of the signal generator.

    Args:
        value (bool | ON | OFF | 0 | 1): The desired output state. True to enable the output, False to disable it.
    """
    if self._value_to_bool(value):
        self.write(":OUTP ON")
    else:
        self.write(":OUTP OFF")