### Navigation

- index
- modules |
- next |
- previous |
- mwavepy v1.4 documentation »
- mwavepy API »

# mwavepy Package

## `mwavepy` Package

mwavepy is an object-oriented approach to microwave engineering, implemented in the Python programming language. It provides a set of objects and features which can be used to build powerful solutions to specific problems. mwavepy’s abilities are; touchstone file manipulation, calibration, VNA data acquisition, circuit design and much more.

This is the main module file for mwavepy. it simply imports classes and methods. It does this in two ways; import all into the current namespace, and import modules themselves for coherent structured referencing

## `convenience` Module

Holds pre-initialized class’s to provide convenience. Also provides some functions, which cant be categorized as anything better than general conviniencies.

> Pre-initialized classes include:
>   Frequency Objects for standard frequency bands Media objects for standard waveguide bands,

`mwavepy.convenience.``find_nearest`(array, value)

  find nearest value in array. taken from http://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array

`mwavepy.convenience.``find_nearest_index`(array, value)

  find nearest value in array. taken from http://stackoverflow.com/questions/2566412/find-nearest-value-in-numpy-array

`mwavepy.convenience.``legend_off`(ax=None)

  turn off the legend for a given axes. if no axes is given then it will use current axes.

`mwavepy.convenience.``now_string`()

`mwavepy.convenience.``plot_complex`(z, *args, **kwargs)

  plots a complex array or list in real vs imaginary.

`mwavepy.convenience.``save_all_figs`(dir='./', format=[, 'eps', 'pdf', 'png'])

## `frequency` Module

Provides the Frequency class, and related functions

class `mwavepy.frequency.``Frequency`(start, stop, npoints, unit='hz', sweep_type='lin')

  Bases: `object`

  represents a frequency band.

  attributes:

    start: starting frequency (in Hz) stop: stoping frequency (in Hz) npoints: number of points, an int unit: unit which to scale a formated axis, when accesssed. see

    > formattedAxis

  frequently many calcluations are made in a given band , so this class is used in other classes so user doesnt have to continually supply frequency info.

  `center`
  `f`

    returns a frequency vector in Hz

  `f_scaled`

    returns a frequency vector in units of self.unit

  classmethod `from_f`(f, *args, **kwargs)

    alternative constructor from a frequency vector, takes:

    > f: frequency array (default in Hz)

    returns:
      mwavepy.Frequency object
  `labelXAxis`(ax=None)
  `multiplier`

    multiplier for formating axis

  `unit`

    The unit to format the frequency axis in. see formatedAxis

  `w`

    angular frequency in radians

`mwavepy.frequency.``f_2_frequency`(f)

  convienience function converts a frequency vector to a Frequency object

  !depricated, use classmethod from_f instead.

## `mathFunctions` Module

Provides commonly used math functions.

`mwavepy.mathFunctions.``complex2MagPhase`(complx, deg=False)

`mwavepy.mathFunctions.``complex2ReIm`(complx)

`mwavepy.mathFunctions.``complex2Scalar`(input)

`mwavepy.mathFunctions.``complex2dB`(complx)

`mwavepy.mathFunctions.``complex_2_db`(input)

  returns the magnitude in dB of a complex number.

  returns:
    20*log10(|z|)

  where z is a complex number

`mwavepy.mathFunctions.``complex_2_degree`(input)

  returns the angle complex number in radians.

`mwavepy.mathFunctions.``complex_2_magnitude`(input)

  returns the magnitude of a complex number.

`mwavepy.mathFunctions.``complex_2_quadrature`(z)

  takes a complex number and returns quadrature, which is (length, arc-length from real axis)

`mwavepy.mathFunctions.``complex_2_radian`(input)

  returns the angle complex number in radians.

`mwavepy.mathFunctions.``complex_components`(z)

  break up a complex array into all possible scalar components

  takes: complex ndarray return:

  > c_real: real part c_imag: imaginary part c_angle: angle in degrees c_mag: magnitude c_arc: arclength from real axis, angle*magnitude

