# Interpolators

Tudat contains a number of interpolators for discrete data sets. The input to an interpolator is a set of combinations of independent variables $$t_{i}$$, and state variables $$\mathbf{x}_{i}$$, where $$\mathbf{x}$$ may be a scalar, vector or matrix. A data sets that is often interpolated using tudat is the the state history, as generated from the propagation of dynamics (see Single-arc Variational Equations Propagation). The general operation of an interpolator is to take a set of combinations $$[t_{i},\mathbf{x}_{i}]$$ and turn this into a continuous function $$\mathbf{x}(t)$$.

The full API documentation for interpolators can be found here here.

## General procedure

The manner in which to use the tudat interpolators is similar to that of the various models for numerical propagation:

1. create settings for the interpolation (see Available types of interpolators);

2. create interpolator based on the settings and the data that is to be interpolated.

An example, for the case of a linear interpolator, is shown below:

Required Show/Hide

from tudatpy.kernel.math import interpolators

# Generate data to interpolate
data_to_interpolate = dict( )
data_to_interpolate = ...

# Create settings for interpolation
linear_interpolation_settings = interpolators.linear_interpolation( )

# Create interpolator
interpolator = interpolators.create_one_dimensional_scalar_interpolator( data_to_interpolate, linear_interpolation_settings )

# Interpolate data set in data_to_interpolate at t=100
independent_variable = 100
interpolated_value = interpolator.interpolate( independent_variable )


In the above examplee, the linear scheme is used to interpolate the data_to_interpolate data set at $$t=100$$ (where typically, but not necessarily, the independent variable in interpolation will represent time, in the context of Tudat).

The data that is to be interpolated must be provided as a dict (in Python) or a std::map (in C++):

• key: independent variable

• value: dependent variable to be interpolated

Based on the type of independent variable, different functions to create the interpolator are available:

## Available types of interpolators

Tudat includes the following interpolators for a data set with a single independent variable:

To use the Hermite spline interpolator, the user must provide not only the states $$\mathbf{x}_{i}$$ and the state derivatives $$d\mathbf{x}_{i}/dt$$ at the independent variable values $$t_{i}$$:

Required Show/Hide

from tudatpy.kernel.math import interpolators

# Generate data to interpolate
data_to_interpolate = dict( )
data_derivatives = dict( )
data_to_interpolate = ...
data_derivatives = ...

# Create settings for Hermite spline interpolation
linear_interpolation_settings = interpolators.hermite_interpolation( )

# Create interpolator
interpolator = interpolators.create_one_dimensional_scalar_interpolator( data_to_interpolate, linear_interpolation_settings, data_derivatives )

# Interpolate data set in data_to_interpolate at t=100
independent_variable = 100
interpolated_value = interpolator.interpolate( independent_variable )