peri.interpolation

Index of module peri.interpolation

peri.interpolation.BarnesInterpolation1D

class peri.interpolation.BarnesInterpolation1D(x, d, filter_size=None, iterations=4, clip=False, clipsize=3, damp=0.95, blocksize=None, donorm=True)

A class for 1-d barnes interpolation. Give data points d at locations x.

See [1], equations 1-7 for implementation.

Parameters:
  • x (ndarray, 1-dimensional) – input positions, x values for data points
  • d (ndarray, 1-dimensional) – input values, y values for data points
  • filter_size (float, optional.) – control parameter for weight function (sigma), should be the average data spacing. Defaults to the average distance for sorted x.
  • iterations (integer, optional) – how many iterations to perform. only two needed with a high damping Defaults to 4
  • clip (boolean, optional) – whether to clip the number of data points used by the filtersize Default is False
  • clipsize (float, optional) – Total clipsize is determined by clipsize * filter_size Default is 3
  • damp (float, optional) – the damping parameter used in accelerating convergence. Default is 0.95
  • blocksize (Int or None, optional) – Memory-based performance feature. For very large x or d calculating the distance matrix between each point can require excessive memory overhead. To avoid this, set blocksize to a moderate int, causing the Barnes to compute the distance matrix in blocks. Does not change the final results. Default is None, which uses all the data all at once, using lots of mem.
  • donorm (bool, optional) – If False, uses an old, incorrect method to evaluate the interpolant rather than the correct version. Default is True. If you’re using this, set it to True.

References

[1]S. E. Koch, M. DesJardins, P. J. Kocin, J. Climate Appl. Meteor. 22 1487-1503 (1983)
__call__(rvecs)

Get the values interpolated at positions rvecs

peri.interpolation.ChebyshevInterpolation1D

class peri.interpolation.ChebyshevInterpolation1D(func, args=(), window=(0.0, 1.0), degree=3, evalpts=4)

A 1D Chebyshev approximation / interpolation for an ND function, approximating (N-1)D in in the last dimension.

Parameters:
  • func (callable) – A function that takes scalar arguments (1D) and returns a N dimensional array corresponding to that scalar. Make it such that, for an array x, f(x)[…..,a] corresponds to f(x[a])
  • args (tuple [optional]) – extra arguments to pass to func
  • window (tuple (length 2)) – The bounds of the function over which we desire the interpolation
  • degree (integer) – Degree of the Chebyshev interpolating polynomial
  • evalpts (integer) – Number of Chebyshev points to evaluate the function at
__call__(x)

Approximates func at the coordinates x, which must be in the window.

\[f(x) = \sum_{k=0}^{N-1} c_k T_k(x) - co/2\]

Output is in the format [A,…,x]