Interpolators

Interpolation for Discrete Time-based Data

The DiscreteTimeData class keeps values changing with time, such as azimuth or elevation. The class receives a strictly increasing time list, and a matching number of data points.

A scipy.interpolate.CubicSpline is initialised under the hood to be able to provide methods like interpolate() for interpolation or roots() to find the real roots. Similarly, deriv_interpolate() provides an interpolator for the first derivative and deriv_roots() find the real roots of the first derivative.

Interpolation for 3D Vectors

The CartInterpolator3D class sets up an interpolator for a set of time-varying 3D vectors (for example a trajectory). This enables retrieval of another 3D vector for a given time, as long as it is within the initial set of values used to set up the interpolator.

The interpolation is carried out individually for each axis. The input values should be smooth and continuous. The actual interpolation algorithm is scipy.interpolate.InterpolatedUnivariateSpline, with the spline_degree defined upon initialisation. The number of data points must be larger than the spline_degree.

The CartInterpolator3D class is not intended to be called or instantiated by the user. It is used for position and velocity interpolation within the Trajectory class.

Reference/API

Interpolators used in the project.

class satmad.utils.interpolators.CartInterpolator3D(t, x, y, z, spline_degree=5, extrapolate_action='raise')

One-dimensional interpolating spline for a given set of 3D data points.

For each of the data sets, fits a spline y = spl(t) of degree spline_degree to the provided t, y data. Uses a InterpolatedUnivariateSpline inside, so the spline function passes through all provided points.

Parameters
  • t ((N,) array_like) – Input dimension of data points – must be strictly increasing

  • x ((N,) array_like) – input dimension of data points

  • y ((N,) array_like) – input dimension of data points

  • z ((N,) array_like) – input dimension of data points

  • spline_degree (int, optional) – Degree of the smoothing spline. Must be 1 <= k <= 5.

  • extrapolate_action (int or str, optional) –

    Controls the extrapolation mode for elements

    not in the interval defined by the knot sequence.

    • if ext=0 or ‘extrapolate’, return the extrapolated value.

    • if ext=1 or ‘zeros’, return 0

    • if ext=2 or ‘raise’, raise a ValueError

    • if ext=3 of ‘const’, return the boundary value.

    The default value is 0.

    See also

    scipy.interpolate.InterpolatedUnivariateSpline

    The interpolator used inside this class.

    Notes

    The number of data points must be larger than the spline_degree.

property interpolator_name

Returns the name of the interpolator.

class satmad.utils.interpolators.DiscreteTimeData(time_list, value_list, axis=0)
Parameters
  • time_list ((N,) array_like) – Input dimension of data points – must be strictly increasing

  • value_list ((N,) array_like) – input dimension of data points

  • axis (int, optional) – Axis along which value_list is assumed to be varying. Meaning that for time_list[i] the corresponding values are np.take(value_list, i, axis=axis). Default is 0.

deriv_interpolate(t)

Computes the interpolated derivative value for the given time(s).

Parameters

t (Time or array_like) – A 1-D array of points at which to return the value of the smoothed spline or its derivatives. Note: t can be unordered but the evaluation is more efficient if t is (partially) ordered.

Returns

Interpolated value or 1-D array of values, depending on the input.

Return type

float or array_like

deriv_roots(discontinuity=True, extrapolate=False)

Find real roots of the the derivative of the data.

Parameters
  • discontinuity (bool, optional) – Whether to report sign changes across discontinuities at breakpoints as roots.

  • extrapolate ({bool, 'periodic', None}, optional) – If bool, determines whether to return roots from the polynomial extrapolated based on first and last intervals, ‘periodic’ works the same as False. If None, use self.extrapolate.

Returns

roots – Roots of the data.

Return type

ndarray

interpolate(t)

Computes the interpolated value for the given time(s).

Parameters

t (Time or array_like) – A 1-D array of points at which to return the value of the smoothed spline or its derivatives. Note: t can be unordered but the evaluation is more efficient if t is (partially) ordered.

Returns

Interpolated value or 1-D array of values, depending on the input.

Return type

float or array_like

roots(discontinuity=True, extrapolate=False)

Find real roots of the the data.

Parameters
  • discontinuity (bool, optional) – Whether to report sign changes across discontinuities at breakpoints as roots.

  • extrapolate ({bool, 'periodic', None}, optional) – If bool, determines whether to return roots from the polynomial extrapolated based on first and last intervals, ‘periodic’ works the same as False. If None, use self.extrapolate.

Returns

roots – Roots of the data.

Return type

ndarray

sec_deriv_interpolate(t)

Computes the interpolated second derivative value for the given time(s).

Parameters

t (Time or array_like) – A 1-D array of points at which to return the value of the smoothed spline or its derivatives. Note: t can be unordered but the evaluation is more efficient if t is (partially) ordered.

Returns

Interpolated value or 1-D array of values, depending on the input.

Return type

float or array_like