Advanced: Converting Coordinate Systems#

The ranges of sensible values for inputs to physics models are often problematic for filters. Some variables may be only valid in strict regions or the scales between variables vary widely enough to expose numerical issues. The ConversionOperator provides a route to bypassing such issues.

Using a Coordinate Converter#

The ModelWrapper accepts converters for each of the hidden state, control system, and outputs. Coordinate converters modify the ModelWrapper such that a BaseFilter operates on a different coordinate system without modification. Conversion to and from the model’s coordinate system occurs when the filter invokes methods from the model.

The OnlineEstimator uses the conversion operators for two reasons:

  1. Transposing states between different filters, which each may use different coordinate systems.

  2. Converting state to the model’s coordinate system so that changes in conversions in filters do not affect the output from the estimator.

These operations require functions which convert single samples and covariances between coordinate systems. Change in covariances are estimated using a first-order Taylor expansion, which provides an exact result for our most-common operator (linear). The convert() method of a MultivariateRandomDistribution employs sample and covariance conversions to produce a new distribution in the desired coordinate system.

Selecting a Conversion Operator#

Coordinate systems available for models may be problematic for many reasons, and we provide different filters for each:

  • Disparate Scales can be normalized with the LinearConversionOperator. Provide anticipated mean and variance for each variable, which will be used to scale and then added to coordinates before passing to the model.

from moirae.estimators.online.filters.conversions import LinearConversionOperator

operator = LinearConversionOperator(additive_array=mean, multiplicative_array=std)