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)
/tmp/ipykernel_581/3507968170.py in <module>
      1 from skrf.vi import vna
      2
----> 3 p =vna.PNA("TCPIP0::192.168.0.2::INSTR")
      4 p.idn

~/checkouts/readthedocs.org/user_builds/scikit-rf-jhillairet/envs/latest/lib/python3.8/site-packages/skrf/vi/vna/keysight_pna.py in __init__(self, address, **kwargs)
     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)

~/checkouts/readthedocs.org/user_builds/scikit-rf-jhillairet/envs/latest/lib/python3.8/site-packages/skrf/vi/vna/abcvna.py in __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", ""))
     90
     91         interface = str(kwargs.get("interface", None)).upper()  # GPIB, SOCKET

~/checkouts/readthedocs.org/user_builds/scikit-rf-jhillairet/envs/latest/lib/python3.8/site-packages/pyvisa/highlevel.py in __new__(cls, visa_library)
   3013         """
   3014         if not isinstance(visa_library, VisaLibraryBase):
-> 3015             visa_library = open_visa_library(visa_library)
   3016
   3017         if visa_library.resource_manager is not None:

~/checkouts/readthedocs.org/user_builds/scikit-rf-jhillairet/envs/latest/lib/python3.8/site-packages/pyvisa/highlevel.py in open_visa_library(specification)
   2922             wrapper = "ivi"
   2923         else:
-> 2924             wrapper = _get_default_wrapper()
   2925
   2926     cls = get_wrapper_class(wrapper)

~/checkouts/readthedocs.org/user_builds/scikit-rf-jhillairet/envs/latest/lib/python3.8/site-packages/pyvisa/highlevel.py in _get_default_wrapper()
   2881     except ValueError:
   2882         logger.debug("Did not find pyvisa-py package")
-> 2883     raise ValueError(
   2884         "Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py."
   2885     )

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)
/tmp/ipykernel_581/1337170554.py in <module>
----> 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)
/tmp/ipykernel_581/3350749200.py in <module>
----> 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
/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf-jhillairet/envs/latest/lib/python3.8/site-packages/IPython/html.py:12: ShimWarning: The `IPython.html` package has been deprecated since IPython 4.0. You should import from `notebook` instead. `IPython.html.widgets` has moved to `ipywidgets`.
  warn("The `IPython.html` package has been deprecated since IPython 4.0. "
[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)
/tmp/ipykernel_581/250195893.py in <module>
      2 matplotlib.use('nbagg')
      3
----> 4 freq= p.frequency
      5 f_start = freq.start/1.e9
      6 f_stop = freq.stop/1.e9

NameError: name 'p' is not defined