`mwavepy.mathFunctions.``db_2_magnitude`(input)

  converts db to normal magnitude

  returns:
    10**((z)/20.)

  where z is a complex number

`mwavepy.mathFunctions.``db_2_np`(x)

  converts a value in nepers to dB

`mwavepy.mathFunctions.``degree_2_radian`(deg)

`mwavepy.mathFunctions.``dirac_delta`(x)

  the dirac function.

  can take numpy arrays or numbers returns 1 or 0

`mwavepy.mathFunctions.``magnitude_2_db`(input)

  converts magnitude to db

  > db is given by
  >   20*log10(|z|)

  where z is a complex number

`mwavepy.mathFunctions.``neuman`(x)

  neumans number

  2-dirac_delta(x)

`mwavepy.mathFunctions.``np_2_db`(x)

  converts a value in dB to neper’s

`mwavepy.mathFunctions.``null`(A, eps=1e-15)

  > calculates the null space of matrix A.

  i found this on stack overflow.

`mwavepy.mathFunctions.``psd2TimeDomain`(f, y, windowType='hamming')

  convert a one sided complex spectrum into a real time-signal. takes

  > f: frequency array, y: complex PSD arary windowType: windowing function, defaults to rect

  returns in the form:
    [timeVector, signalVector]

  timeVector is in inverse units of the input variable f, if spectrum is not baseband then, timeSignal is modulated by

  > exp(t*2*pi*f[0])

  so keep in mind units, also due to this f must be increasing left to right

`mwavepy.mathFunctions.``radian_2_degree`(rad)

`mwavepy.mathFunctions.``scalar2Complex`(input)

## `network` Module

