network (

Provides a n-port network class and associated functions.

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

Network Class

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

Network Representations

Network.s Scattering parameter matrix.
Network.z Impedance parameter matrix.
Network.y Admittance parameter matrix.
Network.a abcd parameter matrix. Used to cascade two-ports
Network.t Scattering transfer parameters

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, 2N-ports Networks together
cascade_list(l) cascade a list of 2N-port networks
de_embed(ntwkA, ntwkB) De-embed ntwkA from ntwkB.
flip(a) invert the ports of a networks s-matrix, ‘flipping’ it over left and right.

Interpolation and Concatenation Along Frequency Axis

stitch(ntwkA, ntwkB, **kwargs) Stitches ntwkA and ntwkB together.
overlap(ntwkA, ntwkB) Returns the overlapping parts of two Networks, interpolating if needed.
Network.resample(freq_or_n, **kwargs) Interpolates s-parameters given a new
Network.interpolate(freq_or_n[, basis, …]) Interpolate a Network allong frequency axis
Network.interpolate_self(freq_or_n, **kwargs) Interpolates s-parameters given a new

Combining Networks

n_oneports_2_nport(ntwk_list, *args, **kwargs) Builds a N-port Network from list of N one-ports
four_oneports_2_twoport(s11, s12, s21, s22, …) Builds a 2-port Network from list of four 1-ports
three_twoports_2_threeport(ntwk_triplet[, …]) Creates 3-port from three 2-port Networks
n_twoports_2_nport(ntwk_list, nports[, offby]) Builds a N-port Network from list of two-ports
concat_ports(ntwk_list[, port_order]) Concatenate networks along the port axis

IO, *args, **kwargs) Read skrf object[s] from a pickle file, obj[, overwrite]) Write skrf object[s] to a file
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.*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.


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

Supporting Functions

inv(s) Calculates ‘inverse’ s-parameter matrix, used for de-embedding
connect_s(A, k, B, l) connect two n-port networks’ s-matrices together.
innerconnect_s(A, k, l) connect two ports of a single n-port network’s s-matrix.
s2z(s[, z0]) Convert scattering parameters [1]_ to impedance parameters [2]_
s2y(s[, z0]) convert scattering parameters [#]_ to admittance parameters [#]_
s2t(s) Converts scattering parameters [#]_ to scattering transfer parameters [#]_ .
s2a(s[, z0]) Converts scattering parameters to abcd parameters [#]_ .
z2s(z[, z0]) convert impedance parameters [1]_ to scattering parameters [2]_
z2y(z) convert impedance parameters [#]_ to admittance parameters [#]_
z2t(z) Not Implemented yet
z2a(z) Converts impedance parameters to abcd parameters [#]_ .
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
fix_z0_shape(z0, nfreqs, nports) Make a port impedance of correct shape for a given network’s matrix
renormalize_s(s, z_old, z_new) Renormalize a s-parameter matrix given old and new port impedances
passivity(s) Passivity metric for a multi-port network.
reciprocity(s) Reciprocity metric for a multi-port network.

Misc Functions

average(list_of_networks[, polar]) Calculates the average network from a list of Networks.
two_port_reflect(ntwk1[, ntwk2]) Generates a two-port reflective two-port, from two one-ports.
chopinhalf(ntwk, *args, **kwargs) Chops a sandwich of identical, reciprocal 2-ports in half.
Network.nudge([amount]) Perturb s-parameters by small amount.
Network.renormalize(z_new[, powerwave]) Renormalize s-parameter matrix given a new port impedances