# Time Domain and Gating¶

## Intro¶

This notebooks demonstrates how to use scikit-rf for time-domain analysis and gating. A quick example is given first, followed by a more detailed explanation.

S-parameters are measured in the frequency domain, but can be analyzed in time domain if you like. In many cases, measurements are not made down to DC. This implies that the time-domain transform is not complete, but it can be very useful non-theless. A major application of time-domain analysis is to use gating to isolation a single response in space. More information about the details of time domain analysis see [1].

References

• [1] Agilent Time Domain Analysis Using a Network Analyzer (Application Note 1287-12) pdf

## Quick Example¶

In [1]:

import skrf as rf
%matplotlib inline
rf.stylely()
from pylab import *

# load data for the waveguide to CPW probe
probe = rf.Network('../metrology/oneport_tiered_calibration/probe.s2p')

# we will focus on s11
s11 = probe.s11

#  time-gate the first largest reflection
s11_gated = s11.time_gate(center=0, span=.2)
s11_gated.name='gated probe'

# plot frequency and time-domain s-parameters
figure(figsize=(8,4))
subplot(121)
s11.plot_s_db()
s11_gated.plot_s_db()
title('Frequency Domain')

subplot(122)
s11.plot_s_db_time()
s11_gated.plot_s_db_time()
title('Time Domain')
tight_layout()

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-c9d19515abc4> in <module>()
22
23 subplot(122)
---> 24 s11.plot_s_db_time()
25 s11_gated.plot_s_db_time()
26 title('Time Domain')

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_s_db_time(self, *args, **kwargs)
1246
1247 def plot_s_db_time(self,*args,**kwargs):
-> 1248     return self.windowed().plot_s_time_db(*args,**kwargs)
1249
1250

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_func(self, m, n, ax, show_legend, attribute, y_label, pad, window, z0, *args, **kwargs)
1055                                              y_label=y_label,
1056                                              show_legend=show_legend, ax=ax,
-> 1057                                              *args, **kwargs)
1058                 #if was_interactive:
1059                 #    plb.interactive(True)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_rectangular(x, y, x_label, y_label, title, show_legend, axis, ax, *args, **kwargs)
305         ax = plb.gca()
306
--> 307     my_plot = ax.plot(x, y, *args, **kwargs)
308
309     if x_label is not None:

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1843                         "the Matplotlib list!)" % (label_namer, func.__name__),
1844                         RuntimeWarning, stacklevel=2)
-> 1845             return func(ax, *args, **kwargs)
1846
1847         inner.__doc__ = _add_data_doc(inner.__doc__,

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_axes.py in plot(self, *args, **kwargs)
1523         kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
1524
-> 1525         for line in self._get_lines(*args, **kwargs):
1527             lines.append(line)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
404                 this += args[0],
405                 args = args[1:]
--> 406             for seg in self._plot_args(this, kwargs):
407                 yield seg
408

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
381             x, y = index_of(tup[-1])
382
--> 383         x, y = self._xy_from_xy(x, y)
384
385         if self.command == 'plot':

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
240         if x.shape[0] != y.shape[0]:
241             raise ValueError("x and y must have same first dimension, but "
--> 242                              "have shapes {} and {}".format(x.shape, y.shape))
243         if x.ndim > 2 or y.ndim > 2:
244             raise ValueError("x and y can be no greater than 2-D, but have "

ValueError: x and y must have same first dimension, but have shapes (401,) and (800,)


## Interpreting Time Domain¶

Out DUT in this example is a waveguide-to-CPW probe, that was measured in this other example.

In [2]:

# load data for the waveguide to CPW probe
probe = rf.Network('../metrology/oneport_tiered_calibration/probe.s2p')
probe

Out[2]:

2-Port Network: 'probe',  500.0-750.0 GHz, 401 pts, z0=[50.+0.j 50.+0.j]

Note there are two time-domain plotting functions in scikit-rf: * Network.plot_s_db_time()
* Network.plot_s_time_db()

The difference is that the former, plot_s_db_time(), employs windowing before plotting to enhance impluse resolution. Windowing will be discussed in a bit, but for now we just use plot_s_db_time().

Plotting all four s-parameters of the probe in both frequency and time-domain.

In [3]:

# plot frequency and time-domain s-parameters
figure(figsize=(8,4))
subplot(121)
probe.plot_s_db()
title('Frequency Domain')
subplot(122)
probe.plot_s_db_time()
title('Time Domain')
tight_layout()

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-df61fab04dec> in <module>()
5 title('Frequency Domain')
6 subplot(122)
----> 7 probe.plot_s_db_time()
8 title('Time Domain')
9 tight_layout()

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_s_db_time(self, *args, **kwargs)
1246
1247 def plot_s_db_time(self,*args,**kwargs):
-> 1248     return self.windowed().plot_s_time_db(*args,**kwargs)
1249
1250

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_func(self, m, n, ax, show_legend, attribute, y_label, pad, window, z0, *args, **kwargs)
1055                                              y_label=y_label,
1056                                              show_legend=show_legend, ax=ax,
-> 1057                                              *args, **kwargs)
1058                 #if was_interactive:
1059                 #    plb.interactive(True)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_rectangular(x, y, x_label, y_label, title, show_legend, axis, ax, *args, **kwargs)
305         ax = plb.gca()
306
--> 307     my_plot = ax.plot(x, y, *args, **kwargs)
308
309     if x_label is not None:

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1843                         "the Matplotlib list!)" % (label_namer, func.__name__),
1844                         RuntimeWarning, stacklevel=2)
-> 1845             return func(ax, *args, **kwargs)
1846
1847         inner.__doc__ = _add_data_doc(inner.__doc__,

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_axes.py in plot(self, *args, **kwargs)
1523         kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
1524
-> 1525         for line in self._get_lines(*args, **kwargs):
1527             lines.append(line)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
404                 this += args[0],
405                 args = args[1:]
--> 406             for seg in self._plot_args(this, kwargs):
407                 yield seg
408

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
381             x, y = index_of(tup[-1])
382
--> 383         x, y = self._xy_from_xy(x, y)
384
385         if self.command == 'plot':

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
240         if x.shape[0] != y.shape[0]:
241             raise ValueError("x and y must have same first dimension, but "
--> 242                              "have shapes {} and {}".format(x.shape, y.shape))
243         if x.ndim > 2 or y.ndim > 2:
244             raise ValueError("x and y can be no greater than 2-D, but have "

ValueError: x and y must have same first dimension, but have shapes (401,) and (800,)


Focusing on the reflection coefficient from the waveguide port (s11), you can see there is an interference pattern present.

In [4]:

probe.plot_s_db(0,0)
title('Reflection Coefficient From \nWaveguide Port')

Out[4]:

Text(0.5,1,'Reflection Coefficient From \nWaveguide Port')


This ripple is evidence of several discrete reflections. Plotting s11 in the time-domain allows us to see where, or when, these reflections occur.

In [5]:

probe_s11 = probe.s11
probe_s11.plot_s_db_time(0,0)
title('Reflection Coefficient From \nWaveguide Port, Time Domain')
ylim(-100,0)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-7eb2390497a9> in <module>()
1 probe_s11 = probe.s11
----> 2 probe_s11.plot_s_db_time(0,0)
3 title('Reflection Coefficient From \nWaveguide Port, Time Domain')
4 ylim(-100,0)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_s_db_time(self, *args, **kwargs)
1246
1247 def plot_s_db_time(self,*args,**kwargs):
-> 1248     return self.windowed().plot_s_time_db(*args,**kwargs)
1249
1250

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_func(self, m, n, ax, show_legend, attribute, y_label, pad, window, z0, *args, **kwargs)
1055                                              y_label=y_label,
1056                                              show_legend=show_legend, ax=ax,
-> 1057                                              *args, **kwargs)
1058                 #if was_interactive:
1059                 #    plb.interactive(True)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_rectangular(x, y, x_label, y_label, title, show_legend, axis, ax, *args, **kwargs)
305         ax = plb.gca()
306
--> 307     my_plot = ax.plot(x, y, *args, **kwargs)
308
309     if x_label is not None:

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1843                         "the Matplotlib list!)" % (label_namer, func.__name__),
1844                         RuntimeWarning, stacklevel=2)
-> 1845             return func(ax, *args, **kwargs)
1846
1847         inner.__doc__ = _add_data_doc(inner.__doc__,

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_axes.py in plot(self, *args, **kwargs)
1523         kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
1524
-> 1525         for line in self._get_lines(*args, **kwargs):
1527             lines.append(line)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
404                 this += args[0],
405                 args = args[1:]
--> 406             for seg in self._plot_args(this, kwargs):
407                 yield seg
408

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
381             x, y = index_of(tup[-1])
382
--> 383         x, y = self._xy_from_xy(x, y)
384
385         if self.command == 'plot':

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
240         if x.shape[0] != y.shape[0]:
241             raise ValueError("x and y must have same first dimension, but "
--> 242                              "have shapes {} and {}".format(x.shape, y.shape))
243         if x.ndim > 2 or y.ndim > 2:
244             raise ValueError("x and y can be no greater than 2-D, but have "

ValueError: x and y must have same first dimension, but have shapes (401,) and (800,)


From this plot we can see two dominant reflections; * one at $$t=0$$ns (the test-port) * and another at $$t=.2$$ns (who knows?).

## Gating The Reflection of Interest¶

To isolate the reflection from the waveguide port, we can use time-gating. This can be done by using the method Network.time_gate(), and provide it an appropriate center and span (in ns). To see the effects of the gate, both the original and gated reponse are compared.

In [6]:

probe_s11_gated = probe_s11.time_gate(center=0, span=.2)
probe_s11_gated.name='gated probe'

s11.plot_s_db_time()
s11_gated.plot_s_db_time()

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-76763523a90e> in <module>()
2 probe_s11_gated.name='gated probe'
3
----> 4 s11.plot_s_db_time()
5 s11_gated.plot_s_db_time()

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_s_db_time(self, *args, **kwargs)
1246
1247 def plot_s_db_time(self,*args,**kwargs):
-> 1248     return self.windowed().plot_s_time_db(*args,**kwargs)
1249
1250

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_func(self, m, n, ax, show_legend, attribute, y_label, pad, window, z0, *args, **kwargs)
1055                                              y_label=y_label,
1056                                              show_legend=show_legend, ax=ax,
-> 1057                                              *args, **kwargs)
1058                 #if was_interactive:
1059                 #    plb.interactive(True)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_rectangular(x, y, x_label, y_label, title, show_legend, axis, ax, *args, **kwargs)
305         ax = plb.gca()
306
--> 307     my_plot = ax.plot(x, y, *args, **kwargs)
308
309     if x_label is not None:

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1843                         "the Matplotlib list!)" % (label_namer, func.__name__),
1844                         RuntimeWarning, stacklevel=2)
-> 1845             return func(ax, *args, **kwargs)
1846
1847         inner.__doc__ = _add_data_doc(inner.__doc__,

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_axes.py in plot(self, *args, **kwargs)
1523         kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
1524
-> 1525         for line in self._get_lines(*args, **kwargs):
1527             lines.append(line)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
404                 this += args[0],
405                 args = args[1:]
--> 406             for seg in self._plot_args(this, kwargs):
407                 yield seg
408

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
381             x, y = index_of(tup[-1])
382
--> 383         x, y = self._xy_from_xy(x, y)
384
385         if self.command == 'plot':

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
240         if x.shape[0] != y.shape[0]:
241             raise ValueError("x and y must have same first dimension, but "
--> 242                              "have shapes {} and {}".format(x.shape, y.shape))
243         if x.ndim > 2 or y.ndim > 2:
244             raise ValueError("x and y can be no greater than 2-D, but have "

ValueError: x and y must have same first dimension, but have shapes (401,) and (800,)


Next, compare both responses in frequency domain to see the effect of the gate.

In [7]:

s11.plot_s_db()
s11_gated.plot_s_db()


### Auto-gate¶

The time-gating method in skrf has an auto-gating feature which can also be used to gate the largest reflection. When no gate parameters are provided, time_gate() does the following: 1. find the two largest peaks * center the gate on the tallest peak * set span to distance between two tallest peaks

You may want to plot the gated network in time-domain to see what the determined gate shape looks like.

In [8]:

title('Waveguide Interface of Probe')
s11.plot_s_db(label='original')
s11.time_gate().plot_s_db(label='autogated') #autogate on the fly

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
1 title('Waveguide Interface of Probe')
2 s11.plot_s_db(label='original')
----> 3 s11.time_gate().plot_s_db(label='autogated') #autogate on the fly

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/network.py in time_gate(self, *args, **kw)
2338         see skrf.time_domain.time_gate
2339         '''
-> 2340         return time_gate(self, *args, **kw)
2341
2342

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/time.py in time_gate(ntwk, start, stop, center, span, mode, window, media, boundary, return_all)
241
242         if span is None:
--> 243             span = detect_span(ntwk)
244
245         center *= 1e-9

160     p1,p2 = find_n_peaks(x,n=2)
161     #distance to nearest neighbor peak
--> 162     span = abs(ntwk.frequency.t_ns[p1]-ntwk.frequency.t_ns[p2])
163     return span
164

IndexError: index 402 is out of bounds for axis 0 with size 401


Might see how the autogate does on the other proben interface,

In [9]:

title('Other Interface of Probe')
probe.s22.plot_s_db()
probe.s22.time_gate().plot_s_db()


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-9-5cf223b675e0> in <module>()
1 title('Other Interface of Probe')
2 probe.s22.plot_s_db()
----> 3 probe.s22.time_gate().plot_s_db()

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/network.py in time_gate(self, *args, **kw)
2338         see skrf.time_domain.time_gate
2339         '''
-> 2340         return time_gate(self, *args, **kw)
2341
2342

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/time.py in time_gate(ntwk, start, stop, center, span, mode, window, media, boundary, return_all)
238             # they didnt provide center, so find the peak
239             n = ntwk.s_time_mag.argmax()
--> 240             center = ntwk.frequency.t_ns[n]
241
242         if span is None:

IndexError: index 401 is out of bounds for axis 0 with size 401


## Determining Distance¶

To make time-domain useful as a diagnostic tool, one would like to convert the x-axis to distance. This requires knowledge of the propagation velocity in the device. skrf provides some transmission-line models in the module skrf.media, which can be used for this.

However…

For dispersive media, such as rectangular waveguide, the phase velocity is a function of frequency, and transforming time to distance is not straightforward. As an approximation, you can normalize the x-axis to the speed of light.

Alternativly, you can simulate the a known device and compare the two time domain responses. This allows you to attribute quantatative meaning to the axes. For example, you could create an ideal delayed load as shown below. Note: the magnitude of a response behind a large impulse doesn not have meaningful units.

In [10]:

from skrf.media import RectangularWaveguide

# create a rectangular waveguide media to gererate a theoretical network
wr1p5 = RectangularWaveguide(frequency=probe.frequency,
a=15*rf.mil,z0=1)

# create an ideal delayed load, parameters are adjusted until the
# theoretical response agrees with the measurement
d=2.4, unit='cm')

probe.plot_s_db_time(0,0, label = 'Measurement')
theory.plot_s_db_time(label='-20dB @ 2.4cm from test-port')
ylim(-100,0)

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-10-d60c34893488> in <module>()
12
13
---> 14 probe.plot_s_db_time(0,0, label = 'Measurement')
15 theory.plot_s_db_time(label='-20dB @ 2.4cm from test-port')
16 ylim(-100,0)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_s_db_time(self, *args, **kwargs)
1246
1247 def plot_s_db_time(self,*args,**kwargs):
-> 1248     return self.windowed().plot_s_time_db(*args,**kwargs)
1249
1250

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_func(self, m, n, ax, show_legend, attribute, y_label, pad, window, z0, *args, **kwargs)
1055                                              y_label=y_label,
1056                                              show_legend=show_legend, ax=ax,
-> 1057                                              *args, **kwargs)
1058                 #if was_interactive:
1059                 #    plb.interactive(True)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_rectangular(x, y, x_label, y_label, title, show_legend, axis, ax, *args, **kwargs)
305         ax = plb.gca()
306
--> 307     my_plot = ax.plot(x, y, *args, **kwargs)
308
309     if x_label is not None:

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1843                         "the Matplotlib list!)" % (label_namer, func.__name__),
1844                         RuntimeWarning, stacklevel=2)
-> 1845             return func(ax, *args, **kwargs)
1846
1847         inner.__doc__ = _add_data_doc(inner.__doc__,

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_axes.py in plot(self, *args, **kwargs)
1523         kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
1524
-> 1525         for line in self._get_lines(*args, **kwargs):
1527             lines.append(line)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
404                 this += args[0],
405                 args = args[1:]
--> 406             for seg in self._plot_args(this, kwargs):
407                 yield seg
408

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
381             x, y = index_of(tup[-1])
382
--> 383         x, y = self._xy_from_xy(x, y)
384
385         if self.command == 'plot':

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
240         if x.shape[0] != y.shape[0]:
241             raise ValueError("x and y must have same first dimension, but "
--> 242                              "have shapes {} and {}".format(x.shape, y.shape))
243         if x.ndim > 2 or y.ndim > 2:
244             raise ValueError("x and y can be no greater than 2-D, but have "

ValueError: x and y must have same first dimension, but have shapes (401,) and (800,)


This plot demonstrates a few important points:

• the theortical delayed load is not a perfect impulse in time. This is due to the dispersion in waveguide.
• the peak of the magnitude in time domain is not identical to that specified, also due to disperison (and windowing).

## What the hell is Windowing?¶

The 'plot_s_db_time()' function does a few things. 1. windows the s-parameters. * converts to time domain
* takes magnitude component, convert to dB * calculates time-axis s * plots

A word about step 1: windowing. A FFT represents a signal with a basis of periodic signals (sinusoids). If your frequency response is not periodic, which in general it isnt, taking a FFT will introduces artifacts in the time-domain results. To minimize these effects, the frequency response is windowed. This makes the frequency response more periodic by tapering off the band-edges.

Windowing is just applied to improve the plot appearance,d it does not affect the original network.

In skrf this can be done explicitly using the 'windowed()' function. By default this function uses the hamming window, but can be adjusted through arguments. The result of windowing is show below.

In [11]:

probe_w = probe.windowed()
probe.plot_s_db(0,0, label = 'Original')
probe_w.plot_s_db(0,0, label = 'Windowed')



Comparing the two time-domain plotting functions, we can see the difference between windowed and not.

In [12]:

probe.plot_s_time_db(0,0, label = 'Original')
probe_w.plot_s_time_db(0,0, label = 'Windowed')

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-02172ae45633> in <module>()
----> 1 probe.plot_s_time_db(0,0, label = 'Original')
2 probe_w.plot_s_time_db(0,0, label = 'Windowed')

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_func(self, m, n, ax, show_legend, attribute, y_label, pad, window, z0, *args, **kwargs)
1055                                              y_label=y_label,
1056                                              show_legend=show_legend, ax=ax,
-> 1057                                              *args, **kwargs)
1058                 #if was_interactive:
1059                 #    plb.interactive(True)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/scikit_rf-0.14.8-py3.5.egg/skrf/plotting.py in plot_rectangular(x, y, x_label, y_label, title, show_legend, axis, ax, *args, **kwargs)
305         ax = plb.gca()
306
--> 307     my_plot = ax.plot(x, y, *args, **kwargs)
308
309     if x_label is not None:

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/__init__.py in inner(ax, *args, **kwargs)
1843                         "the Matplotlib list!)" % (label_namer, func.__name__),
1844                         RuntimeWarning, stacklevel=2)
-> 1845             return func(ax, *args, **kwargs)
1846
1847         inner.__doc__ = _add_data_doc(inner.__doc__,

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_axes.py in plot(self, *args, **kwargs)
1523         kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
1524
-> 1525         for line in self._get_lines(*args, **kwargs):
1527             lines.append(line)

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _grab_next_args(self, *args, **kwargs)
404                 this += args[0],
405                 args = args[1:]
--> 406             for seg in self._plot_args(this, kwargs):
407                 yield seg
408

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
381             x, y = index_of(tup[-1])
382
--> 383         x, y = self._xy_from_xy(x, y)
384
385         if self.command == 'plot':

~/checkouts/readthedocs.org/user_builds/scikit-rf/conda/v0.14.8/lib/python3.5/site-packages/matplotlib/axes/_base.py in _xy_from_xy(self, x, y)
240         if x.shape[0] != y.shape[0]:
241             raise ValueError("x and y must have same first dimension, but "
--> 242                              "have shapes {} and {}".format(x.shape, y.shape))
243         if x.ndim > 2 or y.ndim > 2:
244             raise ValueError("x and y can be no greater than 2-D, but have "

ValueError: x and y must have same first dimension, but have shapes (401,) and (800,)

In [13]: