interpolation

Interpolation functions.

Module summary

Classes

Interpolator(states, t)

Base Interpolation class that mimics the behavior of SpaceObject so that a Interpolator instance can be used instead.

Legendre8(states, t)

Order-8 Legendre polynomial interpolation of uniformly distributed states.

Functions

legendre8(table, t1, tN, t[, ti])

Order-8 Legendre polynomial interpolation

legendre8_loop(table, t1, tN, t)

Order-8 Legendre polynomial interpolation

Contents

Interpolator

class sorts.interpolation.Interpolator(states, t)[source]

Bases: abc.ABC

Base Interpolation class that mimics the behavior of SpaceObject so that a Interpolator instance can be used instead.

To create a Interpolator one must define the get_state method. to return interpolated This method should return states based on the data contained in the instance. This data is preferably internalized at instantiation.

Parameters
  • states (numpy.ndarray) – (6,n) array of states to interpolate between.

  • t (numpy.ndarray) – (n,) vector of times corresponding to the states.

Legendre8

class sorts.interpolation.Legendre8(states, t)[source]

Bases: sorts.interpolation.Interpolator

Order-8 Legendre polynomial interpolation of uniformly distributed states.

Functions

sorts.interpolation.legendre8(table, t1, tN, t, ti=None)[source]

Order-8 Legendre polynomial interpolation

Code adapted from the gdar system developed by NORCE Norwegian Research Centre AS, used with permission.

Parameters:
table: M vectors (M >= 9) to interpolate between, each containing N

values, e.g. for a position vector N=3 (x, y, z) table.shape = (M, N)

t1: time corresponding to M=0 tN: time corresponding to M=N-1 t: times at which to provide N-dimensional answer. ti: indices which sort t in monotonic order

This version requires t to be sorted, which enables optimization by interpolating all t in an interval between two nodes as a single expression. For the typical case where there are many fewer intervals to consider than distinct values to interpolate, this gives much improved performance.

sorts.interpolation.legendre8_loop(table, t1, tN, t)[source]

Order-8 Legendre polynomial interpolation

Code adapted from the gdar system developed by NORCE Norwegian Research Centre AS, used with permission.

Parameters:
table: M vectors (M >= 9) to interpolate between, each containing N

values, e.g. for a position vector N=3 (x, y, z) table.shape = (M, N)

t1: time corresponding to M=0 tN: time corresponding to M=N-1 t: times at which to provide N-dimensional answer.

This version loops over all interpolation instants t. Direct port of IDL, which was directly ported from Fortran.