Network

class mwavepy.Network(touchstone_file=None, name=None)

Represents a n-port microwave network.

the most fundemental properties are:
s: scattering matrix. a kxnxn complex matrix where ‘n’ is number
of ports of network.

z0: characteristic impedance f: frequency vector in Hz. see also frequency, which is a

Frequency object (see help on this class for more info)
The following operators are defined as follows:
‘+’ : element-wise addition of the s-matrix ‘-‘ : element-wise subtraction of the s-matrix ‘*’ : element-wise multiplication of the s-matrix ‘/’ : element-wise division of the s-matrix ‘**’: cascading of 2-port networks ‘//’: de-embdeding of one network from the other.

various other network properties are accesable as well as plotting routines are also defined for convenience,

most properties are derived from the specifications given for touchstone files.

add_noise_polar(mag_dev, phase_dev, **kwargs)

adds a complex zero-mean gaussian white-noise signal of given standard deviations for magnitude and phase

takes:
mag_mag: standard deviation of magnitude phase_dev: standard deviation of phase [in degrees] n_ports: number of ports. defualt to 1
returns:
nothing
change_frequency(new_frequency, **kwargs)
f

the frequency vector for the network, in Hz.

flip()

swaps the ports of a two port

frequency

returns a Frequency object, see frequency.py

interpolate(new_frequency, **kwargs)

calculates an interpolated network. defualt interpolation type is linear. see notes about other interpolation types

takes:
new_frequency: **kwargs: passed to scipy.interpolate.interp1d initializer.
returns:
result: an interpolated Network
note:
usefule keyward for scipy.interpolate.interp1d:
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.
inv

a network representing inverse s-parameters, for de-embeding

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
nudge(amount=1e-12)

perturb s-parameters by small amount. this is usefule to work-around numerical bugs. takes:

amount: amount to add to s parameters
returns:
na
number_of_ports

the number of ports the network has.

passivity
passivity metric for a multi-port network. It 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.

for two port this is
( |S11|^2 + |S21|^2, |S22|^2+|S12|^2)
in general it is
S.H * S

where H is conjugate transpose of S, and * is dot product

note: see more at, http://en.wikipedia.org/wiki/Scattering_parameters#Lossless_networks

plot_polar_generic(attribute_r, attribute_theta, m=0, n=0, ax=None, show_legend=True, **kwargs)

generic plotting function for plotting a Network’s attribute in polar form

takes:

plot_s_all_db(ax=None, show_legend=True, **kwargs)

plots all s parameters in log magnitude

takes:
ax - matplotlib.axes object to plot on, used in case you
want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_s_db(m=None, n=None, ax=None, show_legend=True, **kwargs)

plots the magnitude of the scattering parameter of indecies m, n in log magnitude

takes:

m - first index, int n - second indext, int ax - matplotlib.axes object to plot on, used in case you

want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_s_deg(m=None, n=None, ax=None, show_legend=True, **kwargs)

plots the phase of a scattering parameter of indecies m, n in degrees

takes:

m - first index, int n - second indext, int ax - matplotlib.axes object to plot on, used in case you

want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_s_deg_unwrapped(m=None, n=None, ax=None, show_legend=True, **kwargs)

plots the phase of a scattering parameter of indecies m, n in unwrapped degrees

takes:

m - first index, int n - second indext, int ax - matplotlib.axes object to plot on, used in case you

want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_s_mag(m=None, n=None, ax=None, show_legend=True, **kwargs)

plots the magnitude of a scattering parameter of indecies m, n not in magnitude

takes:

m - first index, int n - second indext, int ax - matplotlib.axes object to plot on, used in case you

want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_s_polar(m=0, n=0, ax=None, show_legend=True, **kwargs)

plots the scattering parameter of indecies m, n in polar form

takes:

m - first index, int n - second indext, int ax - matplotlib.axes object to plot on, used in case you

want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_s_rad(m=None, n=None, ax=None, show_legend=True, **kwargs)

plots the phase of a scattering parameter of indecies m, n in radians

takes:

m - first index, int n - second indext, int ax - matplotlib.axes object to plot on, used in case you

want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_s_rad_unwrapped(m=None, n=None, ax=None, show_legend=True, **kwargs)

plots the phase of a scattering parameter of indecies m, n in unwrapped radians

takes:

m - first index, int n - second indext, int ax - matplotlib.axes object to plot on, used in case you

want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_s_smith(m=None, n=None, r=1, ax=None, show_legend=True, **kwargs)

plots the scattering parameter of indecies m, n on smith chart

takes:

m - first index, int n - second indext, int r - radius of smith chart ax - matplotlib.axes object to plot on, used in case you

want to update an existing plot.

show_legend: boolean, to turn legend show legend of not **kwargs - passed to the matplotlib.plot command

plot_vs_frequency_generic(attribute, y_label=None, m=None, n=None, ax=None, show_legend=True, **kwargs)

generic plotting function for plotting a Network’s attribute vs frequency.

takes:

read_touchstone(filename)

loads values from a touchstone file.

takes:
filename - touchstone file name, string.
note:
ONLY ‘S’ FORMAT SUPORTED AT THE MOMENT all work is tone in the touchstone class.
s

The scattering parameter matrix.

s-matrix has shape fxnxn, where;

f is frequency axis and, n’s are port indicies
s11
s12
s21
s22
s_db

returns the magnitude of the s-parameters, in dB

note:
dB is calculated by
20*log10(|s|)
s_deg

returns the phase of the s-parameters, in radians

s_deg_unwrap

returns the unwrapped phase of the s-paramerts, in degrees

s_mag

returns the magnitude of the s-parameters.

s_rad

returns the phase of the s-parameters, in radians.

s_rad_unwrap

returns the unwrapped phase of the s-parameters, in radians.

t

returns the t-parameters, which are also known as wave cascading matrix.

write_touchstone(filename=None, dir='./')

write a touchstone file representing this network. the only format supported at the moment is :

HZ S RI
takes:
filename: a string containing filename without
extension[None]. if ‘None’, then will use the network’s name. if this is empty, then throws an error.
dir: the directory to save the file in. [string]. Defaults
to ‘./’
note:
in the future could make possible use of the touchtone class, but at the moment this would not provide any benefit as it has not set_ functions.
y
z0

the characteristic impedance of the network.

z0 can be may be a number, or numpy.ndarray of shape n or fxn.

Previous topic

touchstone

Next topic

WorkingBand

This Page