VNA control¶
scikit-rf has a few virtual instrument classes, located in the skrf.vi
module. This page demonstrates the basic control of a PNA
[1]:
from skrf.vi import vna
p =vna.PNA("TCPIP0::192.168.0.2::INSTR")
p.idn
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Input In [1], in <cell line: 3>()
1 from skrf.vi import vna
----> 3 p =vna.PNA("TCPIP0::192.168.0.2::INSTR")
4 p.idn
File ~/checkouts/readthedocs.org/user_builds/scikit-rf/envs/v0.23.0/lib/python3.8/site-packages/skrf/vi/vna/keysight_pna.py:36, in PNA.__init__(self, address, **kwargs)
23 def __init__(self, address=DEFAULT_VISA_ADDRESS, **kwargs):
24 """
25 initialization of PNA Class
26
(...)
34 :param kwargs:
35 """
---> 36 super(PNA, self).__init__(address, **kwargs)
37 self.resource.timeout = kwargs.get("timeout", 2000)
38 self.scpi = keysight_pna_scpi.SCPI(self.resource)
File ~/checkouts/readthedocs.org/user_builds/scikit-rf/envs/v0.23.0/lib/python3.8/site-packages/skrf/vi/vna/abcvna.py:89, in VNA.__init__(self, address, **kwargs)
87 rm = kwargs.get("resource_manager", None)
88 if not rm:
---> 89 rm = pyvisa.ResourceManager(visa_library=kwargs.get("visa_library", ""))
91 interface = str(kwargs.get("interface", None)).upper() # GPIB, SOCKET
92 if interface == "GPIB":
File ~/checkouts/readthedocs.org/user_builds/scikit-rf/envs/v0.23.0/lib/python3.8/site-packages/pyvisa/highlevel.py:2992, in ResourceManager.__new__(cls, visa_library)
2982 """Create a new resource manager tied to the specified VISA library.
2983
2984 Parameters
(...)
2989
2990 """
2991 if not isinstance(visa_library, VisaLibraryBase):
-> 2992 visa_library = open_visa_library(visa_library)
2994 if visa_library.resource_manager is not None:
2995 obj = visa_library.resource_manager
File ~/checkouts/readthedocs.org/user_builds/scikit-rf/envs/v0.23.0/lib/python3.8/site-packages/pyvisa/highlevel.py:2899, in open_visa_library(specification)
2897 wrapper = "ivi"
2898 else:
-> 2899 wrapper = _get_default_wrapper()
2901 cls = get_wrapper_class(wrapper)
2903 try:
File ~/checkouts/readthedocs.org/user_builds/scikit-rf/envs/v0.23.0/lib/python3.8/site-packages/pyvisa/highlevel.py:2858, in _get_default_wrapper()
2856 except ValueError:
2857 logger.debug("Did not find pyvisa-py package")
-> 2858 raise ValueError(
2859 "Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py."
2860 )
ValueError: Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py.
[2]:
ntwks = p.get_network_all_meas()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 ntwks = p.get_network_all_meas()
NameError: name 'p' is not defined
[3]:
[k.plot_s_db(label = k.name) for k in ntwks]
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 [k.plot_s_db(label = k.name) for k in ntwks]
NameError: name 'ntwks' is not defined
Interactive¶
[4]:
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
from IPython.display import clear_output, display, HTML
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 from IPython.html.widgets import interact, interactive, fixed
2 from IPython.html import widgets
3 from IPython.display import clear_output, display, HTML
ModuleNotFoundError: No module named 'IPython.html'
[5]:
import matplotlib
matplotlib.use('nbagg')
freq= p.frequency
f_start = freq.start/1.e9
f_stop = freq.stop/1.e9
f_npts = 101
f_range =(f_start, f_stop,1)
f_range
def dummy(f_start=f_start,f_stop=f_stop):
p.frequency = rf.Frequency(f_start, f_stop,f_npts,'ghz')
p.get_twoport().plot_s_db()
interact(dummy,f_start=f_range,f_stop=f_range)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [5], in <cell line: 4>()
1 import matplotlib
2 matplotlib.use('nbagg')
----> 4 freq= p.frequency
5 f_start = freq.start/1.e9
6 f_stop = freq.stop/1.e9
NameError: name 'p' is not defined