NetworkSet

Introduction

The NetworkSet object represents an unordered set of networks. It provides methods iterating and slicing the set, sorting by datetime, calculating statistical quantities, and displaying uncertainty bounds on plots.

Creating a NetworkSet

Lets take a look in the data/ folder, there are some redundant measurements of a network called ro, which is a radiating open waveguide.


In [ ]:
ls data/ro*

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 into Networks. This can be done quickly with rf.read_all, The argument contains is used to load only files which match a given substring.


In [ ]:
import skrf as rf

rf.read_all(rf.data.pwd, contains='ro')

This can be passed directly to the NetworkSet constructor,


In [ ]:
from skrf import NetworkSet 

ro_dict = rf.read_all(rf.data.pwd, contains='ro')
ro_ns = NetworkSet(ro_dict, name='ro set') 
ro_ns

A NetworkSet can also be constructed directly from a dir with NetworkSet.from_dir() or from a zipfile of touchstones through the class method NetworkSet.from_zip().

Accesing Network Methods

The Network elements in a NetworkSet can be accessed like the elements of list,


In [ ]:
ro_ns[0]

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.


In [ ]:
%matplotlib inline
from pylab import *
import skrf as rf
rf.stylely()

ro_ns.plot_s_db()

Statistical Properties

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


In [ ]:
ro_ns.mean_s

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


In [ ]:
ro_ns.mean_s.plot_s_db(label='ro')

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


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

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 [ ]:
ro_ns.mean_s_deg.plot_s_re()

Plotting Uncertainty Bounds

Uncertainty bounds can be plotted through the methods


In [ ]:
ro_ns.plot_uncertainty_bounds_s_db()

In [ ]:
ro_ns.plot_uncertainty_bounds_s_deg()

Reading and Writing

To write all Networks of a NetworkSet out to individual touchstones,


In [ ]:
ro_ns.write_touchstone(dir='data/')

For temporary data storage, NetworkSets can be saved and read from disk using the functions rf.read and rf.write


In [ ]:
rf.write('ro set.ns', ro_ns)

In [ ]:
ro_ns = rf.read('ro set.ns')
ro_ns

Export to Excel, csv, or html

NetworkSets can also be exported to other filetypes. The format of the output; real/imag, mag/phase is adjustable, as is the output type; csv, excel, html. For example to export mag/phase for each network into an Excel spreadsheet for your boss[s]


In [ ]:
ro_ns.write_spreadsheet('data/ro_spreadsheet.xls', form='db')

More info on this can be found in the function, skrf.io.general.network_2_spreadsheet


In [ ]: