From de512b1b022817afa47340d3c94550d7441b43b1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Thu, 14 Feb 2013 22:36:05 +0100 Subject: [PATCH] Mimic writing between KF and EKF --- src/daComposant/daAlgorithms/KalmanFilter.py | 17 ++++++++--------- src/daComposant/daCore/AssimilationStudy.py | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/daComposant/daAlgorithms/KalmanFilter.py b/src/daComposant/daAlgorithms/KalmanFilter.py index 88fdb7b..9d6a0fd 100644 --- a/src/daComposant/daAlgorithms/KalmanFilter.py +++ b/src/daComposant/daAlgorithms/KalmanFilter.py @@ -128,23 +128,22 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): else: Un = None # - if self._parameters["EstimationType"] == "State" and Cm is not None and Un is not None: - Xn_predicted = Mt * Xn + Cm * Un - Pn_predicted = Mt * Pn * Ma + Q - elif self._parameters["EstimationType"] == "State" and (Cm is None or Un is None): + if self._parameters["EstimationType"] == "State": Xn_predicted = Mt * Xn + if Cm is not None and Un is not None: # Attention : si Cm est aussi dans M, doublon ! + Xn_predicted = Xn_predicted + Cm * Un Pn_predicted = Mt * Pn * Ma + Q elif self._parameters["EstimationType"] == "Parameters": - # Xn_predicted = Mt * Xn - # Pn_predicted = Mt * Pn * Ma + Q # --- > Par principe, M = Id, Q = 0 Xn_predicted = Xn Pn_predicted = Pn # - if self._parameters["EstimationType"] == "Parameters" and Cm is not None and Un is not None: - d = Ynpu - Ht * Xn_predicted - Cm * Un - else: + if self._parameters["EstimationType"] == "State": + d = Ynpu - Ht * Xn_predicted + elif self._parameters["EstimationType"] == "Parameters": d = Ynpu - Ht * Xn_predicted + if Cm is not None and Un is not None: # Attention : si Cm est aussi dans H, doublon ! + d = d - Cm * Un # K = Pn_predicted * Ha * (Ht * Pn_predicted * Ha + R).I Xn = Xn_predicted + K * d diff --git a/src/daComposant/daCore/AssimilationStudy.py b/src/daComposant/daCore/AssimilationStudy.py index 190baf0..98f3f98 100644 --- a/src/daComposant/daCore/AssimilationStudy.py +++ b/src/daComposant/daCore/AssimilationStudy.py @@ -32,6 +32,7 @@ __author__ = "Jean-Philippe ARGAUD" import os, sys import numpy import Logging ; Logging.Logging() # A importer en premier +import scipy.optimize # Import preventif car son abscence a de l'effet import Persistence from BasicObjects import Operator from PlatformInfo import uniq -- 2.39.2