Rational InterpolationΒΆ

Should be a better interpolation method that causes less errors with time-domain transformations.

Based on: https://www.in.tu-clausthal.de/fileadmin/homes/techreports/ifi0606floater.pdf

Example:

In [1]:
import skrf
import matplotlib.pyplot as plt
skrf.stylely()

freq = skrf.F(0.5,110,801)
freq2 = skrf.F(0,110,801)
coax1mm = skrf.media.Coaxial(freq, z0=50, Dint=0.44e-3, Dout=1.0e-3, sigma=1e20)
coax1mm2 = skrf.media.Coaxial(freq2, z0=50, Dint=0.44e-3, Dout=1.0e-3, sigma=1e20)

X = coax1mm.line(10, 'mm', z0=50, name='X', embed=True)
Y = coax1mm.line(80, 'mm', z0=75, name='Y', embed=True)
dut = X**Y**X

X2 = coax1mm2.line(10, 'mm', z0=50, name='X', embed=True)
Y2 = coax1mm2.line(80, 'mm', z0=75, name='Y', embed=True)
dut2 = X2**Y2**X2
dut2.name = 'real'

dut_dc_rational = dut.extrapolate_to_dc(kind='rational', dc_sparam=[[0,1],[1,0]])
dut_dc_rational.name = 'rationnal'
dut_dc_linear = dut.extrapolate_to_dc(kind='linear', dc_sparam=[[0,1],[1,0]])
dut_dc_linear.name = 'linear'
dut_dc_cubic = dut.extrapolate_to_dc(kind='cubic', dc_sparam=[[0,1],[1,0]])
dut_dc_cubic.name = 'cubic'

plt.figure()
plt.title('Step Response Lowpass')
dut2.s11.plot_s_time_step(pad=2000, window='hamming')
dut_dc_rational.s11.plot_s_time_step(pad=2000, window='hamming')
dut_dc_linear.s11.plot_s_time_step(pad=2000, window='hamming')
dut_dc_cubic.s11.plot_s_time_step(pad=2000, window='hamming')

plt.figure()
plt.title('Impulse Response Lowpass')
dut2.s11.plot_s_time_impulse(pad=2000, window='hamming')
dut_dc_rational.s11.plot_s_time_impulse(pad=2000, window='hamming')
dut_dc_linear.s11.plot_s_time_impulse(pad=2000, window='hamming')
dut_dc_cubic.s11.plot_s_time_impulse(pad=2000, window='hamming')

plt.figure()
plt.title('Impulse Response Bandpass')
dut2.s11.plot_s_time(pad=2000, window='hamming')
(dut_dc_rational.s11.windowed()).plot_s_time()
(dut_dc_linear.s11.windowed()).plot_s_time()
(dut_dc_cubic.s11.windowed()).plot_s_time()

plt.show(block=True)
/home/docs/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/tlineFunctions.py:144: RuntimeWarning: divide by zero encountered in true_divide
  return sqrt(rho/(pi*f*mu_r*mu_0))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-95d1e468b9ac> in <module>()
     40 plt.figure()
     41 plt.title('Impulse Response Bandpass')
---> 42 dut2.s11.plot_s_time(pad=2000, window='hamming')
     43 (dut_dc_rational.s11.windowed()).plot_s_time()
     44 (dut_dc_linear.s11.windowed()).plot_s_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_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):
   1526             self.add_line(line)
   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 (801,) and (1600,)
In [2]: