Scikit RF PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 321
At a glance
Powered by AI
The document outlines the structure and capabilities of scikit-rf, a Python package for radio frequency engineering.

The document serves as documentation for the scikit-rf Python package, describing what it is and how it can be used.

Topics covered include installation, an introduction to key concepts like networks and plotting, and chapters on specific features like networks, plotting, calibration and virtual instruments.

scikit-rf

Object Oriented RF Engineering

scikit-rf Documentation
Release dev

Alex Arsenovic

January 04, 2014


Contents

1 Installation 3
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 skrf Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Testing Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Introduction 7
2.1 Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Plotting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 NetworkSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 Virtual Instruments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.6 Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.7 Media . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

3 Networks 17
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 Creating Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Network Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4 Network Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.5 Connecting Multi-ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.6 Interpolation and Stitching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.7 Reading and Writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.8 Impedance and Admittance Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.9 Creating Networks ‘From Scratch’ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.10 Sub-Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.11 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

4 Plotting 29
4.1 Plotting Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.2 Complex Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3 Rectangular Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.4 Customizing Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.5 Saving Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

i
4.6 Misc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

5 NetworkSet 39
5.1 Creating a NetworkSet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 Accesing Network Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.3 Statistical Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.4 Plotting Uncertainty Bounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.5 Reading and Writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

6 Virtual Instruments 47

7 Calibration 49
7.1 Intro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
7.2 Creating a Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
7.3 Saving and Recalling a Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
7.4 One-Port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
7.5 Concise One-port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.6 Two-port . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.7 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

8 Media 55
8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
8.2 Creating Media Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
8.3 Working with Media’s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.4 Network Synthesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
8.5 Building Cicuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
8.6 Design Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
8.7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

9 Examples 63
9.1 Visualizing a Single Stub Matching Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
9.2 One-Port Calibration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

10 Reference 69
10.1 frequency (skrf.frequency) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
10.2 network (skrf.network) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
10.3 networkSet (skrf.networkSet) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
10.4 plotting (skrf.plotting) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
10.5 mathFunctions (skrf.mathFunctions) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
10.6 tlineFunctions (skrf.tlineFunctions) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
10.7 constants (skrf.constants) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
10.8 util (skrf.util) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
10.9 io (skrf.io) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
10.10 calibration (skrf.calibration) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
10.11 media (skrf.media) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
10.12 vi (skrf.vi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318

Python Module Index 319

ii
scikit-rf Documentation, Release dev

These tutorials are meant to give an overview of how skrf can be used. Each page can be followed along in a browser,
or downloaded as an ipython notebook

Contents 1
scikit-rf Documentation, Release dev

2 Contents
CHAPTER 1

Installation

1.1 Introduction

The requirements to run skrf are basically a Python environment setup to do numerical/scientific computing. If you
are new to development, you may want to install a pre-built scientific python IDE like Enthought’s Canopy. This will
install most requirements, as well as provide a nice environment to get started in. If you dont want use Canopy then
see Requirements.

Note: If you want to use skrf for instrument control you will need to install pyvisa as well as the NI-GPIB drivers.

1.2 skrf Installation

Once the requirements are installed, there are two choices for installing skrf:
• windows installer
• python source package
These can be found at http://scikit-rf.org/download.html
If you dont know how to install a python module and dont care to learn how, you want the windows installer.
The current version can be accessed through github. This is mainly of interest for developers.

1.3 Testing Installation

If you can import skrf and dont recieve an error, then installation was succesful.
In [1]: import skrf as rf

Bingo. If instead you get an error like this,


In [1]: import skrf as rf
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)

3
scikit-rf Documentation, Release dev

<ipython-input-1-41c4ee663aa9> in <module>()
----> 1 import skrf as rf
\
ImportError: No module named skrf

Then installation was unsuccesful. If you need help post to the mailing list.

1.4 Requirements

1.4.1 Necessary

• python (>=2.6) http://www.python.org/


• numpy http://numpy.scipy.org/
• scipy http://www.scipy.org/
• matplotlib http://matplotlib.sourceforge.net/

1.4.2 Optional

• ipython http://ipython.scipy.org/moin/ - for interactive shell


• pyvisa http://pyvisa.sourceforge.net/pyvisa/ - for instrument control
• pandas http://pandas.pydata.org/ - for xls spreadsheet export
• xlrd/xlwt http://www.python-excel.org/ - for xls reading/writing

1.4.3 Debian-Based Linux

For debian-based linux users who dont want to install pythonxy, here is a one-shot line to install all requirements,
sudo apt-get install python-pyvisa python-numpy python-scipy python-matplotlib ipython python python-

Once setuptools is installed you can install skrf through easy_install


easy_install scikit-rf

Download This Notebook: Introduction.ipynb

4 Chapter 1. Installation
CHAPTER 2

Introduction

This is a brief introduction to skrf which highlights a range of features without going into detail on any single one.
At the end of each section there are links to other tutorials, that provide more information about a given feature. The
intended audience are those who have a working python stack, and are somewhat familiar with python. If you are
completely new to python, see scipy’s Getting Started
These tutorials are most easily followed by using the ipython shell with the –pylab flag,
>ipython --pylab
In [1]:

or with the ipython notebook. Using ipython with the pylab flag imports several commonly used functions, and turns
on interactive plotting mode which causes plots to display immediately.
Throughout this tutorial, and the rest of the scikit-rf documentation, it is assumed that skrf has been imported as rf.
Whether or not you follow this convention in your own code is up to you.
from pylab import *
import skrf as rf

If this produces an error, please see the Installation tutorial.

2.1 Details

2.1.1 Styling Plots

skrf has a function which updates your matplotlib rcParams so that plots appear like the ones shown in these tutorials.

#rf.stylely({’savefig.dpi’:120})

2.1.2 A Note about the data used in this example

The example code in these tutorials make use of files that are distributed with the source package. The working
directory for these code snippets is scikit-rf/doc/, hence all data files are referenced relative to that directory. If you do
not have the source package, then you may access these files through the skrf.data module (ie from skrf.data import
ring_slot)

5
scikit-rf Documentation, Release dev

2.2 Networks

The Network object represents a N-port microwave Network. A Network can be created in a number of ways.
One way is from data stored in a touchstone file. Lets load one from the directory skrf/data/.
import os
touchstone_file = os.path.join(rf.data.pwd,’ring slot.s2p’)
ring_slot = rf.Network(touchstone_file)

A short description of the network will be printed out if entered onto the command line
ring_slot

2-Port Network: ’ring slot’, 75-110 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]

The basic attributes of a microwave Network are provided by the following properties
• Network.s : Scattering Parameter matrix.
• Network.z0 : Port Characterisic Impedance matrix.
• Network.frequency : Frequency Object.
All of the network parameters are complex numpy.ndarray ‘s of shape FxNxN, where F is the number of frequency
points and N is the number of ports. The Network object has numerous other properties and methods which can found
in the Network docstring. If you are using IPython, then these properties and methods can be ‘tabbed’ out on the
command line.
In [1]: short.s<TAB>
rf.data.line.s rf.data.line.s_arcl rf.data.line.s_im
rf.data.line.s11 rf.data.line.s_arcl_unwrap rf.data.line.s_mag
...

2.2.1 Linear Operations

Element-wise mathematical operations on the scattering parameter matrices are accessible through overloaded opera-
tors. To illustrate their usage, load a couple Networks stored in the data module.
short = rf.data.wr2p2_short

delayshort = rf.data.wr2p2_delayshort
short - delayshort

1-Port Network: ’wr2p2,short’, 330-500 GHz, 201 pts, z0=[ 50.+0.j]

short + delayshort

1-Port Network: ’wr2p2,short’, 330-500 GHz, 201 pts, z0=[ 50.+0.j]

2.2.2 Cascading and De-embedding

Cascading and de-embeding 2-port Networks can also be done though operators. The cascade() function can
be called through the power operator, **. To calculate a new network which is the cascaded connection of the two
individual Networks line and short,

6 Chapter 2. Introduction
scikit-rf Documentation, Release dev

short = rf.data.wr2p2_short
line = rf.data.wr2p2_line
delayshort = line ** short

De-embedding can be accomplished by cascading the inverse of a network. The inverse of a network is accessed
through the property Network.inv. To de-embed the short from delay_short,
short = line.inv ** delayshort

For more information on the functionality provided by the Network object, such as interpolation, stitching, n-port
connections, and IO support see the Networks tutorial.

2.3 Plotting

Amongst other things, the methods of the Network class provide convenient ways to plot components of the network
parameters,
• Network.plot_s_db : plot magnitude of s-parameters in log scale
• Network.plot_s_deg : plot phase of s-parameters in degrees
• Network.plot_s_smith : plot complex s-parameters on Smith Chart
• ...
To plot all four s-parameters of the ring_slot in Mag, Phase, and on the Smith Chart.
ring_slot.plot_s_db()

ring_slot.plot_s_deg()

2.3. Plotting 7
scikit-rf Documentation, Release dev

ring_slot.plot_s_smith()

For more detailed information about plotting see the Plotting tutorial

2.4 NetworkSet

The NetworkSet object represents an unordered set of networks and provides methods for calculating statistical
quantities and displaying uncertainty bounds.
A NetworkSet is created from a list or dict of Network‘s. This can be done quickly with read_all() , which

8 Chapter 2. Introduction
scikit-rf Documentation, Release dev

loads all skrf-readable objects in a directory. The argument contains is used to load only files which match a given
substring.
rf.read_all(rf.data.pwd, contains=’ro’)

{’ro,1’: 1-Port Network: ’ro,1’, 500-750 GHz, 201 pts, z0=[ 50.+0.j],
’ro,2’: 1-Port Network: ’ro,2’, 500-750 GHz, 201 pts, z0=[ 50.+0.j],
’ro,3’: 1-Port Network: ’ro,3’, 500-750 GHz, 201 pts, z0=[ 50.+0.j]}

This can be passed directly to the NetworkSet constructor,


ro_dict = rf.read_all(rf.data.pwd, contains=’ro’)
ro_ns = rf.NetworkSet(ro_dict, name=’ro set’) #name is optional
ro_ns

A NetworkSet of length 3

2.4.1 Statistical Properties

Statistical quantities can be calculated by accessing properties of the NetworkSet. For example, to calculate the
complex average of the set, access the mean_s property
ro_ns.mean_s

1-Port Network: ’ro set’, 500-750 GHz, 201 pts, z0=[ 50.+0.j]

Similarly, to calculate the complex standard deviation of the set,


ro_ns.std_s

1-Port Network: ’ro set’, 500-750 GHz, 201 pts, z0=[ 50.+0.j]

These methods return a Network object, so the results can be saved or plotted in the same way as you would with a
Network. To plot the magnitude of the standard deviation of the set,
ro_ns.std_s.plot_s_mag()
ylabel(’Standard Deviation’)
title(’Standard Deviation of RO’);

2.4. NetworkSet 9
scikit-rf Documentation, Release dev

2.4.2 Plotting Uncertainty Bounds

Uncertainty bounds on any network parameter can be plotted through the methods
figure();
ro_ns.plot_uncertainty_bounds_s_db();

/usr/lib/pymodules/python2.7/matplotlib/axes.py:6851: ComplexWarning: Casting complex values to real


X[0] = start
/usr/lib/pymodules/python2.7/matplotlib/axes.py:6852: ComplexWarning: Casting complex values to real
X[N+1] = end
/usr/lib/pymodules/python2.7/matplotlib/axes.py:6855: ComplexWarning: Casting complex values to real
X[1:N+1,1] = y1slice
/usr/lib/pymodules/python2.7/matplotlib/axes.py:6857: ComplexWarning: Casting complex values to real
X[N+2:,1] = y2slice[::-1]
/usr/lib/python2.7/dist-packages/numpy/core/numeric.py:320: ComplexWarning: Casting complex values to
return array(a, dtype, copy=False, order=order)

10 Chapter 2. Introduction
scikit-rf Documentation, Release dev

See the NetworkSet tutorial for more information.

2.5 Virtual Instruments

...warning:
The vi module is not well written or tested at this point.

The vi module holds classes for GPIB/VISA instruments that are intricately related to skrf, mostly VNA’s. The VNA
classes were created for the sole purpose of retrieving data so that calibration and measurements could be carried out
offline by skrf, control of most other VNA capabilities is neglected.
• To use the virtual instrument classes you must have pyvisa installed.
A list of VNA’s that have been are partially supported.
* :class:‘~vna.HP8510C‘
* :class:‘~vna.HP8720‘
* :class:‘~vna.PNA‘
* :class:‘~vna.ZVA40‘

An example usage of the HP8510C class to retrieve some s-parameter data


from skrf.vi import vna
my_vna = vna.HP8510C(address =16)
#if an error is thrown at this point there is most likely a problem with your visa setup

dut_1 = my_vna.s11
dut_2 = my_vna.s21
dut_3 = my_vna.two_port

Unfortunately, the syntax is different for every VNA class, so the above example wont directly translate to other VNA’s.

2.5. Virtual Instruments 11


scikit-rf Documentation, Release dev

Re-writing all of the VNA classes to follow the same convention is on the [TODO list] (https://github.com/scikit-
rf/scikit-rf/blob/develop/TODO.rst)
See the virtualInstruments tutorial for more information.

2.6 Calibration

skrf has support for one and two-port calibration. skrf‘s default calibration algorithms are generic in that they will
work with any set of standards. If you supply more calibration standards than is needed, skrf will implement a simple
least-squares solution. skrf does not currently support TRL.
Calibrations are performed through a Calibration class. Creating a Calibration object requires at least two
pieces of information:
• a list of measured Network‘s
• a list of ideal Network‘s
The Network elements in each list must all be similar (same #ports, frequency info, etc) and must be aligned to each
other, meaning the first element of ideals list must correspond to the first element of measured list.
Optionally, other information can be provided when relevent such as,
• calibration algorithm
• enforce eciprocity of embedding networks
• etc
When this information is not provided skrf will determine it through inspection, or use a default value.
Below is an example script illustrating how to create a Calibration . See the Calibration tutorial for more details
and examples.

2.6.1 One Port Calibration

import skrf as rf
from skf.calibration import OnePort

my_ideals = rf.read_all(’ideals/’)
my_measured = rf.read_all(’measured/’)
duts = rf.read_all(’measured/’)

## create a Calibration instance


cal = rf.OnePort(\
ideals = [my_ideals[k] for k in [’short’,’open’,’load’]],
measured = [my_measured[k] for k in [’short’,’open’,’load’]],
)

caled_duts = [cal.apply_cal(dut) for dut in duts.values()]

2.7 Media

skrf supports the microwave network synthesis based on transmission line models. Network creation is accomplished
through methods of the Media class, which represents a transmission line object for a given medium. Once constructed,

12 Chapter 2. Introduction
scikit-rf Documentation, Release dev

a Media object contains the neccesary properties such as propagation constant and characteristic impedance, that are
needed to generate microwave circuits.
The basic usage looks something like this,
freq = rf.Frequency(75,110,101,’ghz’)
cpw = rf.media.CPW(freq, w=10e-6, s=5e-6, ep_r=10.6)
cpw.line(100*1e-6, name = ’100um line’)

2-Port Network: ’100um line’, 75-110 GHz, 101 pts, z0=[ 50.06074662+0.j 50.06074662+0.j]

Warning: The network creation and connection syntax of skrf are cumbersome if you need to doing complex
circuit design. For a this type of application, you may be interested in using QUCS_ instead. skrf‘s synthesis
cabilities lend themselves more to scripted applications such as Design Optimization or batch processing.

2.7.1 Media Types

Specific instances of Media objects can be created from relevant physical and electrical properties. Below is a list of
mediums types supported by skrf,
• CPW
• RectangularWaveguide
• Freespace
• DistributedCircuit
• Media

2.7.2 Network Components

Here is a brief list of some generic network components skrf supports,


• match()
• short()
• open()
• load()
• line()
• thru()
• tee()
• delay_short()
• shunt_delay_open()
Usage of these methods can is demonstrated below.
To create a 1-port network for a coplanar waveguide short (this neglects dicontinuity effects),
cpw.short(name = ’short’)

1-Port Network: ’short’, 75-110 GHz, 101 pts, z0=[ 50.06074662+0.j]

Or to create a 90◦ section of cpw line,


cpw.line(d=90,unit=’deg’, name=’line’)

2-Port Network: ’line’, 75-110 GHz, 101 pts, z0=[ 50.06074662+0.j 50.06074662+0.j]

See Media for more information about the Media object and network creation.

2.7. Media 13
scikit-rf Documentation, Release dev

http://www.qucs.sourceforge.net
Introduction.ipynb

14 Chapter 2. Introduction
CHAPTER 3

Networks

#.. contents:
.. ipython::

suppress
In [144]: from pylab import *
In [145]: ion()
In [146]: rcParams[’savefig.dpi’] =120
In [147]: rcParams[’figure.figsize’] = [4,3]
In [147]: rcParams[’figure.subplot.left’] = 0.15
In [147]: clf()

3.1 Introduction

For this tutorial, and the rest of the scikit-rf documentation, it is assumed that skrf has been imported as rf. Whether
or not you follow this convention in your own code is up to you.
In [1]: import skrf as rf

If this produces an error, please see Installation. The code in this tutorial assumes that you are in the directory scikit-
rf/doc.

3.2 Creating Networks

skrf provides an object for a N-port microwave Network. A Network can be created in a number of ways. One
way is from data stored in a touchstone file.
In [1]: ring_slot = rf.Network(’../skrf/data/ring slot.s2p’)
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
<ipython-input-1-98e45ed389ab> in <module>()
----> 1 ring_slot = rf.Network(’../skrf/data/ring slot.s2p’)

15
scikit-rf Documentation, Release dev

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
408 # open file in ’binary’ mode because we are going to try and
409 # upickle it first
--> 410 fid = get_fid(file,’rb’)
411
412 try:

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
133 ’’’
134 if isinstance(file, basestring):
--> 135 return open(file, *args, **kwargs)
136 else:
137 return file

IOError: [Errno 2] No such file or directory: ’../skrf/data/ring slot.s2p’

A short description of the network will be printed out if entered onto the command line
In [1]: ring_slot
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-5c1cb2d95a36> in <module>()
----> 1 ring_slot

NameError: name ’ring_slot’ is not defined

Networks can also be created from a pickled Network (written by Network.write()),


In [1]: ring_slot = rf.Network(’../skrf/data/ring slot.ntwk’)
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
<ipython-input-1-b84a7c83c2f3> in <module>()
----> 1 ring_slot = rf.Network(’../skrf/data/ring slot.ntwk’)

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
408 # open file in ’binary’ mode because we are going to try and
409 # upickle it first
--> 410 fid = get_fid(file,’rb’)
411
412 try:

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
133 ’’’
134 if isinstance(file, basestring):
--> 135 return open(file, *args, **kwargs)
136 else:
137 return file

IOError: [Errno 2] No such file or directory: ’../skrf/data/ring slot.ntwk’

or from directly passing values for the frequency, s-paramters and z0.
In [1]: custom_ntwk = rf.Network(f = [1,2,3], s= [-1, 1j, 0], z0=50)

Seen Network.__init__() for more informaition on network creation.

16 Chapter 3. Networks
scikit-rf Documentation, Release dev

3.3 Network Basics

The basic attributes of a microwave Network are provided by the following properties :
• Network.s : Scattering Parameter matrix.
• Network.z0 : Port Characteristic Impedance matrix.
• Network.frequency : Frequency Object.
All of the network parameters are represented internally as complex numpy.ndarray ‘s of shape FxNxN, where F
is the number of frequency points and N is the number of ports.
In [1]: shape(ring_slot.s)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-d3f838fde0d4> in <module>()
----> 1 shape(ring_slot.s)

NameError: name ’ring_slot’ is not defined

Note that the indexing starts at 0, so the first 10 values of S11 can be accessed with
In [1]: ring_slot.s[:10,0,0]
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-8675dfeb1617> in <module>()
----> 1 ring_slot.s[:10,0,0]

NameError: name ’ring_slot’ is not defined

The Network object has numerous other properties and methods which can found in the Network docstring. If you
are using IPython, then these properties and methods can be ‘tabbed’ out on the command line.
In [1]: short.s<TAB>
rf.data.line.s rf.data.line.s_arcl rf.data.line.s_im
rf.data.line.s11 rf.data.line.s_arcl_unwrap rf.data.line.s_mag
...

Note: Although this tutorial focuses on s-parametes, other network representations such as Impedance (Network.z)
and Admittance Parameters (Network.y) are available as well, see Impedance and Admittance Parameters .

Amongst other things, the methods of the Network class provide convenient ways to plot components of the network
parameters,
• Network.plot_s_db() : plot magnitude of s-parameters in log scale
• Network.plot_s_deg() : plot phase of s-parameters in degrees
• Network.plot_s_smith() : plot complex s-parameters on Smith Chart
• ...
To plot all four s-parameters of the ring_slot on the Smith Chart.
In [1]: ring_slot.plot_s_smith();

3.3. Network Basics 17


scikit-rf Documentation, Release dev

Or plot a pair of s-parameters individually, in log magnitude


In [1]: figure();

In [2]: ring_slot.plot_s_db(m=1, n=0); # s21


---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-120f9a14e6c6> in <module>()
----> 1 ring_slot.plot_s_db(m=1, n=0); # s21

NameError: name ’ring_slot’ is not defined

In [3]: ring_slot.plot_s_db(m=0, n=0); # s11


---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-9ad94c88b833> in <module>()
----> 1 ring_slot.plot_s_db(m=0, n=0); # s11

NameError: name ’ring_slot’ is not defined

18 Chapter 3. Networks
scikit-rf Documentation, Release dev

For more detailed information about plotting see Plotting.

3.4 Network Operators

3.4.1 Linear Operations

Element-wise mathematical operations on the scattering parameter matrices are accessible through overloaded opera-
tors. To illustrate their usage, load a couple Networks stored in the data module.
In [1]: short = rf.data.wr2p2_short

In [2]: delayshort = rf.data.wr2p2_delayshort

In [3]: short - delayshort


Out[3]: 1-Port Network: ’wr2p2,short’, 330-500 GHz, 201 pts, z0=[ 50.+0.j]

In [4]: short + delayshort


Out[4]: 1-Port Network: ’wr2p2,short’, 330-500 GHz, 201 pts, z0=[ 50.+0.j]

In [5]: short * delayshort


Out[5]: 1-Port Network: ’wr2p2,short’, 330-500 GHz, 201 pts, z0=[ 50.+0.j]

In [6]: short / delayshort


Out[6]: 1-Port Network: ’wr2p2,short’, 330-500 GHz, 201 pts, z0=[ 50.+0.j]

In [7]: short / delayshort


Out[7]: 1-Port Network: ’wr2p2,short’, 330-500 GHz, 201 pts, z0=[ 50.+0.j]

All of these operations return Network types, so the methods and properties of a Network are available on the
result. For example, to plot the complex difference between short and delay_short,
In [1]: figure();

In [2]: difference = (short- delayshort)

In [3]: difference.plot_s_mag()

3.4. Network Operators 19


scikit-rf Documentation, Release dev

Another common application is calculating the phase difference using the division operator,
In [1]: figure();

In [2]: (delayshort/short).plot_s_deg()

Linear operators can also be used with scalars or an numpy.ndarray that ais the same length as the Network.
In [1]: open = (short*-1)

In [2]: open.s[:3,...]
Out[2]:
array([[[ 1.-0.j]],

[[ 1.-0.j]],

[[ 1.-0.j]]])

20 Chapter 3. Networks
scikit-rf Documentation, Release dev

In [3]: rando = open *rand(len(open))

In [4]: rando.s[:3,...]
Out[4]:
array([[[ 0.44559823+0.j]],

[[ 0.82269825+0.j]],

[[ 0.15599348+0.j]]])

Note that if you multiply a Network by an numpy.ndarray be sure to place the array on right side.

3.4.2 Cascading and De-embedding

Cascading and de-embeding 2-port Networks can also be done though operators. The cascade() function can
be called through the power operator, **. To calculate a new network which is the cascaded connection of the two
individual Networks line and short,
In [1]: short = rf.data.wr2p2_short

In [2]: line = rf.data.wr2p2_line

In [3]: delayshort = line ** short

De-embedding can be accomplished by cascading the inverse of a network. The inverse of a network is accessed
through the property Network.inv. To de-embed the short from delay_short,
In [1]: short = line.inv ** delayshort

3.5 Connecting Multi-ports

skrf supports the connection of arbitrary ports of N-port networks. It accomplishes this using an algorithm called
sub-network growth 1 , available through the function connect(). Terminating one port of an ideal 3-way splitter
can be done like so,
In [1]: tee = rf.Network(’../skrf/data/tee.s3p’)
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
<ipython-input-1-7ef027af4bd0> in <module>()
----> 1 tee = rf.Network(’../skrf/data/tee.s3p’)

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
408 # open file in ’binary’ mode because we are going to try and
409 # upickle it first
--> 410 fid = get_fid(file,’rb’)
411
412 try:

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
133 ’’’
134 if isinstance(file, basestring):
--> 135 return open(file, *args, **kwargs)
1 Compton, R.C.; , “Perspectives in microwave circuit analysis,” Circuits and Systems, 1989., Proceedings of the 32nd Midwest Symposium on

, vol., no., pp.716-718 vol.2, 14-16 Aug 1989. URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=101955&isnumber=3167

3.5. Connecting Multi-ports 21


scikit-rf Documentation, Release dev

136 else:
137 return file

IOError: [Errno 2] No such file or directory: ’../skrf/data/tee.s3p’

To connect port 1 of the tee, to port 0 of the delay short,


In [1]: terminated_tee = rf.connect(tee,1,delayshort,0)
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-1-2cf62d61ac01> in <module>()
----> 1 terminated_tee = rf.connect(tee,1,delayshort,0)

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
2527 ’’’
2528 # some checking
-> 2529 check_frequency_equal(ntwkA,ntwkB)
2530
2531 # create output Network, from copy of input

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
3836 ’’’
3837 if assert_frequency_equal(ntwkA,ntwkB) == False:
-> 3838 raise IndexError(’Networks dont have matching frequency. See ‘Network.interpolate‘’)
3839
3840 def check_z0_equal(ntwkA,ntwkB):

IndexError: Networks dont have matching frequency. See ‘Network.interpolate‘

Note that this function takes into account port impedances, and if connecting ports have different port impedances an
appropriate impedance mismatch is inserted.

3.6 Interpolation and Stitching

A common need is to change the number of frequency points of a Network. For instance, to use the operators and
cascading functions the networks involved must have matching frequencies. If two networks have different frequency
information, then an error will be raised,
In [1]: line = rf.data.wr2p2_line.copy()

In [2]: line1 = rf.data.wr2p2_line1.copy()

In [3]: line1
Out[3]: 2-Port Network: ’wr2p2,line1’, 330-500 GHz, 101 pts, z0=[ 50.+0.j 50.+0.j]

In [4]: line
Out[4]: 2-Port Network: ’wr2p2,line’, 330-500 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]

In [5]: line1+line
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-5-82040f7eab08> in <module>()
----> 1 line1+line

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
513

22 Chapter 3. Networks
scikit-rf Documentation, Release dev

514 if isinstance(other, Network):


--> 515 self.__compatable_for_scalar_operation_test(other)
516 result.s = self.s + other.s
517 else:

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
641 ’’’
642 if other.frequency != self.frequency:
--> 643 raise IndexError(’Networks must have same frequency. See ‘Network.interpolate‘’)
644
645 if other.s.shape != self.s.shape:

IndexError: Networks must have same frequency. See ‘Network.interpolate‘

This problem can be solved by interpolating one of Networks, using Network.resample().


In [1]: line1
Out[1]: 2-Port Network: ’wr2p2,line1’, 330-500 GHz, 101 pts, z0=[ 50.+0.j 50.+0.j]

In [2]: line1.resample(201)

In [3]: line1
Out[3]: 2-Port Network: ’wr2p2,line1’, 330-500 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]

In [4]: line1+line
Out[4]: 2-Port Network: ’wr2p2,line1’, 330-500 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]

A related application is the need to combine Networks which cover different frequency ranges. Two Netwoks can
be stitched together using stitch(), which concatenates their s-parameter matrices along their frequency axis. To
combine a WR-2.2 Network with a WR-1.5 Network,
In [1]: from skrf.data import wr2p2_line, wr1p5_line

In [2]: line = rf.stitch(wr2p2_line, wr1p5_line)

In [3]: line
Out[3]: 2-Port Network: ’wr2p2,line’, 330-750 GHz, 402 pts, z0=[ 50.+0.j 50.+0.j]

3.7 Reading and Writing

While skrf supports reading and writing the touchstone file format, it also provides native IO capabilities for any
skrf object through the functions read() and write(). These functions can also be called through the Network
methods Network.read() and Network.write(). The Network constructor (Network.__init__() )
calls read() implicitly if a skrf file is passed.
In [1]: line = rf.Network(’../skrf/data/line.s2p’)
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
<ipython-input-1-6b24e2842934> in <module>()
----> 1 line = rf.Network(’../skrf/data/line.s2p’)

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
408 # open file in ’binary’ mode because we are going to try and
409 # upickle it first
--> 410 fid = get_fid(file,’rb’)
411

3.7. Reading and Writing 23


scikit-rf Documentation, Release dev

412 try:

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
133 ’’’
134 if isinstance(file, basestring):
--> 135 return open(file, *args, **kwargs)
136 else:
137 return file

IOError: [Errno 2] No such file or directory: ’../skrf/data/line.s2p’

In [2]: line.write() # write out Network using native IO


line.ntwk

In [3]: rf.Netwrok(’line.ntwk’) # read Network using native IO

Frequently there is an entire directory of files that need to be analyzed. The function read_all() is used to create
objects from all files in a directory quickly. Given a directory of skrf-readable files, read_all() returns a dict
with keys equal to the filenames, and values equal to objects. To load all skrf files in the skrf/data/ directory which
contain the string ‘wr2p2’.
In [1]: dict_o_ntwks = rf.read_all(’../skrf/data/’, contains = ’wr2p2’)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-1-fe2c0eb22851> in <module>()
----> 1 dict_o_ntwks = rf.read_all(’../skrf/data/’, contains = ’wr2p2’)

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
261
262 out={}
--> 263 for filename in os.listdir(dir):
264 if contains is not None and contains not in filename:
265 continue

OSError: [Errno 2] No such file or directory: ’../skrf/data/’

In [2]: dict_o_ntwks
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-2-c353202a1b92> in <module>()
----> 1 dict_o_ntwks

NameError: name ’dict_o_ntwks’ is not defined

read_all() has a companion function, write_all() which takes a dictionary of skrf objects, and writes each
object to an individual file.
In [1]: rf.write_all(dict_o_ntwks, dir = ’.’)

In [2]: ls
wr2p2,delayshort.ntwk wr2p2,line.ntwk wr2p2,short.ntwk

It is also possible to write a dictionary of objects to a single file, by using write(),


In [1]: rf.write(’dict_o_ntwk.p’, dict_o_ntwks)

In [2]: ls
dict_o_ntwk.p

24 Chapter 3. Networks
scikit-rf Documentation, Release dev

A similar function save_sesh(), can be used to save all skrf objects in the current namespace.

3.8 Impedance and Admittance Parameters

This tutorial focuses on s-parameters, but other network represenations are available as well. Impedance and
Admittance Parameters can be accessed through the parameters Network.z and Network.y, respectively.
Scalar components of complex parameters, such as Network.z_re, Network.z_im and plotting methods like
Network.plot_z_mag() are available as well.
In [1]: ring_slot.z[:3,...]
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-7f10ec33de02> in <module>()
----> 1 ring_slot.z[:3,...]

NameError: name ’ring_slot’ is not defined

In [2]: figure();

In [3]: ring_slot.plot_z_im(m=1,n=0)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-3-404fa4ed4520> in <module>()
----> 1 ring_slot.plot_z_im(m=1,n=0)

NameError: name ’ring_slot’ is not defined

3.9 Creating Networks ‘From Scratch’

A Network can be created from scratch by passing values of relevant properties as keyword arguments to the con-
structor,
In [1]: frequency = rf.Frequency(75,110,101,’ghz’)

3.8. Impedance and Admittance Parameters 25


scikit-rf Documentation, Release dev

In [2]: s = -1*ones(101)

In [3]: wr10_short = rf.Network(frequency = frequency, s = s, z0 = 50 )

For more information creating Networks representing transmission line and lumped components, see the media
module.

3.10 Sub-Networks

Frequently, the one-port s-parameters of a multiport network’s are of interest. These can be accessed by the sub-
network properties, which return one-port Network objects,
In [1]: port1_return = line.s11

In [2]: port1_return
Out[2]: 1-Port Network: ’wr2p2,line’, 330-750 GHz, 402 pts, z0=[ 50.+0.j]

3.11 References

26 Chapter 3. Networks
CHAPTER 4

Plotting

Contents
• Plotting
– Plotting Methods
– Complex Plots
* Smith Chart
* Complex Plane
– Rectangular Plots
* Log-Magnitude
* Phase
* Impedance, Admittance
– Customizing Plots
– Saving Plots
– Misc
* Adding Markers to Lines
* Formating Plots

4.1 Plotting Methods

Network plotting abilities are implemented as methods of the Network class. Some of the plotting functions of
network s-parameters are,
• Network.plot_s_re()
• Network.plot_s_im()
• Network.plot_s_mag()
• Network.plot_s_db()
• Network.plot_s_deg()
• Network.plot_s_deg_unwrap()
• Network.plot_s_rad()
• Network.plot_s_rad_unwrap()
• Network.plot_s_smith()
• Network.plot_s_complex()
Similar methods exist for Impedance (Network.z) and Admittance Parameters (Network.y),

27
scikit-rf Documentation, Release dev

• Network.plot_z_re()
• Network.plot_z_im()
• ...
• Network.plot_y_re()
• Network.plot_z_im()
• ...
Step-by-step examples of how to create and customize plots are given below.

4.2 Complex Plots

4.2.1 Smith Chart

As a first example, load a Network from the data module, and plot all four s-parameters on the Smith chart.
In [1]: import skrf as rf

In [2]: from skrf.data import ring_slot

In [3]: ring_slot
Out[3]: 2-Port Network: ’ring slot’, 75-110 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]

In [4]: ring_slot.plot_s_smith()

Note: If you dont see any plots after issuing these commands, then you may not have started ipython with the –pylab
flag. Try from pylab import * to import the matplotlib commands and ion() to turn on interactive plotting. See this
page , for more info on ipython’s pylab mode.

Note: Why do my plots look different? See Formating Plots

The smith chart can be drawn with some impedance values labeled through the draw_labels argument.

28 Chapter 4. Plotting
scikit-rf Documentation, Release dev

In [1]: figure();

In [2]: ring_slot.plot_s_smith(draw_labels=True)

Another common option is to draw addmitance contours, instead of impedance. This is controled through the
chart_type argument.
In [1]: figure();

In [2]: ring_slot.plot_s_smith(chart_type=’y’)

See smith() for more info on customizing the Smith Chart.

Note: If more than one plot_s_smith() command is issued on a single figure, you may need to call draw() to refresh
the chart.

4.2. Complex Plots 29


scikit-rf Documentation, Release dev

4.2.2 Complex Plane

Network parameters can also be plotted in the complex plane without a Smith Chart through
Network.plot_s_complex().
In [1]: figure();

In [2]: ring_slot.plot_s_complex();

4.3 Rectangular Plots

4.3.1 Log-Magnitude

Scalar components of the complex network parameters can be plotted vs frequency as well. To plot the log-magnitude
of the s-parameters vs. frequency,
In [1]: figure();

In [2]: ring_slot.plot_s_db()

30 Chapter 4. Plotting
scikit-rf Documentation, Release dev

When no arguments are passed to the plotting methods, all parameters are plotted. Single parameters can be plotted
by passing indecies m and n to the plotting commands (indexing start from 0). Comparing the simulated reflection
coefficient off the ring slot to a measurement,
In [1]: from skrf.data import ring_slot_meas

In [2]: figure();

In [3]: ring_slot.plot_s_db(m=0,n=0) # s11

In [4]: ring_slot_meas.plot_s_db(m=0,n=0) # s11

See Customizing Plots for more information on customization.

4.3.2 Phase

Plot phase,

4.3. Rectangular Plots 31


scikit-rf Documentation, Release dev

In [1]: figure();

In [2]: ring_slot.plot_s_deg()

Or unwrapped phase,
In [1]: figure();

In [2]: ring_slot.plot_s_deg_unwrap()

4.3.3 Impedance, Admittance

The components the Impendanc and Admittance parameters can be plotted similarly,
In [1]: figure();

In [2]: ring_slot.plot_z_im()

32 Chapter 4. Plotting
scikit-rf Documentation, Release dev

In [1]: figure();

In [2]: ring_slot.plot_y_re()

4.4 Customizing Plots

The legend entries are automatically filled in with the Network’s name. The entry can be overidden by passing the
label argument to the plot method.
In [1]: figure();

In [2]: ring_slot.plot_s_db(m=0,n=0, label = ’Simulation’)

In [3]: ring_slot_meas.plot_s_db(m=0,n=0, label = ’Measured’)

4.4. Customizing Plots 33


scikit-rf Documentation, Release dev

The frequency unit used on the x-axis is automatically filled in from the Networks frequency attribute. To change
the label, change the frequency’s unit.
In [1]: ring_slot.frequency.unit = ’mhz’

Other key word arguments given to the plotting methods are passed through to the matplotlib plot() function.
In [1]: figure();

In [2]: ring_slot.plot_s_db(m=0,n=0, linewidth = 3, linestyle = ’--’, label = ’Simulation’)

In [3]: ring_slot_meas.plot_s_db(m=0,n=0, marker = ’x’, markevery = 10,label = ’Measured’)

All components of the plots can be customized through matplotlib functions.


In [1]: figure();

34 Chapter 4. Plotting
scikit-rf Documentation, Release dev

In [2]: ring_slot.plot_s_smith()

In [3]: xlabel(’Real Part’);

In [4]: ylabel(’Imaginary Part’);

In [5]: title(’Smith Chart’);

In [6]: draw();

4.5 Saving Plots

Plots can be saved in various file formats using the GUI provided by the matplotlib. However, skrf provides a conve-
nience function, called save_all_figs(), that allows all open figures to be saved to disk in multiple file formats,
with filenames pulled from each figure’s title:
>>> rf.save_all_figs(’.’, format=[’eps’,’pdf’])
./WR-10 Ringslot Array Simulated vs Measured.eps
./WR-10 Ringslot Array Simulated vs Measured.pdf

4.6 Misc

4.6.1 Adding Markers to Lines

A common need is to make a color plot, interpretable in greyscale print. There is a convenient function,
add_markers_to_lines(), which adds markers each line in a plots after the plot has been made. In this way,
adding markers to an already written set of plotting commands is easy.
In [1]: figure();

In [2]: ring_slot.plot_s_db(m=0,n=0)

In [3]: ring_slot_meas.plot_s_db(m=0,n=0)

4.5. Saving Plots 35


scikit-rf Documentation, Release dev

In [4]: rf.add_markers_to_lines()

4.6.2 Formating Plots

It is likely that your plots dont look exactly like the ones in this tutorial. This is because matplotlib supports a
vast amount of customization. Formating options can be customized on-the-fly by modifying values of the rcParams
dictionary. Once these are set to your liking they can be saved to your .matplotlibrc file.
Here are some relevant parameters which should get your plots looking close to the ones in this tutorial:
my_params = {
’figure.dpi’: 120,
’figure.figsize’: [4,3],
’figure.subplot.left’ : 0.15,
’figure.subplot.right’ : 0.9,
’figure.subplot.bottom’ : 0.12,
’axes.titlesize’ : ’medium’,
’axes.labelsize’ : 10 ,
’ytick.labelsize’ :’small’,
’xtick.labelsize’ :’small’,
’legend.fontsize’ : 8 #small,
’legend.loc’ : ’best’,
’font.size’ : 10.0,
’font.family’ : ’serif’,
’text.usetex’ : True, # if you have latex
}

rcParams.update(my_params)

The project mpltools provides a way to switch between pre-defined styles, and contains other useful plotting-related
features.

36 Chapter 4. Plotting
CHAPTER 5

NetworkSet

Contents
• NetworkSet
– Creating a NetworkSet
– Accesing Network Methods
– Statistical Properties
– Plotting Uncertainty Bounds
– Reading and Writing

The NetworkSet object represents an unordered set of networks and provides methods for calculating statistical
quantities and displaying uncertainty bounds.

5.1 Creating a NetworkSet

For this example, assume that numerous measurements of a single network are made. These measurements have been
retrieved from a VNA and are in the form of touchstone files. A set of example data can be found in scikit-rf/skrf/data/,
with naming convention ro,*.s1p,
In [9]: import skrf as rf

In [10]: ls ../skrf/data/ro*
ls: cannot access ../skrf/data/ro*: No such file or directory

The files ro,1.s1p , ro,2.s1p, ... are redundant measurements on which we would like to calculate statistics using the
NetworkSet class.
A NetworkSet is created from a list or dict of Network‘s. So first we need to load all of the touchstone files. This
can be done quickly with read_all() , which loads all skrf-readable objects in a directory. The argument contains
is used to load only files which match a given substring.
In [11]: rf.read_all(’../skrf/data/’, contains=’ro’)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-11-97a3022ebf44> in <module>()
----> 1 rf.read_all(’../skrf/data/’, contains=’ro’)

37
scikit-rf Documentation, Release dev

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
261
262 out={}
--> 263 for filename in os.listdir(dir):
264 if contains is not None and contains not in filename:
265 continue

OSError: [Errno 2] No such file or directory: ’../skrf/data/’

This can be passed directly to the NetworkSet constructor,


In [12]: ro_dict = rf.read_all(’../skrf/data/’, contains=’ro’)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-12-764c67ae4274> in <module>()
----> 1 ro_dict = rf.read_all(’../skrf/data/’, contains=’ro’)

/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/envs/new-docs/local/lib/python2.7/site-pac
261
262 out={}
--> 263 for filename in os.listdir(dir):
264 if contains is not None and contains not in filename:
265 continue

OSError: [Errno 2] No such file or directory: ’../skrf/data/’

In [13]: ro_ns = rf.NetworkSet(ro_dict, name=’ro set’) #name is optional


---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-13-213ecf8ea88e> in <module>()
----> 1 ro_ns = rf.NetworkSet(ro_dict, name=’ro set’) #name is optional

NameError: name ’ro_dict’ is not defined

In [14]: ro_ns
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-14-3e1af8578b16> in <module>()
----> 1 ro_ns

NameError: name ’ro_ns’ is not defined

A NetworkSet can also be constructed from zipfile of touchstones through the class method
NetworkSet.from_zip()

5.2 Accesing Network Methods

The Network elements in a NetworkSet can be accessed like the elements of list,
In [15]: ro_ns[0]
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-15-b0862044ecb9> in <module>()
----> 1 ro_ns[0]

NameError: name ’ro_ns’ is not defined

38 Chapter 5. NetworkSet
scikit-rf Documentation, Release dev

Most Network methods are also methods of NetworkSet. These methods are called on each Network element
individually. For example to plot the log-magnitude of the s-parameters of each Network, (see Plotting for details on
Network ploting methods).
In [16]: ro_ns.plot_s_db(label=’Mean Response’)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-16-951799c60e50> in <module>()
----> 1 ro_ns.plot_s_db(label=’Mean Response’)

NameError: name ’ro_ns’ is not defined

5.3 Statistical Properties

Statistical quantities can be calculated by accessing properties of the NetworkSet. For example, to calculate the
complex average of the set, access the mean_s property
In [17]: ro_ns.mean_s
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-17-855108637269> in <module>()
----> 1 ro_ns.mean_s

NameError: name ’ro_ns’ is not defined

Note: Because the statistical operator methods are generated upon initialization they are not explicitly documented
in this manual.

The naming convention of the statistical operator properties are NetworkSet.function_parameter, where function is
the name of the statistical function, and parameter is the Network parameter to operate on. These methods return
a Network object, so they can be saved or plotted in the same way as you would with a Network. To plot the
log-magnitude of the complex mean response

5.3. Statistical Properties 39


scikit-rf Documentation, Release dev

In [18]: figure();

In [19]: ro_ns.mean_s.plot_s_db(label=’ro’)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-19-27acef3161cc> in <module>()
----> 1 ro_ns.mean_s.plot_s_db(label=’ro’)

NameError: name ’ro_ns’ is not defined

Or to plot the standard deviation of the complex s-parameters,


In [20]: figure();

In [21]: ro_ns.std_s.plot_s_re(y_label=’Standard Deviations’)


---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-21-45c70b9eb04a> in <module>()
----> 1 ro_ns.std_s.plot_s_re(y_label=’Standard Deviations’)

NameError: name ’ro_ns’ is not defined

40 Chapter 5. NetworkSet
scikit-rf Documentation, Release dev

Using these properties it is possible to calculate statistical quantities on the scalar components of the complex network
parameters. To calculate the mean of the phase component,
In [22]: figure();

In [23]: ro_ns.mean_s_deg.plot_s_re()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-23-8bebd802d3ba> in <module>()
----> 1 ro_ns.mean_s_deg.plot_s_re()

NameError: name ’ro_ns’ is not defined

5.4 Plotting Uncertainty Bounds

Uncertainty bounds can be plotted through the methods

5.4. Plotting Uncertainty Bounds 41


scikit-rf Documentation, Release dev

In [24]: figure();

In [25]: ro_ns.plot_uncertainty_bounds_s_db()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-25-db9f85fbe2b3> in <module>()
----> 1 ro_ns.plot_uncertainty_bounds_s_db()

NameError: name ’ro_ns’ is not defined

In [26]: figure();

In [27]: ro_ns.plot_uncertainty_bounds_s_deg()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-27-b5201c9bf074> in <module>()
----> 1 ro_ns.plot_uncertainty_bounds_s_deg()

NameError: name ’ro_ns’ is not defined

42 Chapter 5. NetworkSet
scikit-rf Documentation, Release dev

5.5 Reading and Writing

NetworkSets can be saved to disk using skrf’s native IO capabilities. This can be ccomplished through the
NetworkSet.write() method.
In [28]: ro_set.write()

In [29]: ls
ro set.ns

Note: Note that if the NetworkSet’s name attribute is not assigned, then you must provide a filename to
NetworkSet.write().

Alternatively, you can write the Network set by directly calling the write() function. In either case, the resultant
file can be read back into memory using read().
In [30]: ro_ns = rf.read(’ro set.ns’)

5.5. Reading and Writing 43


scikit-rf Documentation, Release dev

44 Chapter 5. NetworkSet
CHAPTER 6

Virtual Instruments

Contents
• Virtual Instruments

Warning: The vi module is not well written or tested at this point.

The vi module holds classes for GPIB/VISA instruments that are intricately related to skrf. Most of the classes were
created for the sole purpose of retrieving data so that calibration and measurements could be carried out offline with
skrf, therefore most other instrument capabilities are neglected.

Note: To use the virtual instrument classes you must have pyvisa installed, and a working VISA installation.

A list of VNA’s that have been are partially supported.


• HP8510C
• HP8720
• PNA
• ZVA40
An example usage of the HP8510C class to retrieve some s-parameter data
In [1]: from skrf.vi import vna

In [2]: my_vna = vna.HP8510C(address =16)

#if an error is thrown at this point there is most likely a problem with your visa setup
In [3]: dut_1 = my_vna.s11

In [4]: dut_2 = my_vna.s21

In [5]: dut_3 = my_vna.two_port

Unfortunately, the syntax is different for every VNA class, so the above example wont directly translate to other
VNA’s. Re-writing all of the VNA classes to follow the same convention is on the TODO list

45
scikit-rf Documentation, Release dev

46 Chapter 6. Virtual Instruments


CHAPTER 7

Calibration

Contents
• Calibration
– Intro
– Creating a Calibration
– Saving and Recalling a Calibration
– One-Port
– Concise One-port
– Two-port
* Switch-terms
– Example
* Using one-port ideals in two-port Calibration

7.1 Intro

This tutorial illustrates how to use skrf to calibrate data taken from a VNA. The explanation of calibration theory and
calibration kit design is beyond the scope of this tutorial. Instead, this tutorial describes how to calibrate a device under
test (DUT), assuming you have measured an acceptable set of standards, and have a coresponding set ideal responses.
skrf‘s default calibration algorithms are generic in that they will work with any set of standards. If you supply more
calibration standards than is needed, skrf will implement a simple least-squares solution.

7.2 Creating a Calibration

Calibrations are performed through a Calibration class. Creating a Calibration object requires at least two
pieces of information:
• a list of measured Network‘s
• a list of ideal Network‘s
The Network elements in each list must all be similar (same #ports, frequency info, etc) and must be aligned to each
other, meaning the first element of ideals list must correspond to the first element of measured list.

47
scikit-rf Documentation, Release dev

Optionally, other information can be provided when relevent such as,


• calibration algorithm
• enforce eciprocity of embedding networks
• etc
When this information is not provided skrf will determine it through inspection, or use a default value.

7.3 Saving and Recalling a Calibration

Like other skrf objects, Calibration‘s can be written-to and read-from disk. Writing can be accomplished by
using Calibration.write(), or rf.write(), and reading is done with rf.read().

7.4 One-Port

This example is written to be instructive, not concise.


import skrf as rf

## created necessary data for Calibration class

# a list of Network types, holding ’ideal’ responses


my_ideals = [\
rf.Network(’ideal/short.s1p’),
rf.Network(’ideal/open.s1p’),
rf.Network(’ideal/load.s1p’),
]

# a list of Network types, holding ’measured’ responses


my_measured = [\
rf.Network(’measured/short.s1p’),
rf.Network(’measured/open.s1p’),
rf.Network(’measured/load.s1p’),
]

## create a Calibration instance


cal = rf.Calibration(\
ideals = my_ideals,
measured = my_measured,
)

## run, and apply calibration to a DUT

# run calibration algorithm


cal.run()

# apply it to a dut
dut = rf.Network(’my_dut.s1p’)
dut_caled = cal.apply_cal(dut)

# plot results
dut_caled.plot_s_db()

48 Chapter 7. Calibration
scikit-rf Documentation, Release dev

# save results
dut_caled.write_touchstone()

7.5 Concise One-port

This example is the same as the first except more concise.


import skrf as rf

my_ideals = rf.load_all_touchstones_in_dir(’ideals/’)
my_measured = rf.load_all_touchstones_in_dir(’measured/’)

## create a Calibration instance


cal = rf.Calibration(\
ideals = [my_ideals[k] for k in [’short’,’open’,’load’]],
measured = [my_measured[k] for k in [’short’,’open’,’load’]],
)

## what you do with ’cal’ may may be similar to above example

7.6 Two-port

Two-port calibration is more involved than one-port. skrf supports two-port calibration using a 8-term error model
based on the algorithm described in 1 , by R.A. Speciale.
Like the one-port algorithm, the two-port calibration can handle any number of standards, providing that some fun-
damental constraints are met. In short, you need three two-port standards; one must be transmissive, and one must
provide a known impedance and be reflective.
One draw-back of using the 8-term error model formulation (which is the same formulation used in TRL) is that
switch-terms may need to be measured in order to achieve a high quality calibration (this was pointed out to me by
Dylan Williams).

7.6.1 Switch-terms

Originally described by Roger Marks 2 , switch-terms account for the fact that the error networks change slightly
depending on which port is being excited. This is due to the internal switch within the VNA.
Switch terms can be measured with a custom measurement configuration on the VNA itself. skrf has support for switch
terms for the HP8510C class, which you can use or extend to different VNA. Without switch-term measurements, your
calibration quality will vary depending on properties of you VNA.
1 Speciale, R.A.; , “A Generalization of the TSD Network-Analyzer Calibration Procedure, Covering n-Port Scattering-Parameter Measurements,

Affected by Leakage Errors,” Microwave Theory and Techniques, IEEE Transactions on , vol.25, no.12, pp. 1100- 1115, Dec 1977. URL:
http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1129282&isnumber=25047
2 Marks, Roger B.; , “Formulations of the Basic Vector Network Analyzer Error Model including Switch-Terms,” ARFTG Conference Digest-

Fall, 50th , vol.32, no., pp.115-126, Dec. 1997. URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4119948&isnumber=4119931

7.5. Concise One-port 49


scikit-rf Documentation, Release dev

7.7 Example

Two-port calibration is accomplished in an identical way to one-port, except all the standards are two-port networks.
This is even true of reflective standards (S21=S12=0). So if you measure reflective standards you must measure two of
them simultaneously, and store information in a two-port. For example, connect a short to port-1 and a load to port-2,
and save a two-port measurement as ‘short,load.s2p’ or similar:
import skrf as rf

## created necessary data for Calibration class

# a list of Network types, holding ’ideal’ responses


my_ideals = [\
rf.Network(’ideal/thru.s2p’),
rf.Network(’ideal/line.s2p’),
rf.Network(’ideal/short, short.s2p’),
]

# a list of Network types, holding ’measured’ responses


my_measured = [\
rf.Network(’measured/thru.s2p’),
rf.Network(’measured/line.s2p’),
rf.Network(’measured/short, short.s2p’),
]

## create a Calibration instance


cal = rf.Calibration(\
ideals = my_ideals,
measured = my_measured,
)

## run, and apply calibration to a DUT

# run calibration algorithm


cal.run()

# apply it to a dut
dut = rf.Network(’my_dut.s2p’)
dut_caled = cal.apply_cal(dut)

# plot results
dut_caled.plot_s_db()
# save results
dut_caled.write_touchstone()

7.7.1 Using one-port ideals in two-port Calibration

Commonly, you have data for ideal data for reflective standards in the form of one-port touchstone files (ie s1p). To
use this with skrf’s two-port calibration method you need to create a two-port network that is a composite of the two
networks. There is a function in the WorkingBand Class which will do this for you, called two_port_reflect.:
short = rf.Network(’ideals/short.s1p’)
load = rf.Network(’ideals/load.s1p’)

50 Chapter 7. Calibration
scikit-rf Documentation, Release dev

short_load = rf.two_port_reflect(short, load)

Bibliography

7.7. Example 51
scikit-rf Documentation, Release dev

52 Chapter 7. Calibration
CHAPTER 8

Media

Contents
• Media
– Introduction
* Media’s Supported by skrf
– Creating Media Objects
* Coplanar Waveguide
* Freespace
* Rectangular Waveguide
– Working with Media’s
– Network Synthesis
– Building Cicuits
– Design Optimization
– References

8.1 Introduction

skrf supports the microwave network synthesis based on transmission line models. Network creation is accomplished
through methods of the Media class, which represents a transmission line object for a given medium. Once constructed,
a Media object contains the neccesary properties such as propagation constant and characteristic impedance, that are
needed to generate microwave circuits.
This tutorial illustrates how created Networks using several different Media objects. The basic usage is,
In [1]: import skrf as rf

In [2]: freq = rf.Frequency(75,110,101,’ghz’)

In [3]: cpw = rf.media.CPW(freq, w=10e-6, s=5e-6, ep_r=10.6)

In [4]: cpw.line(100*1e-6, name = ’100um line’)


Out[4]: 2-Port Network: ’100um line’, 75-110 GHz, 101 pts, z0=[ 50.06074662+0.j 50.06074662+0.j]

More detailed examples illustrating how to create various kinds of Media objects are given below.

53
scikit-rf Documentation, Release dev

Warning: The network creation and connection syntax of skrf are cumbersome if you need to doing complex
circuit design. For a this type of application, you may be interested in using QUCS instead. skrf‘s synthesis
cabilities lend themselves more to scripted applications such as Design Optimization or batch processing.

8.1.1 Media’s Supported by skrf

The base-class, Media, is constructed directly from values of propagation constant and characteristic impedance.
Specific instances of Media objects can be created from relevant physical and electrical properties. Below is a list of
mediums types supported by skrf,
• CPW
• RectangularWaveguide
• Freespace
• DistributedCircuit
• Media

8.2 Creating Media Objects

Typically, network analysis is done within a given frequency band. When a Media object is created, it must be given
a Frequency object. This prevent having to repitously provide frequency information for each new network created.

8.2.1 Coplanar Waveguide

Here is an example of how to initialize a coplanar waveguide 1 media. The instance has a 10um center conductor, gap
of 5um, and substrate with relative permativity of 10.6,
In [1]: import skrf as rf

In [2]: freq = rf.Frequency(75,110,101,’ghz’)

In [3]: cpw = rf.media.CPW(freq, w=10e-6, s=5e-6, ep_r=10.6)

In [4]: cpw
Out[4]:
Coplanar Waveguide Media. 75-110 GHz. 101 points
W= 1.00e-05m, S= 5.00e-06m

See CPW for details on that class.

8.2.2 Freespace

Here is another example, this time constructing a plane-wave in freespace from 10-20GHz
In [1]: freq = rf.Frequency(10,20,101,’ghz’)

In [2]: fs = rf.media.Freespace(freq)

1 http://www.microwaves101.com/encyclopedia/coplanarwaveguide.cfm

54 Chapter 8. Media
scikit-rf Documentation, Release dev

In [3]: fs
Out[3]: Freespace Media. 10-20 GHz. 101 points

See Freespace for details.

8.2.3 Rectangular Waveguide

or a WR-10 Rectangular Waveguide


In [1]: freq = rf.Frequency(75,110,101,’ghz’)

In [2]: wg = rf.media.RectangularWaveguide(freq, a=100*rf.mil,z0=50) # see note below about z0

In [3]: wg
Out[3]:
Rectangular Waveguide Media. 75-110 GHz. 101 points
a= 2.54e-03m, b= 1.27e-03m

See RectangularWaveguide for details.

Note: The z0 argument in the Rectangular Waveguide constructor is used to force a specifc port impedance.
This is commonly used to match the port impedance to what a VNA stores in a touchstone file. See
media.Media.__init__() for more information.

8.3 Working with Media’s

Once constructed, the pertinent wave quantities of the media such as propagation constant and characteristic impedance
can be accessed through the properties propagation_constant and characteristic_impedance. These
properties return complex numpy.ndarray‘s,
In [1]: cpw.propagation_constant[:3]
Out[1]: array([ 0.+3785.59740815j, 0.+3803.26352939j, 0.+3820.92965062j])

In [2]: cpw.characteristic_impedance[:3]
Out[2]: array([ 50.06074662+0.j, 50.06074662+0.j, 50.06074662+0.j])

As an example, plot the cpw’s propagation constant vs frequency.


In [1]: plot(cpw.frequency.f_scaled, cpw.propagation_constant.imag);

In [2]: xlabel(’Frequency [GHz]’);

In [3]: ylabel(’Propagation Constant [rad/m]’);

8.3. Working with Media’s 55


scikit-rf Documentation, Release dev

Because the wave quantities are dynamic they change when the attributes of the cpw line change. To illustrate this,
plot the propagation constant of the cpw for various values of substrated permativity,
In [1]: figure();

In [2]: for ep_r in [9,10,11]:


...: cpw.ep_r = ep_r
...: plot(cpw.frequency.f_scaled, cpw.propagation_constant.imag, label=’er=%.1f’%ep_r)
...:

In [3]: xlabel(’Frequency [GHz]’);

In [4]: ylabel(’Propagation Constant [rad/m]’);

In [5]: legend();

In [6]: cpw.ep_r = 10.6

56 Chapter 8. Media
scikit-rf Documentation, Release dev

8.4 Network Synthesis

Networks are created through methods of a Media object. Here is a brief list of some generic network components
skrf supports,
• match()
• short()
• open()
• load()
• line()
• thru()
• tee()
• delay_short()
• shunt_delay_open()
Usage of these methods can is demonstrated below.
To create a 1-port network for a rectangular waveguide short,
In [1]: wg.short(name = ’short’)
Out[1]: 1-Port Network: ’short’, 75-110 GHz, 101 pts, z0=[ 50.+0.j]

Or to create a 90◦ section of cpw line,


In [1]: cpw.line(d=90,unit=’deg’, name=’line’)
Out[1]: 2-Port Network: ’line’, 75-110 GHz, 101 pts, z0=[ 50.06074662+0.j 50.06074662+0.j]

Note: Simple circuits like short() and open() are ideal short and opens with Γ = −1 and Γ = 1, i.e. they dont
take into account sophisticated effects of the discontinuties. Effects of discontinuities are implemented as methods
specific to a given Media, like CPW.cpw_short.

8.5 Building Cicuits

By connecting a series of simple circuits, more complex circuits can be made. To build a the 90◦ delay short, in the
rectangular waveguide media defined above.
In [1]: delay_short = wg.line(d=90,unit=’deg’) ** wg.short()

In [2]: delay_short.name = ’delay short’

In [3]: delay_short
Out[3]: 1-Port Network: ’delay short’, 75-110 GHz, 101 pts, z0=[ 50.+0.j]

When Networks with more than 2 ports need to be connected together, use rf.connect(). To create a two-port
network for a shunted delayed open, you can create an ideal 3-way splitter (a ‘tee’) and conect the delayed open to one
of its ports,
In [1]: tee = cpw.tee()

In [2]: delay_open = cpw.delay_open(40,’deg’)

8.4. Network Synthesis 57


scikit-rf Documentation, Release dev

In [3]: shunt_open = rf.connect(tee,1,delay_open,0)

If a specific circuit is created frequenctly, it may make sense to use a function to create the circuit. This can be done
most quickly using lamba
In [1]: delay_short = lambda d: wg.line(d,’deg’)**wg.short()

In [2]: delay_short(90)
Out[2]: 1-Port Network: ’’, 75-110 GHz, 101 pts, z0=[ 50.+0.j]

This is how many of skrf‘s network creation methods are made internally.
A more useful example may be to create a function for a shunt-stub tuner, that will work for any media object
In [1]: def shunt_stub(med, d0, d1):
...: return med.line(d0,’deg’)**med.shunt_delay_open(d1,’deg’)
...:

In [2]: shunt_stub(cpw,10,90)
Out[2]: 2-Port Network: ’’, 75-110 GHz, 101 pts, z0=[ 50.06074662+0.j 50.06074662+0.j]

8.6 Design Optimization

The abilities of scipy‘s optimizers can be used to automate network design. In this example, skrf is used to automate
the single stub design. First, we create a ‘cost’ function which returns somthing we want to minimize, such as the
reflection coefficient magnitude at band center. Then, one of scipy’s minimization algorithms is used to determine the
optimal parameters of the stub lengths to minimize this cost.
In [1]: from scipy.optimize import fmin

# the load we are trying to match


In [2]: load = cpw.load(rf.zl_2_Gamma0(z0=50,zl=100))

# single stub circuit generator function


In [3]: def shunt_stub(med, d0, d1):
...: return med.line(d0,’deg’)**med.shunt_delay_open(d1,’deg’)
...:

# define the cost function we want to minimize (this uses sloppy namespace)
In [4]: def cost(d):
...: return (shunt_stub(cpw,d[0],d[1]) ** load)[100].s_mag.squeeze()
...:

# initial guess of optimal delay lengths in degrees


In [5]: d0 = 120,40 # initial guess

#determine the optimal delays


In [6]: d_opt = fmin(cost,(120,40))
Optimization terminated successfully.
Current function value: 0.333333
Iterations: 65
Function evaluations: 140

In [7]: d_opt
Out[7]: array([ 1.74945025e+02, -9.55405994e-08])

58 Chapter 8. Media
scikit-rf Documentation, Release dev

8.7 References

8.7. References 59
scikit-rf Documentation, Release dev

60 Chapter 8. Media
CHAPTER 9

Examples

9.1 Visualizing a Single Stub Matching Network

9.1.1 Introduction

This example illustrates a way to visualize the design space for a single stub matching network. The matching Network
consists of a shunt and series stub arranged as shown below, (image taken from R.M. Weikle’s Notes).
A single stub matching network can be designed to produce maximum power transfer to the load, ZL at a single
frequency. The matching network has two design parameters:
• length of series tline
• length of shunt tline
This script illustrates how to create a plot of reflection coefficient magnitude, vs series and shunt line lengths. The
optimal designs are then seen as the minima of a 2D surface.

9.1.2 Script

import skrf as rf
from pylab import *

# Inputs
wg = rf.wr10 # The Media class
f0 = 90 # Design Frequency in GHz
d_start, d_stop = 0,180 # span of tline lengths [degrees]
n = 21 # number of points
Gamma0 = .5 # the reflection coefficient off the load we are matching

# change wg.frequency so we only simulat at f0


wg.frequency = rf.Frequency(f0,f0,1,’ghz’)
# create load network
load = wg.load(.5)
# the vector of possible line-lengths to simulate at
d_range = linspace(d_start,d_stop,n)

61
scikit-rf Documentation, Release dev

Figure 9.1: Single stub matching Network

62 Chapter 9. Examples
scikit-rf Documentation, Release dev

def single_stub(wg, d):


’’’
function to return series-shunt stub matching network, given a
WorkingBand and the electrical lengths of the stubs
’’’
return wg.shunt_delay_open(d[1],’deg’) ** wg.line(d[0],’deg’)

# loop through all line-lengths for series and shunt tlines, and store
# reflection coefficient magnitude in array
output = array([[ (single_stub(wg, [d0,d1])**load).s_mag[0,0,0] \
for d0 in d_range] for d1 in d_range] )

### Plots

# show the resultant return loss for the parameters space in 2D


figure()
title(’Series-Shunt Stub Matching Network Design Space (2D)’)
imshow(output)
xlabel(’Series T-line [deg]’)
ylabel(’Shunt T-line [deg]’)
xticks(range(0,n+1,n/5),d_range[0::n/5])
yticks(range(0,n+1,n/5),d_range[0::n/5])
cbar = colorbar()
cbar.set_label(’Return Loss Magnitude’)
grid(False)

# show the resultant return loss for the parameters space in 3D


from mpl_toolkits.mplot3d import Axes3D

fig=figure()
ax = Axes3D(fig)
x,y = meshgrid(d_range, d_range)
ax.plot_surface(x,y,output, rstride=1, cstride=1,cmap=cm.jet)
ax.set_xlabel(’Series T-line [deg]’)
ax.set_ylabel(’Shunt T-line[deg]’)
ax.set_zlabel(’Return Loss Magnitude’)
ax.set_title(r’Series-Shunt Stub Matching Network Design Space (3D)’)

show()

9.1. Visualizing a Single Stub Matching Network 63


scikit-rf Documentation, Release dev

Series-Shunt Stub Matching Network Design Space (2D) 1.0


0.0
0.9
36.0 0.8
0.7

Return Loss Magnitude


Shunt T-line [deg]

72.0
0.6
0.5
108.0
0.4

144.0 0.3
0.2
180.0 0.1
0.0 36.0 72.0 108.0 144.0 180.0
Series T-line [deg]

64 Chapter 9. Examples
scikit-rf Documentation, Release dev

Series-Shunt Stub Matching Network Design Space (3D)

1.0

Return Loss Magnitude


0.8

0.6

0.4

0.2
0.0
180
160
140
120 g]
0 20 100 e
40 60 80 line[d
60 T-
Series T80 100 120 40 hunt
-line [d 20 S
eg] 140 160 180 0

9.2 One-Port Calibration

9.2.1 Instructive

This example is written to be instructive, not concise.:


import skrf as rf

## created necessary data for Calibration class

# a list of Network types, holding ’ideal’ responses


my_ideals = [\
rf.Network(’ideal/short.s1p’),
rf.Network(’ideal/open.s1p’),
rf.Network(’ideal/load.s1p’),
]

# a list of Network types, holding ’measured’ responses


my_measured = [\
rf.Network(’measured/short.s1p’),
rf.Network(’measured/open.s1p’),
rf.Network(’measured/load.s1p’),

9.2. One-Port Calibration 65


scikit-rf Documentation, Release dev

## create a Calibration instance


cal = rf.Calibration(\
ideals = my_ideals,
measured = my_measured,
)

## run, and apply calibration to a DUT

# run calibration algorithm


cal.run()

# apply it to a dut
dut = rf.Network(’my_dut.s1p’)
dut_caled = cal.apply_cal(dut)

# plot results
dut_caled.plot_s_db()
# save results
dut_caled.write_touchstone()

9.2.2 Concise

This example is meant to be the same as the first except more concise:
import skrf as rf

my_ideals = rf.load_all_touchstones_in_dir(’ideals/’)
my_measured = rf.load_all_touchstones_in_dir(’measured/’)

## create a Calibration instance


cal = rf.Calibration(\
ideals = [my_ideals[k] for k in [’short’,’open’,’load’]],
measured = [my_measured[k] for k in [’short’,’open’,’load’]],
)

## what you do with ’cal’ may may be similar to above example

66 Chapter 9. Examples
CHAPTER 10

Reference

10.1 frequency (skrf.frequency)

Provides a frequency object and related functions.


Most of the functionality is provided as methods and properties of the Frequency Class.

10.1.1 Frequency Class

Frequency([start, stop, npoints, unit, ...]) A frequency band.

skrf.frequency.Frequency

class skrf.frequency.Frequency(start=0, stop=0, npoints=0, unit=’ghz’, sweep_type=’lin’)


A frequency band.
The frequency object provides a convenient way to work with and access a frequency band. It contains a
fruequency vector as well as a frequency unit. This allows a frequency vector in a given unit to be available
(f_scaled), as well as an absolute frquency axis in ‘Hz’ (f).
A Frequency object can be created from either (start, stop, npoints) using the default constructor, __init__().
Or, it can be created from an arbitrary frequency vector by using the class method from_f().
Internally, the frequency information is stored in the f property combined with the unit property. All other
properties, start stop, etc are generated from these.

Attributes

center Center frequency in Hz


f Frequency vector in Hz
f_scaled Frequency vector in units of unit
multiplier Multiplier for formating axis
multiplier_dict
Continued on next page

67
scikit-rf Documentation, Release dev

Table 10.2 – continued from previous page


npoints starting frequency in Hz
span the frequency span
start starting frequency in Hz
step the inter-frequency step size
stop starting frequency in Hz
t time vector in s.
t_ns time vector in ns.
unit Unit of this frequency band.
unit_dict
w Frequency vector in radians/s

skrf.frequency.Frequency.center

Frequency.center
Center frequency in Hz
Returns center : number
the exact center frequency in units of unit

skrf.frequency.Frequency.f

Frequency.f
Frequency vector in Hz
Returns f : numpy.ndarray
The frequency vector in Hz
See Also:

f_scaled frequency vector in units of unit


w angular frequency vector in rad/s

skrf.frequency.Frequency.f_scaled

Frequency.f_scaled
Frequency vector in units of unit
Returns f_scaled : numpy.ndarray
A frequency vector in units of unit
See Also:

f frequency vector in Hz
w frequency vector in rad/s

68 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.frequency.Frequency.multiplier

Frequency.multiplier
Multiplier for formating axis
This accesses the internal dictionary multiplier_dict using the value of unit
Returns multiplier : number
multiplier for this Frequencies unit

skrf.frequency.Frequency.multiplier_dict

Frequency.multiplier_dict = {‘hz’: 1, ‘khz’: 1000.0, ‘mhz’: 1000000.0, ‘thz’: 1000000000000.0, ‘ghz’: 1000000000.0}

skrf.frequency.Frequency.npoints

Frequency.npoints
starting frequency in Hz

skrf.frequency.Frequency.span

Frequency.span
the frequency span

skrf.frequency.Frequency.start

Frequency.start
starting frequency in Hz

skrf.frequency.Frequency.step

Frequency.step
the inter-frequency step size

skrf.frequency.Frequency.stop

Frequency.stop
starting frequency in Hz

skrf.frequency.Frequency.t

Frequency.t
time vector in s.
t_period = 1/f_step

10.1. frequency (skrf.frequency) 69


scikit-rf Documentation, Release dev

skrf.frequency.Frequency.t_ns

Frequency.t_ns
time vector in ns.
t_period = 1/f_step

skrf.frequency.Frequency.unit

Frequency.unit
Unit of this frequency band.
Possible strings for this attribute are: ‘hz’, ‘khz’, ‘mhz’, ‘ghz’, ‘thz’
Setting this attribute is not case sensitive.
Returns unit : string
lower-case string representing the frequency units

skrf.frequency.Frequency.unit_dict

Frequency.unit_dict = {‘hz’: ‘Hz’, ‘khz’: ‘KHz’, ‘mhz’: ‘MHz’, ‘thz’: ‘THz’, ‘ghz’: ‘GHz’}

skrf.frequency.Frequency.w

Frequency.w
Frequency vector in radians/s
The frequency vector in rad/s
Returns w : numpy.ndarray
The frequency vector in rad/s
See Also:

f_scaled frequency vector in units of unit


f frequency vector in Hz

Methods

__init__ Frequency initializer.


copy returns a new copy of this frequency
from_f Alternative constructor of a Frequency object from a frequency
labelXAxis Label the x-axis of a plot.
overlap Calculates overlapping frequency between self and f2 ..
round_to Round off frequency values to a specfied precision.

70 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.frequency.Frequency.__init__

Frequency.__init__(start=0, stop=0, npoints=0, unit=’ghz’, sweep_type=’lin’)


Frequency initializer.
Creates a Frequency object from start/stop/npoints and a unit. Alternatively, the class method from_f() can
be used to create a Frequency object from a frequency vector instead.
Parameters start : number
start frequency in units of unit
stop : number
stop frequency in units of unit
npoints : int
number of points in the band.
unit : [’hz’,’khz’,’mhz’,’ghz’]
frequency unit of the band. This is used to create the attribute f_scaled. It is also
used by the Network class for plots vs. frequency.
See Also:

from_f constructs a Frequency object from a frequency vector instead of start/stop/npoints.

Notes

The attribute unit sets the property freqMultiplier, which is used to scale the frequency when f_scaled is refer-
enced.

Examples

>>> wr1p5band = Frequency(500,750,401, ’ghz’)

skrf.frequency.Frequency.copy

Frequency.copy()
returns a new copy of this frequency

skrf.frequency.Frequency.from_f

classmethod Frequency.from_f(f, *args, **kwargs)


Alternative constructor of a Frequency object from a frequency vector, the unit of which is set by kwarg ‘unit’
Parameters f : array-like
frequency vector
*args, **kwargs : arguments, keyword arguments
passed on to __init__().
Returns myfrequency : Frequency object

10.1. frequency (skrf.frequency) 71


scikit-rf Documentation, Release dev

the Frequency object

Examples

>>> f = np.linspace(75,100,101)
>>> rf.Frequency.from_f(f, unit=’ghz’)

skrf.frequency.Frequency.labelXAxis

Frequency.labelXAxis(ax=None)
Label the x-axis of a plot.
Sets the labels of a plot using matplotlib.x_label() with string containing the frequency unit.
Parameters ax : matplotlib.Axes, optional
Axes on which to label the plot, defaults what is returned by matplotlib.gca()

skrf.frequency.Frequency.overlap

Frequency.overlap(f2)
Calculates overlapping frequency between self and f2
See Also:
overlap_freq

skrf.frequency.Frequency.round_to

Frequency.round_to(val=’hz’)
Round off frequency values to a specfied precision.
This is useful for dealing with finite precision limitations of VNA’s and/or other software
Parameters val : string or number
if val is a string it should be a frequency unit (ie ‘hz’, ‘mhz’,etc). if its a number, then
this returns f = f-f%val

Examples

>>>f = skrf.Frequency.from_f([.1,1.2,3.5],unit=’hz’) >>>f.round_to(‘hz’)

10.1.2 Functions

overlap_freq(f1, f2) Calculates overlapping frequency between f1 and f2.

skrf.frequency.overlap_freq

skrf.frequency.overlap_freq(f1, f2)
Calculates overlapping frequency between f1 and f2.

72 Chapter 10. Reference


scikit-rf Documentation, Release dev

Or, put more accurately, this returns a Frequency that is the part of f1 that is overlapped by f2. The resultant start
frequency is the smallest f1.f that is greater than f2.f.start, and likewise for the the stop-frequency. This way the
new frequency overlays onto f1.
Parameters f1 : Frequency
a frequency object
f2 : Frequency
a frequency object
Returns f3 : Frequency
part of f1 that is overlapped by f2

10.2 network (skrf.network)

Provides a n-port network class and associated functions.


Most of the functionality in this module is provided as methods and properties of the Network Class.

10.2.1 Network Class

Network([file, name, comments, f_unit]) A n-port electrical network [#]_.

skrf.network.Network

class skrf.network.Network(file=None, name=None, comments=None, f_unit=None, **kwargs)


A n-port electrical network 1 .
For instructions on how to create Network see __init__().
A n-port network may be defined by three quantities,
• network parameter matrix (s, z, or y-matrix)
• port characteristic impedance matrix
• frequency information
The Network class stores these data structures internally in the form of complex numpy.ndarray‘s. These
arrays are not interfaced directly but instead through the use of the properties:
Property Meaning
s scattering parameter matrix
z0 characteristic impedance matrix
f frequency vector
Although these docs focus on s-parameters, other equivalent network representations such as z and y are avail-
able. Scalar projections of the complex network parameters are accesable through properties as well. These also
return numpy.ndarray‘s.
1 http://en.wikipedia.org/wiki/Two-port_network

10.2. network (skrf.network) 73


scikit-rf Documentation, Release dev

Property Meaning
s_re real part of the s-matrix
s_im imaginary part of the s-matrix
s_mag magnitude of the s-matrix
s_db magnitude in log scale of the s-matrix
s_deg phase of the s-matrix in degrees
The following operations act on the networks s-matrix.
Operator Function
+ element-wise addition of the s-matrix
- element-wise difference of the s-matrix
* element-wise multiplication of the s-matrix
/ element-wise division of the s-matrix
** cascading (only for 2-ports)
// de-embedding (for 2-ports, see inv)
Different components of the Network can be visualized through various plotting methods. These methods can
be used to plot individual elements of the s-matrix or all at once. For more info about plotting see the Plotting
tutorial.
Method Meaning
plot_s_smith() plot complex s-parameters on smith chart
plot_s_re() plot real part of s-parameters vs frequency
plot_s_im() plot imaginary part of s-parameters vs frequency
plot_s_mag() plot magnitude of s-parameters vs frequency
plot_s_db() plot magnitude (in dB) of s-parameters vs frequency
plot_s_deg() plot phase of s-parameters (in degrees) vs frequency
plot_s_deg_unwrap() plot phase of s-parameters (in unwrapped degrees) vs frequency
Network objects can be created from a touchstone or pickle file (see __init__()), by a Media object, or
manually by assigning the network properties directly. Network objects can be saved to disk in the form of
touchstone files with the write_touchstone() method.
An exhaustive list of Network Methods and Properties (Attributes) are given below

References

Attributes

a Active scattering parameter matrix.


a_arcl The arcl component of the a-matrix ..
a_arcl_unwrap The arcl_unwrap component of the a-matrix ..
a_db The db component of the a-matrix ..
a_db10 The db10 component of the a-matrix ..
a_deg The deg component of the a-matrix ..
a_deg_unwrap The deg_unwrap component of the a-matrix ..
a_im The im component of the a-matrix ..
a_mag The mag component of the a-matrix ..
a_passivity The passivity component of the a-matrix ..
a_rad The rad component of the a-matrix ..
a_rad_unwrap The rad_unwrap component of the a-matrix ..
a_re The re component of the a-matrix ..
Continued on next page

74 Chapter 10. Reference


scikit-rf Documentation, Release dev

Table 10.6 – continued from previous page


a_reciprocity The reciprocity component of the a-matrix ..
a_time The time component of the a-matrix ..
a_time_db The time_db component of the a-matrix ..
a_time_mag The time_mag component of the a-matrix ..
a_vswr The vswr component of the a-matrix ..
f the frequency vector for the network, in Hz.
frequency frequency information for the network.
inv a Network object with ‘inverse’ s-parameters.
nports the number of ports the network has.
number_of_ports the number of ports the network has.
passivity passivity metric for a multi-port network.
port_tuples Returns a list of tuples, for each port index pair
reciprocity reciprocity metric for a multi-port network.
s Scattering parameter matrix.
s11 one-port sub-network.
s12 one-port sub-network.
s21 one-port sub-network.
s22 one-port sub-network.
s_arcl The arcl component of the s-matrix ..
s_arcl_unwrap The arcl_unwrap component of the s-matrix ..
s_db The db component of the s-matrix ..
s_db10 The db10 component of the s-matrix ..
s_deg The deg component of the s-matrix ..
s_deg_unwrap The deg_unwrap component of the s-matrix ..
s_im The im component of the s-matrix ..
s_mag The mag component of the s-matrix ..
s_passivity The passivity component of the s-matrix ..
s_rad The rad component of the s-matrix ..
s_rad_unwrap The rad_unwrap component of the s-matrix ..
s_re The re component of the s-matrix ..
s_reciprocity The reciprocity component of the s-matrix ..
s_time The time component of the s-matrix ..
s_time_db The time_db component of the s-matrix ..
s_time_mag The time_mag component of the s-matrix ..
s_vswr The vswr component of the s-matrix ..
t Scattering transfer parameters
y Admittance parameter matrix.
y_arcl The arcl component of the y-matrix ..
y_arcl_unwrap The arcl_unwrap component of the y-matrix ..
y_db The db component of the y-matrix ..
y_db10 The db10 component of the y-matrix ..
y_deg The deg component of the y-matrix ..
y_deg_unwrap The deg_unwrap component of the y-matrix ..
y_im The im component of the y-matrix ..
y_mag The mag component of the y-matrix ..
y_passivity The passivity component of the y-matrix ..
y_rad The rad component of the y-matrix ..
y_rad_unwrap The rad_unwrap component of the y-matrix ..
y_re The re component of the y-matrix ..
y_reciprocity The reciprocity component of the y-matrix ..
Continued on next page

10.2. network (skrf.network) 75


scikit-rf Documentation, Release dev

Table 10.6 – continued from previous page


y_time The time component of the y-matrix ..
y_time_db The time_db component of the y-matrix ..
y_time_mag The time_mag component of the y-matrix ..
y_vswr The vswr component of the y-matrix ..
z Impedance parameter matrix.
z0 Characteristic impedance[s] of the network ports.
z_arcl The arcl component of the z-matrix ..
z_arcl_unwrap The arcl_unwrap component of the z-matrix ..
z_db The db component of the z-matrix ..
z_db10 The db10 component of the z-matrix ..
z_deg The deg component of the z-matrix ..
z_deg_unwrap The deg_unwrap component of the z-matrix ..
z_im The im component of the z-matrix ..
z_mag The mag component of the z-matrix ..
z_passivity The passivity component of the z-matrix ..
z_rad The rad component of the z-matrix ..
z_rad_unwrap The rad_unwrap component of the z-matrix ..
z_re The re component of the z-matrix ..
z_reciprocity The reciprocity component of the z-matrix ..
z_time The time component of the z-matrix ..
z_time_db The time_db component of the z-matrix ..
z_time_mag The time_mag component of the z-matrix ..
z_vswr The vswr component of the z-matrix ..

skrf.network.Network.a

Network.a
Active scattering parameter matrix.
Active scattering parameters are simply inverted s-parameters, defined as a = 1/s. Useful in analysis of active
networks. The a-matrix is a 3-dimensional numpy.ndarray which has shape fxnxn, where f is frequency axis
and n is number of ports. Note that indexing starts at 0, so a11 can be accessed by taking the slice a[:,0,0].
Returns a : complex numpy.ndarray of shape fxnxn
the active scattering parameter matrix.
See Also:
s, y, z, t, a

skrf.network.Network.a_arcl

Network.a_arcl
The arcl component of the a-matrix
See Also:
a

76 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.a_arcl_unwrap

Network.a_arcl_unwrap
The arcl_unwrap component of the a-matrix
See Also:
a

skrf.network.Network.a_db

Network.a_db
The db component of the a-matrix
See Also:
a

skrf.network.Network.a_db10

Network.a_db10
The db10 component of the a-matrix
See Also:
a

skrf.network.Network.a_deg

Network.a_deg
The deg component of the a-matrix
See Also:
a

skrf.network.Network.a_deg_unwrap

Network.a_deg_unwrap
The deg_unwrap component of the a-matrix
See Also:
a

skrf.network.Network.a_im

Network.a_im
The im component of the a-matrix
See Also:
a

10.2. network (skrf.network) 77


scikit-rf Documentation, Release dev

skrf.network.Network.a_mag

Network.a_mag
The mag component of the a-matrix
See Also:
a

skrf.network.Network.a_passivity

Network.a_passivity
The passivity component of the a-matrix
See Also:
a

skrf.network.Network.a_rad

Network.a_rad
The rad component of the a-matrix
See Also:
a

skrf.network.Network.a_rad_unwrap

Network.a_rad_unwrap
The rad_unwrap component of the a-matrix
See Also:
a

skrf.network.Network.a_re

Network.a_re
The re component of the a-matrix
See Also:
a

skrf.network.Network.a_reciprocity

Network.a_reciprocity
The reciprocity component of the a-matrix
See Also:
a

78 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.a_time

Network.a_time
The time component of the a-matrix
See Also:
a

skrf.network.Network.a_time_db

Network.a_time_db
The time_db component of the a-matrix
See Also:
a

skrf.network.Network.a_time_mag

Network.a_time_mag
The time_mag component of the a-matrix
See Also:
a

skrf.network.Network.a_vswr

Network.a_vswr
The vswr component of the a-matrix
See Also:
a

skrf.network.Network.f

Network.f
the frequency vector for the network, in Hz.
Returns f : numpy.ndarray
frequency vector in Hz
See Also:

frequency frequency property that holds all frequency information

skrf.network.Network.frequency

Network.frequency
frequency information for the network.

10.2. network (skrf.network) 79


scikit-rf Documentation, Release dev

This property is a Frequency object. It holds the frequency vector, as well frequency unit, and provides other
properties related to frequency information, such as start, stop, etc.
Returns frequency : Frequency object
frequency information for the network.
See Also:

f property holding frequency vector in Hz


change_frequency updates frequency property, and interpolates s-parameters if needed
interpolate interpolate function based on new frequency info

skrf.network.Network.inv

Network.inv
a Network object with ‘inverse’ s-parameters.
This is used for de-embeding. It is defined so that the inverse of a Network cascaded with itself is unity.
Returns inv : a Network object
a Network object with ‘inverse’ s-parameters.
See Also:

inv function which implements the inverse s-matrix

skrf.network.Network.nports

Network.nports
the number of ports the network has.
Returns number_of_ports : number
the number of ports the network has.

skrf.network.Network.number_of_ports

Network.number_of_ports
the number of ports the network has.
Returns number_of_ports : number
the number of ports the network has.

skrf.network.Network.passivity

Network.passivity
passivity metric for a multi-port network.
This returns a matrix who’s diagonals are equal to the total power received at all ports, normalized to the power
at a single excitement port.
mathmatically, this is a test for unitary-ness of the s-parameter matrix 2 .
2 http://en.wikipedia.org/wiki/Scattering_parameters#Lossless_networks

80 Chapter 10. Reference


scikit-rf Documentation, Release dev

for two port this is

(|S11 |2 + |S21 |2 , |S22 |2 + |S12 |2 )

in general it is

SH · S

where H is conjugate transpose of S, and · is dot product.


Returns passivity : numpy.ndarray of shape fxnxn

References

skrf.network.Network.port_tuples

Network.port_tuples
Returns a list of tuples, for each port index pair
A convenience function for the common task fo iterating over all s-parameters index pairs
This just calls: [(y,x) for x in range(self.nports) for y in range(self.nports)]

skrf.network.Network.reciprocity

Network.reciprocity
reciprocity metric for a multi-port network.
This returns the difference between the s-parameter matrix and its transpose.
for two port this is

S − ST

where T is transpose of S
Returns reciprocity : numpy.ndarray of shape fxnxn

skrf.network.Network.s

Network.s
Scattering parameter matrix.
The s-matrix[#]_ is a 3-dimensional numpy.ndarray which has shape fxnxn, where f is frequency axis and
n is number of ports. Note that indexing starts at 0, so s11 can be accessed by taking the slice s[:,0,0].
Returns s : complex numpy.ndarray of shape fxnxn
the scattering parameter matrix.
See Also:
s, y, z, t, a

10.2. network (skrf.network) 81


scikit-rf Documentation, Release dev

References

skrf.network.Network.s11

Network.s11
one-port sub-network.

skrf.network.Network.s12

Network.s12
one-port sub-network.

skrf.network.Network.s21

Network.s21
one-port sub-network.

skrf.network.Network.s22

Network.s22
one-port sub-network.

skrf.network.Network.s_arcl

Network.s_arcl
The arcl component of the s-matrix
See Also:
s

skrf.network.Network.s_arcl_unwrap

Network.s_arcl_unwrap
The arcl_unwrap component of the s-matrix
See Also:
s

skrf.network.Network.s_db

Network.s_db
The db component of the s-matrix
See Also:
s

82 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.s_db10

Network.s_db10
The db10 component of the s-matrix
See Also:
s

skrf.network.Network.s_deg

Network.s_deg
The deg component of the s-matrix
See Also:
s

skrf.network.Network.s_deg_unwrap

Network.s_deg_unwrap
The deg_unwrap component of the s-matrix
See Also:
s

skrf.network.Network.s_im

Network.s_im
The im component of the s-matrix
See Also:
s

skrf.network.Network.s_mag

Network.s_mag
The mag component of the s-matrix
See Also:
s

skrf.network.Network.s_passivity

Network.s_passivity
The passivity component of the s-matrix
See Also:
s

10.2. network (skrf.network) 83


scikit-rf Documentation, Release dev

skrf.network.Network.s_rad

Network.s_rad
The rad component of the s-matrix
See Also:
s

skrf.network.Network.s_rad_unwrap

Network.s_rad_unwrap
The rad_unwrap component of the s-matrix
See Also:
s

skrf.network.Network.s_re

Network.s_re
The re component of the s-matrix
See Also:
s

skrf.network.Network.s_reciprocity

Network.s_reciprocity
The reciprocity component of the s-matrix
See Also:
s

skrf.network.Network.s_time

Network.s_time
The time component of the s-matrix
See Also:
s

skrf.network.Network.s_time_db

Network.s_time_db
The time_db component of the s-matrix
See Also:
s

84 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.s_time_mag

Network.s_time_mag
The time_mag component of the s-matrix
See Also:
s

skrf.network.Network.s_vswr

Network.s_vswr
The vswr component of the s-matrix
See Also:
s

skrf.network.Network.t

Network.t
Scattering transfer parameters
The t-matrix 3 is a 3-dimensional numpy.ndarray which has shape fx2x2, where f is frequency axis. Note
that indexing starts at 0, so t11 can be accessed by taking the slice t[:,0,0].
The t-matrix, also known as the wave cascading matrix, is only defined for a 2-port Network.
Returns t : complex numpy.ndarry of shape fx2x2
t-parameters, aka scattering transfer parameters
See Also:
s, y, z, t, a

References

skrf.network.Network.y

Network.y
Admittance parameter matrix.
The y-matrix 4 is a 3-dimensional numpy.ndarray which has shape fxnxn, where f is frequency axis and n is
number of ports. Note that indexing starts at 0, so y11 can be accessed by taking the slice y[:,0,0].
Returns y : complex numpy.ndarray of shape fxnxn
the admittance parameter matrix.
See Also:
s, y, z, t, a
3 http://en.wikipedia.org/wiki/Scattering_parameters#Scattering_transfer_parameters
4 http://en.wikipedia.org/wiki/Admittance_parameters

10.2. network (skrf.network) 85


scikit-rf Documentation, Release dev

References

skrf.network.Network.y_arcl

Network.y_arcl
The arcl component of the y-matrix
See Also:
y

skrf.network.Network.y_arcl_unwrap

Network.y_arcl_unwrap
The arcl_unwrap component of the y-matrix
See Also:
y

skrf.network.Network.y_db

Network.y_db
The db component of the y-matrix
See Also:
y

skrf.network.Network.y_db10

Network.y_db10
The db10 component of the y-matrix
See Also:
y

skrf.network.Network.y_deg

Network.y_deg
The deg component of the y-matrix
See Also:
y

skrf.network.Network.y_deg_unwrap

Network.y_deg_unwrap
The deg_unwrap component of the y-matrix
See Also:
y

86 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.y_im

Network.y_im
The im component of the y-matrix
See Also:
y

skrf.network.Network.y_mag

Network.y_mag
The mag component of the y-matrix
See Also:
y

skrf.network.Network.y_passivity

Network.y_passivity
The passivity component of the y-matrix
See Also:
y

skrf.network.Network.y_rad

Network.y_rad
The rad component of the y-matrix
See Also:
y

skrf.network.Network.y_rad_unwrap

Network.y_rad_unwrap
The rad_unwrap component of the y-matrix
See Also:
y

skrf.network.Network.y_re

Network.y_re
The re component of the y-matrix
See Also:
y

10.2. network (skrf.network) 87


scikit-rf Documentation, Release dev

skrf.network.Network.y_reciprocity

Network.y_reciprocity
The reciprocity component of the y-matrix
See Also:
y

skrf.network.Network.y_time

Network.y_time
The time component of the y-matrix
See Also:
y

skrf.network.Network.y_time_db

Network.y_time_db
The time_db component of the y-matrix
See Also:
y

skrf.network.Network.y_time_mag

Network.y_time_mag
The time_mag component of the y-matrix
See Also:
y

skrf.network.Network.y_vswr

Network.y_vswr
The vswr component of the y-matrix
See Also:
y

skrf.network.Network.z

Network.z
Impedance parameter matrix.
The z-matrix 5 is a 3-dimensional numpy.ndarray which has shape fxnxn, where f is frequency axis and n is
number of ports. Note that indexing starts at 0, so z11 can be accessed by taking the slice z[:,0,0].
Returns z : complex numpy.ndarray of shape fxnxn
5 http://en.wikipedia.org/wiki/impedance_parameters

88 Chapter 10. Reference


scikit-rf Documentation, Release dev

the Impedance parameter matrix.


See Also:
s, y, z, t, a

References

skrf.network.Network.z0

Network.z0
Characteristic impedance[s] of the network ports.
This property stores the characteristic impedance of each port of the network. Because it is possible that each
port has a different characteristic impedance each varying with frequency, z0 is stored internally as a fxn array.
However because z0 is frequently simple (like 50ohm), it can be set with just number as well.
Returns z0 : numpy.ndarray of shape fxn
characteristic impedance for network

skrf.network.Network.z_arcl

Network.z_arcl
The arcl component of the z-matrix
See Also:
z

skrf.network.Network.z_arcl_unwrap

Network.z_arcl_unwrap
The arcl_unwrap component of the z-matrix
See Also:
z

skrf.network.Network.z_db

Network.z_db
The db component of the z-matrix
See Also:
z

skrf.network.Network.z_db10

Network.z_db10
The db10 component of the z-matrix
See Also:

10.2. network (skrf.network) 89


scikit-rf Documentation, Release dev

skrf.network.Network.z_deg

Network.z_deg
The deg component of the z-matrix
See Also:
z

skrf.network.Network.z_deg_unwrap

Network.z_deg_unwrap
The deg_unwrap component of the z-matrix
See Also:
z

skrf.network.Network.z_im

Network.z_im
The im component of the z-matrix
See Also:
z

skrf.network.Network.z_mag

Network.z_mag
The mag component of the z-matrix
See Also:
z

skrf.network.Network.z_passivity

Network.z_passivity
The passivity component of the z-matrix
See Also:
z

skrf.network.Network.z_rad

Network.z_rad
The rad component of the z-matrix
See Also:
z

90 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.z_rad_unwrap

Network.z_rad_unwrap
The rad_unwrap component of the z-matrix
See Also:
z

skrf.network.Network.z_re

Network.z_re
The re component of the z-matrix
See Also:
z

skrf.network.Network.z_reciprocity

Network.z_reciprocity
The reciprocity component of the z-matrix
See Also:
z

skrf.network.Network.z_time

Network.z_time
The time component of the z-matrix
See Also:
z

skrf.network.Network.z_time_db

Network.z_time_db
The time_db component of the z-matrix
See Also:
z

skrf.network.Network.z_time_mag

Network.z_time_mag
The time_mag component of the z-matrix
See Also:
z

10.2. network (skrf.network) 91


scikit-rf Documentation, Release dev

skrf.network.Network.z_vswr

Network.z_vswr
The vswr component of the z-matrix
See Also:
z

Methods

__init__ Network constructor.


add_noise_polar adds a complex zero-mean gaussian white-noise.
add_noise_polar_flatband adds a flatband complex zero-mean gaussian white-noise signal of
copy Returns a copy of this Network
copy_from Copies the contents of another Network into self
crop Crop Network based on start and stop frequencies.
cropped returns a cropped network, leaves self alone.
flip swaps the ports of a two port Network
flipped returns a flipped network, leaves self alone.
func_on_parameter Aplies a function parameter matrix, one frequency slice at a time
interpolate Return an interpolated network, from a new :class:’~skrf.frequency.Frequency’.
interpolate_from_f Interpolates s-parameters from a frequency vector.
interpolate_self Interpolates s-parameters given a new
interpolate_self_npoints Interpolate network based on a new number of frequency points
multiply_noise multiplys a complex bivariate gaussian white-noise signal
nonreciprocity Normalized non-reciprocity metrica
nudge Perturb s-parameters by small amount.
plot_a_arcl plot the Network attribute a_arcl vs frequency.
plot_a_arcl_unwrap plot the Network attribute a_arcl_unwrap vs frequency.
plot_a_complex plot the Network attribute a vs frequency.
plot_a_db plot the Network attribute a_db vs frequency.
plot_a_db10 plot the Network attribute a_db10 vs frequency.
plot_a_deg plot the Network attribute a_deg vs frequency.
plot_a_deg_unwrap plot the Network attribute a_deg_unwrap vs frequency.
plot_a_im plot the Network attribute a_im vs frequency.
plot_a_mag plot the Network attribute a_mag vs frequency.
plot_a_passivity plot the Network attribute a_passivity vs frequency.
plot_a_polar plot the Network attribute a vs frequency.
plot_a_rad plot the Network attribute a_rad vs frequency.
plot_a_rad_unwrap plot the Network attribute a_rad_unwrap vs frequency.
plot_a_re plot the Network attribute a_re vs frequency.
plot_a_reciprocity plot the Network attribute a_reciprocity vs frequency.
plot_a_time plot the Network attribute a_time vs frequency.
plot_a_time_db plot the Network attribute a_time_db vs frequency.
plot_a_time_mag plot the Network attribute a_time_mag vs frequency.
plot_a_vswr plot the Network attribute a_vswr vs frequency.
plot_it_all
plot_s_arcl plot the Network attribute s_arcl vs frequency.
plot_s_arcl_unwrap plot the Network attribute s_arcl_unwrap vs frequency.
plot_s_complex plot the Network attribute s vs frequency.
Continued on next page

92 Chapter 10. Reference


scikit-rf Documentation, Release dev

Table 10.7 – continued from previous page


plot_s_db plot the Network attribute s_db vs frequency.
plot_s_db10 plot the Network attribute s_db10 vs frequency.
plot_s_db_time
plot_s_deg plot the Network attribute s_deg vs frequency.
plot_s_deg_unwrap plot the Network attribute s_deg_unwrap vs frequency.
plot_s_im plot the Network attribute s_im vs frequency.
plot_s_mag plot the Network attribute s_mag vs frequency.
plot_s_passivity plot the Network attribute s_passivity vs frequency.
plot_s_polar plot the Network attribute s vs frequency.
plot_s_rad plot the Network attribute s_rad vs frequency.
plot_s_rad_unwrap plot the Network attribute s_rad_unwrap vs frequency.
plot_s_re plot the Network attribute s_re vs frequency.
plot_s_reciprocity plot the Network attribute s_reciprocity vs frequency.
plot_s_smith plots the scattering parameter on a smith chart
plot_s_time plot the Network attribute s_time vs frequency.
plot_s_time_db plot the Network attribute s_time_db vs frequency.
plot_s_time_mag plot the Network attribute s_time_mag vs frequency.
plot_s_vswr plot the Network attribute s_vswr vs frequency.
plot_y_arcl plot the Network attribute y_arcl vs frequency.
plot_y_arcl_unwrap plot the Network attribute y_arcl_unwrap vs frequency.
plot_y_complex plot the Network attribute y vs frequency.
plot_y_db plot the Network attribute y_db vs frequency.
plot_y_db10 plot the Network attribute y_db10 vs frequency.
plot_y_deg plot the Network attribute y_deg vs frequency.
plot_y_deg_unwrap plot the Network attribute y_deg_unwrap vs frequency.
plot_y_im plot the Network attribute y_im vs frequency.
plot_y_mag plot the Network attribute y_mag vs frequency.
plot_y_passivity plot the Network attribute y_passivity vs frequency.
plot_y_polar plot the Network attribute y vs frequency.
plot_y_rad plot the Network attribute y_rad vs frequency.
plot_y_rad_unwrap plot the Network attribute y_rad_unwrap vs frequency.
plot_y_re plot the Network attribute y_re vs frequency.
plot_y_reciprocity plot the Network attribute y_reciprocity vs frequency.
plot_y_time plot the Network attribute y_time vs frequency.
plot_y_time_db plot the Network attribute y_time_db vs frequency.
plot_y_time_mag plot the Network attribute y_time_mag vs frequency.
plot_y_vswr plot the Network attribute y_vswr vs frequency.
plot_z_arcl plot the Network attribute z_arcl vs frequency.
plot_z_arcl_unwrap plot the Network attribute z_arcl_unwrap vs frequency.
plot_z_complex plot the Network attribute z vs frequency.
plot_z_db plot the Network attribute z_db vs frequency.
plot_z_db10 plot the Network attribute z_db10 vs frequency.
plot_z_deg plot the Network attribute z_deg vs frequency.
plot_z_deg_unwrap plot the Network attribute z_deg_unwrap vs frequency.
plot_z_im plot the Network attribute z_im vs frequency.
plot_z_mag plot the Network attribute z_mag vs frequency.
plot_z_passivity plot the Network attribute z_passivity vs frequency.
plot_z_polar plot the Network attribute z vs frequency.
plot_z_rad plot the Network attribute z_rad vs frequency.
plot_z_rad_unwrap plot the Network attribute z_rad_unwrap vs frequency.
Continued on next page

10.2. network (skrf.network) 93


scikit-rf Documentation, Release dev

Table 10.7 – continued from previous page


plot_z_re plot the Network attribute z_re vs frequency.
plot_z_reciprocity plot the Network attribute z_reciprocity vs frequency.
plot_z_time plot the Network attribute z_time vs frequency.
plot_z_time_db plot the Network attribute z_time_db vs frequency.
plot_z_time_mag plot the Network attribute z_time_mag vs frequency.
plot_z_vswr plot the Network attribute z_vswr vs frequency.
read Read a Network from a ‘ntwk’ file
read_touchstone loads values from a touchstone file.
renumber renumbers some ports of a two port Network
resample Interpolate network based on a new number of frequency points
time_gate Time-gating
to_dataframe Convert attributes of a Network to a pandas DataFrame
windowed Return a windowed version of s-matrix.
write Write the Network to disk using the pickle module.
write_spreadsheet Write contents of network to a spreadsheet, for your boss to use.
write_touchstone Write a contents of the Network to a touchstone file.

skrf.network.Network.__init__

Network.__init__(file=None, name=None, comments=None, f_unit=None, **kwargs)


Network constructor.
Creates an n-port microwave network from a file or directly from data. If no file or data is given, then an empty
Network is created.
Parameters file : str or file-object
file to load information from. supported formats are:
• touchstone file (.s?p)
• pickled Network (.ntwk, .p) see write()
name : str
Name of this Network. if None will try to use file, if its a str
comments : str
Comments associated with the Network
**kwargs : :
key word arguments can be used to assign properties of the Network, such as s, f and
z0.
See Also:

read read a network from a file


write write a network to a file, using pickle
write_touchstone write a network to a touchstone file

Examples

From a touchstone

94 Chapter 10. Reference


scikit-rf Documentation, Release dev

>>> n = rf.Network(’ntwk1.s2p’)

From a pickle file


>>> n = rf.Network(’ntwk1.ntwk’)

Create a blank network, then fill in values


>>> n = rf.Network()
>>> n.f, n.s, n.z0 = [1,2,3],[1,2,3], [1,2,3]

Directly from values


>>> n = rf.Network(f=[1,2,3],s=[1,2,3],z0=[1,2,3])

skrf.network.Network.add_noise_polar

Network.add_noise_polar(mag_dev, phase_dev, **kwargs)


adds a complex zero-mean gaussian white-noise.
adds a complex zero-mean gaussian white-noise of a given standard deviation for magnitude and phase
Parameters mag_dev : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase [in degrees]

skrf.network.Network.add_noise_polar_flatband

Network.add_noise_polar_flatband(mag_dev, phase_dev, **kwargs)


adds a flatband complex zero-mean gaussian white-noise signal of given standard deviations for magnitude and
phase
Parameters mag_dev : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase [in degrees]

skrf.network.Network.copy

Network.copy()
Returns a copy of this Network
Needed to allow pass-by-value for a Network instead of pass-by-reference

skrf.network.Network.copy_from

Network.copy_from(other)
Copies the contents of another Network into self
Uses copy, so that the data is passed-by-value, not reference

10.2. network (skrf.network) 95


scikit-rf Documentation, Release dev

Parameters other : Network


the network to copy the contents of

Examples

>>> a = rf.N()
>>> b = rf.N(’my_file.s2p’)
>>> a.copy_from (b)

skrf.network.Network.crop

Network.crop(f_start, f_stop)
Crop Network based on start and stop frequencies.
No interpolation is done.
Parameters f_start : number
start frequency of crop range, in units of self.frequency.unit
f_stop : number
stop frequency of crop range, in units of self.frequency.unit

skrf.network.Network.cropped

Network.cropped(f_start, f_stop)
returns a cropped network, leaves self alone.
See Also:
crop

skrf.network.Network.flip

Network.flip()
swaps the ports of a two port Network

skrf.network.Network.flipped

Network.flipped()
returns a flipped network, leaves self alone.
See Also:
flip

skrf.network.Network.func_on_parameter

Network.func_on_parameter(func, attr=’s’, *args, **kwargs)


Aplies a function parameter matrix, one frequency slice at a time

96 Chapter 10. Reference


scikit-rf Documentation, Release dev

This is useful for functions that can only operate on 2d arrays, like numpy.linalg.inv. This loops over f and calls
func(ntwkA.s[f,:,:], *args, **kwargs)
Parameters func : func
function to apply to s-parameters, on a single-freqency slice. (ie func(ntwkA.s[0,:,:],
*args, **kwargs)
*args, **kwargs : :
passed to the func

Examples

>>> from numpy.linalg import inv


>>> ntwk.func_on_parameter(inv)

skrf.network.Network.interpolate

Network.interpolate(new_frequency, **kwargs)
Return an interpolated network, from a new :class:’~skrf.frequency.Frequency’.
Interpolate the networks s-parameters linearly in real and imaginary components. Other interpolation types
can be used by passing appropriate **kwargs. This function returns an interpolated Network. Alternatively
interpolate_self() will interpolate self.
Parameters new_frequency : Frequency
frequency information to interpolate
**kwargs : keyword arguments
passed to scipy.interpolate.interp1d() initializer.
Returns result : Network
an interpolated Network
See Also:
resample, interpolate_self, interpolate_from_f

Notes

See scipy.interpolate.interpolate.interp1d() for useful kwargs. For example


kind [str or int] Specifies the kind of interpolation as a string (‘linear’, ‘nearest’, ‘zero’, ‘slinear’,
‘quadratic, ‘cubic’) or as an integer specifying the order of the spline interpolator to use.

Examples

In [2]: n = rf.data.ring_slot

In [3]: n
Out[3]: 2-Port Network: ’ring slot’, 75-110 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]

In [4]: new_freq = rf.Frequency(75,110,501,’ghz’)

10.2. network (skrf.network) 97


scikit-rf Documentation, Release dev

In [5]: n.interpolate(new_freq, kind = ’cubic’)


Out[5]: 2-Port Network: ’ring slot’, 75-110 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]

skrf.network.Network.interpolate_from_f

Network.interpolate_from_f(f, interp_kwargs={}, **kwargs)


Interpolates s-parameters from a frequency vector.
Given a frequency vector, and optionally a unit (see **kwargs) , interpolate the networks s-parameters linearly
in real and imaginary components.
See interpolate() for more information.
Parameters new_frequency : Frequency
frequency information to interpolate at
interp_kwargs : :
dictionary of kwargs to be passed through to
scipy.interpolate.interpolate.interp1d()
**kwargs : :
passed to scipy.interpolate.interp1d() initializer.
See Also:
resample, interpolate, interpolate_self

Notes

This creates a new Frequency, object using the method from_f(), and then calls
interpolate_self().

skrf.network.Network.interpolate_self

Network.interpolate_self(new_frequency, **kwargs)
Interpolates s-parameters given a new :class:’~skrf.frequency.Frequency’ object.
See interpolate() for more information.
Parameters new_frequency : Frequency
frequency information to interpolate at
**kwargs : keyword arguments
passed to scipy.interpolate.interp1d() initializer.
See Also:
resample, interpolate, interpolate_from_f

98 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.interpolate_self_npoints

Network.interpolate_self_npoints(npoints, **kwargs)
Interpolate network based on a new number of frequency points
Parameters npoints : int
number of frequency points
**kwargs : keyword arguments
passed to scipy.interpolate.interp1d() initializer.
See Also:

interpolate_self same functionality but takes a Frequency object


interpolate same functionality but takes a Frequency object and returns a new Network, instead of updat-
ing itself.

Notes

The function resample() is an alias for interpolate_self_npoints().

Examples

In [2]: n = rf.data.ring_slot

In [3]: n
Out[3]: 2-Port Network: ’ring slot’, 75-110 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]

In [4]: n.resample(501) # resample is an alias

In [5]: n
Out[5]: 2-Port Network: ’ring slot’, 75-110 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]

skrf.network.Network.multiply_noise

Network.multiply_noise(mag_dev, phase_dev, **kwargs)


multiplys a complex bivariate gaussian white-noise signal of given standard deviations for magnitude and phase.
magnitude mean is 1, phase mean is 0
takes: mag_dev: standard deviation of magnitude phase_dev: standard deviation of phase [in degrees] n_ports:
number of ports. defualt to 1
returns: nothing

skrf.network.Network.nonreciprocity

Network.nonreciprocity(m, n, normalize=False)
Normalized non-reciprocity metrica
This is a port-by-port measure of how non-reciprocal a n-port network is. It is defined by,
p
(Smn − Snm )/ (Smn Snm )

10.2. network (skrf.network) 99


scikit-rf Documentation, Release dev

skrf.network.Network.nudge

Network.nudge(amount=1e-12)
Perturb s-parameters by small amount.
This is useful to work-around numerical bugs.
Parameters amount : number,
amount to add to s parameters

Notes

This function is self.s = self.s + 1e-12

skrf.network.Network.plot_a_arcl

Network.plot_a_arcl(m=None, n=None, ax=None, show_legend=True, attribute=’a_arcl’,


y_label=’Arc Length’, *args, **kwargs)
plot the Network attribute a_arcl vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_arcl(m=1,n=0,color=’r’)

100 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_a_arcl_unwrap

Network.plot_a_arcl_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’a_arcl_unwrap’, y_label=’Arc Length’, *args, **kwargs)
plot the Network attribute a_arcl_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_arcl_unwrap(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_complex

Network.plot_a_complex(m=None, n=None, ax=None, show_legend=True, prop_name=’a’, *args,


**kwargs)
plot the Network attribute a vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

10.2. network (skrf.network) 101


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_db

Network.plot_a_db(m=None, n=None, ax=None, show_legend=True, attribute=’a_db’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute a_db vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

102 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_db(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_db10

Network.plot_a_db10(m=None, n=None, ax=None, show_legend=True, attribute=’a_db10’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute a_db10 vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_db10(m=1,n=0,color=’r’)

10.2. network (skrf.network) 103


scikit-rf Documentation, Release dev

skrf.network.Network.plot_a_deg

Network.plot_a_deg(m=None, n=None, ax=None, show_legend=True, attribute=’a_deg’,


y_label=’Phase (deg)’, *args, **kwargs)
plot the Network attribute a_deg vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_deg(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_deg_unwrap

Network.plot_a_deg_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’a_deg_unwrap’, y_label=’Phase (deg)’, *args, **kwargs)
plot the Network attribute a_deg_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

104 Chapter 10. Reference


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_deg_unwrap(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_im

Network.plot_a_im(m=None, n=None, ax=None, show_legend=True, attribute=’a_im’, y_label=’Imag


Part’, *args, **kwargs)
plot the Network attribute a_im vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

10.2. network (skrf.network) 105


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_im(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_mag

Network.plot_a_mag(m=None, n=None, ax=None, show_legend=True, attribute=’a_mag’,


y_label=’Magnitude’, *args, **kwargs)
plot the Network attribute a_mag vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_mag(m=1,n=0,color=’r’)

106 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_a_passivity

Network.plot_a_passivity(m=None, n=None, ax=None, show_legend=True, at-


tribute=’a_passivity’, y_label=’Passivity’, *args, **kwargs)
plot the Network attribute a_passivity vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_passivity(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_polar

Network.plot_a_polar(m=None, n=None, ax=None, show_legend=True, prop_name=’a’, *args,


**kwargs)
plot the Network attribute a vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

10.2. network (skrf.network) 107


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_rad

Network.plot_a_rad(m=None, n=None, ax=None, show_legend=True, attribute=’a_rad’,


y_label=’Phase (rad)’, *args, **kwargs)
plot the Network attribute a_rad vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

108 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_rad(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_rad_unwrap

Network.plot_a_rad_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’a_rad_unwrap’, y_label=’Phase (rad)’, *args, **kwargs)
plot the Network attribute a_rad_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_rad_unwrap(m=1,n=0,color=’r’)

10.2. network (skrf.network) 109


scikit-rf Documentation, Release dev

skrf.network.Network.plot_a_re

Network.plot_a_re(m=None, n=None, ax=None, show_legend=True, attribute=’a_re’, y_label=’Real


Part’, *args, **kwargs)
plot the Network attribute a_re vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_re(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_reciprocity

Network.plot_a_reciprocity(m=None, n=None, ax=None, show_legend=True, at-


tribute=’a_reciprocity’, y_label=’Reciprocity’, *args, **kwargs)
plot the Network attribute a_reciprocity vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

110 Chapter 10. Reference


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_reciprocity(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_time

Network.plot_a_time(m=None, n=None, ax=None, show_legend=True, attribute=’a_time’,


y_label=’Time (real)’, *args, **kwargs)
plot the Network attribute a_time vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

10.2. network (skrf.network) 111


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_time(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_time_db

Network.plot_a_time_db(m=None, n=None, ax=None, show_legend=True, attribute=’a_time_db’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute a_time_db vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_time_db(m=1,n=0,color=’r’)

112 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_a_time_mag

Network.plot_a_time_mag(m=None, n=None, ax=None, show_legend=True, attribute=’a_time_mag’,


y_label=’Magnitude’, *args, **kwargs)
plot the Network attribute a_time_mag vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_time_mag(m=1,n=0,color=’r’)

skrf.network.Network.plot_a_vswr

Network.plot_a_vswr(m=None, n=None, ax=None, show_legend=True, attribute=’a_vswr’,


y_label=’VSWR’, *args, **kwargs)
plot the Network attribute a_vswr vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

10.2. network (skrf.network) 113


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_a_vswr(m=1,n=0,color=’r’)

skrf.network.Network.plot_it_all

Network.plot_it_all(*args, **kwargs)

skrf.network.Network.plot_s_arcl

Network.plot_s_arcl(m=None, n=None, ax=None, show_legend=True, attribute=’s_arcl’,


y_label=’Arc Length’, *args, **kwargs)
plot the Network attribute s_arcl vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments

114 Chapter 10. Reference


scikit-rf Documentation, Release dev

passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_arcl(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_arcl_unwrap

Network.plot_s_arcl_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’s_arcl_unwrap’, y_label=’Arc Length’, *args, **kwargs)
plot the Network attribute s_arcl_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_arcl_unwrap(m=1,n=0,color=’r’)

10.2. network (skrf.network) 115


scikit-rf Documentation, Release dev

skrf.network.Network.plot_s_complex

Network.plot_s_complex(m=None, n=None, ax=None, show_legend=True, prop_name=’s’, *args,


**kwargs)
plot the Network attribute s vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_db

Network.plot_s_db(m=None, n=None, ax=None, show_legend=True, attribute=’s_db’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute s_db vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

116 Chapter 10. Reference


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_db(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_db10

Network.plot_s_db10(m=None, n=None, ax=None, show_legend=True, attribute=’s_db10’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute s_db10 vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

10.2. network (skrf.network) 117


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_db10(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_db_time

Network.plot_s_db_time(*args, **kwargs)

skrf.network.Network.plot_s_deg

Network.plot_s_deg(m=None, n=None, ax=None, show_legend=True, attribute=’s_deg’,


y_label=’Phase (deg)’, *args, **kwargs)
plot the Network attribute s_deg vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

118 Chapter 10. Reference


scikit-rf Documentation, Release dev

>>> myntwk.plot_s_deg(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_deg_unwrap

Network.plot_s_deg_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’s_deg_unwrap’, y_label=’Phase (deg)’, *args, **kwargs)
plot the Network attribute s_deg_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_deg_unwrap(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_im

Network.plot_s_im(m=None, n=None, ax=None, show_legend=True, attribute=’s_im’, y_label=’Imag


Part’, *args, **kwargs)
plot the Network attribute s_im vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all

10.2. network (skrf.network) 119


scikit-rf Documentation, Release dev

ax : matplotlib.Axes object, optional


An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_im(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_mag

Network.plot_s_mag(m=None, n=None, ax=None, show_legend=True, attribute=’s_mag’,


y_label=’Magnitude’, *args, **kwargs)
plot the Network attribute s_mag vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

120 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_mag(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_passivity

Network.plot_s_passivity(m=None, n=None, ax=None, show_legend=True, attribute=’s_passivity’,


y_label=’Passivity’, *args, **kwargs)
plot the Network attribute s_passivity vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_passivity(m=1,n=0,color=’r’)

10.2. network (skrf.network) 121


scikit-rf Documentation, Release dev

skrf.network.Network.plot_s_polar

Network.plot_s_polar(m=None, n=None, ax=None, show_legend=True, prop_name=’s’, *args,


**kwargs)
plot the Network attribute s vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_rad

Network.plot_s_rad(m=None, n=None, ax=None, show_legend=True, attribute=’s_rad’,


y_label=’Phase (rad)’, *args, **kwargs)
plot the Network attribute s_rad vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

122 Chapter 10. Reference


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_rad(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_rad_unwrap

Network.plot_s_rad_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’s_rad_unwrap’, y_label=’Phase (rad)’, *args, **kwargs)
plot the Network attribute s_rad_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

10.2. network (skrf.network) 123


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_rad_unwrap(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_re

Network.plot_s_re(m=None, n=None, ax=None, show_legend=True, attribute=’s_re’, y_label=’Real


Part’, *args, **kwargs)
plot the Network attribute s_re vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_re(m=1,n=0,color=’r’)

124 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_s_reciprocity

Network.plot_s_reciprocity(m=None, n=None, ax=None, show_legend=True, at-


tribute=’s_reciprocity’, y_label=’Reciprocity’, *args, **kwargs)
plot the Network attribute s_reciprocity vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_reciprocity(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_smith

Network.plot_s_smith(m=None, n=None, r=1, ax=None, show_legend=True, chart_type=’z’,


draw_labels=False, label_axes=False, *args, **kwargs)
plots the scattering parameter on a smith chart
plots indices m, n, where m and n can be integers or lists of integers.
Parameters m : int, optional
first index
n : int, optional
second index
ax : matplotlib.Axes object, optional

10.2. network (skrf.network) 125


scikit-rf Documentation, Release dev

axes to plot on. in case you want to update an existing plot.


show_legend : boolean, optional
to turn legend show legend of not, optional
chart_type : [’z’,’y’]
draw impedance or addmitance contours
draw_labels : Boolean
annotate chart with impedance values
label_axes : Boolean
Label axis with titles Real and Imaginary
border : Boolean
draw rectangular border around image with ticks
*args : arguments, optional
passed to the matplotlib.plot command
**kwargs : keyword arguments, optional
passed to the matplotlib.plot command
See Also:
plot_vs_frequency_generic, smith

Examples

>>> myntwk.plot_s_smith()
>>> myntwk.plot_s_smith(m=0,n=1,color=’b’, marker=’x’)

skrf.network.Network.plot_s_time

Network.plot_s_time(m=None, n=None, ax=None, show_legend=True, attribute=’s_time’,


y_label=’Time (real)’, *args, **kwargs)
plot the Network attribute s_time vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot

126 Chapter 10. Reference


scikit-rf Documentation, Release dev

y_label : string, optional


the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_time(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_time_db

Network.plot_s_time_db(m=None, n=None, ax=None, show_legend=True, attribute=’s_time_db’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute s_time_db vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

10.2. network (skrf.network) 127


scikit-rf Documentation, Release dev

Examples

>>> myntwk.plot_s_time_db(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_time_mag

Network.plot_s_time_mag(m=None, n=None, ax=None, show_legend=True, attribute=’s_time_mag’,


y_label=’Magnitude’, *args, **kwargs)
plot the Network attribute s_time_mag vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_time_mag(m=1,n=0,color=’r’)

skrf.network.Network.plot_s_vswr

Network.plot_s_vswr(m=None, n=None, ax=None, show_legend=True, attribute=’s_vswr’,


y_label=’VSWR’, *args, **kwargs)
plot the Network attribute s_vswr vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional

128 Chapter 10. Reference


scikit-rf Documentation, Release dev

secon index of the s-parameter matrix, if None will use all


ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_s_vswr(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_arcl

Network.plot_y_arcl(m=None, n=None, ax=None, show_legend=True, attribute=’y_arcl’,


y_label=’Arc Length’, *args, **kwargs)
plot the Network attribute y_arcl vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments

10.2. network (skrf.network) 129


scikit-rf Documentation, Release dev

passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_arcl(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_arcl_unwrap

Network.plot_y_arcl_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’y_arcl_unwrap’, y_label=’Arc Length’, *args, **kwargs)
plot the Network attribute y_arcl_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_arcl_unwrap(m=1,n=0,color=’r’)

130 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_y_complex

Network.plot_y_complex(m=None, n=None, ax=None, show_legend=True, prop_name=’y’, *args,


**kwargs)
plot the Network attribute y vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_db

Network.plot_y_db(m=None, n=None, ax=None, show_legend=True, attribute=’y_db’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute y_db vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

10.2. network (skrf.network) 131


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_db(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_db10

Network.plot_y_db10(m=None, n=None, ax=None, show_legend=True, attribute=’y_db10’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute y_db10 vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

132 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_db10(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_deg

Network.plot_y_deg(m=None, n=None, ax=None, show_legend=True, attribute=’y_deg’,


y_label=’Phase (deg)’, *args, **kwargs)
plot the Network attribute y_deg vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_deg(m=1,n=0,color=’r’)

10.2. network (skrf.network) 133


scikit-rf Documentation, Release dev

skrf.network.Network.plot_y_deg_unwrap

Network.plot_y_deg_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’y_deg_unwrap’, y_label=’Phase (deg)’, *args, **kwargs)
plot the Network attribute y_deg_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_deg_unwrap(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_im

Network.plot_y_im(m=None, n=None, ax=None, show_legend=True, attribute=’y_im’, y_label=’Imag


Part’, *args, **kwargs)
plot the Network attribute y_im vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

134 Chapter 10. Reference


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_im(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_mag

Network.plot_y_mag(m=None, n=None, ax=None, show_legend=True, attribute=’y_mag’,


y_label=’Magnitude’, *args, **kwargs)
plot the Network attribute y_mag vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

10.2. network (skrf.network) 135


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_mag(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_passivity

Network.plot_y_passivity(m=None, n=None, ax=None, show_legend=True, attribute=’y_passivity’,


y_label=’Passivity’, *args, **kwargs)
plot the Network attribute y_passivity vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_passivity(m=1,n=0,color=’r’)

136 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_y_polar

Network.plot_y_polar(m=None, n=None, ax=None, show_legend=True, prop_name=’y’, *args,


**kwargs)
plot the Network attribute y vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_rad

Network.plot_y_rad(m=None, n=None, ax=None, show_legend=True, attribute=’y_rad’,


y_label=’Phase (rad)’, *args, **kwargs)
plot the Network attribute y_rad vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

10.2. network (skrf.network) 137


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_rad(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_rad_unwrap

Network.plot_y_rad_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’y_rad_unwrap’, y_label=’Phase (rad)’, *args, **kwargs)
plot the Network attribute y_rad_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

138 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_rad_unwrap(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_re

Network.plot_y_re(m=None, n=None, ax=None, show_legend=True, attribute=’y_re’, y_label=’Real


Part’, *args, **kwargs)
plot the Network attribute y_re vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_re(m=1,n=0,color=’r’)

10.2. network (skrf.network) 139


scikit-rf Documentation, Release dev

skrf.network.Network.plot_y_reciprocity

Network.plot_y_reciprocity(m=None, n=None, ax=None, show_legend=True, at-


tribute=’y_reciprocity’, y_label=’Reciprocity’, *args, **kwargs)
plot the Network attribute y_reciprocity vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_reciprocity(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_time

Network.plot_y_time(m=None, n=None, ax=None, show_legend=True, attribute=’y_time’,


y_label=’Time (real)’, *args, **kwargs)
plot the Network attribute y_time vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

140 Chapter 10. Reference


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_time(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_time_db

Network.plot_y_time_db(m=None, n=None, ax=None, show_legend=True, attribute=’y_time_db’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute y_time_db vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

10.2. network (skrf.network) 141


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_time_db(m=1,n=0,color=’r’)

skrf.network.Network.plot_y_time_mag

Network.plot_y_time_mag(m=None, n=None, ax=None, show_legend=True, attribute=’y_time_mag’,


y_label=’Magnitude’, *args, **kwargs)
plot the Network attribute y_time_mag vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_time_mag(m=1,n=0,color=’r’)

142 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_y_vswr

Network.plot_y_vswr(m=None, n=None, ax=None, show_legend=True, attribute=’y_vswr’,


y_label=’VSWR’, *args, **kwargs)
plot the Network attribute y_vswr vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_y_vswr(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_arcl

Network.plot_z_arcl(m=None, n=None, ax=None, show_legend=True, attribute=’z_arcl’,


y_label=’Arc Length’, *args, **kwargs)
plot the Network attribute z_arcl vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

10.2. network (skrf.network) 143


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_arcl(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_arcl_unwrap

Network.plot_z_arcl_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’z_arcl_unwrap’, y_label=’Arc Length’, *args, **kwargs)
plot the Network attribute z_arcl_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

144 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_arcl_unwrap(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_complex

Network.plot_z_complex(m=None, n=None, ax=None, show_legend=True, prop_name=’z’, *args,


**kwargs)
plot the Network attribute z vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z(m=1,n=0,color=’r’)

10.2. network (skrf.network) 145


scikit-rf Documentation, Release dev

skrf.network.Network.plot_z_db

Network.plot_z_db(m=None, n=None, ax=None, show_legend=True, attribute=’z_db’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute z_db vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_db(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_db10

Network.plot_z_db10(m=None, n=None, ax=None, show_legend=True, attribute=’z_db10’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute z_db10 vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

146 Chapter 10. Reference


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_db10(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_deg

Network.plot_z_deg(m=None, n=None, ax=None, show_legend=True, attribute=’z_deg’,


y_label=’Phase (deg)’, *args, **kwargs)
plot the Network attribute z_deg vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

10.2. network (skrf.network) 147


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_deg(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_deg_unwrap

Network.plot_z_deg_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’z_deg_unwrap’, y_label=’Phase (deg)’, *args, **kwargs)
plot the Network attribute z_deg_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_deg_unwrap(m=1,n=0,color=’r’)

148 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_z_im

Network.plot_z_im(m=None, n=None, ax=None, show_legend=True, attribute=’z_im’, y_label=’Imag


Part’, *args, **kwargs)
plot the Network attribute z_im vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_im(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_mag

Network.plot_z_mag(m=None, n=None, ax=None, show_legend=True, attribute=’z_mag’,


y_label=’Magnitude’, *args, **kwargs)
plot the Network attribute z_mag vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

10.2. network (skrf.network) 149


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_mag(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_passivity

Network.plot_z_passivity(m=None, n=None, ax=None, show_legend=True, attribute=’z_passivity’,


y_label=’Passivity’, *args, **kwargs)
plot the Network attribute z_passivity vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

150 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_passivity(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_polar

Network.plot_z_polar(m=None, n=None, ax=None, show_legend=True, prop_name=’z’, *args,


**kwargs)
plot the Network attribute z vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z(m=1,n=0,color=’r’)

10.2. network (skrf.network) 151


scikit-rf Documentation, Release dev

skrf.network.Network.plot_z_rad

Network.plot_z_rad(m=None, n=None, ax=None, show_legend=True, attribute=’z_rad’,


y_label=’Phase (rad)’, *args, **kwargs)
plot the Network attribute z_rad vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_rad(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_rad_unwrap

Network.plot_z_rad_unwrap(m=None, n=None, ax=None, show_legend=True, at-


tribute=’z_rad_unwrap’, y_label=’Phase (rad)’, *args, **kwargs)
plot the Network attribute z_rad_unwrap vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

152 Chapter 10. Reference


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_rad_unwrap(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_re

Network.plot_z_re(m=None, n=None, ax=None, show_legend=True, attribute=’z_re’, y_label=’Real


Part’, *args, **kwargs)
plot the Network attribute z_re vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

10.2. network (skrf.network) 153


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_re(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_reciprocity

Network.plot_z_reciprocity(m=None, n=None, ax=None, show_legend=True, at-


tribute=’z_reciprocity’, y_label=’Reciprocity’, *args, **kwargs)
plot the Network attribute z_reciprocity vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_reciprocity(m=1,n=0,color=’r’)

154 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.Network.plot_z_time

Network.plot_z_time(m=None, n=None, ax=None, show_legend=True, attribute=’z_time’,


y_label=’Time (real)’, *args, **kwargs)
plot the Network attribute z_time vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_time(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_time_db

Network.plot_z_time_db(m=None, n=None, ax=None, show_legend=True, attribute=’z_time_db’,


y_label=’Magnitude (dB)’, *args, **kwargs)
plot the Network attribute z_time_db vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on

10.2. network (skrf.network) 155


scikit-rf Documentation, Release dev

show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_time_db(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_time_mag

Network.plot_z_time_mag(m=None, n=None, ax=None, show_legend=True, attribute=’z_time_mag’,


y_label=’Magnitude’, *args, **kwargs)
plot the Network attribute z_time_mag vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

156 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_time_mag(m=1,n=0,color=’r’)

skrf.network.Network.plot_z_vswr

Network.plot_z_vswr(m=None, n=None, ax=None, show_legend=True, attribute=’z_vswr’,


y_label=’VSWR’, *args, **kwargs)
plot the Network attribute z_vswr vs frequency.
Parameters m : int, optional
first index of s-parameter matrix, if None will use all
n : int, optional
secon index of the s-parameter matrix, if None will use all
ax : matplotlib.Axes object, optional
An existing Axes object to plot on
show_legend : Boolean
draw legend or not
attribute : string
Network attribute to plot
y_label : string, optional
the y-axis label
*args,**kwargs : arguments, keyword arguments
passed to matplotlib.plot()

Notes

This function is dynamically generated upon Network initialization. This is accomplished by calling
plot_vs_frequency_generic()

Examples

>>> myntwk.plot_z_vswr(m=1,n=0,color=’r’)

10.2. network (skrf.network) 157


scikit-rf Documentation, Release dev

skrf.network.Network.read

Network.read(*args, **kwargs)
Read a Network from a ‘ntwk’ file
A ntwk file is written with write(). It is just a pickled file.
Parameters *args, **kwargs : args and kwargs
passed to skrf.io.general.write()
See Also:
write, skrf.io.general.write, skrf.io.general.read

Notes

This function calls skrf.io.general.read().

Examples

>>> rf.read(’myfile.ntwk’)
>>> rf.read(’myfile.p’)

skrf.network.Network.read_touchstone

Network.read_touchstone(filename)
loads values from a touchstone file.
The work of this function is done through the touchstone class.
Parameters filename : str or file-object
touchstone file name.

Notes

only the scattering parameters format is supported at the moment

skrf.network.Network.renumber

Network.renumber(from_ports, to_ports)
renumbers some ports of a two port Network
Parameters from_ports : list-like
to_ports: list-like :

158 Chapter 10. Reference


scikit-rf Documentation, Release dev

Examples

To flip the ports of a 2-port network ‘foo’: >>> foo.renumber( [0,1], [1,0] )
To rotate the ports of a 3-port network ‘bar’ so that port 0 becomes port 1: >>> bar.renumber( [0,1,2], [1,2,0] )
To swap the first and last ports of a network ‘duck’: >>> duck.renumber( [0,-1], [-1,0] )

skrf.network.Network.resample

Network.resample(npoints, **kwargs)
Interpolate network based on a new number of frequency points
Parameters npoints : int
number of frequency points
**kwargs : keyword arguments
passed to scipy.interpolate.interp1d() initializer.
See Also:

interpolate_self same functionality but takes a Frequency object


interpolate same functionality but takes a Frequency object and returns a new Network, instead of updat-
ing itself.

Notes

The function resample() is an alias for interpolate_self_npoints().

Examples

In [2]: n = rf.data.ring_slot

In [3]: n
Out[3]: 2-Port Network: ’ring slot’, 75-110 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]

In [4]: n.resample(501) # resample is an alias

In [5]: n
Out[5]: 2-Port Network: ’ring slot’, 75-110 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]

skrf.network.Network.time_gate

Network.time_gate(t_start, t_stop, window=(‘kaiser’, 6))


Time-gating
Parameters t_start : number
start of time gate, (s)
t_stop : number
stop of time gate (s)

10.2. network (skrf.network) 159


scikit-rf Documentation, Release dev

Returns ntwk : Network


copy of self with time-gated s-parameters

skrf.network.Network.to_dataframe

Network.to_dataframe(*args, **kwargs)
Convert attributes of a Network to a pandas DataFrame
See Also:
skrf.io.general.network_2_dataframe

skrf.network.Network.windowed

Network.windowed(window=(‘kaiser’, 6), normalize=True)


Return a windowed version of s-matrix. Used in time-domain analysis.
When using time domain through s_time_db, or similar properies, the spectrum is ussually windowed, before
the IFFT is taken. This is done to compensate for the band-pass nature of a spectrum 6 .
This function calls scipy.signal.get_window() which gives more details about the windowing.
Parameters window : string, float, or tuple
The type of window to create. See scipy.signal.get_window() for details.
normalize : bool
Normalize the window to preserve power. ie sum(ntwk.s,axis=0) ==
sum(ntwk.windowed().s,axis=0)

References

Examples

>>> ntwk = rf.Network(’myfile.s2p’)


>>> ntwk_w = ntwk.windowed()
>>> ntwk_w.plot_s_time_db()

skrf.network.Network.write

Network.write(file=None, *args, **kwargs)


Write the Network to disk using the pickle module.
The resultant file can be read either by using the Networks constructor, __init__() , the read method
read(), or the general read function skrf.io.general.read()
Parameters file : str or file-object
filename or a file-object. If left as None then the filename will be set to Network.name,
if its not None. If both are None, ValueError is raised.
*args, **kwargs : :
6 Agilent Time Domain Analysis Using a Network Analyzer Application Note 1287-12

160 Chapter 10. Reference


scikit-rf Documentation, Release dev

passed through to write()


See Also:

skrf.io.general.write write any skrf object


skrf.io.general.read read any skrf object

Notes

If the self.name is not None and file is can left as None and the resultant file will have the .ntwk extension
appended to the filename.

Examples

>>> n = rf.N(f=[1,2,3],s=[1,1,1],z0=50, name = ’open’)


>>> n.write()
>>> n2 = rf.read(’open.ntwk’)

skrf.network.Network.write_spreadsheet

Network.write_spreadsheet(*args, **kwargs)
Write contents of network to a spreadsheet, for your boss to use.
See Also:
skrf.io.general.network_2_spreadsheet

skrf.network.Network.write_touchstone

Network.write_touchstone(filename=None, dir=None, write_z0=False, skrf_comment=True)


Write a contents of the Network to a touchstone file.
Parameters filename : a string, optional
touchstone filename, without extension. if ‘None’, then will use the network’s name.
dir : string, optional
the directory to save the file in.
write_z0 : boolean
write impedance information into touchstone as comments, like Ansoft HFSS does
skrf_comment : bool, optional
write created by skrf comment

Notes

format supported at the moment is, HZ S RI

The functionality of this function should take place in the touchstone class.

10.2. network (skrf.network) 161


scikit-rf Documentation, Release dev

10.2.2 Connecting Networks

connect(ntwkA, k, ntwkB, l[, num]) connect two n-port networks together.


innerconnect(ntwkA, k, l[, num]) connect ports of a single n-port network.
cascade(ntwkA, ntwkB) Cascade two 2-port Networks together
de_embed(ntwkA, ntwkB) De-embed ntwkA from ntwkB.
flip(a) invert the ports of a networks s-matrix, ‘flipping’ it over

skrf.network.connect

skrf.network.connect(ntwkA, k, ntwkB, l, num=1)


connect two n-port networks together.
specifically, connect ports k thru k+num-1 on ntwkA to ports l thru l+num-1 on ntwkB. The resultant network has
(ntwkA.nports+ntwkB.nports-2*num) ports. The port indices (‘k’,’l’) start from 0. Port impedances are taken
into account.
Parameters ntwkA : Network
network ‘A’
k : int
starting port index on ntwkA ( port indices start from 0 )
ntwkB : Network
network ‘B’
l : int
starting port index on ntwkB
num : int
number of consecutive ports to connect (default 1)
Returns ntwkC : Network
new network of rank (ntwkA.nports + ntwkB.nports - 2*num)
See Also:

connect_s actual S-parameter connection algorithm.


innerconnect_s actual S-parameter connection algorithm.

Notes

the effect of mis-matched port impedances is handled by inserting a 2-port ‘mismatch’ network between the two
connected ports. This mismatch Network is calculated with the impedance_mismatch() function.

Examples

To implement a cascade of two networks


>>> ntwkA = rf.Network(’ntwkA.s2p’)
>>> ntwkB = rf.Network(’ntwkB.s2p’)
>>> ntwkC = rf.connect(ntwkA, 1, ntwkB,0)

162 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.network.innerconnect

skrf.network.innerconnect(ntwkA, k, l, num=1)
connect ports of a single n-port network.
this results in a (n-2)-port network. remember port indices start from 0.
Parameters ntwkA : Network
network ‘A’
k,l : int
starting port indices on ntwkA ( port indices start from 0 )
num : int
number of consecutive ports to connect
Returns ntwkC : Network
new network of rank (ntwkA.nports - 2*num)
See Also:

connect_s actual S-parameter connection algorithm.


innerconnect_s actual S-parameter connection algorithm.

Notes

a 2-port ‘mismatch’ network is inserted between the connected ports if their impedances are not equal.

Examples

To connect ports ‘0’ and port ‘1’ on ntwkA


>>> ntwkA = rf.Network(’ntwkA.s3p’)
>>> ntwkC = rf.innerconnect(ntwkA, 0,1)

skrf.network.cascade

skrf.network.cascade(ntwkA, ntwkB)
Cascade two 2-port Networks together
Connects port 1 of ntwkA to port 0 of ntwkB. This calls connect(ntwkA,1, ntwkB,0), which is a more general
function.
Parameters ntwkA : Network
network ntwkA
ntwkB : Network
network ntwkB
Returns C : Network
the resultant network of ntwkA cascaded with ntwkB
See Also:

10.2. network (skrf.network) 163


scikit-rf Documentation, Release dev

connect connects two Networks together at arbitrary ports.

skrf.network.de_embed

skrf.network.de_embed(ntwkA, ntwkB)
De-embed ntwkA from ntwkB.
This calls ntwkA.inv ** ntwkB. The syntax of cascading an inverse is more explicit, it is recomended that it be
used instead of this function.
Parameters ntwkA : Network
network ntwkA
ntwkB : Network
network ntwkB
Returns C : Network
the resultant network of ntwkB de-embeded from ntwkA
See Also:

connect connects two Networks together at arbitrary ports.

skrf.network.flip

skrf.network.flip(a)
invert the ports of a networks s-matrix, ‘flipping’ it over
Parameters a : numpy.ndarray
scattering parameter matrix. shape should be should be 2x2, or fx2x2
Returns a’ : numpy.ndarray
flipped scattering parameter matrix, ie interchange of port 0 and port 1

10.2.3 Interpolation and Combining

stitch(ntwkA, ntwkB, **kwargs) Stitches ntwkA and ntwkB together.


overlap(ntwkA, ntwkB) Returns the overlapping parts of two Networks, interpolating if need
Network.resample(npoints, **kwargs) Interpolate network based on a new number of frequency points
Network.interpolate(new_frequency, **kwargs) Return an interpolated network, from a new :class:’~skrf.frequency.
Network.interpolate_self(new_frequency, **kwargs) Interpolates s-parameters given a new
Network.interpolate_from_f(f[, interp_kwargs]) Interpolates s-parameters from a frequency vector.

skrf.network.stitch

skrf.network.stitch(ntwkA, ntwkB, **kwargs)


Stitches ntwkA and ntwkB together.
Concatenates two networks’ data. Given two networks that cover different frequency bands this can be used to
combine their data into a single network.
Parameters ntwkA, ntwkB : Network objects

164 Chapter 10. Reference


scikit-rf Documentation, Release dev

Networks to stitch together


**kwargs : keyword args
passed to Network constructor, for output network
Returns ntwkC : Network
result of stitching the networks ntwkA and ntwkB together

Examples

>>> from skrf.data import wr2p2_line, wr1p5_line


>>> rf.stitch(wr2p2_line, wr1p5_line)
2-Port Network: ’wr2p2,line’, 330-750 GHz, 402 pts, z0=[ 50.+0.j 50.+0.j]

skrf.network.overlap

skrf.network.overlap(ntwkA, ntwkB)
Returns the overlapping parts of two Networks, interpolating if needed.
If frequency vectors for each ntwk dont perfectly overlap, then ntwkB is interpolated so that the resultant net-
works have identical frequencies.
Parameters ntwkA : Network
a ntwk which overlaps ntwkB. (the dominant network)
ntwkB : Network
a ntwk which overlaps ntwkA.
Returns ntwkA_new : Network
part of ntwkA that overlapped ntwkB
ntwkB_new : Network
part of ntwkB that overlapped ntwkA, possibly interpolated
See Also:
skrf.frequency.overlap_freq()

skrf.network.Network.resample

Network.resample(npoints, **kwargs)
Interpolate network based on a new number of frequency points
Parameters npoints : int
number of frequency points
**kwargs : keyword arguments
passed to scipy.interpolate.interp1d() initializer.
See Also:

interpolate_self same functionality but takes a Frequency object

10.2. network (skrf.network) 165


scikit-rf Documentation, Release dev

interpolate same functionality but takes a Frequency object and returns a new Network, instead of updat-
ing itself.

Notes

The function resample() is an alias for interpolate_self_npoints().

Examples

In [2]: n = rf.data.ring_slot

In [3]: n
Out[3]: 2-Port Network: ’ring slot’, 75-110 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]

In [4]: n.resample(501) # resample is an alias

In [5]: n
Out[5]: 2-Port Network: ’ring slot’, 75-110 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]

skrf.network.Network.interpolate

Network.interpolate(new_frequency, **kwargs)
Return an interpolated network, from a new :class:’~skrf.frequency.Frequency’.
Interpolate the networks s-parameters linearly in real and imaginary components. Other interpolation types
can be used by passing appropriate **kwargs. This function returns an interpolated Network. Alternatively
interpolate_self() will interpolate self.
Parameters new_frequency : Frequency
frequency information to interpolate
**kwargs : keyword arguments
passed to scipy.interpolate.interp1d() initializer.
Returns result : Network
an interpolated Network
See Also:
resample, interpolate_self, interpolate_from_f

Notes

See scipy.interpolate.interpolate.interp1d() for useful kwargs. For example


kind [str or int] Specifies the kind of interpolation as a string (‘linear’, ‘nearest’, ‘zero’, ‘slinear’,
‘quadratic, ‘cubic’) or as an integer specifying the order of the spline interpolator to use.

Examples

166 Chapter 10. Reference


scikit-rf Documentation, Release dev

In [2]: n = rf.data.ring_slot

In [3]: n
Out[3]: 2-Port Network: ’ring slot’, 75-110 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j]

In [4]: new_freq = rf.Frequency(75,110,501,’ghz’)

In [5]: n.interpolate(new_freq, kind = ’cubic’)


Out[5]: 2-Port Network: ’ring slot’, 75-110 GHz, 501 pts, z0=[ 50.+0.j 50.+0.j]

skrf.network.Network.interpolate_self

Network.interpolate_self(new_frequency, **kwargs)
Interpolates s-parameters given a new :class:’~skrf.frequency.Frequency’ object.
See interpolate() for more information.
Parameters new_frequency : Frequency
frequency information to interpolate at
**kwargs : keyword arguments
passed to scipy.interpolate.interp1d() initializer.
See Also:
resample, interpolate, interpolate_from_f

skrf.network.Network.interpolate_from_f

Network.interpolate_from_f(f, interp_kwargs={}, **kwargs)


Interpolates s-parameters from a frequency vector.
Given a frequency vector, and optionally a unit (see **kwargs) , interpolate the networks s-parameters linearly
in real and imaginary components.
See interpolate() for more information.
Parameters new_frequency : Frequency
frequency information to interpolate at
interp_kwargs : :
dictionary of kwargs to be passed through to
scipy.interpolate.interpolate.interp1d()
**kwargs : :
passed to scipy.interpolate.interp1d() initializer.
See Also:
resample, interpolate, interpolate_self

Notes

This creates a new Frequency, object using the method from_f(), and then calls
interpolate_self().

10.2. network (skrf.network) 167


scikit-rf Documentation, Release dev

10.2.4 IO

skrf.io.general.read(file, *args, **kwargs) Read skrf object[s] from a pickle file


skrf.io.general.write(file, obj[, overwrite]) Write skrf object[s] to a file
skrf.io.general.ntwk_2_spreadsheet
Network.write([file]) Write the Network to disk using the pickle module.
Network.write_touchstone([filename, dir, ...]) Write a contents of the Network to a touchstone file.
Network.read(*args, **kwargs) Read a Network from a ‘ntwk’ file
Network.write_spreadsheet(*args, **kwargs) Write contents of network to a spreadsheet, for your boss to use.

10.2.5 Noise

Network.add_noise_polar(mag_dev, phase_dev, ...) adds a complex zero-mean gaussian white-noise.


Network.add_noise_polar_flatband(mag_dev, ...) adds a flatband complex zero-mean gaussian white-noise signal of
Network.multiply_noise(mag_dev, phase_dev, ...) multiplys a complex bivariate gaussian white-noise signal

skrf.network.Network.add_noise_polar

Network.add_noise_polar(mag_dev, phase_dev, **kwargs)


adds a complex zero-mean gaussian white-noise.
adds a complex zero-mean gaussian white-noise of a given standard deviation for magnitude and phase
Parameters mag_dev : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase [in degrees]

skrf.network.Network.add_noise_polar_flatband

Network.add_noise_polar_flatband(mag_dev, phase_dev, **kwargs)


adds a flatband complex zero-mean gaussian white-noise signal of given standard deviations for magnitude and
phase
Parameters mag_dev : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase [in degrees]

skrf.network.Network.multiply_noise

Network.multiply_noise(mag_dev, phase_dev, **kwargs)


multiplys a complex bivariate gaussian white-noise signal of given standard deviations for magnitude and phase.
magnitude mean is 1, phase mean is 0
takes: mag_dev: standard deviation of magnitude phase_dev: standard deviation of phase [in degrees] n_ports:
number of ports. defualt to 1
returns: nothing

168 Chapter 10. Reference


scikit-rf Documentation, Release dev

10.2.6 Supporting Functions

inv(s) Calculates ‘inverse’ s-parameter matrix, used for de-embeding


connect_s(A, k, B, l) connect two n-port networks’ s-matricies together.
innerconnect_s(A, k, l) connect two ports of a single n-port network’s s-matrix.
s2z(s[, z0]) Convert scattering parameters [#]_ to impedance parameters [#]_ ..
s2y(s[, z0]) convert scattering parameters [#]_ to admittance parameters [#]_
s2t(s) Converts scattering parameters [#]_ to scattering transfer parameters [#]_ .
z2s(z[, z0]) convert impedance parameters [#]_ to scattering parameters [#]_
z2y(z) convert impedance parameters [#]_ to admittance parameters [#]_
z2t(z) Not Implemented yet
y2s(y[, z0]) convert admittance parameters [#]_ to scattering parameters [#]_
y2z(y) convert admittance parameters [#]_ to impedance parameters [#]_
y2t(y) Not Implemented Yet
t2s(t) converts scattering transfer parameters [#]_ to scattering parameters [#]_
t2z(t) Not Implemented Yet
t2y(t) Not Implemented Yet

skrf.network.inv

skrf.network.inv(s)
Calculates ‘inverse’ s-parameter matrix, used for de-embeding
This is not literally the inverse of the s-parameter matrix. Instead, it is defined such that the inverse of the
s-matrix cascaded with itself is unity.
−1
inv(s) = t2s(s2t(s) )

where x−1 is the matrix inverse. In words, this is the inverse of the scattering transfer parameters matrix
transformed into a scattering parameters matrix.
Parameters s : numpy.ndarray (shape fx2x2)
scattering parameter matrix.
Returns s’ : numpy.ndarray
inverse scattering parameter matrix.
See Also:

t2s converts scattering transfer parameters to scattering parameters


s2t converts scattering parameters to scattering transfer parameters

skrf.network.connect_s

skrf.network.connect_s(A, k, B, l)
connect two n-port networks’ s-matricies together.
specifically, connect port k on network A to port l on network B. The resultant network has nports = (A.rank +
B.rank-2). This function operates on, and returns s-matricies. The function connect() operates on Network
types.
Parameters A : numpy.ndarray
S-parameter matrix of A, shape is fxnxn

10.2. network (skrf.network) 169


scikit-rf Documentation, Release dev

k : int
port index on A (port indices start from 0)
B : numpy.ndarray
S-parameter matrix of B, shape is fxnxn
l : int
port index on B
Returns C : numpy.ndarray
new S-parameter matrix
See Also:

connect operates on Network types


innerconnect_s function which implements the connection connection algorithm

Notes

internally, this function creates a larger composite network and calls the innerconnect_s() function. see
that function for more details about the implementation

skrf.network.innerconnect_s

skrf.network.innerconnect_s(A, k, l)
connect two ports of a single n-port network’s s-matrix.
Specifically, connect port k to port l on A. This results in a (n-2)-port network. This function operates on, and
returns s-matricies. The function innerconnect() operates on Network types.
Parameters A : numpy.ndarray
S-parameter matrix of A, shape is fxnxn
k : int
port index on A (port indices start from 0)
l : int
port index on A
Returns C : numpy.ndarray
new S-parameter matrix

Notes

The algorithm used to calculate the resultant network is called a ‘sub-network growth’, can be found in 7 . The
original paper describing the algorithm is given in 8 .
7 Compton, R.C.; , “Perspectives in microwave circuit analysis,” Circuits and Systems, 1989., Proceedings of the 32nd Midwest Symposium on

, vol., no., pp.716-718 vol.2, 14-16 Aug 1989. URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=101955&isnumber=3167


8 Filipsson, Gunnar; , “A New General Computer Algorithm for S-Matrix Calculation of Interconnected Mul-
tiports,” Microwave Conference, 1981. 11th European , vol., no., pp.700-704, 7-11 Sept. 1981. URL:
http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4131699&isnumber=4131585

170 Chapter 10. Reference


scikit-rf Documentation, Release dev

References

skrf.network.s2z

skrf.network.s2z(s, z0=50)
Convert scattering parameters 9 to impedance parameters 10
√ √
z= z0 · (I + s)(I − s)−1 · z0

Parameters s : complex array-like


scattering parameters
z0 : complex array-like or number
port impedances
Returns z : complex array-like
impedance parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t

References

skrf.network.s2y

skrf.network.s2y(s, z0=50)
convert scattering parameters 11 to admittance parameters 12
√ √
y= y0 · (I − s)(I + s)−1 · y0

Parameters s : complex array-like


scattering parameters
z0 : complex array-like or number
port impedances
Returns y : complex array-like
admittance parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t
9 http://en.wikipedia.org/wiki/S-parameters
10 http://en.wikipedia.org/wiki/impedance_parameters
11 http://en.wikipedia.org/wiki/S-parameters
12 http://en.wikipedia.org/wiki/Admittance_parameters

10.2. network (skrf.network) 171


scikit-rf Documentation, Release dev

References

skrf.network.s2t

skrf.network.s2t(s)
Converts scattering parameters 13 to scattering transfer parameters 14 .
transfer parameters are also refered to as ‘wave cascading matrix’, this function only operates on 2-port net-
works.
Parameters s : numpy.ndarray (shape fx2x2)
scattering parameter matrix
Returns t : numpy.ndarray
scattering transfer parameters (aka wave cascading matrix)
See Also:

inv calculates inverse s-parameters

s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t

References

skrf.network.z2s

skrf.network.z2s(z, z0=50)
convert impedance parameters 15 to scattering parameters 16
√ √ √ √
s = ( y0 · z · y0 − I)( y0 · z · y0 + I)−1

Parameters z : complex array-like


impedance parameters
z0 : complex array-like or number
port impedances
Returns s : complex array-like
scattering parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t
13 http://en.wikipedia.org/wiki/S-parameters
14 http://en.wikipedia.org/wiki/Scattering_transfer_parameters#Scattering_transfer_parameters
15 http://en.wikipedia.org/wiki/impedance_parameters
16 http://en.wikipedia.org/wiki/S-parameters

172 Chapter 10. Reference


scikit-rf Documentation, Release dev

References

skrf.network.z2y

skrf.network.z2y(z)
convert impedance parameters 17 to admittance parameters 18

y = z −1

Parameters z : complex array-like


impedance parameters
Returns y : complex array-like
admittance parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t

References

skrf.network.z2t

skrf.network.z2t(z)
Not Implemented yet
convert impedance parameters 19 to scattering transfer parameters 20
Parameters z : complex array-like or number
impedance parameters
Returns s : complex array-like or number
scattering parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t
17 http://en.wikipedia.org/wiki/impedance_parameters
18 http://en.wikipedia.org/wiki/Admittance_parameters
19 http://en.wikipedia.org/wiki/impedance_parameters
20 http://en.wikipedia.org/wiki/Scattering_transfer_parameters#Scattering_transfer_parameters

10.2. network (skrf.network) 173


scikit-rf Documentation, Release dev

References

skrf.network.y2s

skrf.network.y2s(y, z0=50)
convert admittance parameters 21 to scattering parameters 22
√ √ √ √
s = (I − z0 · y · z0 )(I + z0 · y · z0 )−1

Parameters y : complex array-like


admittance parameters
z0 : complex array-like or number
port impedances
Returns s : complex array-like or number
scattering parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t

References

skrf.network.y2z

skrf.network.y2z(y)
convert admittance parameters 23 to impedance parameters 24

z = y −1

Parameters y : complex array-like


admittance parameters
Returns z : complex array-like
impedance parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t
21 http://en.wikipedia.org/wiki/Admittance_parameters
22 http://en.wikipedia.org/wiki/S-parameters
23 http://en.wikipedia.org/wiki/Admittance_parameters
24 http://en.wikipedia.org/wiki/impedance_parameters

174 Chapter 10. Reference


scikit-rf Documentation, Release dev

References

skrf.network.y2t

skrf.network.y2t(y)
Not Implemented Yet
convert admittance parameters 25 to scattering-transfer parameters 26
Parameters y : complex array-like or number
impedance parameters
Returns t : complex array-like or number
scattering parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t

References

skrf.network.t2s

skrf.network.t2s(t)
converts scattering transfer parameters 27 to scattering parameters 28
transfer parameters are also refered to as ‘wave cascading matrix’, this function only operates on 2-port net-
works. this function only operates on 2-port scattering parameters.
Parameters t : numpy.ndarray (shape fx2x2)
scattering transfer parameters
Returns s : numpy.ndarray
scattering parameter matrix.
See Also:

inv calculates inverse s-parameters

s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t

References

skrf.network.t2z

skrf.network.t2z(t)
Not Implemented Yet
25 http://en.wikipedia.org/wiki/Admittance_parameters
26 http://en.wikipedia.org/wiki/Scattering_transfer_parameters#Scattering_transfer_parameters
27 http://en.wikipedia.org/wiki/Scattering_transfer_parameters#Scattering_transfer_parameters
28 http://en.wikipedia.org/wiki/S-parameters

10.2. network (skrf.network) 175


scikit-rf Documentation, Release dev

Convert scattering transfer parameters 29 to impedance parameters 30


Parameters t : complex array-like or number
impedance parameters
Returns z : complex array-like or number
scattering parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t

References

skrf.network.t2y

skrf.network.t2y(t)
Not Implemented Yet
Convert scattering transfer parameters to admittance parameters 31
Parameters t : complex array-like or number
t-parameters
Returns y : complex array-like or number
admittance parameters
See Also:
s2z, s2y, s2t, z2s, z2y, z2t, y2s, y2z, y2z, t2s, t2z, t2y, Network.s, Network.y, Network.z,
Network.t

References

10.2.7 Misc Functions

average(list_of_networks) Calculates the average network from a list of Networks.


Network.nudge([amount]) Perturb s-parameters by small amount.

skrf.network.average

skrf.network.average(list_of_networks)
Calculates the average network from a list of Networks.
This is complex average of the s-parameters for a list of Networks.
Parameters list_of_networks : list of Network objects
the list of networks to average
Returns ntwk : Network
29 http://en.wikipedia.org/wiki/Scattering_transfer_parameters#Scattering_transfer_parameters
30 http://en.wikipedia.org/wiki/impedance_parameters
31 http://en.wikipedia.org/wiki/Scattering_transfer_parameters#Scattering_transfer_parameters

176 Chapter 10. Reference


scikit-rf Documentation, Release dev

the resultant averaged Network

Notes

This same function can be accomplished with properties of a NetworkSet class.

Examples

>>> ntwk_list = [rf.Network(’myntwk.s1p’), rf.Network(’myntwk2.s1p’)]


>>> mean_ntwk = rf.average(ntwk_list)

skrf.network.Network.nudge

Network.nudge(amount=1e-12)
Perturb s-parameters by small amount.
This is useful to work-around numerical bugs.
Parameters amount : number,
amount to add to s parameters

Notes

This function is self.s = self.s + 1e-12

10.3 networkSet (skrf.networkSet)

Provides a class representing an un-ordered set of n-port microwave networks.


Frequently one needs to make calculations, such as mean or standard deviation, on an entire set of n-port networks.
To facilitate these calculations the NetworkSet class provides convenient ways to make such calculations.
The results are returned in Network objects, so they can be plotted and saved in the same way one would do with a
Network.
The functionality in this module is provided as methods and properties of the NetworkSet Class.

10.3.1 NetworkSet Class

NetworkSet(ntwk_set[, name]) A set of Networks.

skrf.networkSet.NetworkSet

class skrf.networkSet.NetworkSet(ntwk_set, name=None)


A set of Networks.
This class allows functions on sets of Networks, such as mean or standard deviation, to be calculated conve-
niently. The results are returned in Network objects, so that they may be plotted and saved in like Network

10.3. networkSet (skrf.networkSet) 177


scikit-rf Documentation, Release dev

objects.
This class also provides methods which can be used to plot uncertainty bounds for a set of Network.
The names of the NetworkSet properties are generated dynamically upon ititialization, and thus documenta-
tion for individual properties and methods is not available. However, the properties do follow the convention:
>>> my_network_set.function_name_network_property_name

For example, the complex average (mean) Network for a NetworkSet is:
>>> my_network_set.mean_s

This accesses the property ‘s’, for each element in the set, and then calculates the ‘mean’ of the resultant set.
The order of operations is important.
Results are returned as Network objects, so they may be plotted or saved in the same way as for Network
objects:
>>> my_network_set.mean_s.plot_s_mag()
>>> my_network_set.mean_s.write_touchstone(’mean_response’)

If you are calculating functions that return scalar variables, then the result is accessable through the Network
property .s_re. For example:
>>> std_s_deg = my_network_set.std_s_deg

This result would be plotted by:


>>> std_s_deg.plot_s_re()

The operators, properties, and methods of NetworkSet object are dynamically generated by private methods
•__add_a_operator()
•__add_a_func_on_property()
•__add_a_element_wise_method()
•__add_a_plot_uncertainty()
thus, documentation on the individual methods and properties are not available.

Attributes

inv
mean_s_db the mean magnitude in dB.
std_s_db the mean magnitude in dB.

skrf.networkSet.NetworkSet.inv

NetworkSet.inv

skrf.networkSet.NetworkSet.mean_s_db

NetworkSet.mean_s_db
the mean magnitude in dB.

178 Chapter 10. Reference


scikit-rf Documentation, Release dev

note:
the mean is taken on the magnitude before convertedto db, so magnitude_2_db( mean(s_mag))
which is NOT the same as mean(s_db)

skrf.networkSet.NetworkSet.std_s_db

NetworkSet.std_s_db
the mean magnitude in dB.
note:
the mean is taken on the magnitude before convertedto db, so magnitude_2_db( mean(s_mag))
which is NOT the same as mean(s_db)

Methods

__init__ Initializer for NetworkSet


add_polar_noise
animate animate a property of the networkset
copy copies each network of the network set.
element_wise_method calls a given method of each element and returns the result as
from_dir Create a NetworkSet from a directory containing Networks
from_zip creates a NetworkSet from a zipfile of touchstones.
ntwk_attr_2_df Converts an attributes of the Networks within a NetworkSet to a
plot_logsigma plots the uncertainty for the set in units of log-sigma.
plot_minmax_bounds_component plots mean value of the NetworkSet with +- uncertainty bounds
plot_minmax_bounds_s_db this just calls
plot_minmax_bounds_s_time_db this just calls
plot_uncertainty_bounds_component plots mean value of the NetworkSet with +- uncertainty bounds
plot_uncertainty_bounds_s Plots complex uncertianty bounds plot on smith chart.
plot_uncertainty_bounds_s_db this just calls
plot_uncertainty_bounds_s_time_db this just calls
plot_uncertainty_decomposition plots the total and component-wise uncertainty
set_wise_function calls a function on a specific property of the networks in
signature visualization of relative changes in a NetworkSet.
to_dict Returns a dictionary representation of the NetworkSet
uncertainty_ntwk_triplet returns a 3-tuple of Network objects which contain the
write Write the NetworkSet to disk using write()
write_spreadsheet Write contents of network to a spreadsheet, for your boss to use.

skrf.networkSet.NetworkSet.__init__

NetworkSet.__init__(ntwk_set, name=None)
Initializer for NetworkSet
Parameters ntwk_set : list of Network objects
the set of Network objects
name : string

10.3. networkSet (skrf.networkSet) 179


scikit-rf Documentation, Release dev

the name of the NetworkSet, given to the Networks returned from properties of this
class.

skrf.networkSet.NetworkSet.add_polar_noise

NetworkSet.add_polar_noise(ntwk)

skrf.networkSet.NetworkSet.animate

NetworkSet.animate(attr=’s_deg’, ylims=(-5, 5), xlims=None, show=True, savefigs=False, *args,


**kwargs)
animate a property of the networkset
This loops through all elements in the NetworkSet and calls a plotting attribute (ie Network.plot_‘attr‘), with
given *args and **kwargs.
Parameters attr : str
plotting property of a Network (ie ‘s_db’, ‘s_deg’, etc)
ylims : tuple
passed to ylim. needed to have consistent y-limits accross frames
xlims : tuple
passed to xlim
show : bool
show each frame as its animated
savefigs : bool
save each frame as a png
*args, **kwargs : :
passed to the Network plotting function

Notes

using label=None will speed up animation significantly, because it prevents the legend from drawing

Examples

>>>ns.animate(‘s_deg’, ylims=(-5,5),label=None)

skrf.networkSet.NetworkSet.copy

NetworkSet.copy()
copies each network of the network set.

180 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.networkSet.NetworkSet.element_wise_method

NetworkSet.element_wise_method(network_method_name, *args, **kwargs)


calls a given method of each element and returns the result as a new NetworkSet if the output is a Network.

skrf.networkSet.NetworkSet.from_dir

classmethod NetworkSet.from_dir(dir=’.’, *args, **kwargs)


Create a NetworkSet from a directory containing Networks
This just calls
rf.NetworkSet(rf.read_all_networks(dir), *args, **kwargs)

Parameters dir : str


directory containing Network files.
*args, **kwargs : :
passed to NetworkSet constructor

Examples

>>> my_set = rf.NetworkSet.from_dir(’./data/’)

skrf.networkSet.NetworkSet.from_zip

classmethod NetworkSet.from_zip(zip_file_name, sort_filenames=True, *args, **kwargs)


creates a NetworkSet from a zipfile of touchstones.
Parameters zip_file_name : string
name of zipfile
sort_filenames: Boolean :
sort the filenames in teh zip file before constructing the NetworkSet
*args,**kwargs : arguments
passed to NetworkSet constructor

Examples

>>> import skrf as rf


>>> my_set = rf.NetworkSet.from_zip(’myzip.zip’)

skrf.networkSet.NetworkSet.ntwk_attr_2_df

NetworkSet.ntwk_attr_2_df(attr=’s_db’, m=0, n=0, *args, **kwargs)


Converts an attributes of the Networks within a NetworkSet to a Pandas DataFrame

10.3. networkSet (skrf.networkSet) 181


scikit-rf Documentation, Release dev

Examples

df = ns.ntwk_attr_2_df(‘s_db’,m=1,n=0) df.to_excel(‘output.xls’) # see Pandas docs for more info

skrf.networkSet.NetworkSet.plot_logsigma

NetworkSet.plot_logsigma(label_axis=True, *args, **kwargs)


plots the uncertainty for the set in units of log-sigma. Log-sigma is the complex standard deviation, plotted in
units of dB’s.
Parameters *args, **kwargs : arguments
passed to self.std_s.plot_s_db()

skrf.networkSet.NetworkSet.plot_minmax_bounds_component

NetworkSet.plot_minmax_bounds_component(attribute, m=0, n=0, type=’shade’, alpha=0.3,


color_error=None, markevery_error=20,
ax=None, ppf=None, kwargs_error={}, *args,
**kwargs)
plots mean value of the NetworkSet with +- uncertainty bounds in an Network’s attribute. This is designed
to represent uncertainty in a scalar component of the s-parameter. for example ploting the uncertainty in the
magnitude would be expressed by,
mean(abs(s)) +- std(abs(s))
the order of mean and abs is important.
takes: attribute: attribute of Network type to analyze [string] m: first index of attribute matrix [int] n: second
index of attribute matrix [int] type: [’shade’ | ‘bar’], type of plot to draw n_deviations: number of std
deviations to plot as bounds [number] alpha: passed to matplotlib.fill_between() command. [number, 0-1]
color_error: color of the +- std dev fill shading markevery_error: if type==’bar’, this controls frequency
of error bars
ax: Axes to plot on ppf: post processing function. a function applied to the
upper and low

*args,**kwargs: passed to Network.plot_s_re command used to plot mean response


kwargs_error: dictionary of kwargs to pass to the fill_between or errorbar plot command depending
on value of type.

returns: None
Note: for phase uncertainty you probably want s_deg_unwrap, or similar. uncerainty for wrapped phase blows
up at +-pi.

skrf.networkSet.NetworkSet.plot_minmax_bounds_s_db

NetworkSet.plot_minmax_bounds_s_db(*args, **kwargs)
this just calls plot_uncertainty_bounds(attribute= ‘s_mag’,’ppf’:mf.magnitude_2_db*args,**kwargs)
see plot_uncertainty_bounds for help

182 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.networkSet.NetworkSet.plot_minmax_bounds_s_time_db

NetworkSet.plot_minmax_bounds_s_time_db(*args, **kwargs)
this just calls plot_uncertainty_bounds(attribute= ‘s_mag’,’ppf’:mf.magnitude_2_db*args,**kwargs)
see plot_uncertainty_bounds for help

skrf.networkSet.NetworkSet.plot_uncertainty_bounds_component

NetworkSet.plot_uncertainty_bounds_component(attribute, m=0, n=0, type=’shade’,


n_deviations=3, alpha=0.3,
color_error=None, markevery_error=20,
ax=None, ppf=None, kwargs_error={},
*args, **kwargs)
plots mean value of the NetworkSet with +- uncertainty bounds in an Network’s attribute. This is designed
to represent uncertainty in a scalar component of the s-parameter. for example ploting the uncertainty in the
magnitude would be expressed by,
mean(abs(s)) +- std(abs(s))
the order of mean and abs is important.
takes: attribute: attribute of Network type to analyze [string] m: first index of attribute matrix [int] n: second
index of attribute matrix [int] type: [’shade’ | ‘bar’], type of plot to draw n_deviations: number of std
deviations to plot as bounds [number] alpha: passed to matplotlib.fill_between() command. [number, 0-1]
color_error: color of the +- std dev fill shading markevery_error: if type==’bar’, this controls frequency
of error bars
ax: Axes to plot on ppf: post processing function. a function applied to the
upper and low

*args,**kwargs: passed to Network.plot_s_re command used to plot mean response


kwargs_error: dictionary of kwargs to pass to the fill_between or errorbar plot command depending
on value of type.

returns: None
Note: for phase uncertainty you probably want s_deg_unwrap, or similar. uncerainty for wrapped phase blows
up at +-pi.

skrf.networkSet.NetworkSet.plot_uncertainty_bounds_s

NetworkSet.plot_uncertainty_bounds_s(multiplier=200, *args, **kwargs)


Plots complex uncertianty bounds plot on smith chart.
This function plots the complex uncertainty of a NetworkSet as circles on the smith chart. At each frequency a
circle with radii proportional to the complex standard deviation of the set at that frequency is drawn. Due to the
fact that the markersize argument is in pixels, the radii can scaled by the input argument multiplier.
default kwargs are { ‘marker’:’o’, ‘color’:’b’, ‘mew’:0, ‘ls’:’‘, ‘alpha’:.1, ‘label’:None, }

Parameters multipliter : float


controls the circle sizes, by multiples of the standard deviation.

10.3. networkSet (skrf.networkSet) 183


scikit-rf Documentation, Release dev

skrf.networkSet.NetworkSet.plot_uncertainty_bounds_s_db

NetworkSet.plot_uncertainty_bounds_s_db(*args, **kwargs)
this just calls plot_uncertainty_bounds(attribute= ‘s_mag’,’ppf’:mf.magnitude_2_db*args,**kwargs)
see plot_uncertainty_bounds for help

skrf.networkSet.NetworkSet.plot_uncertainty_bounds_s_time_db

NetworkSet.plot_uncertainty_bounds_s_time_db(*args, **kwargs)
this just calls plot_uncertainty_bounds(attribute= ‘s_mag’,’ppf’:mf.magnitude_2_db*args,**kwargs)
see plot_uncertainty_bounds for help

skrf.networkSet.NetworkSet.plot_uncertainty_decomposition

NetworkSet.plot_uncertainty_decomposition(m=0, n=0)
plots the total and component-wise uncertainty
Parameters m : int
first s-parameters index
n::
second s-parameter index

skrf.networkSet.NetworkSet.set_wise_function

NetworkSet.set_wise_function(func, a_property, *args, **kwargs)


calls a function on a specific property of the networks in this NetworkSet.
example: my_ntwk_set.set_wise_func(mean,’s’)

skrf.networkSet.NetworkSet.signature

NetworkSet.signature(m=0, n=0, from_mean=False, operation=’__sub__’, component=’s_mag’,


vmax=None, *args, **kwargs)
visualization of relative changes in a NetworkSet.
Creates a colored image representing the devation of each Network from the from mean Network of the Net-
workSet, vs frequency.
Parameters m : int
first s-parameters index
n : int
second s-parameter index
from_mean : Boolean
calculate distance from mean if True. or distance from first network in networkset if
False.
operation : [’__sub__’, ‘__div__’], ..

184 Chapter 10. Reference


scikit-rf Documentation, Release dev

operation to apply between each network and the reference network, which is either the
mean, or the initial ntwk.
component : [’s_mag’,’s_db’,’s_deg’ ..]
scalar component of Network to plot on the imshow. should be a property of the Net-
work object.
vmax : number
sets upper limit of colorbar, if None, will be set to 3*mean of the magnitude of the
complex difference
*args,**kwargs : arguments, keyword arguments
passed to imshow()

skrf.networkSet.NetworkSet.to_dict

NetworkSet.to_dict()
Returns a dictionary representation of the NetworkSet
The returned dictionary has the Network names for keys, and the Networks as values.

skrf.networkSet.NetworkSet.uncertainty_ntwk_triplet

NetworkSet.uncertainty_ntwk_triplet(attribute, n_deviations=3)
returns a 3-tuple of Network objects which contain the mean, upper_bound, and lower_bound for the given
Network attribute.
Used to save and plot uncertainty information data

skrf.networkSet.NetworkSet.write

NetworkSet.write(file=None, *args, **kwargs)


Write the NetworkSet to disk using write()
Parameters file : str or file-object
filename or a file-object. If left as None then the filename will be set to Calibra-
tion.name, if its not None. If both are None, ValueError is raised.
*args, **kwargs : arguments and keyword arguments
passed through to write()
See Also:
skrf.io.general.write, skrf.io.general.read

Notes

If the self.name is not None and file is can left as None and the resultant file will have the .ns extension appended
to the filename.

10.3. networkSet (skrf.networkSet) 185


scikit-rf Documentation, Release dev

Examples

>>> ns.name = ’my_ns’


>>> ns.write()

skrf.networkSet.NetworkSet.write_spreadsheet

NetworkSet.write_spreadsheet(*args, **kwargs)
Write contents of network to a spreadsheet, for your boss to use.
See Also:
skrf.io.general.network_2_spreadsheet

10.4 plotting (skrf.plotting)

This module provides general plotting functions.

10.4.1 Plots and Charts

smith([smithR, chart_type, draw_labels, ...]) plots the smith chart of a given radius
plot_smith(z[, smith_r, chart_type, ...]) plot complex data on smith chart
plot_rectangular(x, y[, x_label, y_label, ...]) plots rectangular data and optionally label axes.
plot_polar(theta, r[, x_label, y_label, ...]) plots polar data on a polar plot and optionally label axes.
plot_complex_rectangular(z[, x_label, ...]) plot complex data on the complex plane
plot_complex_polar(z[, x_label, y_label, ...]) plot complex data in polar format.

skrf.plotting.smith

skrf.plotting.smith(smithR=1, chart_type=’z’, draw_labels=False, border=False, ax=None)


plots the smith chart of a given radius
Parameters smithR : number
radius of smith chart
chart_type : [’z’,’y’]
Contour type. Possible values are
• ‘z’ : lines of constant impedance
• ‘y’ : lines of constant admittance
draw_labels : Boolean
annotate real and imaginary parts of impedance on the chart (only if smithR=1)
border : Boolean
draw a rectangular border with axis ticks, around the perimeter of the figure. Not used
if draw_labels = True
ax : matplotlib.axes object

186 Chapter 10. Reference


scikit-rf Documentation, Release dev

existing axes to draw smith chart on

skrf.plotting.plot_smith

skrf.plotting.plot_smith(z, smith_r=1, chart_type=’z’, x_label=’Real’, y_label=’Imaginary’,


title=’Complex Plane’, show_legend=True, axis=’equal’, ax=None,
force_chart=False, *args, **kwargs)
plot complex data on smith chart
Parameters z : array-like, of complex data
data to plot
smith_r : number
radius of smith chart
chart_type : [’z’,’y’]
Contour type for chart.
• ‘z’ : lines of constant impedance
• ‘y’ : lines of constant admittance
x_label : string
x-axis label
y_label : string
y-axis label
title : string
plot title
show_legend : Boolean
controls the drawing of the legend
axis_equal: Boolean :
sets axis to be equal increments (calls axis(‘equal’))
force_chart : Boolean
forces the re-drawing of smith chart
ax : matplotlib.axes.AxesSubplot object
axes to draw on
*args,**kwargs : passed to pylab.plot
See Also:

plot_rectangular plots rectangular data


plot_complex_rectangular plot complex data on complex plane
plot_polar plot polar data
plot_complex_polar plot complex data on polar plane
plot_smith plot complex data on smith chart

10.4. plotting (skrf.plotting) 187


scikit-rf Documentation, Release dev

skrf.plotting.plot_rectangular

skrf.plotting.plot_rectangular(x, y, x_label=None, y_label=None, title=None,


show_legend=True, axis=’tight’, ax=None, *args, **kwargs)
plots rectangular data and optionally label axes.
Parameters z : array-like, of complex data
data to plot
x_label : string
x-axis label
y_label : string
y-axis label
title : string
plot title
show_legend : Boolean
controls the drawing of the legend
ax : matplotlib.axes.AxesSubplot object
axes to draw on
*args,**kwargs : passed to pylab.plot

skrf.plotting.plot_polar

skrf.plotting.plot_polar(theta, r, x_label=None, y_label=None, title=None, show_legend=True,


axis_equal=False, ax=None, *args, **kwargs)
plots polar data on a polar plot and optionally label axes.
Parameters theta : array-like
data to plot
r : array-like
x_label : string
x-axis label
y_label : string
y-axis label
title : string
plot title
show_legend : Boolean
controls the drawing of the legend
ax : matplotlib.axes.AxesSubplot object
axes to draw on
*args,**kwargs : passed to pylab.plot
See Also:

188 Chapter 10. Reference


scikit-rf Documentation, Release dev

plot_rectangular plots rectangular data


plot_complex_rectangular plot complex data on complex plane
plot_polar plot polar data
plot_complex_polar plot complex data on polar plane
plot_smith plot complex data on smith chart

skrf.plotting.plot_complex_rectangular

skrf.plotting.plot_complex_rectangular(z, x_label=’Real’, y_label=’Imag’, title=’Complex


Plane’, show_legend=True, axis=’equal’, ax=None,
*args, **kwargs)
plot complex data on the complex plane
Parameters z : array-like, of complex data
data to plot
x_label : string
x-axis label
y_label : string
y-axis label
title : string
plot title
show_legend : Boolean
controls the drawing of the legend
ax : matplotlib.axes.AxesSubplot object
axes to draw on
*args,**kwargs : passed to pylab.plot
See Also:

plot_rectangular plots rectangular data


plot_complex_rectangular plot complex data on complex plane
plot_polar plot polar data
plot_complex_polar plot complex data on polar plane
plot_smith plot complex data on smith chart

skrf.plotting.plot_complex_polar

skrf.plotting.plot_complex_polar(z, x_label=None, y_label=None, title=None,


show_legend=True, axis_equal=False, ax=None, *args,
**kwargs)
plot complex data in polar format.
Parameters z : array-like, of complex data
data to plot

10.4. plotting (skrf.plotting) 189


scikit-rf Documentation, Release dev

x_label : string
x-axis label
y_label : string
y-axis label
title : string
plot title
show_legend : Boolean
controls the drawing of the legend
ax : matplotlib.axes.AxesSubplot object
axes to draw on
*args,**kwargs : passed to pylab.plot
See Also:

plot_rectangular plots rectangular data


plot_complex_rectangular plot complex data on complex plane
plot_polar plot polar data
plot_complex_polar plot complex data on polar plane
plot_smith plot complex data on smith chart

10.4.2 Misc Functions

save_all_figs([dir, format, replace_spaces, ...]) Save all open Figures to disk.


add_markers_to_lines([ax, marker_list, ...]) adds markers to existing lings on a plot
legend_off([ax]) turn off the legend for a given axes.
func_on_all_figs(func, *args, **kwargs) runs a function after making all open figures current.

skrf.plotting.save_all_figs

skrf.plotting.save_all_figs(dir=’./’, format=None, replace_spaces=True, echo=True)


Save all open Figures to disk.
Parameters dir : string
path to save figures into
format : None, or list of strings
the types of formats to save figures as. The elements of this list are passed to :mat-
plotlib:‘savefig‘. This is a list so that you can save each figure in multiple formats.
echo : bool
True prints filenames as they are saved

190 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.plotting.add_markers_to_lines

skrf.plotting.add_markers_to_lines(ax=None, marker_list=[’o’, ‘D’, ‘s’, ‘+’, ‘x’], markev-


ery=10)
adds markers to existing lings on a plot
this is convinient if you have already have a plot made, but then need to add markers afterwards, so that it can be
interpreted in black and white. The markevery argument makes the markers less frequent than the data, which
is generally what you want.
Parameters ax : matplotlib.Axes
axis which to add markers to, defaults to gca()
marker_list : list of marker characters
see matplotlib.plot help for possible marker characters
markevery : int
markevery number of points with a marker.

skrf.plotting.legend_off

skrf.plotting.legend_off(ax=None)
turn off the legend for a given axes.
if no axes is given then it will use current axes.
Parameters ax : matplotlib.Axes object
axes to operate on

skrf.plotting.func_on_all_figs

skrf.plotting.func_on_all_figs(func, *args, **kwargs)


runs a function after making all open figures current.
useful if you need to change the properties of many open figures at once, like turn off the grid.
Parameters func : function
function to call
*args, **kwargs : pased to func

Examples

>>> rf.func_on_all_figs(grid,alpha=.3)

10.5 mathFunctions (skrf.mathFunctions)

Provides commonly used mathematical functions.

10.5.1 Complex Component Conversion

10.5. mathFunctions (skrf.mathFunctions) 191


scikit-rf Documentation, Release dev

complex_2_reim(z) takes:
complex_2_magnitude(input) returns the magnitude of a complex number.
complex_2_db(input) returns the magnitude in dB of a complex number.
complex_2_radian(input) returns the angle complex number in radians.
complex_2_degree(input) returns the angle complex number in radians.
complex_2_magnitude(input) returns the magnitude of a complex number.

skrf.mathFunctions.complex_2_reim

skrf.mathFunctions.complex_2_reim(z)
takes: input: complex number or array
return: real: real part of input imag: imaginary part of input
note: this just calls ‘complex_components’

skrf.mathFunctions.complex_2_magnitude

skrf.mathFunctions.complex_2_magnitude(input)
returns the magnitude of a complex number.

skrf.mathFunctions.complex_2_db

skrf.mathFunctions.complex_2_db(input)
returns the magnitude in dB of a complex number.
returns: 20*log10(|z|)
where z is a complex number

skrf.mathFunctions.complex_2_radian

skrf.mathFunctions.complex_2_radian(input)
returns the angle complex number in radians.

skrf.mathFunctions.complex_2_degree

skrf.mathFunctions.complex_2_degree(input)
returns the angle complex number in radians.

skrf.mathFunctions.complex_2_magnitude

skrf.mathFunctions.complex_2_magnitude(input)
returns the magnitude of a complex number.
Continued on next page

192 Chapter 10. Reference


scikit-rf Documentation, Release dev

Table 10.20 – continued from previous page

10.5.2 Phase Unwrapping

unwrap_rad(input) unwraps a phase given in radians


sqrt_phase_unwrap(input) takes the square root of a complex number with unwraped phase

skrf.mathFunctions.unwrap_rad

skrf.mathFunctions.unwrap_rad(input)
unwraps a phase given in radians

skrf.mathFunctions.sqrt_phase_unwrap

skrf.mathFunctions.sqrt_phase_unwrap(input)
takes the square root of a complex number with unwraped phase
this idea came from Lihan Chen

10.5.3 Unit Conversion

radian_2_degree(rad)
degree_2_radian(deg)
np_2_db(x) converts a value in dB to neper’s
db_2_np(x) converts a value in nepers to dB

skrf.mathFunctions.radian_2_degree

skrf.mathFunctions.radian_2_degree(rad)

skrf.mathFunctions.degree_2_radian

skrf.mathFunctions.degree_2_radian(deg)

skrf.mathFunctions.np_2_db

skrf.mathFunctions.np_2_db(x)
converts a value in dB to neper’s

skrf.mathFunctions.db_2_np

skrf.mathFunctions.db_2_np(x)
converts a value in nepers to dB

10.5. mathFunctions (skrf.mathFunctions) 193


scikit-rf Documentation, Release dev

10.5.4 Scalar-Complex Conversion

These conversions are useful for wrapping other functions that dont support complex numbers.

complex2Scalar(input)
scalar2Complex(input)

skrf.mathFunctions.complex2Scalar

skrf.mathFunctions.complex2Scalar(input)

skrf.mathFunctions.scalar2Complex

skrf.mathFunctions.scalar2Complex(input)

10.5.5 Special Functions

dirac_delta(x) the dirac function.


neuman(x) neumans number
null(A[, eps]) calculates the null space of matrix A.

skrf.mathFunctions.dirac_delta

skrf.mathFunctions.dirac_delta(x)
the dirac function.
can take numpy arrays or numbers returns 1 or 0

skrf.mathFunctions.neuman

skrf.mathFunctions.neuman(x)
neumans number
2-dirac_delta(x)

skrf.mathFunctions.null

skrf.mathFunctions.null(A, eps=1e-15)
calculates the null space of matrix A. i found this on stack overflow.

10.6 tlineFunctions (skrf.tlineFunctions)

This module provides functions related to transmission line theory.

194 Chapter 10. Reference


scikit-rf Documentation, Release dev

10.6.1 Impedance and Reflection Coefficient

These functions relate basic tranmission line quantities such as characteristic impedance, input impedance, reflection
coefficient, etc. Each function has two names. One is a long-winded but readable name and the other is a short-hand
variable-like names. Below is a table relating these two names with each other as well as common mathematical
symbols.
Symbol Variable Name Long Name
Zl z_l load_impedance
Zin z_in input_impedance
Γ0 Gamma_0 reflection_coefficient
Γin Gamma_in reflection_coefficient_at_theta
θ theta electrical_length
There may be a bit of confusion about the difference between the load impedance the input impedance. This is because
the load impedance is the input impedance at the load. An illustration may provide some useful reference.
Below is a (bad) illustration of a section of uniform transmission line of characteristic impedance Z0 , and electrical
length θ. The line is terminated on the right with some load impedance, Zl . The input impedance Zin and input
reflection coefficient Γin are looking in towards the load from the distance θ from the load.

Z0 , θ
o===============o=[Zl ]
→ →
Zin , Γin Z l , Γ0

So, to clarify the confusion,

Zin = Zl , Γin = Γl at θ = 0

Short names

theta(gamma, f, d[, deg]) Calculates the electrical length of a section of transmission line.
zl_2_Gamma0(z0, zl) Returns the reflection coefficient for a given load impedance, and characteristic impedanc
Gamma0_2_zl(z0, Gamma) calculates the input impedance given a reflection coefficient and
zl_2_zin(z0, zl, theta) input impedance of load impedance zl at a given electrical length,
zl_2_Gamma_in(z0, zl, theta)
Gamma0_2_Gamma_in(Gamma0, theta) reflection coefficient at a given electrical length.
Gamma0_2_zin(z0, Gamma0, theta) calculates the input impedance at electrical length theta, given a

skrf.tlineFunctions.theta

skrf.tlineFunctions.theta(gamma, f, d, deg=False)
Calculates the electrical length of a section of transmission line.

θ = γ(f ) · d

Parameters gamma : function


propagation constant function, which takes frequency in hz as a sole argument. see
Notes.

10.6. tlineFunctions (skrf.tlineFunctions) 195


scikit-rf Documentation, Release dev

l : number or array-like
length of line, in meters
f : number or array-like
frequency at which to calculate
deg : Boolean
return in degrees or not.
Returns theta : number or array-like
electrical length in radians or degrees, depending on value of deg.
See Also:

electrical_length_2_distance opposite conversion

Notes

the convention has been chosen that forward propagation is represented by the positive imaginary part of the
value returned by the gamma function

skrf.tlineFunctions.zl_2_Gamma0

skrf.tlineFunctions.zl_2_Gamma0(z0, zl)
Returns the reflection coefficient for a given load impedance, and characteristic impedance.
For a transmission line of characteristic impedance Z0 terminated with load impedance Zl , the complex reflec-
tion coefficient is given by,
Zl − Z0
Γ=
Zl + Z0

Parameters z0 : number or array-like


characteristic impedance
zl : number or array-like
load impedance (aka input impedance)
Returns gamma : number or array-like
reflection coefficient
See Also:

Gamma0_2_zl reflection coefficient to load impedance

Notes

inputs are typecasted to 1D complex array

196 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.tlineFunctions.Gamma0_2_zl

skrf.tlineFunctions.Gamma0_2_zl(z0, Gamma)
calculates the input impedance given a reflection coefficient and characterisitc impedance
1+Γ
Z0 ( )
1−Γ

Parameters Gamma : number or array-like


complex reflection coefficient
z0 : number or array-like
characteristic impedance
Returns zin : number or array-like
input impedance

skrf.tlineFunctions.zl_2_zin

skrf.tlineFunctions.zl_2_zin(z0, zl, theta)


input impedance of load impedance zl at a given electrical length, given characteristic impedance z0.
Parameters z0 : characteristic impedance.
zl : load impedance
theta : electrical length of the line, (may be complex)

skrf.tlineFunctions.zl_2_Gamma_in

skrf.tlineFunctions.zl_2_Gamma_in(z0, zl, theta)

skrf.tlineFunctions.Gamma0_2_Gamma_in

skrf.tlineFunctions.Gamma0_2_Gamma_in(Gamma0, theta)
reflection coefficient at a given electrical length.

Γin = Γ0 e−2jθ

Parameters Gamma0 : number or array-like


reflection coefficient at theta=0
theta : number or array-like
electrical length, (may be complex)
Returns Gamma_in : number or array-like
input reflection coefficient

10.6. tlineFunctions (skrf.tlineFunctions) 197


scikit-rf Documentation, Release dev

skrf.tlineFunctions.Gamma0_2_zin

skrf.tlineFunctions.Gamma0_2_zin(z0, Gamma0, theta)


calculates the input impedance at electrical length theta, given a reflection coefficient and characterisitc
impedance of the medium Parameters ———-
z0 - characteristic impedance. Gamma: reflection coefficient theta: electrical length of the line, (may
be complex)

returns zin: input impedance at theta

Long-names

distance_2_electrical_length(gamma, f, d[, deg]) Calculates the electrical length of a section of trans


electrical_length_2_distance(theta, gamma, f0) Convert electrical length to a physical distance.
reflection_coefficient_at_theta(Gamma0, theta) reflection coefficient at a given electrical length.
reflection_coefficient_2_input_impedance(z0, ...) calculates the input impedance given a reflection c
reflection_coefficient_2_input_impedance_at_theta(z0, ...) calculates the input impedance at electrical length
input_impedance_at_theta(z0, zl, theta) input impedance of load impedance zl at a given el
load_impedance_2_reflection_coefficient(z0, zl) Returns the reflection coefficient for a given load im
load_impedance_2_reflection_coefficient_at_theta(z0, ...)

skrf.tlineFunctions.distance_2_electrical_length

skrf.tlineFunctions.distance_2_electrical_length(gamma, f, d, deg=False)
Calculates the electrical length of a section of transmission line.

θ = γ(f ) · d

Parameters gamma : function


propagation constant function, which takes frequency in hz as a sole argument. see
Notes.
l : number or array-like
length of line, in meters
f : number or array-like
frequency at which to calculate
deg : Boolean
return in degrees or not.
Returns theta : number or array-like
electrical length in radians or degrees, depending on value of deg.
See Also:

electrical_length_2_distance opposite conversion

198 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

the convention has been chosen that forward propagation is represented by the positive imaginary part of the
value returned by the gamma function

skrf.tlineFunctions.electrical_length_2_distance

skrf.tlineFunctions.electrical_length_2_distance(theta, gamma, f0, deg=True)


Convert electrical length to a physical distance.

θ
d=
γ(f0 )

Parameters theta : number or array-like


electical length. units depend on deg option
gamma : function
propagation constant function, which takes frequency in hz as a sole argument. see
Notes
f0 : number or array-like
frequency at which to calculate
deg : Boolean
return in degrees or not.
Returns d: physical distance :
See Also:

distance_2_electrical_length opposite conversion

Notes

the convention has been chosen that forward propagation is represented by the positive imaginary part of the
value returned by the gamma function

skrf.tlineFunctions.reflection_coefficient_at_theta

skrf.tlineFunctions.reflection_coefficient_at_theta(Gamma0, theta)
reflection coefficient at a given electrical length.

Γin = Γ0 e−2jθ

Parameters Gamma0 : number or array-like


reflection coefficient at theta=0
theta : number or array-like
electrical length, (may be complex)

10.6. tlineFunctions (skrf.tlineFunctions) 199


scikit-rf Documentation, Release dev

Returns Gamma_in : number or array-like


input reflection coefficient

skrf.tlineFunctions.reflection_coefficient_2_input_impedance

skrf.tlineFunctions.reflection_coefficient_2_input_impedance(z0, Gamma)
calculates the input impedance given a reflection coefficient and characterisitc impedance
1+Γ
Z0 ( )
1−Γ

Parameters Gamma : number or array-like


complex reflection coefficient
z0 : number or array-like
characteristic impedance
Returns zin : number or array-like
input impedance

skrf.tlineFunctions.reflection_coefficient_2_input_impedance_at_theta

skrf.tlineFunctions.reflection_coefficient_2_input_impedance_at_theta(z0,
Gamma0,
theta)
calculates the input impedance at electrical length theta, given a reflection coefficient and characterisitc
impedance of the medium Parameters ———-
z0 - characteristic impedance. Gamma: reflection coefficient theta: electrical length of the line, (may
be complex)

returns zin: input impedance at theta

skrf.tlineFunctions.input_impedance_at_theta

skrf.tlineFunctions.input_impedance_at_theta(z0, zl, theta)


input impedance of load impedance zl at a given electrical length, given characteristic impedance z0.
Parameters z0 : characteristic impedance.
zl : load impedance
theta : electrical length of the line, (may be complex)

skrf.tlineFunctions.load_impedance_2_reflection_coefficient

skrf.tlineFunctions.load_impedance_2_reflection_coefficient(z0, zl)
Returns the reflection coefficient for a given load impedance, and characteristic impedance.

200 Chapter 10. Reference


scikit-rf Documentation, Release dev

For a transmission line of characteristic impedance Z0 terminated with load impedance Zl , the complex reflec-
tion coefficient is given by,
Zl − Z0
Γ=
Zl + Z0

Parameters z0 : number or array-like


characteristic impedance
zl : number or array-like
load impedance (aka input impedance)
Returns gamma : number or array-like
reflection coefficient
See Also:

Gamma0_2_zl reflection coefficient to load impedance

Notes

inputs are typecasted to 1D complex array

skrf.tlineFunctions.load_impedance_2_reflection_coefficient_at_theta

skrf.tlineFunctions.load_impedance_2_reflection_coefficient_at_theta(z0, zl,
theta)

10.6.2 Distributed Circuit and Wave Quantities

distributed_circuit_2_propagation_impedance(...) Converts distrubuted circuit values to wave quantities.


propagation_impedance_2_distributed_circuit(...) Converts wave quantities to distrubuted circuit values.

skrf.tlineFunctions.distributed_circuit_2_propagation_impedance

skrf.tlineFunctions.distributed_circuit_2_propagation_impedance(distributed_admittance,
dis-
tributed_impedance)
Converts distrubuted circuit values to wave quantities.
This converts complex distributed impedance and admittance to propagation constant and characteristic
impedance. The relation is


r 0
Z
Z0 = 0 γ = Z0 Y 0
Y

Parameters distributed_admittance : number, array-like


distributed admittance

10.6. tlineFunctions (skrf.tlineFunctions) 201


scikit-rf Documentation, Release dev

distributed_impedance : number, array-like


distributed impedance
Returns propagation_constant : number, array-like
distributed impedance
characteristic_impedance : number, array-like
distributed impedance
See Also:

propagation_impedance_2_distributed_circuit opposite conversion

skrf.tlineFunctions.propagation_impedance_2_distributed_circuit

skrf.tlineFunctions.propagation_impedance_2_distributed_circuit(propagation_constant,
characteris-
tic_impedance)
Converts wave quantities to distrubuted circuit values.
Converts complex propagation constant and characteristic impedance to distributed impedance and admittance.
The relation is,
0 0 γ
Z = γZ0 Y =
Z0

Parameters propagation_constant : number, array-like


distributed impedance
characteristic_impedance : number, array-like
distributed impedance
Returns distributed_admittance : number, array-like
distributed admittance
distributed_impedance : number, array-like
distributed impedance
See Also:

distributed_circuit_2_propagation_impedance opposite conversion

10.6.3 Transmission Line Physics

skin_depth(f, rho, mu_r) the skin depth for a material.


surface_resistivity(f, rho, mu_r) surface resistivity.

skrf.tlineFunctions.skin_depth

skrf.tlineFunctions.skin_depth(f, rho, mu_r)


the skin depth for a material.

202 Chapter 10. Reference


scikit-rf Documentation, Release dev

see www.microwaves101.com for more info.


Parameters f : number or array-like
frequency, in Hz
rho : number of array-like
bulk resistivity of material, in ohm*m
mu_r : number or array-like
relative permiability of material
Returns skin depth : number or array-like
the skin depth, in m

skrf.tlineFunctions.surface_resistivity

skrf.tlineFunctions.surface_resistivity(f, rho, mu_r)


surface resistivity.
see www.microwaves101.com for more info.
Parameters f : number or array-like
frequency, in Hz
rho : number or array-like
bulk resistivity of material, in ohm*m
mu_r : number or array-like
relative permiability of material
Returns surface resistivity: ohms/square :

10.7 constants (skrf.constants)

This module contains pre-initialized objects’s.

10.7.1 Standard Waveguide Bands

Frequency Objects

These are predefined Frequency objects that correspond to standard waveguide bands. This information is taken
from the VDI Application Note 1002 32 .
Object Name Description
f_wr10 WR-10, 75-110 GHz
f_wr3 WR-3, 220-325 GHz
f_wr2p2 WR-2.2, 330-500 GHz
f_wr1p5 WR-1.5, 500-750 GHz
f_wr1 WR-1, 750-1100 GHz
... ...
32 VDI Application Note: VDI Waveguide Band Designations (VDI-1002) http://vadiodes.com/VDI/pdf/waveguidechart200908.pdf

10.7. constants (skrf.constants) 203


scikit-rf Documentation, Release dev

RectangularWaveguide Objects

These are predefined RectangularWaveguide objects for standard waveguide bands.


Object Name Description
wr10 WR-10, 75-110 GHz
wr3 WR-3, 220-325 GHz
wr2p2 WR-2.2, 330-500 GHz
wr1p5 WR-1.5, 500-750 GHz
wr1 WR-1, 750-1100 GHz
... ...

10.7.2 Shorthand Names

Below is a list of shorthand object names which can be use to save some typing. These names are defined in the main
__init__ module.
Shorthand Full Object Name
F Frequency
N Network
NS NetworkSet
M Media
C Calibration
The following are shorthand names for commonly used, but unfortunately longwinded functions.
Shorthand Full Object Name
saf save_all_figs()

10.7.3 References

10.8 util (skrf.util)

Holds utility functions that are general conveniences.

10.8.1 General

now_string() returns a unique sortable string, representing the current time


find_nearest(array, value) find nearest value in array.
find_nearest_index(array, value) find nearest value in array.
get_fid(file, *args, **kwargs) Returns a file object, given a filename or file object
get_extn(filename) Get the extension from a filename.

skrf.util.now_string

skrf.util.now_string()
returns a unique sortable string, representing the current time
nice for generating date-time stamps to be used in file-names, the companion function now_string_2_dt()
can be used to read these string back into datetime objects.
See Also:

204 Chapter 10. Reference


scikit-rf Documentation, Release dev

now_string_2_dt

skrf.util.find_nearest

skrf.util.find_nearest(array, value)
find nearest value in array.
taken from http://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array
Parameters array : numpy.ndarray
array we are searching for a value in
value : element of the array
value to search for
Returns found_value : an element of the array
the value that is numerically closest to value

skrf.util.find_nearest_index

skrf.util.find_nearest_index(array, value)
find nearest value in array.
Parameters array : numpy.ndarray
array we are searching for a value in
value : element of the array
value to search for
Returns found_index : int
the index at which the numerically closest element to value was found at
taken from http://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-
array :

skrf.util.get_fid

skrf.util.get_fid(file, *args, **kwargs)


Returns a file object, given a filename or file object
Useful when you want to allow the arguments of a function to be either files or filenames
Parameters file : str or file-object
file to open
*args, **kwargs : arguments and keyword arguments
passed through to pickle.load

10.8. util (skrf.util) 205


scikit-rf Documentation, Release dev

skrf.util.get_extn

skrf.util.get_extn(filename)
Get the extension from a filename.
The extension is defined as everything passed the last ‘.’. Returns None if it aint got one
Parameters filename : string
the filename
Returns ext : string, None
either the extension (not including ‘.’) or None if there isnt one

10.9 io (skrf.io)

This Package provides functions and objects for input/output.


The general functions read() and write() can be used to read and write [almost] any skrf object to disk, using
the pickle module.
Reading and writing touchstone files is supported through the Touchstone class, which can be more easily used
through the Network constructor, __init__()

10.9.1 general (skrf.io.general)

General io functions for reading and writing skrf objects

read(file, *args, **kwargs) Read skrf object[s] from a pickle file


read_all([dir, contains, f_unit, obj_type]) Read all skrf objects in a directory
read_all_networks(*args, **kwargs) Read all networks in a directory.
write(file, obj[, overwrite]) Write skrf object[s] to a file
write_all(dict_objs[, dir]) Write a dictionary of skrf objects individual files in dir.
save_sesh(dict_objs[, file, module, ...]) Save all skrf objects in the local namespace.

skrf.io.general.read

skrf.io.general.read(file, *args, **kwargs)


Read skrf object[s] from a pickle file
Reads a skrf object that is written with write(), which uses the pickle module.
Parameters file : str or file-object
name of file, or a file-object
*args, **kwargs : arguments and keyword arguments
passed through to pickle.load
See Also:

read read a skrf object


write write skrf object[s]

206 Chapter 10. Reference


scikit-rf Documentation, Release dev

read_all read all skrf objects in a directory


write_all write dictionary of skrf objects to a directory

Notes

if file is a file-object it is left open, if it is a filename then a file-object is opened and closed. If file is a file-object
and reading fails, then the position is reset back to 0 using seek if possible.

Examples

>>> n = rf.Network(f=[1,2,3],s=[1,1,1],z0=50)
>>> n.write(’my_ntwk.ntwk’)
>>> n_2 = rf.read(’my_ntwk.ntwk’)

skrf.io.general.read_all

skrf.io.general.read_all(dir=’.’, contains=None, f_unit=None, obj_type=None)


Read all skrf objects in a directory
Attempts to load all files in dir, using read(). Any file that is not readable by skrf is skipped. Optionally,
simple filtering can be achieved through the use of contains argument.
Parameters dir : str, optional
the directory to load from, default ‘.’
contains : str, optional
if not None, only files containing this substring will be loaded
f_unit : [’hz’,’khz’,’mhz’,’ghz’,’thz’]
for all Network objects, set their frequencies’s f_unit
obj_type : str
Name of skrf object types to read (ie ‘Network’)
Returns out : dictionary
dictionary containing all loaded skrf objects. keys are the filenames without extensions,
and the values are the objects
See Also:

read read a skrf object


write write skrf object[s]
read_all read all skrf objects in a directory
write_all write dictionary of skrf objects to a directory

Examples

10.9. io (skrf.io) 207


scikit-rf Documentation, Release dev

>>> rf.read_all(’skrf/data/’)
{’delay_short’: 1-Port Network: ’delay_short’, 75-110 GHz, 201 pts, z0=[ 50.+0.j],
’line’: 2-Port Network: ’line’, 75-110 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j],
’ntwk1’: 2-Port Network: ’ntwk1’, 1-10 GHz, 91 pts, z0=[ 50.+0.j 50.+0.j],
’one_port’: one port Calibration: ’one_port’, 500-750 GHz, 201 pts, 4-ideals/4-measured,
...

>>> rf.read_all(’skrf/data/’, obj_type = ’Network’)


{’delay_short’: 1-Port Network: ’delay_short’, 75-110 GHz, 201 pts, z0=[ 50.+0.j],
’line’: 2-Port Network: ’line’, 75-110 GHz, 201 pts, z0=[ 50.+0.j 50.+0.j],
’ntwk1’: 2-Port Network: ’ntwk1’, 1-10 GHz, 91 pts, z0=[ 50.+0.j 50.+0.j],
...

skrf.io.general.read_all_networks

skrf.io.general.read_all_networks(*args, **kwargs)
Read all networks in a directory.
This is a convenience function. It just calls:
read_all(*args,obj_type=’Network’, **kwargs)

See Also:
read_all

skrf.io.general.write

skrf.io.general.write(file, obj, overwrite=True)


Write skrf object[s] to a file
This uses the pickle module to write skrf objects to a file. Note that you can write any pickl-able python
object. For example, you can write a list or dictionary of Network objects or Calibration objects. This
will write out a single file. If you would like to write out a seperate file for each object, use write_all().
Parameters file : file or string
File or filename to which the data is saved. If file is a file-object, then the filename is
unchanged. If file is a string, an appropriate extension will be appended to the file name
if it does not already have an extension.
obj : an object, or list/dict of objects
object or list/dict of objects to write to disk
overwrite : Boolean
if file exists, should it be overwritten?
See Also:

read read a skrf object


write write skrf object[s]
read_all read all skrf objects in a directory
write_all write dictionary of skrf objects to a directory
skrf.network.Network.write write method of Network

208 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibration.Calibration.write write method of Calibration

Notes

If file is a str, but doesnt contain a suffix, one is chosen automatically. Here are the extensions
skrf object extension
Frequency ‘.freq’
Network ‘.ntwk’
NetworkSet ‘.ns’
Calibration ‘.cal’
Media ‘.med’
other ‘.p’
To make file written by this method cross-platform, the pickling protocol 2 is used. See pickle for more info.

Examples

Convert a touchstone file to a pickled Network,


>>> n = rf.Network(’my_ntwk.s2p’)
>>> rf.write(’my_ntwk’,n)
>>> n_red = rf.read(’my_ntwk.ntwk’)

Writing a list of different objects


>>> n = rf.Network(’my_ntwk.s2p’)
>>> ns = rf.NetworkSet([n,n,n])
>>> rf.write(’out’,[n,ns])
>>> n_red = rf.read(’out.p’)

skrf.io.general.write_all

skrf.io.general.write_all(dict_objs, dir=’.’, *args, **kwargs)


Write a dictionary of skrf objects individual files in dir.
Each object is written to its own file. The filename used for each object is taken from its key in the dictionary.
If no extension exists in the key, then one is added. See write() for a list of extensions. If you would like to
write the dictionary to a single output file use write().
Parameters dict_objs : dict
dictionary of skrf objects
dir : str
directory to save skrf objects into
*args, **kwargs : :
passed through to write(). overwrite option may be of use.
See Also:

read read a skrf object


write write skrf object[s]

10.9. io (skrf.io) 209


scikit-rf Documentation, Release dev

read_all read all skrf objects in a directory


write_all write dictionary of skrf objects to a directory

Notes

Any object in dict_objs that is pickl-able will be written.

Examples

Writing a diction of different skrf objects


>>> from skrf.data import line, short
>>> d = {’ring_slot’:ring_slot, ’one_port_cal’:one_port_cal}
>>> rf.write_all(d)

skrf.io.general.save_sesh

skrf.io.general.save_sesh(dict_objs, file=’skrfSesh.p’, module=’skrf’, exclude_prefix=’_’)


Save all skrf objects in the local namespace.
This is used to save current workspace in a hurry, by passing it the output of locals() (see Examples). Note
this can be used for other modules as well by passing a different module name.
Parameters dict_objs : dict
dictionary containing skrf objects. See the Example.
file : str or file-object, optional
the file to save all objects to
module : str, optional
the module name to grep for.
exclude_prefix: str, optional :
dont save objects which have this as a prefix.
See Also:

read read a skrf object


write write skrf object[s]
read_all read all skrf objects in a directory
write_all write dictionary of skrf objects to a directory

Examples

Write out all skrf objects in current namespace.


>>> rf.write_all(locals(), ’mysesh.p’)

Writing output to spreadsheet

210 Chapter 10. Reference


scikit-rf Documentation, Release dev

network_2_spreadsheet(ntwk[, file_name, ...]) Write a Network object to a spreadsheet, for your boss
networkset_2_spreadsheet(ntwkset[, ...]) Write a NetworkSet object to a spreadsheet, for your boss

skrf.io.general.network_2_spreadsheet

skrf.io.general.network_2_spreadsheet(ntwk, file_name=None, file_type=’excel’, form=’db’,


*args, **kwargs)
Write a Network object to a spreadsheet, for your boss
Write the s-parameters of a network to a spreadsheet, in a variety of forms.This functions makes use of the
pandas module, which in turn makes use of the xlrd module. These are imported during this function call. For
more details about the file-writing functions see the pandas.DataFrom.to_?? functions.
Parameters ntwk : Network object
the network to write
file_name : str, None
the file_name to write. if None, ntwk.name is used.
file_type : [’csv’,’excel’,’html’]
the type of file to write. See pandas.DataFrame.to_??? functions.
form : ‘db’,’ma’,’ri’
format to write data, * db = db, deg * ma = mag, deg * ri = real, imag
*args, **kwargs : :
passed to pandas.DataFrame.to_??? functions.
See Also:

networkset_2_spreadsheet writes a spreadsheet for many networks

Notes

The frequency unit used in the spreadsheet is take from ntwk.frequency.unit

skrf.io.general.networkset_2_spreadsheet

skrf.io.general.networkset_2_spreadsheet(ntwkset, file_name=None, file_type=’excel’,


*args, **kwargs)
Write a NetworkSet object to a spreadsheet, for your boss
Write the s-parameters of a each network in the networkset to a spreadsheet. If the excel file_type is used,
then each network, is written to its own sheet, with the sheetname taken from the network name attribute. This
functions makes use of the pandas module, which in turn makes use of the xlrd module. These are imported
during this function
Parameters ntwkset : NetworkSet object
the network to write
file_name : str, None
the file_name to write. if None, ntwk.name is used.

10.9. io (skrf.io) 211


scikit-rf Documentation, Release dev

file_type : [’csv’,’excel’,’html’]
the type of file to write. See pandas.DataFrame.to_??? functions.
form : ‘db’,’ma’,’ri’
format to write data, * db = db, deg * ma = mag, deg * ri = real, imag
*args, **kwargs : :
passed to pandas.DataFrame.to_??? functions.
See Also:

networkset_2_spreadsheet writes a spreadsheet for many networks

Notes

The frequency unit used in the spreadsheet is take from ntwk.frequency.unit

10.9.2 touchstone (skrf.io.touchstone)

Touchstone class

Touchstone(file) class to read touchstone s-parameter files

skrf.io.touchstone.Touchstone

class skrf.io.touchstone.Touchstone(file)
class to read touchstone s-parameter files
The reference for writing this class is the draft of the Touchstone(R) File Format Specification Rev 2.0 33

Methods

__init__ constructor
get_comments Returns the comments which appear anywhere in the file.
get_format returns the file format string used for the given format.
get_noise_data TODO: NIY
get_noise_names TODO: NIY
get_sparameter_arrays returns the sparameters as a tuple of arrays, where the first element is
get_sparameter_data get the data of the sparameter with the given format.
get_sparameter_names generate a list of column names for the s-parameter data
load_file Load the touchstone file into the interal data structures

skrf.io.touchstone.Touchstone.__init__

Touchstone.__init__(file)
constructor
Parameters file : str or file-object
33 http://www.eda-stds.org/ibis/adhoc/interconnect/touchstone_spec2_draft.pdf

212 Chapter 10. Reference


scikit-rf Documentation, Release dev

touchstone file to load

Examples

From filename
>>> t = rf.Touchstone(’network.s2p’)

From file-object
>>> file = open(’network.s2p’)
>>> t = rf.Touchstone(file)

skrf.io.touchstone.Touchstone.get_comments

Touchstone.get_comments(ignored_comments=[’Created with skrf’])


Returns the comments which appear anywhere in the file. Comment lines containing ignored comments are
removed. By default these are comments which contain special meaning withing skrf and are not user comments.

skrf.io.touchstone.Touchstone.get_format

Touchstone.get_format(format=’ri’)
returns the file format string used for the given format. This is usefull to get some informations.

skrf.io.touchstone.Touchstone.get_noise_data

Touchstone.get_noise_data()
TODO: NIY

skrf.io.touchstone.Touchstone.get_noise_names

Touchstone.get_noise_names()
TODO: NIY

skrf.io.touchstone.Touchstone.get_sparameter_arrays

Touchstone.get_sparameter_arrays()
returns the sparameters as a tuple of arrays, where the first element is the frequency vector (in Hz) and the
s-parameters are a 3d numpy array. The values of the sparameters are complex number. usage:
f,a = self.sgetparameter_arrays() s11 = a[:,0,0]

skrf.io.touchstone.Touchstone.get_sparameter_data

Touchstone.get_sparameter_data(format=’ri’)
get the data of the sparameter with the given format. supported formats are:
orig: unmodified s-parameter data ri: data in real/imaginary ma: data in magnitude and angle (degree)
db: data in log magnitute and angle (degree)

10.9. io (skrf.io) 213


scikit-rf Documentation, Release dev

Returns a list of numpy.arrays

skrf.io.touchstone.Touchstone.get_sparameter_names

Touchstone.get_sparameter_names(format=’ri’)
generate a list of column names for the s-parameter data The names are different for each format. posible format
parameters:
ri, ma, db, orig (where orig refers to one of the three others)
returns a list of strings.

skrf.io.touchstone.Touchstone.load_file

Touchstone.load_file(fid)
Load the touchstone file into the interal data structures
Functions related to reading/writing touchstones.

hfss_touchstone_2_gamma_z0(filename) Extracts Z0 and Gamma comments from touchstone file


hfss_touchstone_2_media(filename[, f_unit]) Creates a Media object from a a HFSS-style touchstone file with Gamma and

skrf.io.touchstone.hfss_touchstone_2_gamma_z0

skrf.io.touchstone.hfss_touchstone_2_gamma_z0(filename)
Extracts Z0 and Gamma comments from touchstone file
Takes a HFSS-style touchstone file with Gamma and Z0 comments and extracts a triplet of arrays being: (fre-
quency, Gamma, Z0)
Parameters filename : string
the HFSS-style touchstone file
Returns f : numpy.ndarray
frequency vector (in Hz)
gamma : complex numpy.ndarray
complex propagation constant
z0 : numpy.ndarray
complex port impedance

Examples

>>> f,gamm,z0 = rf.hfss_touchstone_2_gamma_z0(’line.s2p’)

skrf.io.touchstone.hfss_touchstone_2_media

skrf.io.touchstone.hfss_touchstone_2_media(filename, f_unit=’ghz’)
Creates a Media object from a a HFSS-style touchstone file with Gamma and Z0 comments

214 Chapter 10. Reference


scikit-rf Documentation, Release dev

Parameters filename : string


the HFSS-style touchstone file
f_unit : [’hz’,’khz’,’mhz’,’ghz’]
passed to f_unit parameters of Frequency constructor
Returns my_media : skrf.media.Media object
the transmission line model defined by the gamma, and z0 comments in the HFSS file.
See Also:

hfss_touchstone_2_gamma_z0 returns gamma, and z0

Examples

>>> port1_media, port2_media = rf.hfss_touchstone_2_media(’line.s2p’)

10.9.3 csv (skrf.io.csv)

Functions for reading and writing standard csv files

read_pna_csv(filename, *args, **kwargs) Reads data from a csv file written by an Agilient PNA.
pna_csv_2_ntwks(filename) Reads a PNAX csv file, and returns a list of one-port Networks

skrf.io.csv.read_pna_csv

skrf.io.csv.read_pna_csv(filename, *args, **kwargs)


Reads data from a csv file written by an Agilient PNA.
This function returns a triplet containing the header, comments, and data.
Parameters filename : str
the file
*args, **kwargs : :
Returns header : str
The header string, which is the line following the ‘BEGIN’
comments : str
All lines that begin with a ‘!’
data : numpy.ndarray
An array containing the data. The meaning of which depends on the header.
See Also:

pna_csv_2_ntwks Reads a csv file which contains s-parameter data

10.9. io (skrf.io) 215


scikit-rf Documentation, Release dev

Examples

>>> header, comments, data = rf.read_pna_csv(’myfile.csv’)

skrf.io.csv.pna_csv_2_ntwks

skrf.io.csv.pna_csv_2_ntwks(filename)
Reads a PNAX csv file, and returns a list of one-port Networks
Note this only works if csv is save in Real/Imaginary format for now
Parameters filename : str
filename
Returns out : list of Network objects
list of Networks representing the data contained in column pairs

10.10 calibration (skrf.calibration)

This Package provides a high-level class representing a calibration instance, as well as calibration algorithms and
supporting functions.
Both one and two port calibrations are supported. These calibration algorithms allow for redundant measurements, by
using a simple least squares estimator to solve for the embedding network.

10.10.1 Modules

calibration (skrf.calibration.calibration)

Contains the Calibration class, and supporting functions

Calibration Class

Calibration(measured, ideals[, type, ...]) An object to represent a VNA calibration instance.

skrf.calibration.calibration.Calibration
class skrf.calibration.calibration.Calibration(measured, ideals, type=None,
is_reciprocal=False, name=None,
sloppy_input=False, switch_terms=None,
**kwargs)
An object to represent a VNA calibration instance.
A Calibration object is used to perform a calibration given a set meaurements and ideals responses. It can run a
calibration, store results, and apply the results to calculate corrected measurements.

Attributes

216 Chapter 10. Reference


scikit-rf Documentation, Release dev

Ts T-matricies used for de-embeding, a two-port calibration.


caled_ntwk_sets returns a NetworkSet for each caled_ntwk, based on their names
caled_ntwks list of the calibrated, calibration standards.
calibration_algorithm_dict
coefs coefs: a dictionary holding the calibration coefficients
coefs_ntwks for one port cal’s
coefs_ntwks_2p coefs: a dictionary holding the calibration coefficients
error_ntwk A Network object which represents the error network being
nports the number of ports in the calibration
nstandards number of ideal/measurement pairs in calibration
output_from_cal a dictionary holding all of the output from the calibration
residual_ntwks returns a the residuals for each calibration standard in the
residuals if calibration is overdeteremined, this holds the residuals
type string representing what type of calibration is to be

skrf.calibration.calibration.Calibration.Ts
Calibration.Ts
T-matricies used for de-embeding, a two-port calibration.

skrf.calibration.calibration.Calibration.caled_ntwk_sets
Calibration.caled_ntwk_sets
returns a NetworkSet for each caled_ntwk, based on their names

skrf.calibration.calibration.Calibration.caled_ntwks
Calibration.caled_ntwks
list of the calibrated, calibration standards.

skrf.calibration.calibration.Calibration.calibration_algorithm_dict
Calibration.calibration_algorithm_dict = {‘8-term’: <function two_port at 0x5f2be60>, ‘two port’: <function two
dictionary holding calibration algorithms.

skrf.calibration.calibration.Calibration.coefs
Calibration.coefs
coefs: a dictionary holding the calibration coefficients
for one port cal’s ‘directivity’:e00 ‘reflection tracking’:e01e10 ‘source match’:e11
for 7-error term two port cal’s TODO:

skrf.calibration.calibration.Calibration.coefs_ntwks
Calibration.coefs_ntwks
for one port cal’s ‘directivity’:e00 ‘reflection tracking’:e01e10 ‘source match’:e11
for 7-error term two port cal’s TODO

skrf.calibration.calibration.Calibration.coefs_ntwks_2p
Calibration.coefs_ntwks_2p
coefs: a dictionary holding the calibration coefficients

10.10. calibration (skrf.calibration) 217


scikit-rf Documentation, Release dev

for one port cal’s ‘directivity’:e00 ‘reflection tracking’:e01e10 ‘source match’:e11


for 7-error term two port cal’s TODO

skrf.calibration.calibration.Calibration.error_ntwk
Calibration.error_ntwk
A Network object which represents the error network being calibrated out.

skrf.calibration.calibration.Calibration.nports
Calibration.nports
the number of ports in the calibration

skrf.calibration.calibration.Calibration.nstandards
Calibration.nstandards
number of ideal/measurement pairs in calibration

skrf.calibration.calibration.Calibration.output_from_cal
Calibration.output_from_cal
a dictionary holding all of the output from the calibration algorithm

skrf.calibration.calibration.Calibration.residual_ntwks
Calibration.residual_ntwks
returns a the residuals for each calibration standard in the form of a list of Network types.
these residuals are calculated in the ‘calibrated domain’, meaning they are
r = (E.inv ** m - i)

where, r: residual network, E: embedding network, m: measured network i: ideal network

This way the units of the residual networks are meaningful


note: the residuals are only calculated if they are not existent.
so, if you want to re-calculate the residual networks then you delete the property ‘_residual_ntwks’.

skrf.calibration.calibration.Calibration.residuals
Calibration.residuals
if calibration is overdeteremined, this holds the residuals in the form of a vector.
also available are the complex residuals in the form of skrf.Network’s, see the property ‘residual_ntwks’
from numpy.lstsq: residues: the sum of the residues; squared euclidean norm for each column vector in b
(given ax=b)

skrf.calibration.calibration.Calibration.type
Calibration.type
string representing what type of calibration is to be performed. supported types at the moment are:
‘one port’: standard one-port cal. if more than 2 measurement/ideal pairs are given it will calculate the least
squares solution.
‘two port’: two port calibration based on the error-box model
note: algorithms referenced by calibration_algorithm_dict, are stored in calibrationAlgorithms.py

218 Chapter 10. Reference


scikit-rf Documentation, Release dev

Methods

__init__ Calibration initializer.


apply_cal apply the current calibration to a measurement.
apply_cal_to_all_in_dir convience function to apply calibration to an entire directory
biased_error estimate of biased error for overdetermined calibration with
func_per_standard
mean_residuals
plot_caled_ntwk_sets plots calibrated network sets with uncertainty bounds.
plot_caled_ntwks Plot specified parameters the :caled_ntwks.
plot_coefs plot magnitude of the error coeficient dictionary
plot_coefs_db
plot_errors plot calibration error metrics for an over-determined calibration.
plot_residuals plots a component of the residual errors on the Calibration-plane.
plot_residuals_db see plot_residuals
plot_residuals_mag see plot_residuals
plot_residuals_smith see plot_residuals
plot_uncertainty_per_standard Plots uncertainty associated with each calibration standard.
remove_std
run runs the calibration algorihtm.
total_error estimate of total error for overdetermined calibration with
unbiased_error estimate of unbiased error for overdetermined calibration with
uncertainty_per_standard given that you have repeat-connections of single standard,
write Write the Calibration to disk using write()

skrf.calibration.calibration.Calibration.__init__
Calibration.__init__(measured, ideals, type=None, is_reciprocal=False, name=None,
sloppy_input=False, switch_terms=None, **kwargs)
Calibration initializer.
Parameters measured : list of Network objects
Raw measurements of the calibration standards. The order must align with the ideals
parameter ( or use sloppy_input)
ideals : list of Network objects
Predicted ideal response of the calibration standards. The order must align with ideals
list ( or use sloppy_input

Notes

All calibration algorithms are in stored in skrf.calibration.calibrationAlgorithms , refer to that


file for documentation on the algorithms themselves. The Calibration class accesses those functions through the
attribute ‘calibration_algorihtm_dict’.
It is not required that the measured Networks have the same frequency objects as the ideals, but the measured
frequency must be a subset, so that the ideals can be interpolated.

10.10. calibration (skrf.calibration) 219


scikit-rf Documentation, Release dev

References

Examples

See the Calibration tutorial, or the examples sections for One-Port Calibration and
../../../examples/twoport_calibration

skrf.calibration.calibration.Calibration.apply_cal
Calibration.apply_cal(input_ntwk)
apply the current calibration to a measurement.
takes:
input_ntwk: the measurement to apply the calibration to, a Network type.
returns: caled: the calibrated measurement, a Network type.

skrf.calibration.calibration.Calibration.apply_cal_to_all_in_dir
Calibration.apply_cal_to_all_in_dir(dir=’.’, contains=None, f_unit=’ghz’)
convience function to apply calibration to an entire directory of measurements, and return a dictionary of the
calibrated results, optionally the user can ‘grep’ the direction by using the contains switch.
takes: dir: directory of measurements (string) contains: will only load measurements who’s filename contains
this string.

f_unit: frequency unit, to use for all networks. see frequency.Frequency.unit for info.

returns:
ntwkDict: a dictionary of calibrated measurements, the keys are the filenames.

skrf.calibration.calibration.Calibration.biased_error
Calibration.biased_error(std_names=None)
estimate of biased error for overdetermined calibration with multiple connections of each standard
takes:
std_names: list of strings to uniquely identify each standard.*
returns:
systematic error: skrf.Network type who’s .s_mag is proportional to the systematic error metric
note:
mathematically, this is mean_s(|mean_c(r)|)
where: r: complex residual errors mean_c: complex mean taken accross connection mean_s: complex
mean taken accross standard

skrf.calibration.calibration.Calibration.func_per_standard
Calibration.func_per_standard(func, attribute=’s’, std_names=None)

skrf.calibration.calibration.Calibration.mean_residuals
Calibration.mean_residuals()

220 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibration.Calibration.plot_caled_ntwk_sets
Calibration.plot_caled_ntwk_sets(attr=’s_db’, *args, **kwargs)
plots calibrated network sets with uncertainty bounds.
For use with redundantly measured calibration standards.
Parameters attr : str
plotable uncertainty bounds attribute of a NetworkSet object. ie ‘s_db’, ‘s_deg’
*args, **kwargs : :
passed to the plotting method

skrf.calibration.calibration.Calibration.plot_caled_ntwks
Calibration.plot_caled_ntwks(attr=’s_smith’, *args, **kwargs)
Plot specified parameters the :caled_ntwks.
Parameters attr : str
plotable attribute of a Network object. ie ‘s_db’, ‘s_smith’
*args, **kwargs : :
passed to the plotting method

skrf.calibration.calibration.Calibration.plot_coefs
Calibration.plot_coefs(attr=’s_db’, port=None, *args, **kwargs)
plot magnitude of the error coeficient dictionary

skrf.calibration.calibration.Calibration.plot_coefs_db
Calibration.plot_coefs_db(*args, **kwargs)

skrf.calibration.calibration.Calibration.plot_errors
Calibration.plot_errors(std_names=None, scale=’db’, *args, **kwargs)
plot calibration error metrics for an over-determined calibration.
see biased_error, unbiased_error, and total_error for more info

skrf.calibration.calibration.Calibration.plot_residuals
Calibration.plot_residuals(attribute, *args, **kwargs)
plots a component of the residual errors on the Calibration-plane.
takes:
attribute: name of ploting method of Network class to call
possible options are: ‘mag’, ‘db’, ‘smith’, ‘deg’, etc
*args,**kwargs: passed to plot_s_‘atttribute’()
note: the residuals are calculated by:
(self.apply_cal(self.measured[k])-self.ideals[k])

skrf.calibration.calibration.Calibration.plot_residuals_db
Calibration.plot_residuals_db(*args, **kwargs)
see plot_residuals

10.10. calibration (skrf.calibration) 221


scikit-rf Documentation, Release dev

skrf.calibration.calibration.Calibration.plot_residuals_mag
Calibration.plot_residuals_mag(*args, **kwargs)
see plot_residuals

skrf.calibration.calibration.Calibration.plot_residuals_smith
Calibration.plot_residuals_smith(*args, **kwargs)
see plot_residuals

skrf.calibration.calibration.Calibration.plot_uncertainty_per_standard
Calibration.plot_uncertainty_per_standard(scale=’db’, *args, **kwargs)
Plots uncertainty associated with each calibration standard.
This requires that each calibration standard is measured multiple times. The uncertainty associated with each
standard is calculated by the complex standard deviation.
Parameters scale : ‘db’, ‘lin’
plot uncertainties on linear or log scale
*args, **kwargs : passed to uncertainty_per_standard()
See Also:
uncertainty_per_standard()

skrf.calibration.calibration.Calibration.remove_std
Calibration.remove_std(prefix)

skrf.calibration.calibration.Calibration.run
Calibration.run()
runs the calibration algorihtm.
this is automatically called the first time any dependent property is referenced (like error_ntwk), but only the
first time. if you change something and want to re-run the calibration
use this.

skrf.calibration.calibration.Calibration.total_error
Calibration.total_error(std_names=None)
estimate of total error for overdetermined calibration with multiple connections of each standard. This is the
combined effects of both biased and un-biased errors
takes:
std_names: list of strings to uniquely identify each standard.*
returns:
composit error: skrf.Network type who’s .s_mag is proportional to the composit error metric
note:
mathematically, this is std_cs(r)
where: r: complex residual errors std_cs: standard deviation taken accross connections
and standards

222 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibration.Calibration.unbiased_error
Calibration.unbiased_error(std_names=None)
estimate of unbiased error for overdetermined calibration with multiple connections of each standard
takes:
std_names: list of strings to uniquely identify each standard.*
returns:
stochastic error: skrf.Network type who’s .s_mag is proportional to the stochastic error metric
see also: uncertainty_per_standard, for this a measure of unbiased errors for each standard
note:
mathematically, this is mean_s(std_c(r))
where: r: complex residual errors std_c: standard deviation taken accross connections mean_s: complex
mean taken accross standards

skrf.calibration.calibration.Calibration.uncertainty_per_standard
Calibration.uncertainty_per_standard(std_names=None, attribute=’s’)
given that you have repeat-connections of single standard, this calculates the complex standard deviation (dis-
tance) for each standard in the calibration across connection #.
takes:
std_names: list of strings to uniquely identify each standard.*
attribute: string passed to func_on_networks to calculate std deviation on a component if desired.
[’s’]
returns: list of skrf.Networks, whose magnitude of s-parameters is proportional to the standard deviation for
that standard
*example:
if your calibration had ideals named like: ‘short 1’, ‘short 2’, ‘open 1’, ‘open 2’, etc.
you would pass this mycal.uncertainty_per_standard([’short’,’open’,’match’])

skrf.calibration.calibration.Calibration.write
Calibration.write(file=None, *args, **kwargs)
Write the Calibration to disk using write()
Parameters file : str or file-object
filename or a file-object. If left as None then the filename will be set to Calibra-
tion.name, if its not None. If both are None, ValueError is raised.
*args, **kwargs : arguments and keyword arguments
passed through to write()
See Also:
skrf.io.general.write, skrf.io.general.read

10.10. calibration (skrf.calibration) 223


scikit-rf Documentation, Release dev

Notes

If the self.name is not None and file is can left as None and the resultant file will have the .ntwk extension
appended to the filename.

Examples

>>> cal.name = ’my_cal’


>>> cal.write()

calibrationAlgorithms (skrf.calibration.calibrationAlgorithms)

Contains calibrations algorithms and related functions, which are used in the Calibration class.

Calibration Algorithms

one_port(measured, ideals) Standard algorithm for a one port calibration.


one_port_nls(measured, ideals) one port non-linear least squares.
two_port(measured, ideals[, switch_terms]) Two port calibration based on the 8-term error model.
parameterized_self_calibration(measured, ideals) An iterative, general self-calibration routine.
parameterized_self_calibration_nls(measured, ...) An iterative, general self-calibration routine.

skrf.calibration.calibrationAlgorithms.one_port
skrf.calibration.calibrationAlgorithms.one_port(measured, ideals)
Standard algorithm for a one port calibration.
If more than three standards are supplied then a least square algorithm is applied.
Parameters measured : list of Network objects or numpy.ndarray
a list of the measured reflection coefficients. The elements of the list can either a kxnxn
numpy.ndarray, representing a s-matrix, or list of 1-port Network objects.
ideals : list of Network objects or numpy.ndarray
a list of the ideal reflection coefficients. The elements of the list can either a kxnxn
numpy.ndarray, representing a s-matrix, or list of 1-port Network objects.
Returns output : a dictionary
output information from the calibration, the keys are
• ‘error coeffcients’: dictionary containing standard error coefficients
• ‘residuals’: a matrix of residuals from the least squared calculation. see
numpy.linalg.lstsq() for more info
See Also:

one_port_nls for a non-linear least square implementation

Notes

uses numpy.linalg.lstsq() for least squares calculation

224 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibrationAlgorithms.one_port_nls
skrf.calibration.calibrationAlgorithms.one_port_nls(measured, ideals)
one port non-linear least squares.
Parameters measured : list of Network objects or numpy.ndarray
a list of the measured reflection coefficients. The elements of the list can either a kxnxn
numpy.ndarray, representing a s-matrix, or list of 1-port Network objects.
ideals : list of Network objects or numpy.ndarray
a list of the ideal reflection coefficients. The elements of the list can either a kxnxn
numpy.ndarray, representing a s-matrix, or list of 1-port Network objects.
Returns output : a dictionary
a dictionary containing the following keys:
• ‘error coeffcients’: dictionary containing standard error coefficients
• ‘residuals’: a matrix of residuals from the least squared calculation. see
numpy.linalg.lstsq() for more info
• ‘cov_x’: covariance matrix

Notes

Uses scipy.optmize.leastsq() for non-linear least squares calculation

skrf.calibration.calibrationAlgorithms.two_port
skrf.calibration.calibrationAlgorithms.two_port(measured, ideals,
switch_terms=None)
Two port calibration based on the 8-term error model.
Takes two ordered lists of measured and ideal responses. Optionally, switch terms 34 can be taken into account
by passing a tuple containing the forward and reverse switch terms as 1-port Networks. This algorithm is based
on the work in 35 .
Parameters measured : list of 2-port Network objects
Raw measurements of the calibration standards. The order must align with the ideals
parameter
ideals : list of 2-port Network objects
Predicted ideal response of the calibration standards. The order must align with ideals
list measured: ordered list of measured networks. list elements
switch_terms : tuple of Network objects
The two measured switch terms in the order (forward, reverse). This is only applicable
in two-port calibrations. See Roger Mark’s paper on switch terms 3 for explanation of
what they are.
Returns output : a dictionary
34 Marks, Roger B.; , “Formulations of the Basic Vector Network Analyzer Error Model including Switch-Terms,” ARFTG Conference Digest-

Fall, 50th , vol.32, no., pp.115-126, Dec. 1997. URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4119948&isnumber=4119931


35 Speciale, R.A.; , “A Generalization of the TSD Network-Analyzer Calibration Procedure, Covering n-Port Scattering-Parameter Measurements,

Affected by Leakage Errors,” Microwave Theory and Techniques, IEEE Transactions on , vol.25, no.12, pp. 1100- 1115, Dec 1977. URL:
http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1129282&isnumber=25047

10.10. calibration (skrf.calibration) 225


scikit-rf Documentation, Release dev

output information, contains the following keys: * ‘error coefficients’: * ‘error vector’:
* ‘residuals’:

Notes

support for gathering switch terms on HP8510C is in skrf.vi.vna

References

skrf.calibration.calibrationAlgorithms.parameterized_self_calibration
skrf.calibration.calibrationAlgorithms.parameterized_self_calibration(measured,
ide-
als,
show-
Progress=True,
**kwargs)
An iterative, general self-calibration routine.
A self calibration routine based off of residual error minimization which can take any mixture of parameterized
standards.
Parameters measured : list of Network objects
a list of the measured networks
ideals : list of ParametricStandard objects
a list of the ideal networks
showProgress : Boolean
turn printing progress on/off
**kwargs : key-word arguments
passed to minimization algorithm (scipy.optimize.fmin)
Returns output : a dictionary
a dictionary containing the following keys:
• ‘error_coefficients’ : dictionary of error coefficients
• ‘residuals’: residual matrix (shape depends on #stds)
• ‘parameter_vector_final’: final results for parameter vector
• ‘mean_residual_list’: the mean, magnitude of the residuals at each iteration of
calibration. this is the variable being minimized.
See Also:

parametricStandard sub-module for more info on them


parameterized_self_calibration_nls similar algorithm, but uses a non-linear least-squares esti-
mator

226 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibrationAlgorithms.parameterized_self_calibration_nls
skrf.calibration.calibrationAlgorithms.parameterized_self_calibration_nls(measured,
ide-
als_ps,
show-
Progress=True,
**kwargs)
An iterative, general self-calibration routine.
A self calibration routine based off of residual error minimization which can take any mixture of parameterized
standards. Uses a non-linear least squares estimator to calculate the residuals.
Parameters measured : list of Network objects
a list of the measured networks
ideals : list of Network objects
a list of the ideal networks
showProgress : Boolean
turn printing progress on/off
**kwargs : key-word arguments
passed to minimization algorithm (scipy.optimize.fmin)
Returns output : a dictionary
a dictionary containing the following keys:
• ‘error_coefficients’ : dictionary of error coefficients
• ‘residuals’: residual matrix (shape depends on #stds)
• ‘parameter_vector_final’: final results for parameter vector
• ‘mean_residual_list’: the mean, magnitude of the residuals at each iteration of
calibration. this is the variable being minimized.
See Also:

parametricStandard sub-module for more info on them


parameterized_self_calibration_nls similar algorithm, but uses a non-linear least-squares esti-
mator

Supporting Functions

unterminate_switch_terms(two_port, gamma_f, ...) Unterminates switch terms from raw measurements.


abc_2_coefs_dict(abc) converts an abc ndarry to a dictionarry containing the error
eight_term_2_one_port_coefs(coefs)

skrf.calibration.calibrationAlgorithms.unterminate_switch_terms
skrf.calibration.calibrationAlgorithms.unterminate_switch_terms(two_port,
gamma_f,
gamma_r)
Unterminates switch terms from raw measurements.
In order to use the 8-term error model on a VNA which employs a switched source, the effects of the switch

10.10. calibration (skrf.calibration) 227


scikit-rf Documentation, Release dev

must be accounted for. This is done through switch terms as described in 36 . The two switch terms are defined
as,
a2 a1
Γf = , sourced by port 1Γr = , sourced by port 2
b2 b1
These can be measured by four-sampler VNA’s by setting up user-defined traces onboard the VNA. If the VNA
doesnt have 4-samplers, then you can measure switch terms indirectly by using a two-tier two-port calibration.
Firts do a SOLT, then convert the 12-term error coefs to 8-term, and pull out the switch terms.
Parameters two_port : 2-port Network
the raw measurement
gamma_f : 1-port Network
the measured forward switch term. gamma_f = a2/b2 sourced by port1
gamma_r : 1-port Network
the measured reverse switch term
Returns ntwk : Network object

References

skrf.calibration.calibrationAlgorithms.abc_2_coefs_dict
skrf.calibration.calibrationAlgorithms.abc_2_coefs_dict(abc)
converts an abc ndarry to a dictionarry containing the error coefficients.
takes:
abc [Nx3 numpy.ndarray, which holds the complex calibration]
coefficients. the components of abc are a[:] = abc[:,0] b[:] = abc[:,1] c[:] = abc[:,2],
a, b and c are related to the error network by a = det(e) = e01*e10 - e00*e11 b = e00 c = e11
returns:
coefsDict: dictionary containing the following ‘directivity’:e00 ‘reflection tracking’:e01e10 ‘source
match’:e11
note: e00 = directivity error e10e01 = reflection tracking error e11 = source match error

skrf.calibration.calibrationAlgorithms.eight_term_2_one_port_coefs
skrf.calibration.calibrationAlgorithms.eight_term_2_one_port_coefs(coefs)

calibrationFunctions (skrf.calibration.calibrationFunctions)

Functions which operate on or pertain to Calibration Objects

cartesian_product_calibration_set(ideals, ...) This function is used for calculating calibration uncertainty due to un-b

36 “Formulations of the Basic Vector Network Analyzer Error Model including Switch Terms” by Roger B. Marks

228 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibrationFunctions.cartesian_product_calibration_set

skrf.calibration.calibrationFunctions.cartesian_product_calibration_set(ideals,
mea-
sured,
*args,
**kwargs)
This function is used for calculating calibration uncertainty due to un-biased, non-systematic errors.
It creates an ensemble of calibration instances. the set of measurement lists used in the ensemble is the Cartesian
Product of all instances of each measured standard.
The idea is that if you have multiple measurements of each standard, then the multiple calibrations can be
made by generating all possible combinations of measurements. This produces a conceptually simple, but
computationally expensive way to estimate calibration uncertainty.
takes: ideals: list of ideal Networks measured: list of measured Networks *args,**kwargs: passed to Calibra-
tion initializer
returns: cal_ensemble: a list of Calibration instances.
you can use the output to estimate uncertainty by calibrating a DUT with all calibrations, and then running
statistics on the resultant set of Networks. for example
import skrf as rf # define you lists of ideals and measured networks cal_ensemble =
rf.cartesian_product_calibration_ensemble( ideals, measured) dut = rf.Network(‘dut.s1p’) network_ensemble
= [cal.apply_cal(dut) for cal in cal_ensemble] rf.plot_uncertainty_mag(network_ensemble) [net-
work.plot_s_smith() for network in network_ensemble]

10.10.2 Classes

Calibration(measured, ideals[, type, ...]) An object to represent a VNA calibration instance.

skrf.calibration.calibration.Calibration

class skrf.calibration.calibration.Calibration(measured, ideals, type=None,


is_reciprocal=False, name=None,
sloppy_input=False, switch_terms=None,
**kwargs)
An object to represent a VNA calibration instance.
A Calibration object is used to perform a calibration given a set meaurements and ideals responses. It can run a
calibration, store results, and apply the results to calculate corrected measurements.

Attributes

Ts T-matricies used for de-embeding, a two-port calibration.


caled_ntwk_sets returns a NetworkSet for each caled_ntwk, based on their names
caled_ntwks list of the calibrated, calibration standards.
calibration_algorithm_dict
coefs coefs: a dictionary holding the calibration coefficients
coefs_ntwks for one port cal’s
Continued on next page

10.10. calibration (skrf.calibration) 229


scikit-rf Documentation, Release dev

Table 10.42 – continued from previous page


coefs_ntwks_2p coefs: a dictionary holding the calibration coefficients
error_ntwk A Network object which represents the error network being
nports the number of ports in the calibration
nstandards number of ideal/measurement pairs in calibration
output_from_cal a dictionary holding all of the output from the calibration
residual_ntwks returns a the residuals for each calibration standard in the
residuals if calibration is overdeteremined, this holds the residuals
type string representing what type of calibration is to be

skrf.calibration.calibration.Calibration.Ts

Calibration.Ts
T-matricies used for de-embeding, a two-port calibration.

skrf.calibration.calibration.Calibration.caled_ntwk_sets

Calibration.caled_ntwk_sets
returns a NetworkSet for each caled_ntwk, based on their names

skrf.calibration.calibration.Calibration.caled_ntwks

Calibration.caled_ntwks
list of the calibrated, calibration standards.

skrf.calibration.calibration.Calibration.calibration_algorithm_dict

Calibration.calibration_algorithm_dict = {‘8-term’: <function two_port at 0x5f2be60>, ‘two port’: <function two


dictionary holding calibration algorithms.

skrf.calibration.calibration.Calibration.coefs

Calibration.coefs
coefs: a dictionary holding the calibration coefficients
for one port cal’s ‘directivity’:e00 ‘reflection tracking’:e01e10 ‘source match’:e11
for 7-error term two port cal’s TODO:

skrf.calibration.calibration.Calibration.coefs_ntwks

Calibration.coefs_ntwks
for one port cal’s ‘directivity’:e00 ‘reflection tracking’:e01e10 ‘source match’:e11
for 7-error term two port cal’s TODO

230 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibration.Calibration.coefs_ntwks_2p

Calibration.coefs_ntwks_2p
coefs: a dictionary holding the calibration coefficients
for one port cal’s ‘directivity’:e00 ‘reflection tracking’:e01e10 ‘source match’:e11
for 7-error term two port cal’s TODO

skrf.calibration.calibration.Calibration.error_ntwk

Calibration.error_ntwk
A Network object which represents the error network being calibrated out.

skrf.calibration.calibration.Calibration.nports

Calibration.nports
the number of ports in the calibration

skrf.calibration.calibration.Calibration.nstandards

Calibration.nstandards
number of ideal/measurement pairs in calibration

skrf.calibration.calibration.Calibration.output_from_cal

Calibration.output_from_cal
a dictionary holding all of the output from the calibration algorithm

skrf.calibration.calibration.Calibration.residual_ntwks

Calibration.residual_ntwks
returns a the residuals for each calibration standard in the form of a list of Network types.
these residuals are calculated in the ‘calibrated domain’, meaning they are
r = (E.inv ** m - i)

where, r: residual network, E: embedding network, m: measured network i: ideal network

This way the units of the residual networks are meaningful


note: the residuals are only calculated if they are not existent.
so, if you want to re-calculate the residual networks then you delete the property ‘_residual_ntwks’.

skrf.calibration.calibration.Calibration.residuals

Calibration.residuals
if calibration is overdeteremined, this holds the residuals in the form of a vector.
also available are the complex residuals in the form of skrf.Network’s, see the property ‘residual_ntwks’

10.10. calibration (skrf.calibration) 231


scikit-rf Documentation, Release dev

from numpy.lstsq: residues: the sum of the residues; squared euclidean norm for each column vector in b
(given ax=b)

skrf.calibration.calibration.Calibration.type

Calibration.type
string representing what type of calibration is to be performed. supported types at the moment are:
‘one port’: standard one-port cal. if more than 2 measurement/ideal pairs are given it will calculate the least
squares solution.
‘two port’: two port calibration based on the error-box model
note: algorithms referenced by calibration_algorithm_dict, are stored in calibrationAlgorithms.py

Methods

__init__ Calibration initializer.


apply_cal apply the current calibration to a measurement.
apply_cal_to_all_in_dir convience function to apply calibration to an entire directory
biased_error estimate of biased error for overdetermined calibration with
func_per_standard
mean_residuals
plot_caled_ntwk_sets plots calibrated network sets with uncertainty bounds.
plot_caled_ntwks Plot specified parameters the :caled_ntwks.
plot_coefs plot magnitude of the error coeficient dictionary
plot_coefs_db
plot_errors plot calibration error metrics for an over-determined calibration.
plot_residuals plots a component of the residual errors on the Calibration-plane.
plot_residuals_db see plot_residuals
plot_residuals_mag see plot_residuals
plot_residuals_smith see plot_residuals
plot_uncertainty_per_standard Plots uncertainty associated with each calibration standard.
remove_std
run runs the calibration algorihtm.
total_error estimate of total error for overdetermined calibration with
unbiased_error estimate of unbiased error for overdetermined calibration with
uncertainty_per_standard given that you have repeat-connections of single standard,
write Write the Calibration to disk using write()

skrf.calibration.calibration.Calibration.__init__

Calibration.__init__(measured, ideals, type=None, is_reciprocal=False, name=None,


sloppy_input=False, switch_terms=None, **kwargs)
Calibration initializer.
Parameters measured : list of Network objects
Raw measurements of the calibration standards. The order must align with the ideals
parameter ( or use sloppy_input)
ideals : list of Network objects

232 Chapter 10. Reference


scikit-rf Documentation, Release dev

Predicted ideal response of the calibration standards. The order must align with ideals
list ( or use sloppy_input

Notes

All calibration algorithms are in stored in skrf.calibration.calibrationAlgorithms , refer to that


file for documentation on the algorithms themselves. The Calibration class accesses those functions through the
attribute ‘calibration_algorihtm_dict’.
It is not required that the measured Networks have the same frequency objects as the ideals, but the measured
frequency must be a subset, so that the ideals can be interpolated.

References

Examples

See the Calibration tutorial, or the examples sections for One-Port Calibration and
../../../examples/twoport_calibration

skrf.calibration.calibration.Calibration.apply_cal

Calibration.apply_cal(input_ntwk)
apply the current calibration to a measurement.
takes:
input_ntwk: the measurement to apply the calibration to, a Network type.
returns: caled: the calibrated measurement, a Network type.

skrf.calibration.calibration.Calibration.apply_cal_to_all_in_dir

Calibration.apply_cal_to_all_in_dir(dir=’.’, contains=None, f_unit=’ghz’)


convience function to apply calibration to an entire directory of measurements, and return a dictionary of the
calibrated results, optionally the user can ‘grep’ the direction by using the contains switch.
takes: dir: directory of measurements (string) contains: will only load measurements who’s filename contains
this string.

f_unit: frequency unit, to use for all networks. see frequency.Frequency.unit for info.

returns:
ntwkDict: a dictionary of calibrated measurements, the keys are the filenames.

skrf.calibration.calibration.Calibration.biased_error

Calibration.biased_error(std_names=None)
estimate of biased error for overdetermined calibration with multiple connections of each standard
takes:
std_names: list of strings to uniquely identify each standard.*

10.10. calibration (skrf.calibration) 233


scikit-rf Documentation, Release dev

returns:
systematic error: skrf.Network type who’s .s_mag is proportional to the systematic error metric
note:
mathematically, this is mean_s(|mean_c(r)|)
where: r: complex residual errors mean_c: complex mean taken accross connection mean_s: complex
mean taken accross standard

skrf.calibration.calibration.Calibration.func_per_standard

Calibration.func_per_standard(func, attribute=’s’, std_names=None)

skrf.calibration.calibration.Calibration.mean_residuals

Calibration.mean_residuals()

skrf.calibration.calibration.Calibration.plot_caled_ntwk_sets

Calibration.plot_caled_ntwk_sets(attr=’s_db’, *args, **kwargs)


plots calibrated network sets with uncertainty bounds.
For use with redundantly measured calibration standards.
Parameters attr : str
plotable uncertainty bounds attribute of a NetworkSet object. ie ‘s_db’, ‘s_deg’
*args, **kwargs : :
passed to the plotting method

skrf.calibration.calibration.Calibration.plot_caled_ntwks

Calibration.plot_caled_ntwks(attr=’s_smith’, *args, **kwargs)


Plot specified parameters the :caled_ntwks.
Parameters attr : str
plotable attribute of a Network object. ie ‘s_db’, ‘s_smith’
*args, **kwargs : :
passed to the plotting method

skrf.calibration.calibration.Calibration.plot_coefs

Calibration.plot_coefs(attr=’s_db’, port=None, *args, **kwargs)


plot magnitude of the error coeficient dictionary

skrf.calibration.calibration.Calibration.plot_coefs_db

Calibration.plot_coefs_db(*args, **kwargs)

234 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibration.Calibration.plot_errors

Calibration.plot_errors(std_names=None, scale=’db’, *args, **kwargs)


plot calibration error metrics for an over-determined calibration.
see biased_error, unbiased_error, and total_error for more info

skrf.calibration.calibration.Calibration.plot_residuals

Calibration.plot_residuals(attribute, *args, **kwargs)


plots a component of the residual errors on the Calibration-plane.
takes:
attribute: name of ploting method of Network class to call
possible options are: ‘mag’, ‘db’, ‘smith’, ‘deg’, etc
*args,**kwargs: passed to plot_s_‘atttribute’()
note: the residuals are calculated by:
(self.apply_cal(self.measured[k])-self.ideals[k])

skrf.calibration.calibration.Calibration.plot_residuals_db

Calibration.plot_residuals_db(*args, **kwargs)
see plot_residuals

skrf.calibration.calibration.Calibration.plot_residuals_mag

Calibration.plot_residuals_mag(*args, **kwargs)
see plot_residuals

skrf.calibration.calibration.Calibration.plot_residuals_smith

Calibration.plot_residuals_smith(*args, **kwargs)
see plot_residuals

skrf.calibration.calibration.Calibration.plot_uncertainty_per_standard

Calibration.plot_uncertainty_per_standard(scale=’db’, *args, **kwargs)


Plots uncertainty associated with each calibration standard.
This requires that each calibration standard is measured multiple times. The uncertainty associated with each
standard is calculated by the complex standard deviation.
Parameters scale : ‘db’, ‘lin’
plot uncertainties on linear or log scale
*args, **kwargs : passed to uncertainty_per_standard()
See Also:
uncertainty_per_standard()

10.10. calibration (skrf.calibration) 235


scikit-rf Documentation, Release dev

skrf.calibration.calibration.Calibration.remove_std

Calibration.remove_std(prefix)

skrf.calibration.calibration.Calibration.run

Calibration.run()
runs the calibration algorihtm.
this is automatically called the first time any dependent property is referenced (like error_ntwk), but only the
first time. if you change something and want to re-run the calibration
use this.

skrf.calibration.calibration.Calibration.total_error

Calibration.total_error(std_names=None)
estimate of total error for overdetermined calibration with multiple connections of each standard. This is the
combined effects of both biased and un-biased errors
takes:
std_names: list of strings to uniquely identify each standard.*
returns:
composit error: skrf.Network type who’s .s_mag is proportional to the composit error metric
note:
mathematically, this is std_cs(r)
where: r: complex residual errors std_cs: standard deviation taken accross connections
and standards

skrf.calibration.calibration.Calibration.unbiased_error

Calibration.unbiased_error(std_names=None)
estimate of unbiased error for overdetermined calibration with multiple connections of each standard
takes:
std_names: list of strings to uniquely identify each standard.*
returns:
stochastic error: skrf.Network type who’s .s_mag is proportional to the stochastic error metric
see also: uncertainty_per_standard, for this a measure of unbiased errors for each standard
note:
mathematically, this is mean_s(std_c(r))
where: r: complex residual errors std_c: standard deviation taken accross connections mean_s: complex
mean taken accross standards

236 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.calibration.calibration.Calibration.uncertainty_per_standard

Calibration.uncertainty_per_standard(std_names=None, attribute=’s’)
given that you have repeat-connections of single standard, this calculates the complex standard deviation (dis-
tance) for each standard in the calibration across connection #.
takes:
std_names: list of strings to uniquely identify each standard.*
attribute: string passed to func_on_networks to calculate std deviation on a component if desired.
[’s’]
returns: list of skrf.Networks, whose magnitude of s-parameters is proportional to the standard deviation for
that standard
*example:
if your calibration had ideals named like: ‘short 1’, ‘short 2’, ‘open 1’, ‘open 2’, etc.
you would pass this mycal.uncertainty_per_standard([’short’,’open’,’match’])

skrf.calibration.calibration.Calibration.write

Calibration.write(file=None, *args, **kwargs)


Write the Calibration to disk using write()
Parameters file : str or file-object
filename or a file-object. If left as None then the filename will be set to Calibra-
tion.name, if its not None. If both are None, ValueError is raised.
*args, **kwargs : arguments and keyword arguments
passed through to write()
See Also:
skrf.io.general.write, skrf.io.general.read

Notes

If the self.name is not None and file is can left as None and the resultant file will have the .ntwk extension
appended to the filename.

Examples

>>> cal.name = ’my_cal’


>>> cal.write()

10.11 media (skrf.media)

This package provides objects representing transmission line mediums.

10.11. media (skrf.media) 237


scikit-rf Documentation, Release dev

The Media object is the base-class that is inherited by specific transmission line instances, such as Freespace, or
RectangularWaveguide. The Media object provides generic methods to produce Network‘s for any transmi-
sion line medium, such as line() and delay_short(). These methods are inherited by the specific tranmission
line classes, which interally define relevant quantities such as propagation constant, and characteristic impedance. This
allows the specific transmission line mediums to produce networks without re-implementing methods for each specific
media instance.
Network components specific to an given transmission line medium such as cpw_short() and
microstrip_bend(), are implemented in those object

10.11.1 Media base-class

Media The base-class for all transmission line mediums.

skrf.media.media.Media

class skrf.media.media.Media(frequency, propagation_constant, characteristic_impedance,


z0=None)
The base-class for all transmission line mediums.
The Media object provides generic methods to produce Network‘s for any transmision line medium, such as
line() and delay_short().
The initializer for this class has flexible argument types. This allows for the important attributes of the Media
object to be dynamic. For example, if a Media object’s propagation constant is a function of some attribute of
that object, say conductor_width, then the propagation constant will change when that attribute changes. See
__init__() for details.
The network creation methods build off of each other. For example, the specicial load cases, suc as short()
and open() call load() with given arguments for Gamma0, and the delay_ and shunt_ functions call
line() and shunt() respectively. This minimizes re-implementation.
Most methods initialize the Network by calling match() to create a ‘blank’ Network, and then fill in the
s-matrix.

Attributes

Z0 Characterisitc impedance
characteristic_impedance Characterisitc impedance
gamma Propagation constant
portz0 Port Impedance
propagation_constant Propagation constant
v_p complex phase velocity (in m/s)
z0 Port Impedance

skrf.media.media.Media.Z0

Media.Z0
Characterisitc impedance
The characteristic_impedance can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the characterisitc impedance to be dynamic, meaning

238 Chapter 10. Reference


scikit-rf Documentation, Release dev

changing with some attribute of the media. See __init__() for more explanation.
Returns characteristic_impedance : numpy.ndarray

skrf.media.media.Media.characteristic_impedance

Media.characteristic_impedance
Characterisitc impedance
The characteristic_impedance can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the characterisitc impedance to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns characteristic_impedance : numpy.ndarray

skrf.media.media.Media.gamma

Media.gamma
Propagation constant
The propagation constant can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the propagation constant to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns propagation_constant : numpy.ndarray
complex propagation constant for this media

Notes

propagation_constant must adhere to the following convention,


• positive real(propagation_constant) = attenuation
• positive imag(propagation_constant) = forward propagation

skrf.media.media.Media.portz0

Media.portz0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

10.11. media (skrf.media) 239


scikit-rf Documentation, Release dev

skrf.media.media.Media.propagation_constant

Media.propagation_constant
Propagation constant
The propagation constant can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the propagation constant to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns propagation_constant : numpy.ndarray
complex propagation constant for this media

Notes

propagation_constant must adhere to the following convention,


• positive real(propagation_constant) = attenuation
• positive imag(propagation_constant) = forward propagation

skrf.media.media.Media.v_p

Media.v_p
complex phase velocity (in m/s)

j · ω/γ

where: * ω is angular frequency (rad/s), * γ is complex propagation constant (rad/m)


See Also:
propgation_constant

skrf.media.media.Media.z0

Media.z0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

Methods

240 Chapter 10. Reference


scikit-rf Documentation, Release dev

__init__ The Media initializer.


capacitor Capacitor
delay_load Delayed load
delay_open Delayed open transmission line
delay_short Delayed Short
electrical_length calculates the electrical length for a given distance, at
from_csv create a Media from numerical values stored in a csv file.
guess_length_of_delay_short Guess physical length of a delay short.
impedance_mismatch Two-port network for an impedance miss-match
inductor Inductor
line Matched transmission line of given length
load Load of given reflection coefficient.
match Perfect matched load (Γ0 = 0).
open Open (Γ0 = 1)
random Complex random network.
resistor Resistor
short Short (Γ0 = −1)
shunt Shunts a Network
shunt_capacitor Shunted capacitor
shunt_delay_load Shunted delayed load
shunt_delay_open Shunted delayed open
shunt_delay_short Shunted delayed short
shunt_inductor Shunted inductor
splitter Ideal, lossless n-way splitter.
tee Ideal, lossless tee.
theta_2_d Converts electrical length to physical distance.
thru Matched transmission line of length 0.
white_gaussian_polar Complex zero-mean gaussian white-noise network.
write_csv write this media’s frequency, z0, and gamma to a csv file.

skrf.media.media.Media.__init__

Media.__init__(frequency, propagation_constant, characteristic_impedance, z0=None)


The Media initializer.
This initializer has flexible argument types. The parameters propagation_constant, characterisitc_impedance
and z0 can all be either static or dynamic. This is achieved by allowing those arguments to be either:
•functions which take no arguments or
•values (numbers or arrays)
In the case where the media’s propagation constant may change after initialization, because you adjusted a
parameter of the media, then passing the propagation_constant as a function allows it to change when the
media’s parameters do.
Parameters frequency : Frequency object
frequency band of this transmission line medium
propagation_constant : number, array-like, or a function
propagation constant for the medium.
characteristic_impedance : number,array-like, or a function

10.11. media (skrf.media) 241


scikit-rf Documentation, Release dev

characteristic impedance of transmission line medium.


z0 : number, array-like, or a function
the port impedance for media , IF its different from the characterisitc impedance of the
transmission line medium (None) [a number]. if z0= None then will set to character-
isitc_impedance
See Also:

from_csv() function to create a Media object from a csv file containing gamma/z0

Notes

propagation_constant must adhere to the following convention,


• positive real(gamma) = attenuation
• positive imag(gamma) = forward propagation

the z0 parameter is needed in some cases. For example, the RectangularWaveguide is an example where
you may need this, because the characteristic impedance is frequency dependent, but the touchstone’s created
by most VNA’s have z0=1

skrf.media.media.Media.capacitor

Media.capacitor(C, **kwargs)
Capacitor
Parameters C : number, array
Capacitance, in Farads. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns capacitor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.media.Media.delay_load

Media.delay_load(Gamma0, d, unit=’m’, **kwargs)


Delayed load
A load with reflection coefficient Gamma0 at the end of a matched line of length d.
Parameters Gamma0 : number, array-like
reflection coefficient of load (not in dB)
d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]

242 Chapter 10. Reference


scikit-rf Documentation, Release dev

the units of d. possible options are:


• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_load : Network object
a delayed load
See Also:

line creates the network for line


load creates the network for the load

Notes

This calls
line(d,unit, **kwargs) ** load(Gamma0, **kwargs)

Examples

>>> my_media.delay_load(-.5, 90, ’deg’, z0=50)

skrf.media.media.Media.delay_open

Media.delay_open(d, unit=’m’, **kwargs)


Delayed open transmission line
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_open : Network object
a delayed open
See Also:

delay_load delay_short just calls this function

10.11. media (skrf.media) 243


scikit-rf Documentation, Release dev

skrf.media.media.Media.delay_short

Media.delay_short(d, unit=’m’, **kwargs)


Delayed Short
A transmission line of given length terminated with a short.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_short : Network object
a delayed short
See Also:

delay_load delay_short just calls this function

skrf.media.media.Media.electrical_length

Media.electrical_length(d, deg=False)
calculates the electrical length for a given distance, at the center frequency.
Parameters d: number or array-like :
delay distance, in meters
deg: Boolean :
return electral length in deg?
Returns theta: number or array-like :
electrical length in radians or degrees, depending on value of deg.

skrf.media.media.Media.from_csv

classmethod Media.from_csv(filename, *args, **kwargs)


create a Media from numerical values stored in a csv file.
the csv file format must be written by the function write_csv() which produces the following format
f[$unit], Re(Z0), Im(Z0), Re(gamma), Im(gamma), Re(port Z0), Im(port Z0) 1, 1, 1, 1, 1, 1, 1 2, 1,
1, 1, 1, 1, 1 .....

244 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.media.Media.guess_length_of_delay_short

Media.guess_length_of_delay_short(aNtwk)
Guess physical length of a delay short.
Unwraps the phase and determines the slope, which is then used in conjunction with
propagation_constant to estimate the physical distance to the short.
Parameters aNtwk : Network object
(note: if this is a measurment it needs to be normalized to the reference plane)

skrf.media.media.Media.impedance_mismatch

Media.impedance_mismatch(z1, z2, **kwargs)


Two-port network for an impedance miss-match
Parameters z1 : number, or array-like
complex impedance of port 1
z2 : number, or array-like
complex impedance of port 2
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns missmatch : Network object
a 2-port network representing the impedance missmatch
See Also:

match called to create a ‘blank’ network

Notes

If z1 and z2 are arrays, they must be of same length as the Media.frequency.npoints

skrf.media.media.Media.inductor

Media.inductor(L, **kwargs)
Inductor
Parameters L : number, array
Inductance, in Henrys. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns inductor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

10.11. media (skrf.media) 245


scikit-rf Documentation, Release dev

skrf.media.media.Media.line

Media.line(d, unit=’m’, **kwargs)


Matched transmission line of given length
The units of length are interpreted according to the value of unit.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns line : Network object
matched tranmission line of given length

Examples

>>> my_media.line(90, ’deg’, z0=50)

skrf.media.media.Media.load

Media.load(Gamma0, nports=1, **kwargs)


Load of given reflection coefficient.
Parameters Gamma0 : number, array-like
Reflection coefficient of load (linear, not in db). If its an array it must be of shape:
kxnxn, where k is #frequency points in media, and n is nports
nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns load :class:‘~skrf.network.Network‘ object :
n-port load, where S = Gamma0*eye(...)

skrf.media.media.Media.match

Media.match(nports=1, z0=None, **kwargs)


Perfect matched load (Γ0 = 0).
Parameters nports : int

246 Chapter 10. Reference


scikit-rf Documentation, Release dev

number of ports
z0 : number, or array-like
characterisitc impedance. Default is None, in which case the Media’s z0 is used. This
sets the resultant Network’s z0.
**kwargs : key word arguments
passed to Network initializer
Returns match : Network object
a n-port match

Examples

>>> my_match = my_media.match(2,z0 = 50, name=’Super Awesome Match’)

skrf.media.media.Media.open

Media.open(nports=1, **kwargs)
Open (Γ0 = 1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns match : Network object
a n-port open circuit
See Also:

match function called to create a ‘blank’ network

skrf.media.media.Media.random

Media.random(n_ports=1, **kwargs)
Complex random network.
Creates a n-port network whose s-matrix is filled with random complex numbers.
Parameters n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
the network

10.11. media (skrf.media) 247


scikit-rf Documentation, Release dev

skrf.media.media.Media.resistor

Media.resistor(R, *args, **kwargs)


Resistor
Parameters R : number, array
Resistance , in Ohms. If this is an array, must be of same length as frequency vector.
*args, **kwargs : arguments, key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns resistor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.media.Media.short

Media.short(nports=1, **kwargs)
Short (Γ0 = −1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns match : Network object
a n-port short circuit
See Also:

match function called to create a ‘blank’ network

skrf.media.media.Media.shunt

Media.shunt(ntwk, **kwargs)
Shunts a Network
This creates a tee() and connects connects ntwk to port 1, and returns the result
Parameters ntwk : Network object
**kwargs : keyword arguments
passed to tee()
Returns shunted_ntwk : Network object
a shunted a ntwk. The resultant shunted_ntwk will have (2 + ntwk.number_of_ports -1)
ports.

248 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.media.Media.shunt_capacitor

Media.shunt_capacitor(C, *args, **kwargs)


Shunted capacitor
Parameters C : number, array-like
Capacitance in Farads.
*args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_capacitor : Network object
shunted capcitor(2-port)

Notes

This calls:
shunt(capacitor(C,*args, **kwargs))

skrf.media.media.Media.shunt_delay_load

Media.shunt_delay_load(*args, **kwargs)
Shunted delayed load
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_load
Returns shunt_delay_load : Network object
a shunted delayed load (2-port)

Notes

This calls:
shunt(delay_load(*args, **kwargs))

skrf.media.media.Media.shunt_delay_open

Media.shunt_delay_open(*args, **kwargs)
Shunted delayed open
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_open : Network object
shunted delayed open (2-port)

10.11. media (skrf.media) 249


scikit-rf Documentation, Release dev

Notes

This calls:
shunt(delay_open(*args, **kwargs))

skrf.media.media.Media.shunt_delay_short

Media.shunt_delay_short(*args, **kwargs)
Shunted delayed short
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_load : Network object
shunted delayed open (2-port)

Notes

This calls:
shunt(delay_short(*args, **kwargs))

skrf.media.media.Media.shunt_inductor

Media.shunt_inductor(L, *args, **kwargs)


Shunted inductor
Parameters L : number, array-like
Inductance in Farads.
*args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_inductor : Network object
shunted inductor(2-port)

Notes

This calls:
shunt(inductor(C,*args, **kwargs))

skrf.media.media.Media.splitter

Media.splitter(nports, **kwargs)
Ideal, lossless n-way splitter.
Parameters nports : int

250 Chapter 10. Reference


scikit-rf Documentation, Release dev

number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a n-port splitter
See Also:

match called to create a ‘blank’ network

skrf.media.media.Media.tee

Media.tee(**kwargs)
Ideal, lossless tee. (3-port splitter)
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a 3-port splitter
See Also:

splitter this just calls splitter(3)


match called to create a ‘blank’ network

skrf.media.media.Media.theta_2_d

Media.theta_2_d(theta, deg=True)
Converts electrical length to physical distance.
The given electrical length is to be at the center frequency.
Parameters theta : number
electrical length, at band center (see deg for unit)
deg : Boolean
is theta in degrees?
Returns d : number
physical distance in meters

skrf.media.media.Media.thru

Media.thru(**kwargs)
Matched transmission line of length 0.
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns thru : Network object

10.11. media (skrf.media) 251


scikit-rf Documentation, Release dev

matched tranmission line of 0 length


See Also:

line this just calls line(0)

skrf.media.media.Media.white_gaussian_polar

Media.white_gaussian_polar(phase_dev, mag_dev, n_ports=1, **kwargs)


Complex zero-mean gaussian white-noise network.
Creates a network whose s-matrix is complex zero-mean gaussian white-noise, of given standard deviations for
phase and magnitude components. This ‘noise’ network can be added to networks to simulate additive noise.
Parameters phase_mag : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase
n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
a noise network

skrf.media.media.Media.write_csv

Media.write_csv(filename=’f, gamma, z0.csv’)


write this media’s frequency, z0, and gamma to a csv file.
Parameters filename : string
file name to write out data to
See Also:

from_csv class method to initialize Media object from a csv file written from this function

10.11.2 Transmission Line Classes

DistributedCircuit Generic, distributed circuit TEM transmission line


RectangularWaveguide Rectangular Waveguide medium.
CPW Coplanar waveguide class
Freespace Represents a plane-wave in a homogeneous freespace, defined by the space’s relative permativity and

252 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.distributedCircuit.DistributedCircuit

class skrf.media.distributedCircuit.DistributedCircuit(frequency, C, I, R, G, *args,


**kwargs)
Generic, distributed circuit TEM transmission line
A TEM transmission line, defined in terms of distributed impedance and admittance values. A Distributed
Circuit may be defined in terms of the following attributes,
Quantity Symbol Property
0
Distributed Capacitance C C
0
Distributed Inductance I I
0
Distributed Resistance R R
0
Distributed Conductance G G
From these, the following quantities may be calculated, which are functions of angular frequency (ω):
Quantity Symbol Property
0 0 0
Distributed Impedance Z = R + jωI Z
0 0 0
Distributed Admittance Y = G + jωC Y
From these we can calculate properties which define their wave behavior:
Quantity Symbol
q 0 Method
Characteristic Impedance Z0 = YZ 0 Z0()

Propagation Constant γ = Z0 Y 0 gamma()
Given the following definitions, the components of propagation constant are interpreted as follows:

+<e{γ} = attenuation
−=m{γ} = forward propagation

Attributes

0
Y Distributed Admittance, Y
0
Z Distributed Impedance, Z
characteristic_impedance Characterisitc impedance
portz0 Port Impedance
propagation_constant Propagation constant
v_p complex phase velocity (in m/s)
z0 Port Impedance

skrf.media.distributedCircuit.DistributedCircuit.Y

DistributedCircuit.Y
0
Distributed Admittance, Y
Defined as
0 0 0
Y = G + jωC

Returns Y : numpy.ndarray
Distributed Admittance in units of S/m

10.11. media (skrf.media) 253


scikit-rf Documentation, Release dev

skrf.media.distributedCircuit.DistributedCircuit.Z

DistributedCircuit.Z
0
Distributed Impedance, Z
Defined as
0 0 0
Z = R + jωI

Returns Z : numpy.ndarray
Distributed impedance in units of ohm/m

skrf.media.distributedCircuit.DistributedCircuit.characteristic_impedance

DistributedCircuit.characteristic_impedance
Characterisitc impedance
The characteristic_impedance can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the characterisitc impedance to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns characteristic_impedance : numpy.ndarray

skrf.media.distributedCircuit.DistributedCircuit.portz0

DistributedCircuit.portz0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

skrf.media.distributedCircuit.DistributedCircuit.propagation_constant

DistributedCircuit.propagation_constant
Propagation constant
The propagation constant can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the propagation constant to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns propagation_constant : numpy.ndarray
complex propagation constant for this media

254 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

propagation_constant must adhere to the following convention,


• positive real(propagation_constant) = attenuation
• positive imag(propagation_constant) = forward propagation

skrf.media.distributedCircuit.DistributedCircuit.v_p

DistributedCircuit.v_p
complex phase velocity (in m/s)

j · ω/γ

where: * ω is angular frequency (rad/s), * γ is complex propagation constant (rad/m)


See Also:
propgation_constant

skrf.media.distributedCircuit.DistributedCircuit.z0

DistributedCircuit.z0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

Methods

Z0 Characteristic Impedance, Z0
__init__ Distributed Circuit constructor.
capacitor Capacitor
delay_load Delayed load
delay_open Delayed open transmission line
delay_short Delayed Short
electrical_length calculates the electrical length for a given distance, at
from_Media Initializes a DistributedCircuit from an existing
from_csv create a Media from numerical values stored in a csv file.
gamma Propagation Constant, γ
Continued on next page

10.11. media (skrf.media) 255


scikit-rf Documentation, Release dev

Table 10.49 – continued from previous page


guess_length_of_delay_short Guess physical length of a delay short.
impedance_mismatch Two-port network for an impedance miss-match
inductor Inductor
line Matched transmission line of given length
load Load of given reflection coefficient.
match Perfect matched load (Γ0 = 0).
open Open (Γ0 = 1)
random Complex random network.
resistor Resistor
short Short (Γ0 = −1)
shunt Shunts a Network
shunt_capacitor Shunted capacitor
shunt_delay_load Shunted delayed load
shunt_delay_open Shunted delayed open
shunt_delay_short Shunted delayed short
shunt_inductor Shunted inductor
splitter Ideal, lossless n-way splitter.
tee Ideal, lossless tee.
theta_2_d Converts electrical length to physical distance.
thru Matched transmission line of length 0.
white_gaussian_polar Complex zero-mean gaussian white-noise network.
write_csv write this media’s frequency, z0, and gamma to a csv file.

skrf.media.distributedCircuit.DistributedCircuit.Z0

DistributedCircuit.Z0()
Characteristic Impedance, Z0
r
Z0
Z0 =
Y0

Returns Z0 : numpy.ndarray
Characteristic Impedance in units of ohms

skrf.media.distributedCircuit.DistributedCircuit.__init__

DistributedCircuit.__init__(frequency, C, I, R, G, *args, **kwargs)


Distributed Circuit constructor.
Parameters frequency : Frequency object
C : number, or array-like
distributed capacitance, in F/m
I : number, or array-like
distributed inductance, in H/m
R : number, or array-like
distributed resistance, in Ohm/m

256 Chapter 10. Reference


scikit-rf Documentation, Release dev

G : number, or array-like
distributed conductance, in S/m

Notes

C,I,R,G can all be vectors as long as they are the same length
This object can be constructed from a Media instance too, see the classmethod from_Media()

skrf.media.distributedCircuit.DistributedCircuit.capacitor

DistributedCircuit.capacitor(C, **kwargs)
Capacitor
Parameters C : number, array
Capacitance, in Farads. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns capacitor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.distributedCircuit.DistributedCircuit.delay_load

DistributedCircuit.delay_load(Gamma0, d, unit=’m’, **kwargs)


Delayed load
A load with reflection coefficient Gamma0 at the end of a matched line of length d.
Parameters Gamma0 : number, array-like
reflection coefficient of load (not in dB)
d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_load : Network object
a delayed load
See Also:

10.11. media (skrf.media) 257


scikit-rf Documentation, Release dev

line creates the network for line


load creates the network for the load

Notes

This calls
line(d,unit, **kwargs) ** load(Gamma0, **kwargs)

Examples

>>> my_media.delay_load(-.5, 90, ’deg’, z0=50)

skrf.media.distributedCircuit.DistributedCircuit.delay_open

DistributedCircuit.delay_open(d, unit=’m’, **kwargs)


Delayed open transmission line
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_open : Network object
a delayed open
See Also:

delay_load delay_short just calls this function

skrf.media.distributedCircuit.DistributedCircuit.delay_short

DistributedCircuit.delay_short(d, unit=’m’, **kwargs)


Delayed Short
A transmission line of given length terminated with a short.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:

258 Chapter 10. Reference


scikit-rf Documentation, Release dev

• m : meters, physical length in meters (default)


• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_short : Network object
a delayed short
See Also:

delay_load delay_short just calls this function

skrf.media.distributedCircuit.DistributedCircuit.electrical_length

DistributedCircuit.electrical_length(d, deg=False)
calculates the electrical length for a given distance, at the center frequency.
Parameters d: number or array-like :
delay distance, in meters
deg: Boolean :
return electral length in deg?
Returns theta: number or array-like :
electrical length in radians or degrees, depending on value of deg.

skrf.media.distributedCircuit.DistributedCircuit.from_Media

classmethod DistributedCircuit.from_Media(my_media, *args, **kwargs)


Initializes a DistributedCircuit from an existing :class:’~skrf.media.media.Media’ instance.

skrf.media.distributedCircuit.DistributedCircuit.from_csv

classmethod DistributedCircuit.from_csv(filename, *args, **kwargs)


create a Media from numerical values stored in a csv file.
the csv file format must be written by the function write_csv() which produces the following format
f[$unit], Re(Z0), Im(Z0), Re(gamma), Im(gamma), Re(port Z0), Im(port Z0) 1, 1, 1, 1, 1, 1, 1 2, 1,
1, 1, 1, 1, 1 .....

skrf.media.distributedCircuit.DistributedCircuit.gamma

DistributedCircuit.gamma()
Propagation Constant, γ

10.11. media (skrf.media) 259


scikit-rf Documentation, Release dev

Defined as,

γ= Z0 Y 0

Returns gamma : numpy.ndarray


Propagation Constant,

Notes

The components of propagation constant are interpreted as follows:


positive real(gamma) = attenuation positive imag(gamma) = forward propagation

skrf.media.distributedCircuit.DistributedCircuit.guess_length_of_delay_short

DistributedCircuit.guess_length_of_delay_short(aNtwk)
Guess physical length of a delay short.
Unwraps the phase and determines the slope, which is then used in conjunction with
propagation_constant to estimate the physical distance to the short.
Parameters aNtwk : Network object
(note: if this is a measurment it needs to be normalized to the reference plane)

skrf.media.distributedCircuit.DistributedCircuit.impedance_mismatch

DistributedCircuit.impedance_mismatch(z1, z2, **kwargs)


Two-port network for an impedance miss-match
Parameters z1 : number, or array-like
complex impedance of port 1
z2 : number, or array-like
complex impedance of port 2
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns missmatch : Network object
a 2-port network representing the impedance missmatch
See Also:

match called to create a ‘blank’ network

Notes

If z1 and z2 are arrays, they must be of same length as the Media.frequency.npoints

260 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.distributedCircuit.DistributedCircuit.inductor

DistributedCircuit.inductor(L, **kwargs)
Inductor
Parameters L : number, array
Inductance, in Henrys. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns inductor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.distributedCircuit.DistributedCircuit.line

DistributedCircuit.line(d, unit=’m’, **kwargs)


Matched transmission line of given length
The units of length are interpreted according to the value of unit.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns line : Network object
matched tranmission line of given length

Examples

>>> my_media.line(90, ’deg’, z0=50)

skrf.media.distributedCircuit.DistributedCircuit.load

DistributedCircuit.load(Gamma0, nports=1, **kwargs)


Load of given reflection coefficient.
Parameters Gamma0 : number, array-like
Reflection coefficient of load (linear, not in db). If its an array it must be of shape:
kxnxn, where k is #frequency points in media, and n is nports

10.11. media (skrf.media) 261


scikit-rf Documentation, Release dev

nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns load :class:‘~skrf.network.Network‘ object :
n-port load, where S = Gamma0*eye(...)

skrf.media.distributedCircuit.DistributedCircuit.match

DistributedCircuit.match(nports=1, z0=None, **kwargs)


Perfect matched load (Γ0 = 0).
Parameters nports : int
number of ports
z0 : number, or array-like
characterisitc impedance. Default is None, in which case the Media’s z0 is used. This
sets the resultant Network’s z0.
**kwargs : key word arguments
passed to Network initializer
Returns match : Network object
a n-port match

Examples

>>> my_match = my_media.match(2,z0 = 50, name=’Super Awesome Match’)

skrf.media.distributedCircuit.DistributedCircuit.open

DistributedCircuit.open(nports=1, **kwargs)
Open (Γ0 = 1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns match : Network object
a n-port open circuit
See Also:

match function called to create a ‘blank’ network

262 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.distributedCircuit.DistributedCircuit.random

DistributedCircuit.random(n_ports=1, **kwargs)
Complex random network.
Creates a n-port network whose s-matrix is filled with random complex numbers.
Parameters n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
the network

skrf.media.distributedCircuit.DistributedCircuit.resistor

DistributedCircuit.resistor(R, *args, **kwargs)


Resistor
Parameters R : number, array
Resistance , in Ohms. If this is an array, must be of same length as frequency vector.
*args, **kwargs : arguments, key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns resistor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.distributedCircuit.DistributedCircuit.short

DistributedCircuit.short(nports=1, **kwargs)
Short (Γ0 = −1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns match : Network object
a n-port short circuit
See Also:

match function called to create a ‘blank’ network

10.11. media (skrf.media) 263


scikit-rf Documentation, Release dev

skrf.media.distributedCircuit.DistributedCircuit.shunt

DistributedCircuit.shunt(ntwk, **kwargs)
Shunts a Network
This creates a tee() and connects connects ntwk to port 1, and returns the result
Parameters ntwk : Network object
**kwargs : keyword arguments
passed to tee()
Returns shunted_ntwk : Network object
a shunted a ntwk. The resultant shunted_ntwk will have (2 + ntwk.number_of_ports -1)
ports.

skrf.media.distributedCircuit.DistributedCircuit.shunt_capacitor

DistributedCircuit.shunt_capacitor(C, *args, **kwargs)


Shunted capacitor
Parameters C : number, array-like
Capacitance in Farads.
*args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_capacitor : Network object
shunted capcitor(2-port)

Notes

This calls:
shunt(capacitor(C,*args, **kwargs))

skrf.media.distributedCircuit.DistributedCircuit.shunt_delay_load

DistributedCircuit.shunt_delay_load(*args, **kwargs)
Shunted delayed load
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_load
Returns shunt_delay_load : Network object
a shunted delayed load (2-port)

264 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This calls:
shunt(delay_load(*args, **kwargs))

skrf.media.distributedCircuit.DistributedCircuit.shunt_delay_open

DistributedCircuit.shunt_delay_open(*args, **kwargs)
Shunted delayed open
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_open : Network object
shunted delayed open (2-port)

Notes

This calls:
shunt(delay_open(*args, **kwargs))

skrf.media.distributedCircuit.DistributedCircuit.shunt_delay_short

DistributedCircuit.shunt_delay_short(*args, **kwargs)
Shunted delayed short
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_load : Network object
shunted delayed open (2-port)

Notes

This calls:
shunt(delay_short(*args, **kwargs))

skrf.media.distributedCircuit.DistributedCircuit.shunt_inductor

DistributedCircuit.shunt_inductor(L, *args, **kwargs)


Shunted inductor
Parameters L : number, array-like
Inductance in Farads.
*args,**kwargs : arguments, keyword arguments

10.11. media (skrf.media) 265


scikit-rf Documentation, Release dev

passed to func:delay_open
Returns shunt_inductor : Network object
shunted inductor(2-port)

Notes

This calls:
shunt(inductor(C,*args, **kwargs))

skrf.media.distributedCircuit.DistributedCircuit.splitter

DistributedCircuit.splitter(nports, **kwargs)
Ideal, lossless n-way splitter.
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a n-port splitter
See Also:

match called to create a ‘blank’ network

skrf.media.distributedCircuit.DistributedCircuit.tee

DistributedCircuit.tee(**kwargs)
Ideal, lossless tee. (3-port splitter)
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a 3-port splitter
See Also:

splitter this just calls splitter(3)


match called to create a ‘blank’ network

skrf.media.distributedCircuit.DistributedCircuit.theta_2_d

DistributedCircuit.theta_2_d(theta, deg=True)
Converts electrical length to physical distance.
The given electrical length is to be at the center frequency.

266 Chapter 10. Reference


scikit-rf Documentation, Release dev

Parameters theta : number


electrical length, at band center (see deg for unit)
deg : Boolean
is theta in degrees?
Returns d : number
physical distance in meters

skrf.media.distributedCircuit.DistributedCircuit.thru

DistributedCircuit.thru(**kwargs)
Matched transmission line of length 0.
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns thru : Network object
matched tranmission line of 0 length
See Also:

line this just calls line(0)

skrf.media.distributedCircuit.DistributedCircuit.white_gaussian_polar

DistributedCircuit.white_gaussian_polar(phase_dev, mag_dev, n_ports=1, **kwargs)


Complex zero-mean gaussian white-noise network.
Creates a network whose s-matrix is complex zero-mean gaussian white-noise, of given standard deviations for
phase and magnitude components. This ‘noise’ network can be added to networks to simulate additive noise.
Parameters phase_mag : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase
n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
a noise network

10.11. media (skrf.media) 267


scikit-rf Documentation, Release dev

skrf.media.distributedCircuit.DistributedCircuit.write_csv

DistributedCircuit.write_csv(filename=’f, gamma, z0.csv’)


write this media’s frequency, z0, and gamma to a csv file.
Parameters filename : string
file name to write out data to
See Also:

from_csv class method to initialize Media object from a csv file written from this function

skrf.media.rectangularWaveguide.RectangularWaveguide

class skrf.media.rectangularWaveguide.RectangularWaveguide(frequency, a, b=None,


mode_type=’te’, m=1,
n=0, ep_r=1, mu_r=1,
rho=None, rough-
ness=None, *args,
**kwargs)
Rectangular Waveguide medium.
Represents a single mode of a homogeneously filled rectangular waveguide of cross-section a x b. The mode is
determined by mode-type (te or tm) and mode indecies ( m and n ).
Quantity Symbol Variable
Characteristic Wave Number k0 k0
Cut-off Wave Number kc kc
Longitudinal Wave Number kz kz
Transverse Wave Number (a) kx kx
Transverse Wave Number (b) ky ky
Characteristic Impedance Z0 Z0

Attributes

alpha_c Loss due to finite conductivity and roughness of sidewalls


characteristic_impedance Characterisitc impedance
ep The permativity of the filling material
f_cutoff cutoff frequency for this mode
f_norm frequency vector normalized to cuttoff
gamma Propagation constant
k0 Characteristic wave number
kc Cut-off wave number
kx Eigen value in the ‘a’ direction
ky Eigen-value in the b direction.
lambda_cutoff cuttoff wavelength
mu The permeability of the filling material
portz0 Port Impedance
propagation_constant Propagation constant
rho conductivty of sidewalls in ohm*m
v_p complex phase velocity (in m/s)
Continued on next page

268 Chapter 10. Reference


scikit-rf Documentation, Release dev

Table 10.50 – continued from previous page


z0 Port Impedance

skrf.media.rectangularWaveguide.RectangularWaveguide.alpha_c

RectangularWaveguide.alpha_c
Loss due to finite conductivity and roughness of sidewalls
In units of np/m See property rho for setting conductivity.
Effects of finite conductivity are taken from 37 . If roughness is not None, then its effects the conductivity by
σ
σc =
˛w2
where
1.6
kw = 1 + e(−δ/2h)
δ = skindepthh = surf aceroughness

This is taken from Ansoft HFSS help documents.

References

http://eceweb1.rutgers.edu/~orfanidi/ewa/

skrf.media.rectangularWaveguide.RectangularWaveguide.characteristic_impedance

RectangularWaveguide.characteristic_impedance
Characterisitc impedance
The characteristic_impedance can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the characterisitc impedance to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns characteristic_impedance : numpy.ndarray

skrf.media.rectangularWaveguide.RectangularWaveguide.ep

RectangularWaveguide.ep
The permativity of the filling material
Returns ep : number
filling material’s relative permativity

skrf.media.rectangularWaveguide.RectangularWaveguide.f_cutoff

RectangularWaveguide.f_cutoff
cutoff frequency for this mode

max(
37 Electromagnetic Waves and Antennas by Sophocles J. Orfanidis

10.11. media (skrf.media) 269


scikit-rf Documentation, Release dev

rac{m cdot v}{2a} , rac{n cdot v}{2b})


where v= sqrt(ep*mu)

skrf.media.rectangularWaveguide.RectangularWaveguide.f_norm

RectangularWaveguide.f_norm
frequency vector normalized to cuttoff

skrf.media.rectangularWaveguide.RectangularWaveguide.gamma

RectangularWaveguide.gamma
Propagation constant
The propagation constant can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the propagation constant to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns propagation_constant : numpy.ndarray
complex propagation constant for this media

Notes

propagation_constant must adhere to the following convention,


• positive real(propagation_constant) = attenuation
• positive imag(propagation_constant) = forward propagation

skrf.media.rectangularWaveguide.RectangularWaveguide.k0

RectangularWaveguide.k0
Characteristic wave number
Returns k0 : number
characteristic wave number

skrf.media.rectangularWaveguide.RectangularWaveguide.kc

RectangularWaveguide.kc
Cut-off wave number
Defined as
r
q π2 π2
kc = kx2 + ky2 = m +n
a b
Returns kc : number
cut-off wavenumber

270 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.rectangularWaveguide.RectangularWaveguide.kx

RectangularWaveguide.kx
Eigen value in the ‘a’ direction
Defined as
π
kx = m
a
Returns kx : number
eigen-value in a direction

skrf.media.rectangularWaveguide.RectangularWaveguide.ky

RectangularWaveguide.ky
Eigen-value in the b direction.
Defined as
π
ky = n
b
Returns ky : number
eigen-value in b direction

skrf.media.rectangularWaveguide.RectangularWaveguide.lambda_cutoff

RectangularWaveguide.lambda_cutoff
cuttoff wavelength

fc ∗ v
wherev = sqrt(ep ∗ mu)

skrf.media.rectangularWaveguide.RectangularWaveguide.mu

RectangularWaveguide.mu
The permeability of the filling material
Returns mu : number
filling material’s relative permeability

skrf.media.rectangularWaveguide.RectangularWaveguide.portz0

RectangularWaveguide.portz0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.

10.11. media (skrf.media) 271


scikit-rf Documentation, Release dev

The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

skrf.media.rectangularWaveguide.RectangularWaveguide.propagation_constant

RectangularWaveguide.propagation_constant
Propagation constant
The propagation constant can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the propagation constant to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns propagation_constant : numpy.ndarray
complex propagation constant for this media

Notes

propagation_constant must adhere to the following convention,


• positive real(propagation_constant) = attenuation
• positive imag(propagation_constant) = forward propagation

skrf.media.rectangularWaveguide.RectangularWaveguide.rho

RectangularWaveguide.rho
conductivty of sidewalls in ohm*m
Parameters val : float, array-like or str
the conductivity in ohm*m. If array-like must be same length as self.frequency. if str, it
must be a key in skrf.data.materials.

Examples

>>> wg.rho = 2.8e-8


>>> wg.rho = 2.8e-8 * ones(len(wg.frequency))
>>> wg.rho = ’al’
>>> wg.rho = ’aluminum’

skrf.media.rectangularWaveguide.RectangularWaveguide.v_p

RectangularWaveguide.v_p
complex phase velocity (in m/s)

j · ω/γ

272 Chapter 10. Reference


scikit-rf Documentation, Release dev

where: * ω is angular frequency (rad/s), * γ is complex propagation constant (rad/m)


See Also:
propgation_constant

skrf.media.rectangularWaveguide.RectangularWaveguide.z0

RectangularWaveguide.z0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

Methods

Z0 The characteristic impedance


__init__ RectangularWaveguide initializer
capacitor Capacitor
delay_load Delayed load
delay_open Delayed open transmission line
delay_short Delayed Short
electrical_length calculates the electrical length for a given distance, at
from_csv create a Media from numerical values stored in a csv file.
guess_length_of_delay_short Guess physical length of a delay short.
impedance_mismatch Two-port network for an impedance miss-match
inductor Inductor
kz The Longitudinal wave number, aka propagation constant.
line Matched transmission line of given length
load Load of given reflection coefficient.
match Perfect matched load (Γ0 = 0).
open Open (Γ0 = 1)
random Complex random network.
resistor Resistor
short Short (Γ0 = −1)
shunt Shunts a Network
shunt_capacitor Shunted capacitor
shunt_delay_load Shunted delayed load
shunt_delay_open Shunted delayed open
shunt_delay_short Shunted delayed short
shunt_inductor Shunted inductor
splitter Ideal, lossless n-way splitter.
Continued on next page

10.11. media (skrf.media) 273


scikit-rf Documentation, Release dev

Table 10.51 – continued from previous page


tee Ideal, lossless tee.
theta_2_d Converts electrical length to physical distance.
thru Matched transmission line of length 0.
white_gaussian_polar Complex zero-mean gaussian white-noise network.
write_csv write this media’s frequency, z0, and gamma to a csv file.

skrf.media.rectangularWaveguide.RectangularWaveguide.Z0

RectangularWaveguide.Z0()
The characteristic impedance

skrf.media.rectangularWaveguide.RectangularWaveguide.__init__

RectangularWaveguide.__init__(frequency, a, b=None, mode_type=’te’, m=1, n=0, ep_r=1,


mu_r=1, rho=None, roughness=None, *args, **kwargs)
RectangularWaveguide initializer
Parameters frequency : class:~skrf.frequency.Frequency object
frequency band for this media
a : number
width of waveguide, in meters.
b : number
height of waveguide, in meters. If None defaults to a/2
mode_type : [’te’,’tm’]
mode type, transverse electric (te) or transverse magnetic (tm) to-z. where z is direction
of propagation
m : int
mode index in ‘a’-direction
n : int
mode index in ‘b’-direction
ep_r : number, array-like,
filling material’s relative permativity
mu_r : number, array-like
filling material’s relative permeability
rho : number, array-like, string
resistivity (ohm-m) of the conductor walls. If array-like must be same length as fre-
quency. if str, it must be a key in skrf.data.materials.
roughness : number, or array-like
surface roughness of the conductor walls in units of RMS deviation from surface
*args,**kwargs : arguments, keywrod arguments
passed to Media‘s constructor (__init__()

274 Chapter 10. Reference


scikit-rf Documentation, Release dev

Examples

Most common usage is standard aspect ratio (2:1) dominant mode, TE10 mode of wr10 waveguide can be
constructed by
>>> freq = rf.Frequency(75,110,101,’ghz’)
>>> rf.RectangularWaveguide(freq, 100*mil)

skrf.media.rectangularWaveguide.RectangularWaveguide.capacitor

RectangularWaveguide.capacitor(C, **kwargs)
Capacitor
Parameters C : number, array
Capacitance, in Farads. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns capacitor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.rectangularWaveguide.RectangularWaveguide.delay_load

RectangularWaveguide.delay_load(Gamma0, d, unit=’m’, **kwargs)


Delayed load
A load with reflection coefficient Gamma0 at the end of a matched line of length d.
Parameters Gamma0 : number, array-like
reflection coefficient of load (not in dB)
d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_load : Network object
a delayed load
See Also:

10.11. media (skrf.media) 275


scikit-rf Documentation, Release dev

line creates the network for line


load creates the network for the load

Notes

This calls
line(d,unit, **kwargs) ** load(Gamma0, **kwargs)

Examples

>>> my_media.delay_load(-.5, 90, ’deg’, z0=50)

skrf.media.rectangularWaveguide.RectangularWaveguide.delay_open

RectangularWaveguide.delay_open(d, unit=’m’, **kwargs)


Delayed open transmission line
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_open : Network object
a delayed open
See Also:

delay_load delay_short just calls this function

skrf.media.rectangularWaveguide.RectangularWaveguide.delay_short

RectangularWaveguide.delay_short(d, unit=’m’, **kwargs)


Delayed Short
A transmission line of given length terminated with a short.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:

276 Chapter 10. Reference


scikit-rf Documentation, Release dev

• m : meters, physical length in meters (default)


• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_short : Network object
a delayed short
See Also:

delay_load delay_short just calls this function

skrf.media.rectangularWaveguide.RectangularWaveguide.electrical_length

RectangularWaveguide.electrical_length(d, deg=False)
calculates the electrical length for a given distance, at the center frequency.
Parameters d: number or array-like :
delay distance, in meters
deg: Boolean :
return electral length in deg?
Returns theta: number or array-like :
electrical length in radians or degrees, depending on value of deg.

skrf.media.rectangularWaveguide.RectangularWaveguide.from_csv

classmethod RectangularWaveguide.from_csv(filename, *args, **kwargs)


create a Media from numerical values stored in a csv file.
the csv file format must be written by the function write_csv() which produces the following format
f[$unit], Re(Z0), Im(Z0), Re(gamma), Im(gamma), Re(port Z0), Im(port Z0) 1, 1, 1, 1, 1, 1, 1 2, 1,
1, 1, 1, 1, 1 .....

skrf.media.rectangularWaveguide.RectangularWaveguide.guess_length_of_delay_short

RectangularWaveguide.guess_length_of_delay_short(aNtwk)
Guess physical length of a delay short.
Unwraps the phase and determines the slope, which is then used in conjunction with
propagation_constant to estimate the physical distance to the short.
Parameters aNtwk : Network object
(note: if this is a measurment it needs to be normalized to the reference plane)

10.11. media (skrf.media) 277


scikit-rf Documentation, Release dev

skrf.media.rectangularWaveguide.RectangularWaveguide.impedance_mismatch

RectangularWaveguide.impedance_mismatch(z1, z2, **kwargs)


Two-port network for an impedance miss-match
Parameters z1 : number, or array-like
complex impedance of port 1
z2 : number, or array-like
complex impedance of port 2
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns missmatch : Network object
a 2-port network representing the impedance missmatch
See Also:

match called to create a ‘blank’ network

Notes

If z1 and z2 are arrays, they must be of same length as the Media.frequency.npoints

skrf.media.rectangularWaveguide.RectangularWaveguide.inductor

RectangularWaveguide.inductor(L, **kwargs)
Inductor
Parameters L : number, array
Inductance, in Henrys. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns inductor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.rectangularWaveguide.RectangularWaveguide.kz

RectangularWaveguide.kz()
The Longitudinal wave number, aka propagation constant.
Defined as
q
kz = ± k02 − kc2

This is.
• IMAGINARY for propagating modes

278 Chapter 10. Reference


scikit-rf Documentation, Release dev

• REAL for non-propagating modes,

Returns kz : number
The propagation constant

skrf.media.rectangularWaveguide.RectangularWaveguide.line

RectangularWaveguide.line(d, unit=’m’, **kwargs)


Matched transmission line of given length
The units of length are interpreted according to the value of unit.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns line : Network object
matched tranmission line of given length

Examples

>>> my_media.line(90, ’deg’, z0=50)

skrf.media.rectangularWaveguide.RectangularWaveguide.load

RectangularWaveguide.load(Gamma0, nports=1, **kwargs)


Load of given reflection coefficient.
Parameters Gamma0 : number, array-like
Reflection coefficient of load (linear, not in db). If its an array it must be of shape:
kxnxn, where k is #frequency points in media, and n is nports
nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns load :class:‘~skrf.network.Network‘ object :
n-port load, where S = Gamma0*eye(...)

10.11. media (skrf.media) 279


scikit-rf Documentation, Release dev

skrf.media.rectangularWaveguide.RectangularWaveguide.match

RectangularWaveguide.match(nports=1, z0=None, **kwargs)


Perfect matched load (Γ0 = 0).
Parameters nports : int
number of ports
z0 : number, or array-like
characterisitc impedance. Default is None, in which case the Media’s z0 is used. This
sets the resultant Network’s z0.
**kwargs : key word arguments
passed to Network initializer
Returns match : Network object
a n-port match

Examples

>>> my_match = my_media.match(2,z0 = 50, name=’Super Awesome Match’)

skrf.media.rectangularWaveguide.RectangularWaveguide.open

RectangularWaveguide.open(nports=1, **kwargs)
Open (Γ0 = 1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns match : Network object
a n-port open circuit
See Also:

match function called to create a ‘blank’ network

skrf.media.rectangularWaveguide.RectangularWaveguide.random

RectangularWaveguide.random(n_ports=1, **kwargs)
Complex random network.
Creates a n-port network whose s-matrix is filled with random complex numbers.
Parameters n_ports : int
number of ports.
**kwargs : passed to Network

280 Chapter 10. Reference


scikit-rf Documentation, Release dev

initializer
Returns result : Network object
the network

skrf.media.rectangularWaveguide.RectangularWaveguide.resistor

RectangularWaveguide.resistor(R, *args, **kwargs)


Resistor
Parameters R : number, array
Resistance , in Ohms. If this is an array, must be of same length as frequency vector.
*args, **kwargs : arguments, key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns resistor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.rectangularWaveguide.RectangularWaveguide.short

RectangularWaveguide.short(nports=1, **kwargs)
Short (Γ0 = −1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns match : Network object
a n-port short circuit
See Also:

match function called to create a ‘blank’ network

skrf.media.rectangularWaveguide.RectangularWaveguide.shunt

RectangularWaveguide.shunt(ntwk, **kwargs)
Shunts a Network
This creates a tee() and connects connects ntwk to port 1, and returns the result
Parameters ntwk : Network object
**kwargs : keyword arguments
passed to tee()
Returns shunted_ntwk : Network object

10.11. media (skrf.media) 281


scikit-rf Documentation, Release dev

a shunted a ntwk. The resultant shunted_ntwk will have (2 + ntwk.number_of_ports -1)


ports.

skrf.media.rectangularWaveguide.RectangularWaveguide.shunt_capacitor

RectangularWaveguide.shunt_capacitor(C, *args, **kwargs)


Shunted capacitor
Parameters C : number, array-like
Capacitance in Farads.
*args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_capacitor : Network object
shunted capcitor(2-port)

Notes

This calls:
shunt(capacitor(C,*args, **kwargs))

skrf.media.rectangularWaveguide.RectangularWaveguide.shunt_delay_load

RectangularWaveguide.shunt_delay_load(*args, **kwargs)
Shunted delayed load
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_load
Returns shunt_delay_load : Network object
a shunted delayed load (2-port)

Notes

This calls:
shunt(delay_load(*args, **kwargs))

skrf.media.rectangularWaveguide.RectangularWaveguide.shunt_delay_open

RectangularWaveguide.shunt_delay_open(*args, **kwargs)
Shunted delayed open
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_open : Network object
shunted delayed open (2-port)

282 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This calls:
shunt(delay_open(*args, **kwargs))

skrf.media.rectangularWaveguide.RectangularWaveguide.shunt_delay_short

RectangularWaveguide.shunt_delay_short(*args, **kwargs)
Shunted delayed short
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_load : Network object
shunted delayed open (2-port)

Notes

This calls:
shunt(delay_short(*args, **kwargs))

skrf.media.rectangularWaveguide.RectangularWaveguide.shunt_inductor

RectangularWaveguide.shunt_inductor(L, *args, **kwargs)


Shunted inductor
Parameters L : number, array-like
Inductance in Farads.
*args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_inductor : Network object
shunted inductor(2-port)

Notes

This calls:
shunt(inductor(C,*args, **kwargs))

skrf.media.rectangularWaveguide.RectangularWaveguide.splitter

RectangularWaveguide.splitter(nports, **kwargs)
Ideal, lossless n-way splitter.
Parameters nports : int

10.11. media (skrf.media) 283


scikit-rf Documentation, Release dev

number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a n-port splitter
See Also:

match called to create a ‘blank’ network

skrf.media.rectangularWaveguide.RectangularWaveguide.tee

RectangularWaveguide.tee(**kwargs)
Ideal, lossless tee. (3-port splitter)
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a 3-port splitter
See Also:

splitter this just calls splitter(3)


match called to create a ‘blank’ network

skrf.media.rectangularWaveguide.RectangularWaveguide.theta_2_d

RectangularWaveguide.theta_2_d(theta, deg=True)
Converts electrical length to physical distance.
The given electrical length is to be at the center frequency.
Parameters theta : number
electrical length, at band center (see deg for unit)
deg : Boolean
is theta in degrees?
Returns d : number
physical distance in meters

skrf.media.rectangularWaveguide.RectangularWaveguide.thru

RectangularWaveguide.thru(**kwargs)
Matched transmission line of length 0.
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns thru : Network object

284 Chapter 10. Reference


scikit-rf Documentation, Release dev

matched tranmission line of 0 length


See Also:

line this just calls line(0)

skrf.media.rectangularWaveguide.RectangularWaveguide.white_gaussian_polar

RectangularWaveguide.white_gaussian_polar(phase_dev, mag_dev, n_ports=1, **kwargs)


Complex zero-mean gaussian white-noise network.
Creates a network whose s-matrix is complex zero-mean gaussian white-noise, of given standard deviations for
phase and magnitude components. This ‘noise’ network can be added to networks to simulate additive noise.
Parameters phase_mag : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase
n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
a noise network

skrf.media.rectangularWaveguide.RectangularWaveguide.write_csv

RectangularWaveguide.write_csv(filename=’f, gamma, z0.csv’)


write this media’s frequency, z0, and gamma to a csv file.
Parameters filename : string
file name to write out data to
See Also:

from_csv class method to initialize Media object from a csv file written from this function

skrf.media.cpw.CPW

class skrf.media.cpw.CPW(frequency, w, s, ep_r, t=None, rho=None, *args, **kwargs)


Coplanar waveguide class
This class was made from the technical documentation 38 provided by the qucs project 39
. The variables and
properties of this class are coincident with their derivations.
38 http://qucs.sourceforge.net/docs/technical.pdf
39 http://www.qucs.sourceforge.net/

10.11. media (skrf.media) 285


scikit-rf Documentation, Release dev

Attributes

286 Chapter 10. Reference


scikit-rf Documentation, Release dev

K_ratio intermediary parameter. see qucs docs on cpw lines.


alpha_conductor Losses due to conductor resistivity
characteristic_impedance Characterisitc impedance
ep_re intermediary parameter. see qucs docs on cpw lines.
k1 intermediary parameter. see qucs docs on cpw lines.
portz0 Port Impedance
propagation_constant Propagation constant
v_p complex phase velocity (in m/s)
z0 Port Impedance

skrf.media.cpw.CPW.K_ratio

CPW.K_ratio
intermediary parameter. see qucs docs on cpw lines.

skrf.media.cpw.CPW.alpha_conductor

CPW.alpha_conductor
Losses due to conductor resistivity
Returns alpha_conductor : array-like
lossyness due to conductor losses
See Also :
———- :
surface_resistivity : calculates surface resistivity

skrf.media.cpw.CPW.characteristic_impedance

CPW.characteristic_impedance
Characterisitc impedance
The characteristic_impedance can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the characterisitc impedance to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns characteristic_impedance : numpy.ndarray

skrf.media.cpw.CPW.ep_re

CPW.ep_re
intermediary parameter. see qucs docs on cpw lines.

skrf.media.cpw.CPW.k1

CPW.k1
intermediary parameter. see qucs docs on cpw lines.

10.11. media (skrf.media) 287


scikit-rf Documentation, Release dev

skrf.media.cpw.CPW.portz0

CPW.portz0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

skrf.media.cpw.CPW.propagation_constant

CPW.propagation_constant
Propagation constant
The propagation constant can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the propagation constant to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns propagation_constant : numpy.ndarray
complex propagation constant for this media

Notes

propagation_constant must adhere to the following convention,


• positive real(propagation_constant) = attenuation
• positive imag(propagation_constant) = forward propagation

skrf.media.cpw.CPW.v_p

CPW.v_p
complex phase velocity (in m/s)

j · ω/γ

where: * ω is angular frequency (rad/s), * γ is complex propagation constant (rad/m)


See Also:
propgation_constant

288 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.cpw.CPW.z0

CPW.z0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

Methods

Z0 Characterisitc impedance
__init__ Coplanar Waveguide initializer
capacitor Capacitor
delay_load Delayed load
delay_open Delayed open transmission line
delay_short Delayed Short
electrical_length calculates the electrical length for a given distance, at
from_csv create a Media from numerical values stored in a csv file.
gamma Propagation constant ..
guess_length_of_delay_short Guess physical length of a delay short.
impedance_mismatch Two-port network for an impedance miss-match
inductor Inductor
line Matched transmission line of given length
load Load of given reflection coefficient.
match Perfect matched load (Γ0 = 0).
open Open (Γ0 = 1)
random Complex random network.
resistor Resistor
short Short (Γ0 = −1)
shunt Shunts a Network
shunt_capacitor Shunted capacitor
shunt_delay_load Shunted delayed load
shunt_delay_open Shunted delayed open
shunt_delay_short Shunted delayed short
shunt_inductor Shunted inductor
splitter Ideal, lossless n-way splitter.
tee Ideal, lossless tee.
theta_2_d Converts electrical length to physical distance.
thru Matched transmission line of length 0.
white_gaussian_polar Complex zero-mean gaussian white-noise network.
write_csv write this media’s frequency, z0, and gamma to a csv file.

10.11. media (skrf.media) 289


scikit-rf Documentation, Release dev

skrf.media.cpw.CPW.Z0

CPW.Z0()
Characterisitc impedance

skrf.media.cpw.CPW.__init__

CPW.__init__(frequency, w, s, ep_r, t=None, rho=None, *args, **kwargs)


Coplanar Waveguide initializer
Parameters frequency : Frequency object
frequency band of this transmission line medium
w : number, or array-like
width of center conductor, in m.
s : number, or array-like
width of gap, in m.
ep_r : number, or array-like
relative permativity of substrate
t : number, or array-like, optional
conductor thickness, in m.
rho: number, or array-like, optional :
resistivity of conductor (None)

skrf.media.cpw.CPW.capacitor

CPW.capacitor(C, **kwargs)
Capacitor
Parameters C : number, array
Capacitance, in Farads. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns capacitor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.cpw.CPW.delay_load

CPW.delay_load(Gamma0, d, unit=’m’, **kwargs)


Delayed load
A load with reflection coefficient Gamma0 at the end of a matched line of length d.
Parameters Gamma0 : number, array-like

290 Chapter 10. Reference


scikit-rf Documentation, Release dev

reflection coefficient of load (not in dB)


d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_load : Network object
a delayed load
See Also:

line creates the network for line


load creates the network for the load

Notes

This calls
line(d,unit, **kwargs) ** load(Gamma0, **kwargs)

Examples

>>> my_media.delay_load(-.5, 90, ’deg’, z0=50)

skrf.media.cpw.CPW.delay_open

CPW.delay_open(d, unit=’m’, **kwargs)


Delayed open transmission line
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.

10.11. media (skrf.media) 291


scikit-rf Documentation, Release dev

Returns delay_open : Network object


a delayed open
See Also:

delay_load delay_short just calls this function

skrf.media.cpw.CPW.delay_short

CPW.delay_short(d, unit=’m’, **kwargs)


Delayed Short
A transmission line of given length terminated with a short.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_short : Network object
a delayed short
See Also:

delay_load delay_short just calls this function

skrf.media.cpw.CPW.electrical_length

CPW.electrical_length(d, deg=False)
calculates the electrical length for a given distance, at the center frequency.
Parameters d: number or array-like :
delay distance, in meters
deg: Boolean :
return electral length in deg?
Returns theta: number or array-like :
electrical length in radians or degrees, depending on value of deg.

292 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.cpw.CPW.from_csv

classmethod CPW.from_csv(filename, *args, **kwargs)


create a Media from numerical values stored in a csv file.
the csv file format must be written by the function write_csv() which produces the following format
f[$unit], Re(Z0), Im(Z0), Re(gamma), Im(gamma), Re(port Z0), Im(port Z0) 1, 1, 1, 1, 1, 1, 1 2, 1,
1, 1, 1, 1, 1 .....

skrf.media.cpw.CPW.gamma

CPW.gamma()
Propagation constant
See Also:

alpha_conductor calculates losses to conductors

skrf.media.cpw.CPW.guess_length_of_delay_short

CPW.guess_length_of_delay_short(aNtwk)
Guess physical length of a delay short.
Unwraps the phase and determines the slope, which is then used in conjunction with
propagation_constant to estimate the physical distance to the short.
Parameters aNtwk : Network object
(note: if this is a measurment it needs to be normalized to the reference plane)

skrf.media.cpw.CPW.impedance_mismatch

CPW.impedance_mismatch(z1, z2, **kwargs)


Two-port network for an impedance miss-match
Parameters z1 : number, or array-like
complex impedance of port 1
z2 : number, or array-like
complex impedance of port 2
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns missmatch : Network object
a 2-port network representing the impedance missmatch
See Also:

match called to create a ‘blank’ network

10.11. media (skrf.media) 293


scikit-rf Documentation, Release dev

Notes

If z1 and z2 are arrays, they must be of same length as the Media.frequency.npoints

skrf.media.cpw.CPW.inductor

CPW.inductor(L, **kwargs)
Inductor
Parameters L : number, array
Inductance, in Henrys. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns inductor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.cpw.CPW.line

CPW.line(d, unit=’m’, **kwargs)


Matched transmission line of given length
The units of length are interpreted according to the value of unit.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns line : Network object
matched tranmission line of given length

Examples

>>> my_media.line(90, ’deg’, z0=50)

294 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.cpw.CPW.load

CPW.load(Gamma0, nports=1, **kwargs)


Load of given reflection coefficient.
Parameters Gamma0 : number, array-like
Reflection coefficient of load (linear, not in db). If its an array it must be of shape:
kxnxn, where k is #frequency points in media, and n is nports
nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns load :class:‘~skrf.network.Network‘ object :
n-port load, where S = Gamma0*eye(...)

skrf.media.cpw.CPW.match

CPW.match(nports=1, z0=None, **kwargs)


Perfect matched load (Γ0 = 0).
Parameters nports : int
number of ports
z0 : number, or array-like
characterisitc impedance. Default is None, in which case the Media’s z0 is used. This
sets the resultant Network’s z0.
**kwargs : key word arguments
passed to Network initializer
Returns match : Network object
a n-port match

Examples

>>> my_match = my_media.match(2,z0 = 50, name=’Super Awesome Match’)

skrf.media.cpw.CPW.open

CPW.open(nports=1, **kwargs)
Open (Γ0 = 1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.

10.11. media (skrf.media) 295


scikit-rf Documentation, Release dev

Returns match : Network object


a n-port open circuit
See Also:

match function called to create a ‘blank’ network

skrf.media.cpw.CPW.random

CPW.random(n_ports=1, **kwargs)
Complex random network.
Creates a n-port network whose s-matrix is filled with random complex numbers.
Parameters n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
the network

skrf.media.cpw.CPW.resistor

CPW.resistor(R, *args, **kwargs)


Resistor
Parameters R : number, array
Resistance , in Ohms. If this is an array, must be of same length as frequency vector.
*args, **kwargs : arguments, key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns resistor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.cpw.CPW.short

CPW.short(nports=1, **kwargs)
Short (Γ0 = −1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns match : Network object
a n-port short circuit

296 Chapter 10. Reference


scikit-rf Documentation, Release dev

See Also:

match function called to create a ‘blank’ network

skrf.media.cpw.CPW.shunt

CPW.shunt(ntwk, **kwargs)
Shunts a Network
This creates a tee() and connects connects ntwk to port 1, and returns the result
Parameters ntwk : Network object
**kwargs : keyword arguments
passed to tee()
Returns shunted_ntwk : Network object
a shunted a ntwk. The resultant shunted_ntwk will have (2 + ntwk.number_of_ports -1)
ports.

skrf.media.cpw.CPW.shunt_capacitor

CPW.shunt_capacitor(C, *args, **kwargs)


Shunted capacitor
Parameters C : number, array-like
Capacitance in Farads.
*args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_capacitor : Network object
shunted capcitor(2-port)

Notes

This calls:
shunt(capacitor(C,*args, **kwargs))

skrf.media.cpw.CPW.shunt_delay_load

CPW.shunt_delay_load(*args, **kwargs)
Shunted delayed load
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_load
Returns shunt_delay_load : Network object
a shunted delayed load (2-port)

10.11. media (skrf.media) 297


scikit-rf Documentation, Release dev

Notes

This calls:
shunt(delay_load(*args, **kwargs))

skrf.media.cpw.CPW.shunt_delay_open

CPW.shunt_delay_open(*args, **kwargs)
Shunted delayed open
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_open : Network object
shunted delayed open (2-port)

Notes

This calls:
shunt(delay_open(*args, **kwargs))

skrf.media.cpw.CPW.shunt_delay_short

CPW.shunt_delay_short(*args, **kwargs)
Shunted delayed short
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_load : Network object
shunted delayed open (2-port)

Notes

This calls:
shunt(delay_short(*args, **kwargs))

skrf.media.cpw.CPW.shunt_inductor

CPW.shunt_inductor(L, *args, **kwargs)


Shunted inductor
Parameters L : number, array-like
Inductance in Farads.
*args,**kwargs : arguments, keyword arguments

298 Chapter 10. Reference


scikit-rf Documentation, Release dev

passed to func:delay_open
Returns shunt_inductor : Network object
shunted inductor(2-port)

Notes

This calls:
shunt(inductor(C,*args, **kwargs))

skrf.media.cpw.CPW.splitter

CPW.splitter(nports, **kwargs)
Ideal, lossless n-way splitter.
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a n-port splitter
See Also:

match called to create a ‘blank’ network

skrf.media.cpw.CPW.tee

CPW.tee(**kwargs)
Ideal, lossless tee. (3-port splitter)
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a 3-port splitter
See Also:

splitter this just calls splitter(3)


match called to create a ‘blank’ network

skrf.media.cpw.CPW.theta_2_d

CPW.theta_2_d(theta, deg=True)
Converts electrical length to physical distance.
The given electrical length is to be at the center frequency.

10.11. media (skrf.media) 299


scikit-rf Documentation, Release dev

Parameters theta : number


electrical length, at band center (see deg for unit)
deg : Boolean
is theta in degrees?
Returns d : number
physical distance in meters

skrf.media.cpw.CPW.thru

CPW.thru(**kwargs)
Matched transmission line of length 0.
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns thru : Network object
matched tranmission line of 0 length
See Also:

line this just calls line(0)

skrf.media.cpw.CPW.white_gaussian_polar

CPW.white_gaussian_polar(phase_dev, mag_dev, n_ports=1, **kwargs)


Complex zero-mean gaussian white-noise network.
Creates a network whose s-matrix is complex zero-mean gaussian white-noise, of given standard deviations for
phase and magnitude components. This ‘noise’ network can be added to networks to simulate additive noise.
Parameters phase_mag : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase
n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
a noise network

300 Chapter 10. Reference


scikit-rf Documentation, Release dev

skrf.media.cpw.CPW.write_csv

CPW.write_csv(filename=’f, gamma, z0.csv’)


write this media’s frequency, z0, and gamma to a csv file.
Parameters filename : string
file name to write out data to
See Also:

from_csv class method to initialize Media object from a csv file written from this function

skrf.media.freespace.Freespace

class skrf.media.freespace.Freespace(frequency, ep_r=(1+0j), mu_r=(1+0j), *args, **kwargs)


Represents a plane-wave in a homogeneous freespace, defined by the space’s relative permativity and relative
permeability.
The field properties of space are related to a disctributed circuit transmission line model given in circuit theory
by:
Circuit Property Field Property
distributed_capacitance real(ep_0*ep_r)
distributed_resistance imag(ep_0*ep_r)
distributed_inductance real(mu_0*mu_r)
distributed_conductance imag(mu_0*mu_r)

This class’s inheritence is; Media-> DistributedCircuit-> Freespace

Attributes

0
Y Distributed Admittance, Y
0
Z Distributed Impedance, Z
characteristic_impedance Characterisitc impedance
portz0 Port Impedance
propagation_constant Propagation constant
v_p complex phase velocity (in m/s)
z0 Port Impedance

skrf.media.freespace.Freespace.Y

Freespace.Y
0
Distributed Admittance, Y
Defined as
0 0 0
Y = G + jωC

Returns Y : numpy.ndarray
Distributed Admittance in units of S/m

10.11. media (skrf.media) 301


scikit-rf Documentation, Release dev

skrf.media.freespace.Freespace.Z

Freespace.Z
0
Distributed Impedance, Z
Defined as
0 0 0
Z = R + jωI

Returns Z : numpy.ndarray
Distributed impedance in units of ohm/m

skrf.media.freespace.Freespace.characteristic_impedance

Freespace.characteristic_impedance
Characterisitc impedance
The characteristic_impedance can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the characterisitc impedance to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns characteristic_impedance : numpy.ndarray

skrf.media.freespace.Freespace.portz0

Freespace.portz0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

skrf.media.freespace.Freespace.propagation_constant

Freespace.propagation_constant
Propagation constant
The propagation constant can be either a number, array-like, or a function. If it is a function is must take no
arguments. The reason to make it a function is if you want the propagation constant to be dynamic, meaning
changing with some attribute of the media. See __init__() for more explanation.
Returns propagation_constant : numpy.ndarray
complex propagation constant for this media

302 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

propagation_constant must adhere to the following convention,


• positive real(propagation_constant) = attenuation
• positive imag(propagation_constant) = forward propagation

skrf.media.freespace.Freespace.v_p

Freespace.v_p
complex phase velocity (in m/s)

j · ω/γ

where: * ω is angular frequency (rad/s), * γ is complex propagation constant (rad/m)


See Also:
propgation_constant

skrf.media.freespace.Freespace.z0

Freespace.z0
Port Impedance
The port impedance is usually equal to the characteristic_impedance. Therefore, if the port impedance
is None then this will return characteristic_impedance.
However, in some cases such as rectangular waveguide, the port impedance is traditionally set to 1 (normalized).
In such a case this property may be used.
The Port Impedance can be either a number, array-like, or a function. If it is a function is must take no arguments.
The reason to make it a function is if you want the Port Impedance to be dynamic, meaning changing with some
attribute of the media. See __init__() for more explanation.
Returns port_impedance : numpy.ndarray
the media’s port impedance

Methods

Z0 Characteristic Impedance, Z0
__init__ Freespace initializer
capacitor Capacitor
delay_load Delayed load
delay_open Delayed open transmission line
delay_short Delayed Short
electrical_length calculates the electrical length for a given distance, at
from_Media Initializes a DistributedCircuit from an existing
from_csv create a Media from numerical values stored in a csv file.
gamma Propagation Constant, γ
Continued on next page

10.11. media (skrf.media) 303


scikit-rf Documentation, Release dev

Table 10.55 – continued from previous page


guess_length_of_delay_short Guess physical length of a delay short.
impedance_mismatch Two-port network for an impedance miss-match
inductor Inductor
line Matched transmission line of given length
load Load of given reflection coefficient.
match Perfect matched load (Γ0 = 0).
open Open (Γ0 = 1)
random Complex random network.
resistor Resistor
short Short (Γ0 = −1)
shunt Shunts a Network
shunt_capacitor Shunted capacitor
shunt_delay_load Shunted delayed load
shunt_delay_open Shunted delayed open
shunt_delay_short Shunted delayed short
shunt_inductor Shunted inductor
splitter Ideal, lossless n-way splitter.
tee Ideal, lossless tee.
theta_2_d Converts electrical length to physical distance.
thru Matched transmission line of length 0.
white_gaussian_polar Complex zero-mean gaussian white-noise network.
write_csv write this media’s frequency, z0, and gamma to a csv file.

skrf.media.freespace.Freespace.Z0

Freespace.Z0()
Characteristic Impedance, Z0
r
Z0
Z0 =
Y0

Returns Z0 : numpy.ndarray
Characteristic Impedance in units of ohms

skrf.media.freespace.Freespace.__init__

Freespace.__init__(frequency, ep_r=(1+0j), mu_r=(1+0j), *args, **kwargs)


Freespace initializer
Parameters frequency : Frequency object
frequency band of this transmission line medium
ep_r : number, array-like
complex relative permativity
mu_r : number, array-like
possibly complex, relative permiability
*args, **kwargs : arguments and keyword arguments

304 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

The distributed circuit parameters are related to a space’s field properties by


Circuit Property Field Property
distributed_capacitance real(ep_0*ep_r)
distributed_resistance :math:‘omega imag(ep_0*ep_r)
distributed_inductance real(mu_0*mu_r)
distributed_conductance :math:‘omega imag(mu_0*mu_r)

skrf.media.freespace.Freespace.capacitor

Freespace.capacitor(C, **kwargs)
Capacitor
Parameters C : number, array
Capacitance, in Farads. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns capacitor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.freespace.Freespace.delay_load

Freespace.delay_load(Gamma0, d, unit=’m’, **kwargs)


Delayed load
A load with reflection coefficient Gamma0 at the end of a matched line of length d.
Parameters Gamma0 : number, array-like
reflection coefficient of load (not in dB)
d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_load : Network object
a delayed load

10.11. media (skrf.media) 305


scikit-rf Documentation, Release dev

See Also:

line creates the network for line


load creates the network for the load

Notes

This calls
line(d,unit, **kwargs) ** load(Gamma0, **kwargs)

Examples

>>> my_media.delay_load(-.5, 90, ’deg’, z0=50)

skrf.media.freespace.Freespace.delay_open

Freespace.delay_open(d, unit=’m’, **kwargs)


Delayed open transmission line
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_open : Network object
a delayed open
See Also:

delay_load delay_short just calls this function

skrf.media.freespace.Freespace.delay_short

Freespace.delay_short(d, unit=’m’, **kwargs)


Delayed Short
A transmission line of given length terminated with a short.
Parameters d : number
the length of transmissin line (see unit argument)

306 Chapter 10. Reference


scikit-rf Documentation, Release dev

unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns delay_short : Network object
a delayed short
See Also:

delay_load delay_short just calls this function

skrf.media.freespace.Freespace.electrical_length

Freespace.electrical_length(d, deg=False)
calculates the electrical length for a given distance, at the center frequency.
Parameters d: number or array-like :
delay distance, in meters
deg: Boolean :
return electral length in deg?
Returns theta: number or array-like :
electrical length in radians or degrees, depending on value of deg.

skrf.media.freespace.Freespace.from_Media

classmethod Freespace.from_Media(my_media, *args, **kwargs)


Initializes a DistributedCircuit from an existing :class:’~skrf.media.media.Media’ instance.

skrf.media.freespace.Freespace.from_csv

classmethod Freespace.from_csv(filename, *args, **kwargs)


create a Media from numerical values stored in a csv file.
the csv file format must be written by the function write_csv() which produces the following format
f[$unit], Re(Z0), Im(Z0), Re(gamma), Im(gamma), Re(port Z0), Im(port Z0) 1, 1, 1, 1, 1, 1, 1 2, 1,
1, 1, 1, 1, 1 .....

10.11. media (skrf.media) 307


scikit-rf Documentation, Release dev

skrf.media.freespace.Freespace.gamma

Freespace.gamma()
Propagation Constant, γ
Defined as,

γ= Z0 Y 0

Returns gamma : numpy.ndarray


Propagation Constant,

Notes

The components of propagation constant are interpreted as follows:


positive real(gamma) = attenuation positive imag(gamma) = forward propagation

skrf.media.freespace.Freespace.guess_length_of_delay_short

Freespace.guess_length_of_delay_short(aNtwk)
Guess physical length of a delay short.
Unwraps the phase and determines the slope, which is then used in conjunction with
propagation_constant to estimate the physical distance to the short.
Parameters aNtwk : Network object
(note: if this is a measurment it needs to be normalized to the reference plane)

skrf.media.freespace.Freespace.impedance_mismatch

Freespace.impedance_mismatch(z1, z2, **kwargs)


Two-port network for an impedance miss-match
Parameters z1 : number, or array-like
complex impedance of port 1
z2 : number, or array-like
complex impedance of port 2
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns missmatch : Network object
a 2-port network representing the impedance missmatch
See Also:

match called to create a ‘blank’ network

308 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

If z1 and z2 are arrays, they must be of same length as the Media.frequency.npoints

skrf.media.freespace.Freespace.inductor

Freespace.inductor(L, **kwargs)
Inductor
Parameters L : number, array
Inductance, in Henrys. If this is an array, must be of same length as frequency vector.
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns inductor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.freespace.Freespace.line

Freespace.line(d, unit=’m’, **kwargs)


Matched transmission line of given length
The units of length are interpreted according to the value of unit.
Parameters d : number
the length of transmissin line (see unit argument)
unit : [’m’,’deg’,’rad’]
the units of d. possible options are:
• m : meters, physical length in meters (default)
• deg :degrees, electrical length in degrees
• rad :radians, electrical length in radians
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns line : Network object
matched tranmission line of given length

Examples

>>> my_media.line(90, ’deg’, z0=50)

10.11. media (skrf.media) 309


scikit-rf Documentation, Release dev

skrf.media.freespace.Freespace.load

Freespace.load(Gamma0, nports=1, **kwargs)


Load of given reflection coefficient.
Parameters Gamma0 : number, array-like
Reflection coefficient of load (linear, not in db). If its an array it must be of shape:
kxnxn, where k is #frequency points in media, and n is nports
nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns load :class:‘~skrf.network.Network‘ object :
n-port load, where S = Gamma0*eye(...)

skrf.media.freespace.Freespace.match

Freespace.match(nports=1, z0=None, **kwargs)


Perfect matched load (Γ0 = 0).
Parameters nports : int
number of ports
z0 : number, or array-like
characterisitc impedance. Default is None, in which case the Media’s z0 is used. This
sets the resultant Network’s z0.
**kwargs : key word arguments
passed to Network initializer
Returns match : Network object
a n-port match

Examples

>>> my_match = my_media.match(2,z0 = 50, name=’Super Awesome Match’)

skrf.media.freespace.Freespace.open

Freespace.open(nports=1, **kwargs)
Open (Γ0 = 1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.

310 Chapter 10. Reference


scikit-rf Documentation, Release dev

Returns match : Network object


a n-port open circuit
See Also:

match function called to create a ‘blank’ network

skrf.media.freespace.Freespace.random

Freespace.random(n_ports=1, **kwargs)
Complex random network.
Creates a n-port network whose s-matrix is filled with random complex numbers.
Parameters n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
the network

skrf.media.freespace.Freespace.resistor

Freespace.resistor(R, *args, **kwargs)


Resistor
Parameters R : number, array
Resistance , in Ohms. If this is an array, must be of same length as frequency vector.
*args, **kwargs : arguments, key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns resistor : a 2-port Network
See Also:

match function called to create a ‘blank’ network

skrf.media.freespace.Freespace.short

Freespace.short(nports=1, **kwargs)
Short (Γ0 = −1)
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns match : Network object
a n-port short circuit

10.11. media (skrf.media) 311


scikit-rf Documentation, Release dev

See Also:

match function called to create a ‘blank’ network

skrf.media.freespace.Freespace.shunt

Freespace.shunt(ntwk, **kwargs)
Shunts a Network
This creates a tee() and connects connects ntwk to port 1, and returns the result
Parameters ntwk : Network object
**kwargs : keyword arguments
passed to tee()
Returns shunted_ntwk : Network object
a shunted a ntwk. The resultant shunted_ntwk will have (2 + ntwk.number_of_ports -1)
ports.

skrf.media.freespace.Freespace.shunt_capacitor

Freespace.shunt_capacitor(C, *args, **kwargs)


Shunted capacitor
Parameters C : number, array-like
Capacitance in Farads.
*args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_capacitor : Network object
shunted capcitor(2-port)

Notes

This calls:
shunt(capacitor(C,*args, **kwargs))

skrf.media.freespace.Freespace.shunt_delay_load

Freespace.shunt_delay_load(*args, **kwargs)
Shunted delayed load
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_load
Returns shunt_delay_load : Network object
a shunted delayed load (2-port)

312 Chapter 10. Reference


scikit-rf Documentation, Release dev

Notes

This calls:
shunt(delay_load(*args, **kwargs))

skrf.media.freespace.Freespace.shunt_delay_open

Freespace.shunt_delay_open(*args, **kwargs)
Shunted delayed open
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_open : Network object
shunted delayed open (2-port)

Notes

This calls:
shunt(delay_open(*args, **kwargs))

skrf.media.freespace.Freespace.shunt_delay_short

Freespace.shunt_delay_short(*args, **kwargs)
Shunted delayed short
Parameters *args,**kwargs : arguments, keyword arguments
passed to func:delay_open
Returns shunt_delay_load : Network object
shunted delayed open (2-port)

Notes

This calls:
shunt(delay_short(*args, **kwargs))

skrf.media.freespace.Freespace.shunt_inductor

Freespace.shunt_inductor(L, *args, **kwargs)


Shunted inductor
Parameters L : number, array-like
Inductance in Farads.
*args,**kwargs : arguments, keyword arguments

10.11. media (skrf.media) 313


scikit-rf Documentation, Release dev

passed to func:delay_open
Returns shunt_inductor : Network object
shunted inductor(2-port)

Notes

This calls:
shunt(inductor(C,*args, **kwargs))

skrf.media.freespace.Freespace.splitter

Freespace.splitter(nports, **kwargs)
Ideal, lossless n-way splitter.
Parameters nports : int
number of ports
**kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a n-port splitter
See Also:

match called to create a ‘blank’ network

skrf.media.freespace.Freespace.tee

Freespace.tee(**kwargs)
Ideal, lossless tee. (3-port splitter)
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns tee : Network object
a 3-port splitter
See Also:

splitter this just calls splitter(3)


match called to create a ‘blank’ network

skrf.media.freespace.Freespace.theta_2_d

Freespace.theta_2_d(theta, deg=True)
Converts electrical length to physical distance.
The given electrical length is to be at the center frequency.

314 Chapter 10. Reference


scikit-rf Documentation, Release dev

Parameters theta : number


electrical length, at band center (see deg for unit)
deg : Boolean
is theta in degrees?
Returns d : number
physical distance in meters

skrf.media.freespace.Freespace.thru

Freespace.thru(**kwargs)
Matched transmission line of length 0.
Parameters **kwargs : key word arguments
passed to match(), which is called initially to create a ‘blank’ network.
Returns thru : Network object
matched tranmission line of 0 length
See Also:

line this just calls line(0)

skrf.media.freespace.Freespace.white_gaussian_polar

Freespace.white_gaussian_polar(phase_dev, mag_dev, n_ports=1, **kwargs)


Complex zero-mean gaussian white-noise network.
Creates a network whose s-matrix is complex zero-mean gaussian white-noise, of given standard deviations for
phase and magnitude components. This ‘noise’ network can be added to networks to simulate additive noise.
Parameters phase_mag : number
standard deviation of magnitude
phase_dev : number
standard deviation of phase
n_ports : int
number of ports.
**kwargs : passed to Network
initializer
Returns result : Network object
a noise network

10.11. media (skrf.media) 315


scikit-rf Documentation, Release dev

skrf.media.freespace.Freespace.write_csv

Freespace.write_csv(filename=’f, gamma, z0.csv’)


write this media’s frequency, z0, and gamma to a csv file.
Parameters filename : string
file name to write out data to
See Also:

from_csv class method to initialize Media object from a csv file written from this function

10.12 vi (skrf.vi)

This module holds Virtual Instruments that are intricately related to skrf.
• Development

316 Chapter 10. Reference


Python Module Index

s
skrf.calibration, 218
skrf.calibration.calibration, 218
skrf.calibration.calibrationAlgorithms,
226
skrf.calibration.calibrationFunctions,
230
skrf.constants, 205
skrf.frequency, 69
skrf.io, 208
skrf.io.csv, 217
skrf.io.general, 208
skrf.io.touchstone, 214
skrf.mathFunctions, 193
skrf.media, 239
skrf.network, 75
skrf.networkSet, 179
skrf.plotting, 188
skrf.tlineFunctions, 196
skrf.util, 206
skrf.vi, 318

317

You might also like