cora.util.cubicspline

Module for interpolating sampled functions.

Classes

Interpolater

A class to interpolate data sets.

LogInterpolater

Perform a cubic spline interpolation in log-space.

SinhInterpolater

Perform a cubic spline interpolation in a sinh scaled space.

Exceptions

InterpolationException

Exceptions in the Interpolation module.

class cora.util.cubicspline.Interpolater

Bases: object

A class to interpolate data sets.

This class performs cubic spline interpolation. See Numerical Recipes for details. Uses Natural spline conditions, y’’[0] = y’’[-1] = 0. Written using Cython for massive speedup.

Constructor to initialise from data.

Need to supply a 2d data array of X-Y pairs to interpolate. i.e. [[x0,y0], [x1,y1], …]

data()

Return the data array.

classmethod fromfile(file, colspec=None)

Perform Interpolation from given file.

Load up the file and generate an Interpolater.

colspec - 2 element list of columns to interpolate

test(min, max, samp)

Take regular samples from the Interpolater.

Take the interpolater, and take samp samples between min and max. Returning an array.

value(x)

Returns the value of the function at x.

exception cora.util.cubicspline.InterpolationException

Bases: Exception

Exceptions in the Interpolation module.

class cora.util.cubicspline.LogInterpolater

Bases: Interpolater

Perform a cubic spline interpolation in log-space.

Initialise the interpolater. Data must not be negative or zero, otherwise logarithmic interpolation blows up.

value(x)

Return the value of the log-interpolated function.

class cora.util.cubicspline.SinhInterpolater

Bases: Interpolater

Perform a cubic spline interpolation in a sinh scaled space.

The interpolation is done within the space of arcsinh(x / x_t) and arcsinh(f / f_t), this gives an effective log interpolation for absolute values greater than the threshold and linear when less than the threshold. This allows an effective log interpolation which will handle zero and negative values.

Parameters:
  • data (np.ndarray[:, 2]) – The data points packed as [[x0, f0], …].

  • x_t – The sinc threshold value for the positions.

  • f_t – The function value threshold.

value(x)

Return the value of the log-interpolated function.