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,244 @@
1
+ """Provides methods to fetch and read the SParams 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 SParamsResults(object):
25
+ """Provides methods to fetch and read the SParams measurement results."""
26
+
27
+ def __init__(self, signal_obj):
28
+ """Provides methods to fetch and read the SParams 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 S-Parameter measurement.
36
+
37
+ Use "sparam<*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.SParamsCorrectionState):
59
+ Returns the error correction state of the VNA S-Parameter 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,
71
+ attributes.AttributeID.SPARAMS_RESULTS_CORRECTION_STATE.value,
72
+ )
73
+ attr_val = enums.SParamsCorrectionState(attr_val)
74
+ except (KeyError, ValueError):
75
+ raise errors.DriverTooNewError() # type: ignore
76
+ finally:
77
+ self._session_function_lock.exit_read_lock()
78
+
79
+ return attr_val, error_code
80
+
81
+ @_raise_if_disposed
82
+ def get_correction_level(self, selector_string):
83
+ r"""Gets the level of error correction applied to the specified S-Parameter measurement.
84
+
85
+ Use "sparam<*n*>" as the selector string to read this attribute.
86
+
87
+ +--------------+--------------------------------------------------------------------------------------------------------------------------+
88
+ | Name (value) | Description |
89
+ +==============+==========================================================================================================================+
90
+ | Uncorrected | Correction is not applied to the configured S-Parameter. |
91
+ +--------------+--------------------------------------------------------------------------------------------------------------------------+
92
+ | N-Port | Full N-Port correction is applied to the configured S-Parameter, where N refers to the number of VNA ports involved in |
93
+ | | the correction. |
94
+ +--------------+--------------------------------------------------------------------------------------------------------------------------+
95
+ | 1-Path | One Path Two Port correction is applied to the configured transmission measurement. Refer to |
96
+ | | :py:attr:`~nirfmxvna.attributes.AttributeID.CORRECTION_PORT_SUBSET_RESPONSE_PORTS` attribute for more information about |
97
+ | | one-path two-port correction. |
98
+ +--------------+--------------------------------------------------------------------------------------------------------------------------+
99
+
100
+ Args:
101
+ selector_string (string):
102
+ Pass an empty string.
103
+
104
+ Returns:
105
+ Tuple (attr_val, error_code):
106
+
107
+ attr_val (string):
108
+ Returns the level of error correction applied to the specified S-Parameter measurement.
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_string(
119
+ updated_selector_string,
120
+ attributes.AttributeID.SPARAMS_RESULTS_CORRECTION_LEVEL.value,
121
+ )
122
+ finally:
123
+ self._session_function_lock.exit_read_lock()
124
+
125
+ return attr_val, error_code
126
+
127
+ @_raise_if_disposed
128
+ def fetch_x_data(self, selector_string, timeout):
129
+ r"""Fetches an array of frequency values when you perform S-Parameter measurement with
130
+ :py:attr:`~nirfmxvna.attributes.AttributeID.SWEEP_TYPE` attribute set to **List** or **Linear** or **Segment**. It
131
+ fetches an array of time values when you perform S-Parameter measurement with
132
+ :py:attr:`~nirfmxvna.attributes.AttributeID.SWEEP_TYPE` attribute set to **CW Time**.
133
+
134
+ Args:
135
+ selector_string (string):
136
+ This parameter specifies a selector string comprising of result name.
137
+
138
+ Example:
139
+
140
+ ""
141
+
142
+ "result::r1"
143
+
144
+
145
+ timeout (float):
146
+ This parameter specifies the timeout, in seconds, for fetching the specified measurement. Set this value to an
147
+ appropriate time, longer than expected for fetching the measurement.A value of -1 specifies that the method waits until
148
+ the measurement is complete. The default value is 10.
149
+
150
+ Returns:
151
+ Tuple (x, error_code):
152
+
153
+ x (float):
154
+ This parameter returns X-Axis Data.
155
+
156
+ error_code (int):
157
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
158
+ """
159
+ try:
160
+ self._session_function_lock.enter_read_lock()
161
+ _helper.validate_not_none(selector_string, "selector_string")
162
+ updated_selector_string = _helper.validate_and_update_selector_string(
163
+ selector_string, self._signal_obj
164
+ )
165
+ x, error_code = self._interpreter.s_params_fetch_x_data(
166
+ updated_selector_string, timeout
167
+ )
168
+ finally:
169
+ self._session_function_lock.exit_read_lock()
170
+
171
+ return x, error_code
172
+
173
+ @_raise_if_disposed
174
+ def fetch_y_data(self, selector_string, timeout):
175
+ r"""Fetches the S-Parameter data for all :py:attr:`~nirfmxvna.attributes.AttributeID.SPARAMS_FORMAT` types.
176
+
177
+ Use "sparam<*n*>" as the selector string to read results from this method.
178
+
179
+ For different :py:attr:`~nirfmxvna.attributes.AttributeID.SPARAMS_FORMAT`, the data is returned as follows:
180
+
181
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
182
+ | SParam Format | Y1 | Y2 |
183
+ +======================+========================================================================+=============================================================================+
184
+ | Magnitude (0) | Magnitude of the S-Parameter data | Empty array |
185
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
186
+ | Phase (1) | Phase of the S-Parameter data | Empty array |
187
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
188
+ | Complex (2) | Real part of the complex S-Parameter data | Imaginary part of the complex S-Parameter data |
189
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
190
+ | SWR (3) | Standing wave ratio computed from the S-Parameter data | Empty array |
191
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
192
+ | Smith Impedance (4) | Real part of the complex impedance computed from the S-Parameter data | Imaginary part of the complex impedance computed from the S-Parameter data |
193
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
194
+ | Smith Admittance (5) | Real part of the complex admittance computed from the S-Parameter data | Imaginary part of the complex admittance computed from the S-Parameter data |
195
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
196
+ | Polar (6) | Magnitude of the S-Parameter data | Phase of the S-Parameter data |
197
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
198
+ | Group Delay (7) | Group delay computed from the S-Parameter data | Empty array |
199
+ +----------------------+------------------------------------------------------------------------+-----------------------------------------------------------------------------+
200
+
201
+ Args:
202
+ selector_string (string):
203
+ This parameter specifies a selector string comprising of result name, and S-Parameter number.
204
+
205
+ Example:
206
+
207
+ "sparam0"
208
+
209
+ "result::r1/sparam0"
210
+
211
+ You can use the :py:meth:`build_s_parameter_string` method to build the selector string.
212
+
213
+ timeout (float):
214
+ This parameter specifies the timeout, in seconds, for fetching the specified measurement. Set this value to an
215
+ appropriate time, longer than expected for fetching the measurement.A value of -1 specifies that the method waits until
216
+ the measurement is complete. The default value is 10.
217
+
218
+ Returns:
219
+ Tuple (y1, y2, error_code):
220
+
221
+ y1 (float):
222
+ This parameter returns Y1 data array. You can refer to the method description for interpreting Y data based on
223
+ :py:attr:`~nirfmxvna.attributes.AttributeID.SPARAMS_FORMAT` type.
224
+
225
+ y2 (float):
226
+ This parameter returns Y2 data array. You can refer to the method description for interpreting Y data based on
227
+ :py:attr:`~nirfmxvna.attributes.AttributeID.SPARAMS_FORMAT` type.
228
+
229
+ error_code (int):
230
+ Returns the status code of this method. The status code either indicates success or describes a warning condition.
231
+ """
232
+ try:
233
+ self._session_function_lock.enter_read_lock()
234
+ _helper.validate_not_none(selector_string, "selector_string")
235
+ updated_selector_string = _helper.validate_and_update_selector_string(
236
+ selector_string, self._signal_obj
237
+ )
238
+ y1, y2, error_code = self._interpreter.s_params_fetch_y_data(
239
+ updated_selector_string, timeout
240
+ )
241
+ finally:
242
+ self._session_function_lock.exit_read_lock()
243
+
244
+ return y1, y2, error_code