Agilent Signal Analyzer
Bases: VisaDriver
A driver for controlling Agilent Spectrum Analyzers via the VISA interface.
This class provides methods to control and query Agilent Spectrum Analyzers, including setting and querying frequency span, center frequency, resolution bandwidth (RBW), video bandwidth (VBW), sweep time, and data format. It also includes methods to retrieve calculated data, trace data, and maximum point data.
Usage
from driverlib.agilent import AgilentSA
agilent_sa = AgilentSA("TCPIP0::123.456.789.012::inst0::INSTR")
freqs, data = agilent_sa.get_calc_data()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource_location |
str
|
The VISA resource name used to connect to the device. |
required |
Initialize the AgilentSA object with the specified resource location.
The constructor configures the communication termination character as a newline character.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
resource_location |
str
|
The VISA resource name used to connect to the device. |
required |
Source code in driverlib/agilent/agilent_sa.py
32 33 34 35 36 37 38 39 40 |
|
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 |
|
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 |
|
print_error
print_error()
Print eventual errors occurred.
Source code in driverlib/visa_driver.py
135 136 137 |
|
reset
reset()
Reset instrument to factory default state. Does not clear volatile memory.
Source code in driverlib/visa_driver.py
139 140 141 142 |
|
clear
clear()
Clear event register, error queue -when power is cycled-.
Source code in driverlib/visa_driver.py
144 145 146 147 |
|
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 |
|
get_span
get_span()
Query the frequency span of the spectrum analyzer.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The frequency span in Hz. |
Source code in driverlib/agilent/agilent_sa.py
42 43 44 45 46 47 48 |
|
set_span
set_span(value)
Set the frequency span of the spectrum analyzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
float
|
The desired frequency span in Hz. |
required |
Source code in driverlib/agilent/agilent_sa.py
50 51 52 53 54 55 56 |
|
get_center
get_center()
Query the center frequency of the spectrum analyzer.
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The center frequency in Hz. |
Source code in driverlib/agilent/agilent_sa.py
60 61 62 63 64 65 66 |
|
set_center
set_center(value)
Set the center frequency of the spectrum analyzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
float
|
The desired center frequency in Hz. |
required |
Source code in driverlib/agilent/agilent_sa.py
68 69 70 71 72 73 74 |
|
get_rbw
get_rbw()
Query the resolution bandwidth (RBW) of the spectrum analyzer.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The RBW in Hz. |
Source code in driverlib/agilent/agilent_sa.py
78 79 80 81 82 83 84 |
|
set_rbw
set_rbw(value)
Set the resolution bandwidth (RBW) of the spectrum analyzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
int
|
The desired RBW in Hz. |
required |
Source code in driverlib/agilent/agilent_sa.py
86 87 88 89 90 91 92 |
|
get_vbw
get_vbw()
Query the video bandwidth (VBW) of the spectrum analyzer.
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
The VBW in Hz. |
Source code in driverlib/agilent/agilent_sa.py
96 97 98 99 100 101 102 |
|
set_vbw
set_vbw(value)
Set the video bandwidth (VBW) of the spectrum analyzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
int
|
The desired VBW in Hz. |
required |
Source code in driverlib/agilent/agilent_sa.py
104 105 106 107 108 109 110 |
|
get_sweep_time
get_sweep_time()
Query the sweep time of the spectrum analyzer.
Returns:
Type | Description |
---|---|
Optional[float]
|
Optional[float]: The sweep time in seconds, or None if set to auto. |
Source code in driverlib/agilent/agilent_sa.py
114 115 116 117 118 119 120 121 122 123 |
|
set_sweep_time
set_sweep_time(value)
Set the sweep time of the spectrum analyzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
Optional[float]
|
The desired sweep time in seconds, or None to set to auto. |
required |
Source code in driverlib/agilent/agilent_sa.py
125 126 127 128 129 130 131 132 133 134 |
|
get_data_format
get_data_format()
Query the data format for trace data from the spectrum analyzer.
Returns:
Name | Type | Description |
---|---|---|
_FORMATS_TYPE |
_FORMATS_TYPE
|
The current data format. |
Source code in driverlib/agilent/agilent_sa.py
138 139 140 141 142 143 144 |
|
set_data_format
set_data_format(value='ASCii')
Set the data format for trace data from the spectrum analyzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
_FORMATS_TYPE
|
The desired data format. |
'ASCii'
|
Source code in driverlib/agilent/agilent_sa.py
146 147 148 149 150 151 152 |
|
get_calc_data
get_calc_data()
Retrieve the calculated data from the spectrum analyzer.
Returns:
Type | Description |
---|---|
Tuple[ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray]: The frequencies and amplitude as np.arrays. |
Source code in driverlib/agilent/agilent_sa.py
156 157 158 159 160 161 162 163 164 165 166 167 |
|
get_trace
get_trace(trace=1)
Retrieve the trace data for a specified trace number from the spectrum analyzer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trace |
int
|
The trace number. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
np.ndarray: The trace data as a numpy array. |
Source code in driverlib/agilent/agilent_sa.py
169 170 171 172 173 174 175 176 177 178 179 |
|
get_freq_and_trace
get_freq_and_trace(trace=1, center=None, span=None)
Retrieves the trace data and corresponding frequency points from the spectrum analyzer.
This method allows specifying a trace number, and optionally the center frequency and span to use for frequency calculations. If the center frequency and span are not provided, the current settings of the spectrum analyzer are used.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trace |
int
|
The trace number to retrieve data from. Defaults to 1. |
1
|
center |
Optional[float]
|
The center frequency in Hz. If None, the current center frequency of the spectrum analyzer is used. Defaults to None. |
None
|
span |
Optional[float]
|
The frequency span in Hz. If None, the current span of the spectrum analyzer is used. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray]: A tuple containing two numpy arrays. The first array contains the trace data points, and the second contains the corresponding frequency points in Hz. |
Source code in driverlib/agilent/agilent_sa.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
get_max_point
get_max_point(marker=1)
Find the maximum point on the specified marker and returns its frequency.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
marker |
int
|
The marker number. Defaults to 1. |
1
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The frequency of the maximum point in Hz. |
Source code in driverlib/agilent/agilent_sa.py
223 224 225 226 227 228 229 230 231 232 233 |
|
set_trace_parameters_and_get
set_trace_parameters_and_get(center, span, rbw=100, vbw=30, swt=None)
Configure and measure.
This method sets the center frequency, span, resolution bandwidth (RBW), video bandwidth (VBW), and sweep time for the spectrum analyzer. It then retrieves the trace data displayed on the screen along with the corresponding frequency values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center |
float
|
Center frequency in Hz. |
required |
span |
float
|
Frequency span in Hz. |
required |
rbw |
int
|
Resolution bandwidth in Hz. Defaults to 100. |
100
|
vbw |
int
|
Video bandwidth in Hz. Defaults to 30. |
30
|
swt |
Optional[float]
|
Total sweep time in seconds. None for auto. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
Tuple[np.ndarray, np.ndarray]: A tuple containing two numpy arrays. The first array |
ndarray
|
contains the trace data, and the second contains the corresponding frequencies. |
Source code in driverlib/agilent/agilent_sa.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|