nirfmxvna 26.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nirfmxvna/__init__.py +106 -0
- nirfmxvna/attributes.py +2234 -0
- nirfmxvna/enums.py +1048 -0
- nirfmxvna/errors.py +96 -0
- nirfmxvna/examples/nirfmxvna_calibration_with_calset_save_two_port.py +186 -0
- nirfmxvna/examples/nirfmxvna_pulsed_s_params.py +174 -0
- nirfmxvna/examples/nirfmxvna_s_params_corrected_with_calset_load_two_port_grpc.py +234 -0
- nirfmxvna/examples/nirfmxvna_waves.py +174 -0
- nirfmxvna/grpc_session_options.py +64 -0
- nirfmxvna/internal/_custom_types.py +13 -0
- nirfmxvna/internal/_grpc_stub_interpreter.py +1757 -0
- nirfmxvna/internal/_helper.py +387 -0
- nirfmxvna/internal/_library.py +3790 -0
- nirfmxvna/internal/_library_interpreter.py +3011 -0
- nirfmxvna/internal/_library_singleton.py +53 -0
- nirfmxvna/internal/nidevice_pb2.py +37 -0
- nirfmxvna/internal/nidevice_pb2_grpc.py +3 -0
- nirfmxvna/internal/nirfmxvna_pb2.py +1094 -0
- nirfmxvna/internal/nirfmxvna_pb2_grpc.py +9990 -0
- nirfmxvna/internal/session_pb2.py +33 -0
- nirfmxvna/internal/session_pb2_grpc.py +3 -0
- nirfmxvna/iq.py +31 -0
- nirfmxvna/iq_configuration.py +290 -0
- nirfmxvna/iq_results.py +108 -0
- nirfmxvna/marker.py +31 -0
- nirfmxvna/marker_configuration.py +429 -0
- nirfmxvna/marker_results.py +168 -0
- nirfmxvna/s_params.py +31 -0
- nirfmxvna/s_params_configuration.py +1656 -0
- nirfmxvna/s_params_results.py +244 -0
- nirfmxvna/vna.py +12920 -0
- nirfmxvna/waves.py +31 -0
- nirfmxvna/waves_configuration.py +1255 -0
- nirfmxvna/waves_results.py +235 -0
- nirfmxvna-26.3.0.dist-info/METADATA +228 -0
- nirfmxvna-26.3.0.dist-info/RECORD +38 -0
- nirfmxvna-26.3.0.dist-info/WHEEL +4 -0
- nirfmxvna-26.3.0.dist-info/licenses/LICENSE +30 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""
|
|
2
|
+
RFmx VNA Waves Example
|
|
3
|
+
|
|
4
|
+
Steps:
|
|
5
|
+
1. Open a new RFmx session.
|
|
6
|
+
2. Configure Frequency Reference.
|
|
7
|
+
3. Configure Sweep settings: Frequency List, IF Bandwidth, and Power Level and Test Rx Attenuation
|
|
8
|
+
with different port names.
|
|
9
|
+
4. Configure Averaging.
|
|
10
|
+
5. Select Wave measurement.
|
|
11
|
+
6. Configure Number of Waves.
|
|
12
|
+
7. Configure each Wave and Format.
|
|
13
|
+
8. Configure Magnitude Units & Phase Trace Type.
|
|
14
|
+
9. Initiate the Measurement.
|
|
15
|
+
10. Read the Num Waves.
|
|
16
|
+
11. Fetch Waves X data.
|
|
17
|
+
12. Fetch Waves Y data for each Wave.
|
|
18
|
+
13. Close RFmx Session.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import argparse
|
|
22
|
+
import sys
|
|
23
|
+
|
|
24
|
+
import nirfmxinstr
|
|
25
|
+
import nirfmxvna
|
|
26
|
+
import numpy
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def example(resource_name, option_string):
|
|
30
|
+
"""VNA waves example."""
|
|
31
|
+
# Configuration parameters
|
|
32
|
+
sweep_type = nirfmxvna.SweepType.LINEAR
|
|
33
|
+
start_frequency = 1e9 # Hz
|
|
34
|
+
stop_frequency = 10e9 # Hz
|
|
35
|
+
frequency_points = 10
|
|
36
|
+
port1_power_level = -10.0 # dBm
|
|
37
|
+
port2_power_level = -10.0 # dBm
|
|
38
|
+
port1_test_receiver_attenuation = 0.0 # dB
|
|
39
|
+
port2_test_receiver_attenuation = 0.0 # dB
|
|
40
|
+
if_bandwidth = 100.0e3 # Hz
|
|
41
|
+
|
|
42
|
+
frequency_reference_source = "PXI_Clk"
|
|
43
|
+
frequency_reference_frequency = 100e6 # Hz
|
|
44
|
+
|
|
45
|
+
number_of_waves = 4
|
|
46
|
+
waves = ["a1_1", "b1_1", "a1_2", "b1_2"]
|
|
47
|
+
waves_formats = [
|
|
48
|
+
nirfmxvna.WavesFormat.MAGNITUDE,
|
|
49
|
+
nirfmxvna.WavesFormat.PHASE,
|
|
50
|
+
nirfmxvna.WavesFormat.MAGNITUDE,
|
|
51
|
+
nirfmxvna.WavesFormat.PHASE,
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
magnitude_units = nirfmxvna.WavesMagnitudeUnits.DBM
|
|
55
|
+
phase_trace_type = nirfmxvna.WavesPhaseTraceType.WRAPPED
|
|
56
|
+
|
|
57
|
+
averaging_enabled = nirfmxvna.AveragingEnabled.FALSE
|
|
58
|
+
averaging_count = 10
|
|
59
|
+
|
|
60
|
+
measurement = nirfmxvna.MeasurementTypes.WAVES
|
|
61
|
+
enable_all_traces = False
|
|
62
|
+
|
|
63
|
+
timeout = 10.0 # seconds
|
|
64
|
+
|
|
65
|
+
instr_session = None
|
|
66
|
+
vna_signal = None
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
# Create a new RFmx Session
|
|
70
|
+
instr_session = nirfmxinstr.Session(resource_name, option_string)
|
|
71
|
+
|
|
72
|
+
# Get VNA signal configuration
|
|
73
|
+
vna_signal = instr_session.get_vna_signal_configuration()
|
|
74
|
+
|
|
75
|
+
instr_session.configure_frequency_reference(
|
|
76
|
+
"", frequency_reference_source, frequency_reference_frequency
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
vna_signal.set_sweep_type("", sweep_type)
|
|
80
|
+
vna_signal.set_start_frequency("", start_frequency)
|
|
81
|
+
vna_signal.set_stop_frequency("", stop_frequency)
|
|
82
|
+
vna_signal.set_number_of_points("", frequency_points)
|
|
83
|
+
vna_signal.set_if_bandwidth("", if_bandwidth)
|
|
84
|
+
|
|
85
|
+
port_selector_string = nirfmxvna.Vna.build_port_string("", "port1")
|
|
86
|
+
vna_signal.set_power_level(port_selector_string, port1_power_level)
|
|
87
|
+
vna_signal.set_test_receiver_attenuation(
|
|
88
|
+
port_selector_string, port1_test_receiver_attenuation
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
port_selector_string = nirfmxvna.Vna.build_port_string("", "port2")
|
|
92
|
+
vna_signal.set_power_level(port_selector_string, port2_power_level)
|
|
93
|
+
vna_signal.set_test_receiver_attenuation(
|
|
94
|
+
port_selector_string, port2_test_receiver_attenuation
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
vna_signal.set_averaging_enabled("", averaging_enabled)
|
|
98
|
+
vna_signal.set_averaging_count("", averaging_count)
|
|
99
|
+
|
|
100
|
+
vna_signal.select_measurements("", measurement, enable_all_traces)
|
|
101
|
+
|
|
102
|
+
vna_signal.waves.configuration.set_number_of_waves("", number_of_waves)
|
|
103
|
+
|
|
104
|
+
for i in range(number_of_waves):
|
|
105
|
+
wave_selector_string = nirfmxvna.Vna.build_wave_string("", i)
|
|
106
|
+
vna_signal.waves.configuration.configure_wave(wave_selector_string, waves[i])
|
|
107
|
+
vna_signal.waves.configuration.set_format(wave_selector_string, waves_formats[i])
|
|
108
|
+
|
|
109
|
+
vna_signal.waves.configuration.set_magnitude_units("", magnitude_units)
|
|
110
|
+
vna_signal.waves.configuration.set_phase_trace_type("", phase_trace_type)
|
|
111
|
+
|
|
112
|
+
vna_signal.initiate("", "")
|
|
113
|
+
|
|
114
|
+
# Retrieve results
|
|
115
|
+
number_of_waves_result, error_code = vna_signal.waves.configuration.get_number_of_waves("")
|
|
116
|
+
|
|
117
|
+
waves_x_data_result, _ = vna_signal.waves.results.fetch_x_data("", timeout)
|
|
118
|
+
|
|
119
|
+
waves_y1_data_result = []
|
|
120
|
+
waves_y2_data_result = []
|
|
121
|
+
|
|
122
|
+
for i in range(number_of_waves_result):
|
|
123
|
+
wave_selector_string = nirfmxvna.Vna.build_wave_string("", i)
|
|
124
|
+
|
|
125
|
+
y1_data, y2_data, error_code = vna_signal.waves.results.fetch_y_data(
|
|
126
|
+
wave_selector_string, timeout
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
waves_y1_data_result.append(y1_data)
|
|
130
|
+
waves_y2_data_result.append(y2_data)
|
|
131
|
+
|
|
132
|
+
except Exception as e:
|
|
133
|
+
print(f"Error occurred: {e}")
|
|
134
|
+
sys.exit(1)
|
|
135
|
+
|
|
136
|
+
finally:
|
|
137
|
+
if vna_signal is not None:
|
|
138
|
+
vna_signal.dispose()
|
|
139
|
+
vna_signal = None
|
|
140
|
+
if instr_session is not None:
|
|
141
|
+
instr_session.close()
|
|
142
|
+
instr_session = None
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _parse_args():
|
|
146
|
+
parser = argparse.ArgumentParser(
|
|
147
|
+
description="VNA Waves Example",
|
|
148
|
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
149
|
+
)
|
|
150
|
+
parser.add_argument(
|
|
151
|
+
"-r",
|
|
152
|
+
"--resource",
|
|
153
|
+
type=str,
|
|
154
|
+
default="VNA",
|
|
155
|
+
help="Resource name of the VNA device",
|
|
156
|
+
)
|
|
157
|
+
parser.add_argument(
|
|
158
|
+
"-o",
|
|
159
|
+
"--option-string",
|
|
160
|
+
type=str,
|
|
161
|
+
default="",
|
|
162
|
+
help="Option string",
|
|
163
|
+
)
|
|
164
|
+
return parser.parse_args()
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def main():
|
|
168
|
+
"""Main function."""
|
|
169
|
+
args = _parse_args()
|
|
170
|
+
example(args.resource, args.option_string)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
if __name__ == "__main__":
|
|
174
|
+
main()
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""Collection of options that specifies session behaviors related to gRPC."""
|
|
2
|
+
|
|
3
|
+
from enum import IntEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SessionInitializationBehavior(IntEnum):
|
|
7
|
+
AUTO = 0
|
|
8
|
+
r"""
|
|
9
|
+
The NI gRPC Device Server will attach to an existing session with the specified name if it exists, otherwise the server
|
|
10
|
+
will initialize a new session.
|
|
11
|
+
|
|
12
|
+
Note:
|
|
13
|
+
When using the Session as a context manager and the context exits, the behavior depends on what happened when the constructor
|
|
14
|
+
was called. If it resulted in a new session being initialized on the NI gRPC Device Server, then it will automatically close the
|
|
15
|
+
server session. If it instead attached to an existing session, then it will detach from the server session and leave it open.
|
|
16
|
+
"""
|
|
17
|
+
INITIALIZE_SERVER_SESSION = 1
|
|
18
|
+
r"""
|
|
19
|
+
Require the NI gRPC Device Server to initialize a new session with the specified name.
|
|
20
|
+
|
|
21
|
+
Note:
|
|
22
|
+
When using the Session as a context manager and the context exits, it will automatically close the
|
|
23
|
+
server session.
|
|
24
|
+
"""
|
|
25
|
+
ATTACH_TO_SERVER_SESSION = 2
|
|
26
|
+
r"""
|
|
27
|
+
Require the NI gRPC Device Server to attach to an existing session with the specified name.
|
|
28
|
+
|
|
29
|
+
Note:
|
|
30
|
+
When using the Session as a context manager and the context exits, it will detach from the server session
|
|
31
|
+
and leave it open.
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class GrpcSessionOptions(object):
|
|
36
|
+
"""Collection of options that specifies session behaviors related to gRPC."""
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
grpc_channel,
|
|
41
|
+
session_name,
|
|
42
|
+
*,
|
|
43
|
+
initialization_behavior=SessionInitializationBehavior.AUTO
|
|
44
|
+
):
|
|
45
|
+
r"""Collection of options that specifies session behaviors related to gRPC.
|
|
46
|
+
|
|
47
|
+
Creates and returns an object you can pass to a Session constructor.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
grpc_channel (grpc.Channel): Specifies the channel to the NI gRPC Device Server.
|
|
51
|
+
|
|
52
|
+
session_name (str): User-specified name that identifies the driver session on the NI gRPC Device
|
|
53
|
+
Server. This is different from the resource name parameter many APIs take as a separate
|
|
54
|
+
parameter. Specifying a name makes it easy to share sessions across multiple gRPC clients.
|
|
55
|
+
You can use an empty string if you want to always initialize a new session on the server.
|
|
56
|
+
To attach to an existing session, you must specify the session name it was initialized with.
|
|
57
|
+
|
|
58
|
+
initialization_behavior (enum): Specifies whether it is acceptable to initialize a new
|
|
59
|
+
session or attach to an existing one, or if only one of the behaviors is desired.
|
|
60
|
+
The driver session exists on the NI gRPC Device Server.
|
|
61
|
+
"""
|
|
62
|
+
self.grpc_channel = grpc_channel
|
|
63
|
+
self.session_name = session_name
|
|
64
|
+
self.initialization_behavior = initialization_behavior
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Contains custom structures."""
|
|
2
|
+
|
|
3
|
+
import ctypes
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ComplexDouble(ctypes.Structure):
|
|
7
|
+
"Internal ctypes implementation detail that corresponds to NIComplexDouble in C API." ""
|
|
8
|
+
_fields_ = [("real", ctypes.c_double), ("imag", ctypes.c_double)]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ComplexSingle(ctypes.Structure):
|
|
12
|
+
"Internal ctypes implementation detail that corresponds to NIComplexSingle in C API." ""
|
|
13
|
+
_fields_ = [("real", ctypes.c_float), ("imag", ctypes.c_float)]
|