From 59b589cfc4d5f8fd53230bda363fe11b250bcc50 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Thu, 28 May 2015 22:33:54 +0200 Subject: [PATCH] Minor source corrections for calculation precision control --- src/daComposant/daAlgorithms/Blue.py | 3 +++ src/daComposant/daAlgorithms/ExtendedKalmanFilter.py | 4 +++- src/daComposant/daAlgorithms/KalmanFilter.py | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/daComposant/daAlgorithms/Blue.py b/src/daComposant/daAlgorithms/Blue.py index 7e05f14..069e937 100644 --- a/src/daComposant/daAlgorithms/Blue.py +++ b/src/daComposant/daAlgorithms/Blue.py @@ -150,6 +150,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): # --------------------------------- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"] or \ "SimulationQuantiles" in self._parameters["StoreSupplementaryCalculations"]: + if (Y.size <= Xb.size) and (Y.size > 100): K = B * Ha * (R + Hm * B * Ha).I + elif (Y.size > Xb.size) and (Y.size > 100): K = (BI + Ha * RI * Hm).I * Ha * RI + else: pass # K deja calcule A = B - K * Hm * B if min(A.shape) != max(A.shape): raise ValueError("The %s a posteriori covariance matrix A is of shape %s, despites it has to be a squared matrix. There is an error in the observation operator, please check it."%(self._name,str(A.shape))) diff --git a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py index f9e2c81..fdc69cc 100644 --- a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py @@ -166,8 +166,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if Cm is not None and Un is not None: # Attention : si Cm est aussi dans H, doublon ! d = d - Cm * Un # + _A = R + Ht * Pn_predicted * Ha + _u = numpy.linalg.solve( _A , d ) + Xn = Xn_predicted + Pn_predicted * Ha * _u Kn = Pn_predicted * Ha * (R + Ht * Pn_predicted * Ha).I - Xn = Xn_predicted + Kn * d Pn = Pn_predicted - Kn * Ht * Pn_predicted # self.StoredVariables["Analysis"].store( Xn.A1 ) diff --git a/src/daComposant/daAlgorithms/KalmanFilter.py b/src/daComposant/daAlgorithms/KalmanFilter.py index d1d50b9..9695541 100644 --- a/src/daComposant/daAlgorithms/KalmanFilter.py +++ b/src/daComposant/daAlgorithms/KalmanFilter.py @@ -137,8 +137,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if Cm is not None and Un is not None: # Attention : si Cm est aussi dans H, doublon ! d = d - Cm * Un # + _A = R + Ht * Pn_predicted * Ha + _u = numpy.linalg.solve( _A , d ) + Xn = Xn_predicted + Pn_predicted * Ha * _u Kn = Pn_predicted * Ha * (R + Ht * Pn_predicted * Ha).I - Xn = Xn_predicted + Kn * d Pn = Pn_predicted - Kn * Ht * Pn_predicted # self.StoredVariables["Analysis"].store( Xn.A1 ) -- 2.39.2