# obspy.signal.interpolation.lanczos_interpolation

`lanczos_interpolation`(data, old_start, old_dt, new_start, new_dt, new_npts, a, window='lanczos', *args, **kwargs)

  Function performing Lanczos resampling, see https://en.wikipedia.org/wiki/Lanczos_resampling for details. Essentially a finite support version of sinc resampling (the ideal reconstruction filter). For large values of `a` it converges towards sinc resampling. If used for downsampling, make sure to apply an appropriate anti-aliasing lowpass filter first.

  Note

  In most cases you do not want to call this method directly but invoke it via either the `obspy.core.stream.Stream.interpolate()` or `obspy.core.trace.Trace.interpolate()` method. These offer a nicer API that naturally integrates with the rest of ObsPy. Use `method="lanczos"` to use this interpolation method. In that case the only additional parameters of interest are `a` and `window`.

  Parameters: | data (array_like) Array to interpolate. old_start (float) The start of the array as a number. old_dt The time delta of the current array. new_start (float) The start of the interpolated array. Must be greater or equal to the current start of the array. new_dt (float) The desired new time delta. new_npts (int) The new number of samples. a (int) The width of the window in samples on either side. Runtime scales linearly with the value of `a` but the interpolation also gets better. window (str) The window used to taper the sinc function. One of `"lanczos"`, `"hanning"`, `"blackman"`. The window determines the trade-off between “sharpness” and the amplitude of the wiggles in the pass and stop band. Please use the `plot_lanczos_windows()` function to judge these for any given application.

  Values of `a` >= 20 show good results even for data that has energy close to the Nyquist frequency. If your data is extremely oversampled you can get away with much smaller `a`‘s.

  To get an idea of the response of the filter and the effect of the different windows, please use the `plot_lanczos_windows()` function.

  Also be aware of any boundary effects. All values outside the data range are assumed to be zero which matters when calculating interpolated values at the boundaries. At each side the area with potential boundary effects is `a` * `old_dt`. If you want to avoid any boundary effects you will have to remove these values.

  Mathematical Details:

  The \(\operatorname{sinc}\) function is defined as

  \[\operatorname{sinc}(t) = \frac{\sin(\pi t)}{\pi t}.\]

  The Lanczos kernel is then given by a multiplication of the \(\operatorname{sinc}\) function with an additional window function resulting in a finite support kernel.

  \[\begin{split}\begin{align} L(t) = \begin{cases} \operatorname{sinc}(t)\, \cdot \operatorname{sinc}(t/a) & \text{if } t \in [-a, a] \text{ and } \texttt{window} = \texttt{lanczos}\\ \operatorname{sinc}(t)\, \cdot \frac{1}{2} (1 + \cos(\pi\, t/a)) & \text{if } t \in [-a, a] \text{ and } \texttt{window} = \texttt{hanning}\\ \operatorname{sinc}(t)\, \cdot \left( \frac{21}{50} + \frac{1}{2} \cos(\pi\, t/a) + \frac{2}{25} \cos (2\pi\, t/a) \right) & \text{if } t \in [-a, a] \text{ and } \texttt{window} = \texttt{blackman}\\ 0 & \text{else} \end{cases} \end{align}\end{split}\]

  Finally interpolation is performed by convolving the discrete signal \(s_i\) with that kernel and evaluating it at the new time samples \(t_j\):

  \[\begin{align} S(t_j) = \sum_{i = \left \lfloor{t_j / \Delta t}\right \rfloor -a + 1} ^{\left \lfloor{t_j / \Delta t}\right \rfloor + a} s_i L(t_j/\Delta t - i), \end{align}\]

  where \(\lfloor \cdot \rfloor\) denotes the floor function. For more details and justification please see [Burger2009] and [vanDriel2015].

### Thank you!

We would like to thank our contributors, whose efforts make this software what it is. These people have helped by writing code and documentation, and by testing. They have created and maintained this product, its associated libraries and applications, our build tools and our web sites.

#### Contributors

- Ackerley, Nick
- Allgeyer, Sebastien
- Ammon, Charles J.
- Antunes, Emanuel
- Arnarsson, Ólafur St.
- Bank, Markus
- Barsch, Robert
- Behr, Yannik
- Bernardi, Fabrizio
- Bernauer, Felix
- Bes de Berc, Maxime
- Beyreuther, Moritz
- Boltz, Shawn
- Bonaimé, Sébastien
- Carothers, Lloyd
- Chamberlain, Calum
- Chambers, Derrick
- Chen, Zhao
- Clark, Adam
- Danecek, Peter
- Egdorf, Sven
- Engels, Fabian
- Ermert, Laura
- Eulenfeld, Tom

- Fabbri, Tommaso
- Falco, Nicholas
- Fee, Jeremy
- Grellier, Clément
- Grunberg, Marc
- Hammer, Conny
- Heimann, Sebastian
- Heiniger, Lukas
- Hope, Gaute
- Igel, Heiner
- Inza, Adolfo
- Isken, Marius
- Ketchum, David
- Koymans, Mathijs
- Kremers, Simon
- Kress, Victor
- Krieger, Lars
- Krischer, Lion
- Kula, Damian
- Käufl, Paul
- Köhler, Andreas
- Lecocq, Thomas
- Leeman, John
- Legovini, Paride

- Lesage, Philippe
- Li, Yulin
- Lomax, Anthony
- Lopes, Rui L.
- MacCarthy, Jonathan
- Maggi, Alessia
- Martin, Henri
- Medlin, Andrew
- Megies, Tobias
- Meschede, Matthias
- Michelini, Alberto
- Miller, Nathaniel C.
- Morgenstern, Bernhard
- Nof, Ran Novitsky
- Panning, Mark P.
- Parker, Tom
- Pestourie, Romain
- Rapagnani, Giovanni
- Reyes, Celso
- Ringler, Adam
- Rothenhäusler, Nicolas
- Russo, Emiliano
- Sales de Andrade, Elliott

- Satriano, Claudio
- Saul, Joachim
- Scheingraber, Chris
- Schneider, Simon
- Sippl, Christian
- Snoke, Arthur
- Stange, Stefan
- Stähler, Simon C.
- Sullivan, Benjamin
- Tian, Dongdong
- Trabant, Chad
- Trani, Luca
- Uieda, Leonardo
- Walker, Andrew
- Walther, Marcus
- Wassermann, Joachim
- Williams, Mark C.
- Winkelman, Andrew
- Zaccarelli, Riccardo
- Zad, Seyed Kasra Hosseini
- Zhu, Lijun
- van Driel, Martin
- van Wijk, Kasper

#### Funds

ObsPy was partially funded by the

- German Science Foundation (DFG) via grant DFG IG 16/9-1
- German Ministry for Education and Research (BMBF), GEOTECHNOLOGIEN grant 03G0646H.
- NERA project (Network of European Research Infrastructures for Earthquake Risk Assessment and Mitigation) under the European Community's Seventh Framework Programme (FP7/2007-2013) grant agreement n° 262330
- Leibniz Institute for Applied Geophysics (LIAG)
- VERCE EU-FP7 project (no. 283543)