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.
Files changed (38) hide show
  1. nirfmxvna/__init__.py +106 -0
  2. nirfmxvna/attributes.py +2234 -0
  3. nirfmxvna/enums.py +1048 -0
  4. nirfmxvna/errors.py +96 -0
  5. nirfmxvna/examples/nirfmxvna_calibration_with_calset_save_two_port.py +186 -0
  6. nirfmxvna/examples/nirfmxvna_pulsed_s_params.py +174 -0
  7. nirfmxvna/examples/nirfmxvna_s_params_corrected_with_calset_load_two_port_grpc.py +234 -0
  8. nirfmxvna/examples/nirfmxvna_waves.py +174 -0
  9. nirfmxvna/grpc_session_options.py +64 -0
  10. nirfmxvna/internal/_custom_types.py +13 -0
  11. nirfmxvna/internal/_grpc_stub_interpreter.py +1757 -0
  12. nirfmxvna/internal/_helper.py +387 -0
  13. nirfmxvna/internal/_library.py +3790 -0
  14. nirfmxvna/internal/_library_interpreter.py +3011 -0
  15. nirfmxvna/internal/_library_singleton.py +53 -0
  16. nirfmxvna/internal/nidevice_pb2.py +37 -0
  17. nirfmxvna/internal/nidevice_pb2_grpc.py +3 -0
  18. nirfmxvna/internal/nirfmxvna_pb2.py +1094 -0
  19. nirfmxvna/internal/nirfmxvna_pb2_grpc.py +9990 -0
  20. nirfmxvna/internal/session_pb2.py +33 -0
  21. nirfmxvna/internal/session_pb2_grpc.py +3 -0
  22. nirfmxvna/iq.py +31 -0
  23. nirfmxvna/iq_configuration.py +290 -0
  24. nirfmxvna/iq_results.py +108 -0
  25. nirfmxvna/marker.py +31 -0
  26. nirfmxvna/marker_configuration.py +429 -0
  27. nirfmxvna/marker_results.py +168 -0
  28. nirfmxvna/s_params.py +31 -0
  29. nirfmxvna/s_params_configuration.py +1656 -0
  30. nirfmxvna/s_params_results.py +244 -0
  31. nirfmxvna/vna.py +12920 -0
  32. nirfmxvna/waves.py +31 -0
  33. nirfmxvna/waves_configuration.py +1255 -0
  34. nirfmxvna/waves_results.py +235 -0
  35. nirfmxvna-26.3.0.dist-info/METADATA +228 -0
  36. nirfmxvna-26.3.0.dist-info/RECORD +38 -0
  37. nirfmxvna-26.3.0.dist-info/WHEEL +4 -0
  38. nirfmxvna-26.3.0.dist-info/licenses/LICENSE +30 -0
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # source: session.proto
4
+ """Generated protocol buffer code."""
5
+ from google.protobuf import (
6
+ descriptor as _descriptor,
7
+ descriptor_pool as _descriptor_pool,
8
+ symbol_database as _symbol_database,
9
+ )
10
+ from google.protobuf.internal import builder as _builder
11
+
12
+ # @@protoc_insertion_point(imports)
13
+
14
+ _sym_db = _symbol_database.Default()
15
+
16
+
17
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
18
+ b'\n\rsession.proto\x12\rnidevice_grpc"\x17\n\x07Session\x12\x0c\n\x04name\x18\x01 \x01(\t*\xbc\x01\n\x1dSessionInitializationBehavior\x12/\n+SESSION_INITIALIZATION_BEHAVIOR_UNSPECIFIED\x10\x00\x12\x32\n.SESSION_INITIALIZATION_BEHAVIOR_INITIALIZE_NEW\x10\x01\x12\x36\n2SESSION_INITIALIZATION_BEHAVIOR_ATTACH_TO_EXISTING\x10\x02\x42\x42\n\x12\x63om.ni.grpc.deviceB\x08NiDeviceP\x01\xaa\x02\x1fNationalInstruments.Grpc.Deviceb\x06proto3'
19
+ )
20
+
21
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
22
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "session_pb2", globals())
23
+ if _descriptor._USE_C_DESCRIPTORS == False:
24
+
25
+ DESCRIPTOR._options = None
26
+ DESCRIPTOR._serialized_options = (
27
+ b"\n\022com.ni.grpc.deviceB\010NiDeviceP\001\252\002\037NationalInstruments.Grpc.Device"
28
+ )
29
+ _SESSIONINITIALIZATIONBEHAVIOR._serialized_start = 58
30
+ _SESSIONINITIALIZATIONBEHAVIOR._serialized_end = 246
31
+ _SESSION._serialized_start = 32
32
+ _SESSION._serialized_end = 55
33
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,3 @@
1
+ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
+ """Client and server classes corresponding to protobuf-defined services."""
3
+ import grpc
nirfmxvna/iq.py ADDED
@@ -0,0 +1,31 @@
1
+ """Represents the IQ measurement."""
2
+
3
+ import functools
4
+
5
+ import nirfmxvna.iq_configuration as configuration
6
+ import nirfmxvna.iq_results as results
7
+
8
+
9
+ def _raise_if_disposed(f):
10
+ """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""
11
+
12
+ @functools.wraps(f)
13
+ def aux(*xs, **kws):
14
+ meas_obj = xs[0] # parameter 0 is 'self' which is the measurement object
15
+ if meas_obj._signal_obj.is_disposed:
16
+ raise Exception("Cannot access a disposed Vna signal configuration")
17
+ return f(*xs, **kws)
18
+
19
+ return aux
20
+
21
+
22
+ class IQ(object):
23
+ """Represents the IQ measurement."""
24
+
25
+ def __init__(self, signal_obj):
26
+ """Represents the IQ measurement."""
27
+ self._signal_obj = signal_obj
28
+ self._session_function_lock = signal_obj._session_function_lock
29
+ self._interpreter = signal_obj._interpreter
30
+ self.configuration = configuration.IQConfiguration(signal_obj) # type: ignore
31
+ self.results = results.IQResults(signal_obj) # type: ignore
@@ -0,0 +1,290 @@
1
+ """Provides methods to configure the IQ measurement."""
2
+
3
+ import functools
4
+
5
+ import nirfmxvna.attributes as attributes
6
+ import nirfmxvna.internal._helper as _helper
7
+
8
+
9
+ def _raise_if_disposed(f):
10
+ """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""
11
+
12
+ @functools.wraps(f)
13
+ def aux(*xs, **kws):
14
+ meas_obj = xs[0] # parameter 0 is 'self' which is the measurement object
15
+ if meas_obj._signal_obj.is_disposed:
16
+ raise Exception("Cannot access a disposed Vna signal configuration")
17
+ return f(*xs, **kws)
18
+
19
+ return aux
20
+
21
+
22
+ class IQConfiguration(object):
23
+ """Provides methods to configure the IQ measurement."""
24
+
25
+ def __init__(self, signal_obj):
26
+ """Provides methods to configure the IQ measurement."""
27
+ self._signal_obj = signal_obj
28
+ self._session_function_lock = signal_obj._session_function_lock
29
+ self._interpreter = signal_obj._interpreter
30
+
31
+ @_raise_if_disposed
32
+ def get_measurement_enabled(self, selector_string):
33
+ r"""
34
+
35
+ Args:
36
+ selector_string (string):
37
+ Pass an empty string.
38
+
39
+ Returns:
40
+ Tuple (attr_val, error_code):
41
+
42
+ attr_val (bool):
43
+
44
+
45
+ error_code (int):
46
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
47
+ """
48
+ try:
49
+ self._session_function_lock.enter_read_lock()
50
+ updated_selector_string = _helper.validate_and_update_selector_string(
51
+ selector_string, self._signal_obj
52
+ )
53
+ attr_val, error_code = self._interpreter.get_attribute_i32(
54
+ updated_selector_string, attributes.AttributeID.IQ_MEASUREMENT_ENABLED.value
55
+ )
56
+ attr_val = bool(attr_val)
57
+ finally:
58
+ self._session_function_lock.exit_read_lock()
59
+
60
+ return attr_val, error_code
61
+
62
+ @_raise_if_disposed
63
+ def set_measurement_enabled(self, selector_string, value):
64
+ r"""
65
+
66
+ Args:
67
+ selector_string (string):
68
+ Pass an empty string.
69
+
70
+ value (bool):
71
+
72
+
73
+ Returns:
74
+ int:
75
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
76
+ """
77
+ try:
78
+ self._session_function_lock.enter_read_lock()
79
+ updated_selector_string = _helper.validate_and_update_selector_string(
80
+ selector_string, self._signal_obj
81
+ )
82
+ error_code = self._interpreter.set_attribute_i32(
83
+ updated_selector_string,
84
+ attributes.AttributeID.IQ_MEASUREMENT_ENABLED.value,
85
+ int(value),
86
+ )
87
+ finally:
88
+ self._session_function_lock.exit_read_lock()
89
+
90
+ return error_code
91
+
92
+ @_raise_if_disposed
93
+ def get_acquisition_time(self, selector_string):
94
+ r"""You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
95
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
96
+ about the string syntax for named signals.
97
+
98
+ Args:
99
+ selector_string (string):
100
+ Pass an empty string.
101
+
102
+ Returns:
103
+ Tuple (attr_val, error_code):
104
+
105
+ attr_val (float):
106
+ You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
107
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
108
+ about the string syntax for named signals.
109
+
110
+ error_code (int):
111
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
112
+ """
113
+ try:
114
+ self._session_function_lock.enter_read_lock()
115
+ updated_selector_string = _helper.validate_and_update_selector_string(
116
+ selector_string, self._signal_obj
117
+ )
118
+ attr_val, error_code = self._interpreter.get_attribute_f64(
119
+ updated_selector_string, attributes.AttributeID.IQ_ACQUISITION_TIME.value
120
+ )
121
+ finally:
122
+ self._session_function_lock.exit_read_lock()
123
+
124
+ return attr_val, error_code
125
+
126
+ @_raise_if_disposed
127
+ def set_acquisition_time(self, selector_string, value):
128
+ r"""You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
129
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
130
+ about the string syntax for named signals.
131
+
132
+ Args:
133
+ selector_string (string):
134
+ Pass an empty string.
135
+
136
+ value (float):
137
+ You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
138
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
139
+ about the string syntax for named signals.
140
+
141
+ Returns:
142
+ int:
143
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
144
+ """
145
+ try:
146
+ self._session_function_lock.enter_read_lock()
147
+ updated_selector_string = _helper.validate_and_update_selector_string(
148
+ selector_string, self._signal_obj
149
+ )
150
+ error_code = self._interpreter.set_attribute_f64(
151
+ updated_selector_string, attributes.AttributeID.IQ_ACQUISITION_TIME.value, value
152
+ )
153
+ finally:
154
+ self._session_function_lock.exit_read_lock()
155
+
156
+ return error_code
157
+
158
+ @_raise_if_disposed
159
+ def get_receiver_port(self, selector_string):
160
+ r"""You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
161
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
162
+ about the string syntax for named signals.
163
+
164
+ Args:
165
+ selector_string (string):
166
+ Pass an empty string.
167
+
168
+ Returns:
169
+ Tuple (attr_val, error_code):
170
+
171
+ attr_val (string):
172
+ You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
173
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
174
+ about the string syntax for named signals.
175
+
176
+ error_code (int):
177
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
178
+ """
179
+ try:
180
+ self._session_function_lock.enter_read_lock()
181
+ updated_selector_string = _helper.validate_and_update_selector_string(
182
+ selector_string, self._signal_obj
183
+ )
184
+ attr_val, error_code = self._interpreter.get_attribute_string(
185
+ updated_selector_string, attributes.AttributeID.IQ_RECEIVER_PORT.value
186
+ )
187
+ finally:
188
+ self._session_function_lock.exit_read_lock()
189
+
190
+ return attr_val, error_code
191
+
192
+ @_raise_if_disposed
193
+ def set_receiver_port(self, selector_string, value):
194
+ r"""You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
195
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
196
+ about the string syntax for named signals.
197
+
198
+ Args:
199
+ selector_string (string):
200
+ Pass an empty string.
201
+
202
+ value (string):
203
+ You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
204
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
205
+ about the string syntax for named signals.
206
+
207
+ Returns:
208
+ int:
209
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
210
+ """
211
+ try:
212
+ self._session_function_lock.enter_read_lock()
213
+ updated_selector_string = _helper.validate_and_update_selector_string(
214
+ selector_string, self._signal_obj
215
+ )
216
+ _helper.validate_not_none(value, "value")
217
+ error_code = self._interpreter.set_attribute_string(
218
+ updated_selector_string, attributes.AttributeID.IQ_RECEIVER_PORT.value, value
219
+ )
220
+ finally:
221
+ self._session_function_lock.exit_read_lock()
222
+
223
+ return error_code
224
+
225
+ @_raise_if_disposed
226
+ def get_source_port(self, selector_string):
227
+ r"""You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
228
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
229
+ about the string syntax for named signals.
230
+
231
+ Args:
232
+ selector_string (string):
233
+ Pass an empty string.
234
+
235
+ Returns:
236
+ Tuple (attr_val, error_code):
237
+
238
+ attr_val (string):
239
+ You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
240
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
241
+ about the string syntax for named signals.
242
+
243
+ error_code (int):
244
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
245
+ """
246
+ try:
247
+ self._session_function_lock.enter_read_lock()
248
+ updated_selector_string = _helper.validate_and_update_selector_string(
249
+ selector_string, self._signal_obj
250
+ )
251
+ attr_val, error_code = self._interpreter.get_attribute_string(
252
+ updated_selector_string, attributes.AttributeID.IQ_SOURCE_PORT.value
253
+ )
254
+ finally:
255
+ self._session_function_lock.exit_read_lock()
256
+
257
+ return attr_val, error_code
258
+
259
+ @_raise_if_disposed
260
+ def set_source_port(self, selector_string, value):
261
+ r"""You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
262
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
263
+ about the string syntax for named signals.
264
+
265
+ Args:
266
+ selector_string (string):
267
+ Pass an empty string.
268
+
269
+ value (string):
270
+ You do not need to use a selector string to configure or read this attribute for the default signal instance. Refer to
271
+ the `Selector String <https://www.ni.com/docs/en-US/bundle/rfmx/page/selector-strings-net.html>`_ topic for information
272
+ about the string syntax for named signals.
273
+
274
+ Returns:
275
+ int:
276
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
277
+ """
278
+ try:
279
+ self._session_function_lock.enter_read_lock()
280
+ updated_selector_string = _helper.validate_and_update_selector_string(
281
+ selector_string, self._signal_obj
282
+ )
283
+ _helper.validate_not_none(value, "value")
284
+ error_code = self._interpreter.set_attribute_string(
285
+ updated_selector_string, attributes.AttributeID.IQ_SOURCE_PORT.value, value
286
+ )
287
+ finally:
288
+ self._session_function_lock.exit_read_lock()
289
+
290
+ return error_code
@@ -0,0 +1,108 @@
1
+ """Provides methods to fetch and read the IQ measurement results."""
2
+
3
+ import functools
4
+
5
+ import nirfmxvna.attributes as attributes
6
+ import nirfmxvna.enums as enums
7
+ import nirfmxvna.errors as errors
8
+ import nirfmxvna.internal._helper as _helper
9
+
10
+
11
+ def _raise_if_disposed(f):
12
+ """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""
13
+
14
+ @functools.wraps(f)
15
+ def aux(*xs, **kws):
16
+ meas_obj = xs[0] # parameter 0 is 'self' which is the measurement object
17
+ if meas_obj._signal_obj.is_disposed:
18
+ raise Exception("Cannot access a disposed Vna signal configuration")
19
+ return f(*xs, **kws)
20
+
21
+ return aux
22
+
23
+
24
+ class IQResults(object):
25
+ """Provides methods to fetch and read the IQ measurement results."""
26
+
27
+ def __init__(self, signal_obj):
28
+ """Provides methods to fetch and read the IQ measurement results."""
29
+ self._signal_obj = signal_obj
30
+ self._session_function_lock = signal_obj._session_function_lock
31
+ self._interpreter = signal_obj._interpreter
32
+
33
+ @_raise_if_disposed
34
+ def get_correction_state(self, selector_string):
35
+ r"""Gets the error correction state of the VNA IQ measurement.
36
+
37
+ Use "iq<*n*>" as the selector string to read this attribute.
38
+
39
+ +-----------------------+---------------------------------------------------------------------------------------------------------------------+
40
+ | Name (Value) | Description |
41
+ +=======================+=====================================================================================================================+
42
+ | None (0) | Error correction is not applied. |
43
+ +-----------------------+---------------------------------------------------------------------------------------------------------------------+
44
+ | Corrected (1) | Error correction is applied without interpolation using the error terms from the calset. |
45
+ +-----------------------+---------------------------------------------------------------------------------------------------------------------+
46
+ | Interpolated (2) | Error correction is applied with error terms for at least one sweep point interpolated from the calset error terms. |
47
+ +-----------------------+---------------------------------------------------------------------------------------------------------------------+
48
+ | Settings Modified (3) | Settings during the measurment differ from those used during calibration. |
49
+ +-----------------------+---------------------------------------------------------------------------------------------------------------------+
50
+
51
+ Args:
52
+ selector_string (string):
53
+ Pass an empty string.
54
+
55
+ Returns:
56
+ Tuple (attr_val, error_code):
57
+
58
+ attr_val (enums.IQCorrectionState):
59
+ Returns the error correction state of the VNA IQ measurement.
60
+
61
+ error_code (int):
62
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
63
+ """
64
+ try:
65
+ self._session_function_lock.enter_read_lock()
66
+ updated_selector_string = _helper.validate_and_update_selector_string(
67
+ selector_string, self._signal_obj
68
+ )
69
+ attr_val, error_code = self._interpreter.get_attribute_i32(
70
+ updated_selector_string, attributes.AttributeID.IQ_RESULTS_CORRECTION_STATE.value
71
+ )
72
+ attr_val = enums.IQCorrectionState(attr_val)
73
+ except (KeyError, ValueError):
74
+ raise errors.DriverTooNewError() # type: ignore
75
+ finally:
76
+ self._session_function_lock.exit_read_lock()
77
+
78
+ return attr_val, error_code
79
+
80
+ @_raise_if_disposed
81
+ def fetch_data(self, selector_string, timeout, data):
82
+ r"""
83
+
84
+ Args:
85
+ selector_string (string):
86
+ timeout (float):
87
+ data (numpy.complex64):
88
+ Returns:
89
+ Tuple (x0, dx, error_code):
90
+
91
+ x0 (float):
92
+ dx (float):
93
+ error_code (int):
94
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
95
+ """
96
+ try:
97
+ self._session_function_lock.enter_read_lock()
98
+ _helper.validate_not_none(selector_string, "selector_string")
99
+ updated_selector_string = _helper.validate_and_update_selector_string(
100
+ selector_string, self._signal_obj
101
+ )
102
+ x0, dx, error_code = self._interpreter.iq_fetch_data(
103
+ updated_selector_string, timeout, data
104
+ )
105
+ finally:
106
+ self._session_function_lock.exit_read_lock()
107
+
108
+ return x0, dx, error_code
nirfmxvna/marker.py ADDED
@@ -0,0 +1,31 @@
1
+ """Represents the Marker measurement."""
2
+
3
+ import functools
4
+
5
+ import nirfmxvna.marker_configuration as configuration
6
+ import nirfmxvna.marker_results as results
7
+
8
+
9
+ def _raise_if_disposed(f):
10
+ """From https://stackoverflow.com/questions/5929107/decorators-with-parameters."""
11
+
12
+ @functools.wraps(f)
13
+ def aux(*xs, **kws):
14
+ meas_obj = xs[0] # parameter 0 is 'self' which is the measurement object
15
+ if meas_obj._signal_obj.is_disposed:
16
+ raise Exception("Cannot access a disposed Vna signal configuration")
17
+ return f(*xs, **kws)
18
+
19
+ return aux
20
+
21
+
22
+ class Marker(object):
23
+ """Represents the Marker measurement."""
24
+
25
+ def __init__(self, signal_obj):
26
+ """Represents the Marker measurement."""
27
+ self._signal_obj = signal_obj
28
+ self._session_function_lock = signal_obj._session_function_lock
29
+ self._interpreter = signal_obj._interpreter
30
+ self.configuration = configuration.MarkerConfiguration(signal_obj) # type: ignore
31
+ self.results = results.MarkerResults(signal_obj) # type: ignore