# Rational InterpolationΒΆ

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

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')

plt.figure()
plt.title('Impulse Response Lowpass')

plt.figure()
plt.title('Impulse Response Bandpass')
(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')
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:

1843                         "the Matplotlib list!)" % (label_namer, func.__name__),
1844                         RuntimeWarning, stacklevel=2)
-> 1845             return func(ax, *args, **kwargs)
1846

1523         kwargs = cbook.normalize_kwargs(kwargs, _alias_map)
1524
-> 1525         for line in self._get_lines(*args, **kwargs):
1527             lines.append(line)

404                 this += args[0],
405                 args = args[1:]
--> 406             for seg in self._plot_args(this, kwargs):
407                 yield seg
408

381             x, y = index_of(tup[-1])
382
--> 383         x, y = self._xy_from_xy(x, y)
384
385         if self.command == 'plot':


In [2]: