INTEP interpolation algorithm

PyAstronomy.pyasl.intep(x, y, xinter, boundsError=True, fillValue=None)

The INTEP interpolation algorithm

The INTEP interpolation algorithm is described by Hill 1982, PDAO 16, 67 (“Intep - an Effective Interpolation Subroutine”). The implementation at hand is based on the FORTRAN code stated therein.

The aim of the algorithm is to imitate the curve “an experienced scientist” would draw through a given set of points.

Parameters
xarray

Independent values.

yarray

Dependent values.

xinterarray

Values at which to interpolate the tabulated data given by x and y.

boundsErrorboolean, optional

If True, an exception will be raised if values need to be extrapolated beyond the limits of the given tabulated data. Values beyond the limits are simply replaced with the closest valid value available, which might not be a good approximation. Set this flag to False suppress the exception.

fillValuefloat, optional

If given (i.e., not None), this value will be used to represent values outside of the given bounds. Note that boundsError must be set False for this to have an effect. For instance, use np.NaN.

Returns
Interpolated valuesarray

Interpolated values at the locations specified by xinter.

Example

from PyAstronomy import pyasl
import numpy as np
import matplotlib.pylab as plt

# Create some tabulated data
x = np.arange(10.)
y = np.sin(x/5.*2.*np.pi)

# Choose the values at which to interpolate
xx = np.arange(120.)/10.-2.0
# Interpolate and suppress the exception that
# would indicate that some of our requested
# values (xx) are beyond the range covered by x.
yy = pyasl.intep(x, y, xx, boundsError=False)

# Plot the result
plt.plot(x, y, 'bp')
plt.plot(xx, yy, 'r--')
plt.show()