Provides the Network class and related functions.

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

  Bases: `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 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
  `add_noise_polar_flatband`(mag_dev, phase_dev, **kwargs)

    adds a flatband 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_passivity`(port=None, ax=None, show_legend=True, *args, **kwargs)

    plots the passivity of a network, possible for a specific port. see the property ‘passivity’ for more information.

    takes:

      port: list of ports[ints] to plot passivity for [None] 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 *args,**kwargs - passed to the matplotlib.plot command

  `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, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_complex`(m=None, n=None, ax=None, show_legend=True, *args, **kwargs)

    plots the scattering parameter of indecies m, n on complex plane

    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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_db`(m=None, n=None, ax=None, show_legend=True, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_deg`(m=None, n=None, ax=None, show_legend=True, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_deg_unwrap`(m=None, n=None, ax=None, show_legend=True, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_deg_unwrapped`(m=None, n=None, ax=None, show_legend=True, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_im`(m=None, n=None, ax=None, show_legend=True, *args, **kwargs)

    plots the imaginary part of a scattering parameter of indecies m, n

    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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_mag`(m=None, n=None, ax=None, show_legend=True, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_polar`(m=0, n=0, ax=None, show_legend=True, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_rad`(m=None, n=None, ax=None, show_legend=True, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_rad_unwrapped`(m=None, n=None, ax=None, show_legend=True, *args, **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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_re`(m=None, n=None, ax=None, show_legend=True, *args, **kwargs)

    plots the real part of a scattering parameter of indecies m, n

    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 *args,**kwargs - passed to the matplotlib.plot command

  `plot_s_smith`(m=None, n=None, r=1, ax=None, show_legend=True, chart_type='z', *args, **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 chart_type: string determining countour type. options are:

      > ‘z’: impedance contours (default) ‘y’: admittance contours

      *args,**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_im`

    returns the imaginary part of the s-parameters.

  `s_mag`

    returns the magnitude of the s-parameters.

  `s_quad`

    this is like a arc-length, its s_quad = s_rad * s_mag

    used in calculating differences in phase, but in units of distance

  `s_rad`

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

  `s_rad_unwrap`

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

  `s_re`

    returns the real part of the s-parameters.

  `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.

`mwavepy.network.``average`(list_of_networks)

  calculates the average network from a list of Networks. this is complex average of the s-parameters for a list of Networks

  takes:
    list_of_networks: a list of Networks
  returns:
    ntwk: the resultant averaged Network [mwavepy.Network]

`mwavepy.network.``cascade`(a, b)

  DEPRECATED. see connect_s() instead.

  cascade two s-matricies together.

  a’s port 2 == b’s port 1

  if you want a different port configuration use the flip() fuction takes:

  > a: a 2x2 or kx2x2 s-matrix b: a 2x2, kx2x2, 1x1, or kx1x1 s-matrix

  note:
    BE AWARE! this relies on s2t function which has a inf problem if s11 or s22 is 1.

`mwavepy.network.``connect`(ntwkA, k, ntwkB, l)

  connect two n-port networks together. specifically, connect port ‘k’ on ntwkA to port ‘l’ on ntwkB. The resultant network has (ntwkA.nports+ntwkB.nports -2) ports. The port index’s (‘k’,’l’) start from 0. Port impedances are taken into account.

  takes:
    ntwkA: network ‘A’, [mwavepy.Network] k: port index on ntwkA [int] ( port indecies start from 0 ) ntwkB: network ‘B’, [mwavepy.Network] l: port index on ntwkB [int]
  returns:
    ntwkC’: new network of rank (ntwkA.nports+ntwkB.nports -2)-ports
  note:
    see functions connect_s() and innerconnect_s() for actual

  S-parameter connection algorithm.

  > the effect of mis-matched port impedances is handled by inserting

  a 2-port ‘mismatch’ network between the two connected ports.

`mwavepy.network.``connect_s`(S, k, T, l)

  connect two n-port networks together. specifically, connect port ‘k’ on network ‘S’ to port ‘l’ on network ‘T’. The resultant network has (S.rank + T.rank-2)-ports

  takes:
    S: S-parameter matrix [numpy.ndarray]. k: port index on S (port indecies start from 0) [int] T: S-parameter matrix [numpy.ndarray] l: port index on T [int]
  returns:
    S’: new S-parameter matrix [numpy.ndarry]
  note:
    shape of S-parameter matrices can be either nxn, or fxnxn, where
  f is the frequency axis.
    internally, this function creates a larger composite network

  and calls the innerconnect() function. see that function for more details about the implementation

`mwavepy.network.``csv_2_touchstone`(filename)

  converts a csv file saved from a Rhode swarz and possibly other

  takes:
    filename: name of file
  returns:
    Network object

`mwavepy.network.``de_embed`(a, b)

  de-embed a 2x2 s-matrix from another 2x2 s-matrix

  c = b**-1 * a

  note:
    BE AWARE! this relies on s2t function which has a inf problem if s11 or s22 is 1.

`mwavepy.network.``flip`(a)

  invert the ports of a networks s-matrix, ‘flipping’ it over

  note:
    only works for 2-ports at the moment

`mwavepy.network.``fon`(ntwk_list, func, attribute='s', *args, **kwargs)

  Applies a function to some attribute of aa list of networks, and returns the result in the form of a Network. This means information that may not be s-parameters is stored in the s-matrix of the returned Network.

  takes:
    ntwk_list: list of mwavepy.Network types func: function to operate on ntwk_list s-matrices attribute: attribute of Network’s in ntwk_list for func to act on *args: passed to func **kwargs: passed to func
  returns:
    mwavepy.Network type, with s-matrix the result of func,
      operating on ntwk_list’s s-matrices
  example:
    averaging can be implemented with func_on_networks by
      func_on_networks(ntwk_list,mean)

`mwavepy.network.``func_on_networks`(ntwk_list, func, attribute='s', *args, **kwargs)

  Applies a function to some attribute of aa list of networks, and returns the result in the form of a Network. This means information that may not be s-parameters is stored in the s-matrix of the returned Network.

  takes:
    ntwk_list: list of mwavepy.Network types func: function to operate on ntwk_list s-matrices attribute: attribute of Network’s in ntwk_list for func to act on *args: passed to func **kwargs: passed to func
  returns:
    mwavepy.Network type, with s-matrix the result of func,
      operating on ntwk_list’s s-matrices
  example:
    averaging can be implemented with func_on_networks by
      func_on_networks(ntwk_list,mean)

`mwavepy.network.``impedance_mismatch`(z1, z2)

  returns a two-port network for a impedance mis-match

  takes:
    z1: complex impedance of port 1 [ number, list, or 1D ndarray] z2: complex impedance of port 2 [ number, list, or 1D ndarray]
  returns:
    2-port s-matrix for the impedance mis-match

`mwavepy.network.``innerconnect`(ntwkA, k, l)

  connect two ports of a single n-port network, resulting in a (n-2)-port network. port indecies start from 0.

  takes:
    ntwk: the network. [mwavepy.Network] k: port index [int] (port indecies start from 0) l: port index [int]
  returns:
    ntwk’: new network of with n-2 ports. [mwavepy.Network]
  note:
    see functions connect_s() and innerconnect_s() for actual

  S-parameter connection algorithm.

`mwavepy.network.``innerconnect_s`(S, k, l)

  connect two ports of a single n-port network, resulting in a (n-2)-port network.

  takes:
    S: S-parameter matrix [numpy.ndarray] k: port index [int] l: port index [int]
  returns:
    S’: new S-parameter matrix [numpy.ndarry]
  This function is based on the algorithm presented in the paper:
    ‘Perspectives in Microwave Circuit Analysis’ by R. C. Compton
      and D. B. Rutledge
  The original algorithm is given in
    ‘A NEW GENERAL COMPUTER ALGORITHM FOR S-MATRIX CALCULATION OF INTERCONNECTED MULTIPORTS’ by Gunnar Filipsson

`mwavepy.network.``inv`(s)

  inverse s-parameters, used for de-embeding

`mwavepy.network.``load_all_touchstones`(dir='.', contains=None, f_unit=None)

  loads all touchtone files in a given dir

  takes:

    dir - the path to the dir, passed as a string (defalut is cwd) contains - string which filename must contain to be loaded, not

    > used if None.(default None)

  returns:
    ntwkDict - a Dictonary with keys equal to the file name (without
      a suffix), and values equal to the corresponding ntwk types

`mwavepy.network.``one_port_2_two_port`(ntwk)

  calculates the two-port network given a symetric, reciprocal and lossless one-port network.

  takes:
    ntwk: a symetric, reciprocal and lossless one-port network.
  returns:
    ntwk: the resultant two-port Network

`mwavepy.network.``plot_uncertainty_bounds`(ntwk_list, attribute='s_mag', m=0, n=0, n_deviations=3, alpha=0.3, fill_color='b', std_attribute=None, *args, **kwargs)

  plots mean value with +- uncertainty bounds in an Network attribute, for a list of Networks.

  takes:
    ntwk_list: list of Netmwork types [list] attribute: attribute of Network type to analyze [string] m: first index of attribute matrix [int] n: second index of attribute matrix [int] n_deviations: number of std deviations to plot as bounds [number] alpha: passed to matplotlib.fill_between() command. [number, 0-1] *args,**kwargs: passed to Network.plot_‘attribute’ command
  returns:
    None
  Caution:

    > if your list_of_networks is for a calibrated short, then the

    std dev of deg_unwrap might blow up, because even though each network is unwrapped, they may fall on either side fo the pi relative to one another.

`mwavepy.network.``plot_uncertainty_bounds_s_db`(ntwk_list, attribute='s_mag', m=0, n=0, n_deviations=3, alpha=0.3, fill_color='b', *args, **kwargs)

  plots mean value with +- uncertainty bounds in an Network’s attribute for a list of Networks.

  This is plotted on a log scale (db), but uncertainty is calculated in the linear domain

  takes:
    ntwk_list: list of Netmwork types [list] attribute: attribute of Network type to analyze [string] m: first index of attribute matrix [int] n: second index of attribute matrix [int] n_deviations: number of std deviations to plot as bounds [number] alpha: passed to matplotlib.fill_between() command. [number, 0-1] *args,**kwargs: passed to Network.plot_‘attribute’ command
  returns:
    None
  Caution:

    > if your list_of_networks is for a calibrated short, then the

    std dev of deg_unwrap might blow up, because even though each network is unwrapped, they may fall on either side fo the pi relative to one another.

`mwavepy.network.``plot_uncertainty_bounds_s_deg`(*args, **kwargs)
  this just calls
    plot_uncertainty_bounds(attribute= ‘s_deg_unwrap’,*args,**kwargs)

  see plot_uncertainty_bounds for help

  note; the attribute ‘s_deg_unwrap’ is called on purpose to alleviate the phase wraping effects on std dev. if you DO want to look at ‘s_deg’ and not ‘s_deg_unwrap’ then use plot_uncertainty_bounds

`mwavepy.network.``plot_uncertainty_bounds_s_im`(*args, **kwargs)
  this just calls
    plot_uncertainty_bounds(attribute= ‘s_im’,*args,**kwargs)

  see plot_uncertainty_bounds for help

`mwavepy.network.``plot_uncertainty_bounds_s_mag`(*args, **kwargs)
  this just calls
    plot_uncertainty_bounds(attribute= ‘s_mag’,*args,**kwargs)

  see plot_uncertainty_bounds for help

`mwavepy.network.``plot_uncertainty_bounds_s_re`(*args, **kwargs)
  this just calls
    plot_uncertainty_bounds(attribute= ‘s_re’,*args,**kwargs)

  see plot_uncertainty_bounds for help

`mwavepy.network.``s2t`(s)

  converts a scattering parameters to ‘wave cascading parameters’

  input matrix shape should be should be 2x2, or kx2x2

  BUG: if s -matrix has ones for reflection, thsi will produce inf’s you cant cascade a matrix like this anyway, but we should handle it better

`mwavepy.network.``t2s`(t)

  converts a ‘wave cascading parameters’ to scattering parameters

  input matrix shape should be should be 2x2, or kx2x2

`mwavepy.network.``two_port_reflect`(ntwk1, ntwk2, **kwargs)
  generates a two-port reflective (S21=S12=0) network, from the
    2 one-port networks
  takes:
    ntwk1: Network on port 1 [mwavepy.Network] ntwk2: Network on port 2 [mwavepy.Network]
  returns:
    result: two-port reflective network, S12=S21=0 [mwavepy.Network]

  example: to use a working band to create a two-port reflective standard from two one-port standards

  > my_media= ... two_port_reflect(my_media.short(), my_media.match())

`mwavepy.network.``write_dict_of_networks`(ntwkDict, dir='.')

  writes a dictionary of networks to a given directory

## `plotting` Module

provides plotting functions, which dont belong to any class.

`mwavepy.plotting.``smith`(smithR=1, chart_type='z', ax=None)

  plots the smith chart of a given radius takes:

  > smithR - radius of smith chart chart_type: string representing contour type: acceptable values are

  > > ‘z’: lines of constant impedance ‘y’: lines of constant admittance

  > ax - matplotlib.axes instance

## `tlineFunctions` Module

transmission line theory related functions

`mwavepy.tlineFunctions.``Gamma0_2_Gamma_in`(Gamma0, theta)

  reflection coefficient at electrical length theta takes:

  > Gamma0: reflection coefficient at theta=0 theta: electrical length, (may be complex)

  returns:
    Gamma_in
  note:
    = Gamma0 * exp(-2j* theta)

`mwavepy.tlineFunctions.``Gamma0_2_zin`(z0, Gamma0, theta)

  calculates the input impedance at electrical length theta, given a reflection coefficient and characterisitc impedance of the medium takes:

  > z0 - characteristic impedance. Gamma: reflection coefficient theta: electrical length of the line, (may be complex)

  returns
    zin: input impedance at theta

`mwavepy.tlineFunctions.``Gamma0_2_zl`(z0, Gamma)

  calculates the input impedance given a reflection coefficient and characterisitc impedance of the medium takes:

  > Gamma: reflection coefficient z0 - characteristic impedance.

`mwavepy.tlineFunctions.``distance_2_electrical_length`(gamma, f, d, deg=False)

  calculates the electrical length of a section of transmission line.

  takes:
    gamma: propagation constant function [function],
      (a function which takes frequency in hz )

    l: length of line. in meters f: frequency at which to calculate. [array-like or float]. deg: return in degrees or not. [boolean].

  returns:
    theta: electrical length in radians or degrees,
      depending on value of deg.

`mwavepy.tlineFunctions.``distributed_circuit_2_propagation_impedance`(distributed_admittance, distributed_impedance)

  converts complex distributed impedance and admittance to propagation constant and characteristic impedance.

  takes:
    distributed_admittance: what it says [complex number or array] distributed_impedance: what it says [complex number or array]
  returns:
    propagation_constant: what it says [complex number or array] characteristic_impedance: what it says [complex number or array]

`mwavepy.tlineFunctions.``electrical_length`(gamma, f, d, deg=False)

  calculates the electrical length of a section of transmission line.

  takes:
    gamma: propagation constant function [function],
      (a function which takes frequency in hz )

    l: length of line. in meters f: frequency at which to calculate. [array-like or float]. deg: return in degrees or not. [boolean].

  returns:
    theta: electrical length in radians or degrees,
      depending on value of deg.

`mwavepy.tlineFunctions.``electrical_length_2_distance`(theta, gamma, f0, deg=True)

  convert electrical length to a physical distance.

  takes:
    theta: electrical length gamma: propagation constant function [function] f0: frequency of interest [number] deg: is theta in degrees [Boolean]
  returns:
    d: physical distance

  note: the gamma function must take a single variable, that is frequency and return complex propagation constant such that the propagating part is positive imag part.

`mwavepy.tlineFunctions.``input_impedance_2_reflection_coefficient`(z0, zl)

  calculates the reflection coefficient for a given input impedance takes:

  > zl: input (load) impedance [number of array]. z0 - characteristic impedance[number of array].

  note:
    input data is typecasted to 1D complex array

`mwavepy.tlineFunctions.``input_impedance_2_reflection_coefficient_at_theta`(z0, zl, theta)

`mwavepy.tlineFunctions.``input_impedance_at_theta`(z0, zl, theta)

  input impedance of load impedance zl at electrical length theta, given characteristic impedance z0.

  takes:
    z0 - characteristic impedance. zl: load impedance theta: electrical length of the line, (may be complex)

`mwavepy.tlineFunctions.``propagation_impedance_2_distributed_circuit`(propagation_constant, characteristic_impedance)

  converts complex propagation constant and characteristic impedance to distributed impedance and admittance.

  takes:
    propagation_constant: what it says [complex number or array] characteristic_impedance: what it says [complex number or array]
  returns:
    distributed_admittance: what it says [complex number or array] distributed_impedance: what it says [complex number or array]

`mwavepy.tlineFunctions.``reflection_coefficient_2_input_impedance`(z0, Gamma)

  calculates the input impedance given a reflection coefficient and characterisitc impedance of the medium takes:

  > Gamma: reflection coefficient z0 - characteristic impedance.

`mwavepy.tlineFunctions.``reflection_coefficient_2_input_impedance_at_theta`(z0, Gamma0, theta)

  calculates the input impedance at electrical length theta, given a reflection coefficient and characterisitc impedance of the medium takes:

  > z0 - characteristic impedance. Gamma: reflection coefficient theta: electrical length of the line, (may be complex)

  returns
    zin: input impedance at theta

`mwavepy.tlineFunctions.``reflection_coefficient_at_theta`(Gamma0, theta)

  reflection coefficient at electrical length theta takes:

  > Gamma0: reflection coefficient at theta=0 theta: electrical length, (may be complex)

  returns:
    Gamma_in
  note:
    = Gamma0 * exp(-2j* theta)

`mwavepy.tlineFunctions.``skin_depth`(f, rho, mu_r)

  the skin depth for a material. see www.microwaves101.com for more info.

  takes:
    f: frequency, in Hz rho: bulk resistivity of material, in ohm*m mu_r: relative permiability of material
  returns:
    skin depth: in m

`mwavepy.tlineFunctions.``surface_resistivity`(f, rho, mu_r)

  surface resistivity. see www.microwaves101.com for more info.

  takes:
    f: frequency, in Hz rho: bulk resistivity of material, in ohm*m mu_r: relative permiability of material
  returns:
    surface resistivity: ohms/square

`mwavepy.tlineFunctions.``theta`(gamma, f, d, deg=False)

  calculates the electrical length of a section of transmission line.

  takes:
    gamma: propagation constant function [function],
      (a function which takes frequency in hz )

    l: length of line. in meters f: frequency at which to calculate. [array-like or float]. deg: return in degrees or not. [boolean].

  returns:
    theta: electrical length in radians or degrees,
      depending on value of deg.

`mwavepy.tlineFunctions.``zl_2_Gamma0`(z0, zl)

  calculates the reflection coefficient for a given input impedance takes:

  > zl: input (load) impedance [number of array]. z0 - characteristic impedance[number of array].

  note:
    input data is typecasted to 1D complex array

`mwavepy.tlineFunctions.``zl_2_Gamma_in`(z0, zl, theta)

`mwavepy.tlineFunctions.``zl_2_zin`(z0, zl, theta)

  input impedance of load impedance zl at electrical length theta, given characteristic impedance z0.

  takes:
    z0 - characteristic impedance. zl: load impedance theta: electrical length of the line, (may be complex)

## `touchstone` Module

contains touchstone class ( written by Werner Hoch )

class `mwavepy.touchstone.``touchstone`(filename)

  class to read touchstone s-parameter files The reference for writing this class is the draft of the Touchstone(R) File Format Specification Rev 2.0 http://www.eda-stds.org/ibis/adhoc/interconnect/touchstone_spec2_draft.pdf

  `get_format`(format='ri')

    returns the file format string used for the given format. This is usefull to get some informations.

  `get_noise_data`()

    TODO: NIY

  `get_noise_names`()

    TODO: NIY

  `get_sparameter_arrays`()

    returns the sparameters as a tuple of arrays, where the first element is the frequency vector (in Hz) and the s-parameters are a 3d numpy array. The values of the sparameters are complex number. usage:

    > f,a = self.sgetparameter_arrays() s11 = a[:,0,0]

  `get_sparameter_data`(format='ri')

    get the data of the sparameter with the given format. supported formats are:

    > orig: unmodified s-parameter data ri: data in real/imaginary ma: data in magnitude and angle (degree) db: data in log magnitute and angle (degree)

    Returns a list of numpy.arrays

  `get_sparameter_names`(format='ri')

    generate a list of column names for the s-parameter data The names are different for each format. posible format parameters:

    > ri, ma, db, orig (where orig refers to one of the three others)

    returns a list of strings.

  `load_file`(filename)

    Load the touchstone file into the interal data structures

## Subpackages

- media Package
  - `media` Package
  - `cpw` Module
  - `distributedCircuit` Module
  - `freespace` Module
  - `media` Module
  - `rectangularWaveguide` Module
- calibration Package
  - `calibration` Package
  - `calibration` Module
  - `calibrationAlgorithms` Module
  - Subpackages
    - parametricStandard Package
      - `parametricStandard` Package
      - `generic` Module
      - `parametricStandard` Module
      - `rectangularWaveguide` Module
- virtualInstruments Package
  - `virtualInstruments` Package
  - `futekLoadCell` Module
  - `generalSocketReader` Module
  - `lifetimeProbeTester` Module
  - `lifetimeProbeTesterFunctions` Module
  - `stages` Module
  - `vna` Module

### Navigation

- index
- modules |
- next |
- previous |
- mwavepy v1.4 documentation »
- mwavepy API »