| |
- __builtin__.object
-
- Network
class Network(__builtin__.object) |
|
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 two 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. |
|
Methods defined here:
- __add__(self, other)
- element-wise addition of s-matrix
- __div__(self, other)
- element-wise complex division of s-matrix
- __eq__(self, other)
- __floordiv__(self, other)
- implements de-embeding another network[s], from this network
see de_embed
- __getitem__(self, key)
- returns a Network object at a given single frequency
- __init__(self, touchstone_file=None, name=None)
- constructor.
takes:
file: if given will load information from touchstone file
name: name of this network.
- __mul__(self, a)
- element-wise complex multiplication of s-matrix
- __ne__(self, other)
- __pow__(self, other)
- implements cascading this network with another network
- __sub__(self, other)
- element-wise subtraction of s-matrix
- add_noise_polar(self, 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(self, new_frequency, **kwargs)
- flip(self)
- swaps the ports of a two port
- interpolate(self, 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.
- multiply_noise(self, 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(self, amount=9.9999999999999998e-13)
- perturb s-parameters by small amount. this is usefule to work-around
numerical bugs.
takes:
amount: amount to add to s parameters
returns:
na
- plot_polar_generic(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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(self, 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.
- write_touchstone(self, filename=None)
- write a touchstone file representing this network. the only
format supported at the moment is :
HZ S RI
takes:
filename - filename (not including extension)
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.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- f
- the frequency vector for the network, in Hz.
- frequency
- returns a Frequency object, see frequency.py
- inv
- a network representing inverse s-parameters, for de-embeding
- number_of_ports
- the number of ports the network has.
- passivity
- returns passivity metric for a multi-port network. mathmatically,
this is a test for unitary-ness.
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
http://en.wikipedia.org/wiki/Scattering_parameters#Lossless_networks
- s
- The scattering parameter matrix.
s-matrix has shape fxmxn,
where;
f is frequency axis and,
m and n 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.
- y
- z0
- the characteristic impedance of the network.
| |