2 Copyright (C) 2008-2024 EDF R&D
4 This file is part of SALOME ADAO module.
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 .. index:: single: KalmanFilter
25 .. _section_ref_algorithm_KalmanFilter:
27 Calculation algorithm "*KalmanFilter*"
28 --------------------------------------
30 .. ------------------------------------ ..
31 .. include:: snippets/Header2Algo01.rst
33 This algorithm realizes an estimation of the state of a dynamic system by a
34 Kalman Filter. In discrete form, it is an iterative (or recursive) estimator of
35 the current state using the previous state and the current observations. The
36 time (or pseudo-time) between two steps is the time between successive
37 observations. Each iteration step is composed of two successive phases,
38 classically called "*prediction*" and "*correction*". The prediction step uses
39 an incremental evolution operator to establish an estimate of the current state
40 from the state estimated at the previous step. The correction (or *update*)
41 step uses the current observations to improve the estimate by correcting the
44 It is theoretically reserved for observation and incremental evolution
45 operators cases which are linear, even if it sometimes works in "slightly"
46 non-linear cases. One can verify the linearity of the operators with the help
47 of a :ref:`section_ref_algorithm_LinearityTest`.
49 Conceptually, we can represent the temporal pattern of action of the evolution
50 and observation operators in this algorithm in the following way, with **x**
51 the state, **P** the state error covariance, *t* the discrete iterative time :
53 .. _schema_temporel_KF:
54 .. figure:: images/schema_temporel_KF.png
58 **Timeline of steps in Kalman filter data assimilation**
60 In this scheme, the analysis **(x,P)** is obtained by means of the
61 "*correction*" by observing the "*prediction*" of the previous state. We notice
62 that there is no analysis performed at the initial time step (numbered 0 in the
63 time indexing) because there is no forecast at this time (the background is
64 stored as a pseudo analysis at the initial time step). If the observations are
65 provided in series by the user, the first one is therefore not used.
67 This filter can also be used to estimate (jointly or solely) parameters and not
68 the state, in which case neither the time nor the evolution have any meaning.
69 The iteration steps are then linked to the insertion of a new observation in
70 the recursive estimation. One should consult the section
71 :ref:`section_theory_dynamic` for the implementation concepts.
73 In case of non-linearity of the operators, even slightly marked, it will be
74 preferred a :ref:`section_ref_algorithm_ExtendedKalmanFilter`, or a
75 :ref:`section_ref_algorithm_UnscentedKalmanFilter` and a
76 :ref:`section_ref_algorithm_UnscentedKalmanFilter` that are more powerful. One
77 can verify the linearity of the operators with the help of a
78 :ref:`section_ref_algorithm_LinearityTest`.
80 .. ------------------------------------ ..
81 .. include:: snippets/Header2Algo12.rst
83 .. include:: snippets/FeaturePropLocalOptimization.rst
85 .. include:: snippets/FeaturePropDerivativeNeeded.rst
87 .. include:: snippets/FeaturePropParallelDerivativesOnly.rst
89 .. ------------------------------------ ..
90 .. include:: snippets/Header2Algo02.rst
92 .. include:: snippets/Background.rst
94 .. include:: snippets/BackgroundError.rst
96 .. include:: snippets/EvolutionError.rst
98 .. include:: snippets/EvolutionModel.rst
100 .. include:: snippets/Observation.rst
102 .. include:: snippets/ObservationError.rst
104 .. include:: snippets/ObservationOperator.rst
106 .. ------------------------------------ ..
107 .. include:: snippets/Header2Algo03AdOp.rst
109 .. include:: snippets/EstimationOf_State.rst
111 StoreSupplementaryCalculations
112 .. index:: single: StoreSupplementaryCalculations
114 *List of names*. This list indicates the names of the supplementary
115 variables, that can be available during or at the end of the algorithm, if
116 they are initially required by the user. Their availability involves,
117 potentially, costly calculations or memory consumptions. The default is then
118 a void list, none of these variables being calculated and stored by default
119 (excepted the unconditional variables). The possible names are in the
120 following list (the detailed description of each named variable is given in
121 the following part of this specific algorithmic documentation, in the
122 sub-section "*Information and variables available at the end of the
125 "APosterioriCorrelations",
126 "APosterioriCovariance",
127 "APosterioriStandardDeviations",
128 "APosterioriVariances",
131 "CostFunctionJAtCurrentOptimum",
133 "CostFunctionJbAtCurrentOptimum",
135 "CostFunctionJoAtCurrentOptimum",
139 "ForecastCovariance",
142 "InnovationAtCurrentAnalysis",
143 "InnovationAtCurrentState",
144 "SimulatedObservationAtCurrentAnalysis",
145 "SimulatedObservationAtCurrentOptimum",
146 "SimulatedObservationAtCurrentState",
150 ``{"StoreSupplementaryCalculations":["CurrentState", "Residu"]}``
152 .. ------------------------------------ ..
153 .. include:: snippets/Header2Algo04.rst
155 .. include:: snippets/Analysis.rst
157 .. ------------------------------------ ..
158 .. include:: snippets/Header2Algo05.rst
160 .. include:: snippets/Analysis.rst
162 .. include:: snippets/APosterioriCorrelations.rst
164 .. include:: snippets/APosterioriCovariance.rst
166 .. include:: snippets/APosterioriStandardDeviations.rst
168 .. include:: snippets/APosterioriVariances.rst
170 .. include:: snippets/BMA.rst
172 .. include:: snippets/CostFunctionJ.rst
174 .. include:: snippets/CostFunctionJAtCurrentOptimum.rst
176 .. include:: snippets/CostFunctionJb.rst
178 .. include:: snippets/CostFunctionJbAtCurrentOptimum.rst
180 .. include:: snippets/CostFunctionJo.rst
182 .. include:: snippets/CostFunctionJoAtCurrentOptimum.rst
184 .. include:: snippets/CurrentOptimum.rst
186 .. include:: snippets/CurrentState.rst
188 .. include:: snippets/CurrentStepNumber.rst
190 .. include:: snippets/ForecastCovariance.rst
192 .. include:: snippets/ForecastState.rst
194 .. include:: snippets/IndexOfOptimum.rst
196 .. include:: snippets/InnovationAtCurrentAnalysis.rst
198 .. include:: snippets/InnovationAtCurrentState.rst
200 .. include:: snippets/SimulatedObservationAtCurrentAnalysis.rst
202 .. include:: snippets/SimulatedObservationAtCurrentOptimum.rst
204 .. include:: snippets/SimulatedObservationAtCurrentState.rst
206 .. ------------------------------------ ..
207 .. _section_ref_algorithm_KalmanFilter_examples:
209 .. include:: snippets/Header2Algo09.rst
212 .. include:: scripts/simple_KalmanFilter1.rst
214 .. literalinclude:: scripts/simple_KalmanFilter1.py
216 .. include:: snippets/Header2Algo10.rst
218 .. literalinclude:: scripts/simple_KalmanFilter1.res
221 .. include:: snippets/Header2Algo11.rst
223 .. _simple_KalmanFilter1_state:
224 .. image:: scripts/simple_KalmanFilter1_state.png
228 .. _simple_KalmanFilter1_variance:
229 .. image:: scripts/simple_KalmanFilter1_variance.png
234 .. include:: scripts/simple_KalmanFilter2.rst
236 .. literalinclude:: scripts/simple_KalmanFilter2.py
238 .. include:: snippets/Header2Algo10.rst
240 .. literalinclude:: scripts/simple_KalmanFilter2.res
243 .. include:: snippets/Header2Algo11.rst
245 .. _simple_KalmanFilter2_state:
246 .. image:: scripts/simple_KalmanFilter2_state.png
250 .. _simple_KalmanFilter2_variance:
251 .. image:: scripts/simple_KalmanFilter2_variance.png
255 .. ------------------------------------ ..
256 .. include:: snippets/Header2Algo06.rst
258 - :ref:`section_ref_algorithm_ExtendedKalmanFilter`
259 - :ref:`section_ref_algorithm_EnsembleKalmanFilter`
260 - :ref:`section_ref_algorithm_UnscentedKalmanFilter`
262 .. ------------------------------------ ..
263 .. include:: snippets/Header2Algo07.rst