Time Domain and Gating


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 isolate a single response in space. More information about the details of time domain analysis see [1].


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

Quick Example

In [1]:
import skrf as rf
%matplotlib inline
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
title('Frequency Domain')

title('Time Domain')
/home/docs/checkouts/readthedocs.org/user_builds/scikit-rf/conda/latest/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88
  return f(*args, **kwds)

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')
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
title('Frequency Domain')
title('Time Domain')

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

In [4]:
title('Reflection Coefficient From \nWaveguide Port')
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
title('Reflection Coefficient From \nWaveguide Port, Time Domain')
(-100, 0)

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'


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

In [7]:


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.time_gate().plot_s_db(label='autogated') #autogate on the fly

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

In [9]:
title('Other Interface of Probe')


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.


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,

# create an ideal delayed load, parameters are adjusted until the
# theoretical response agrees with the measurement
theory = wr1p5.delay_load(Gamma0=rf.db_2_mag(-20),
                          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')
(-100, 0)

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')
In [13]: