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)\).
See also
The full API documentation for interpolators can be found here.
General procedure#
The manner in which to use the tudat interpolators is similar to that of the various models for numerical propagation:
create settings for the interpolation (see Available types of interpolators);
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
from tudatpy.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 example above, 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 variablevalue: dependent variable to be interpolated
Based on the type of independent variable, different functions to create the interpolator are available:
scalar interpolator (see the
create_one_dimensional_scalar_interpolator()function, as in the example above)vector interpolator (see the
create_one_dimensional_vector_interpolator()function)matrix interpolator (see the
create_one_dimensional_matrix_interpolator()function)
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
from tudatpy.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 )
Additional settings#
To create interpolator settings, there are a number of additional settings that a user may want to modify (these have default values in the factory functions for the interpolator settings), related to:
the look-up scheme, through the enum
AvailableLookupScheme;the behaviour beyond the boundaries of the domain, through the enum
BoundaryInterpolationType;the behaviour close to the boundaries of the domain, through the enum
LagrangeInterpolatorBoundaryHandling(for thelagrange_interpolation()only).