Salome HOME
Updating copyright date information (1)
[modules/adao.git] / src / daComposant / daAlgorithms / UnscentedKalmanFilter.py
index fdb6b4f1da464af3a56c153c8dc963efce4c531c..fb05316dbb62d39d2b678b6db90bea251d72e829 100644 (file)
@@ -1,6 +1,6 @@
-#-*-coding:iso-8859-1-*-
+# -*- coding: utf-8 -*-
 #
-# Copyright (C) 2008-2017 EDF R&D
+# Copyright (C) 2008-2018 EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -75,22 +75,26 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             name     = "StoreInternalVariables",
             default  = False,
             typecast = bool,
-            message  = "Stockage des variables internes ou intermédiaires du calcul",
+            message  = "Stockage des variables internes ou intermédiaires du calcul",
             )
         self.defineRequiredParameter(
             name     = "StoreSupplementaryCalculations",
             default  = [],
             typecast = tuple,
-            message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
+            message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
             listval  = ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", "APosterioriVariances", "BMA", "CurrentState", "CostFunctionJ", "CostFunctionJb", "CostFunctionJo", "Innovation"]
             )
         self.defineRequiredParameter( # Pas de type
             name     = "Bounds",
             message  = "Liste des valeurs de bornes",
             )
+        self.requireInputArguments(
+            mandatory= ("Xb", "Y", "HO", "R", "B" ),
+            optional = ("U", "EM", "CM", "Q"),
+            )
 
     def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
-        self._pre_run(Parameters)
+        self._pre_run(Parameters, Xb, Y, R, B, Q)
         #
         if self._parameters["EstimationOf"] == "Parameters":
             self._parameters["StoreInternalVariables"] = True
@@ -118,19 +122,14 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         Wc = numpy.array( Ww )
         Wc[0] = Lambda / (L + Lambda) + (1. - Alpha**2 + Beta)
         #
-        # Opérateurs
+        # Opérateurs
         # ----------
-        if B is None:
-            raise ValueError("Background error covariance matrix has to be properly defined!")
-        if R is None:
-            raise ValueError("Observation error covariance matrix has to be properly defined!")
-        #
         H = HO["Direct"].appliedControledFormTo
         #
         if self._parameters["EstimationOf"] == "State":
             M = EM["Direct"].appliedControledFormTo
         #
-        if CM is not None and CM.has_key("Tangent") and U is not None:
+        if CM is not None and "Tangent" in CM and U is not None:
             Cm = CM["Tangent"].asMatrix(Xb)
         else:
             Cm = None
@@ -142,7 +141,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         else:
             duration = 2
         #
-        # Précalcul des inversions de B et R
+        # Précalcul des inversions de B et R
         # ----------------------------------
         if self._parameters["StoreInternalVariables"]:
             BI = B.getI()