NetworkSet

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

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 [1]: import skrf as rf

In [2]: ls ../skrf/data/ro*
../skrf/data/ro,1.s1p  ../skrf/data/ro,2.s1p  ../skrf/data/ro,3.s1p

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 [1]: rf.read_all('../skrf/data/', contains='ro')
 Out[1]: 
{'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,

In [1]: ro_dict = rf.read_all('../skrf/data/', contains='ro')

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

In [3]: ro_ns
 Out[3]: A NetworkSet of length 3

A NetworkSet can also be constructed from 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 [1]: ro_ns[0]
 Out[1]: 1-Port Network: 'ro,1',  500-750 GHz, 201 pts, z0=[ 50.+0.j]

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 [1]: ro_ns.plot_s_db(label='Mean Response')
 Out[1]: [None, None, None]
../_images/ns_plot_s_db.png

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 [1]: ro_ns.mean_s
 Out[1]: 1-Port Network: 'ro set',  500-750 GHz, 201 pts, z0=[ 50.+0.j]

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

In [1]: figure();

In [2]: ro_ns.mean_s.plot_s_db(label='ro')
../_images/ns_mean_s_plot_s_db.png

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

In [1]: figure();

In [2]: ro_ns.std_s.plot_s_re(y_label='Standard Deviations')
../_images/ns_std_s_plot_s_re.png

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 [1]: figure();

In [2]: ro_ns.mean_s_deg.plot_s_re()
../_images/ns_mean_s_deg.png

Plotting Uncertainty Bounds

Uncertainty bounds can be plotted through the methods

In [1]: figure();

In [2]: ro_ns.plot_uncertainty_bounds_s_db()

In [3]: figure();

In [4]: ro_ns.plot_uncertainty_bounds_s_deg()
../_images/ns_plot_uncertainty_bounds_s_db.png ../_images/ns_plot_uncertainty_bounds_s_deg.png

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 [1]: ro_set.write()

In [2]: 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 [1]: ro_ns = rf.read('ro set.ns')

Table Of Contents

Previous topic

Plotting

Next topic

Virtual Instruments

This Page