]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Adding user variable and minor corrections
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 9 Sep 2015 19:55:14 +0000 (21:55 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 9 Sep 2015 19:56:01 +0000 (21:56 +0200)
doc/en/ref_algorithm_3DVAR.rst
doc/fr/ref_algorithm_3DVAR.rst
src/daComposant/daAlgorithms/3DVAR.py
src/daComposant/daAlgorithms/ExtendedKalmanFilter.py
src/daComposant/daAlgorithms/KalmanFilter.py
src/daComposant/daCore/BasicObjects.py
src/daComposant/daCore/Persistence.py
src/daSalome/daYacsSchemaCreator/infos_daComposant.py

index ed3ef44e7fb6b29e017406b50775add8d70a4bb5..660ba8a913868326aea10653e236d62cf434c791 100644 (file)
@@ -166,9 +166,9 @@ The options of the algorithm are the following:
     are in the following list: ["APosterioriCorrelations",
     "APosterioriCovariance", "APosterioriStandardDeviations",
     "APosterioriVariances", "BMA", "CostFunctionJ", "CurrentOptimum",
-    "CurrentState", "IndexOfOptimum", "Innovation", "MahalanobisConsistency",
-    "OMA", "OMB", "SigmaObs2", "SimulatedObservationAtBackground",
-    "SimulatedObservationAtCurrentOptimum",
+    "CurrentState", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState",
+    "MahalanobisConsistency", "OMA", "OMB", "SigmaObs2",
+    "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentOptimum",
     "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum",
     "SimulationQuantiles"].
 
index b6b3b97d4dd750f92f34f31fa2ebbc2ba08edbb4..d1b550c0081de94ad9570c7942d3d9ef5fce252f 100644 (file)
@@ -171,9 +171,9 @@ Les options de l'algorithme sont les suivantes:
     possibles sont dans la liste suivante : ["APosterioriCorrelations",
     "APosterioriCovariance", "APosterioriStandardDeviations",
     "APosterioriVariances", "BMA", "CostFunctionJ", "CurrentOptimum",
-    "CurrentState", "IndexOfOptimum", "Innovation", "MahalanobisConsistency",
-    "OMA", "OMB", "SigmaObs2", "SimulatedObservationAtBackground",
-    "SimulatedObservationAtCurrentOptimum",
+    "CurrentState", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState",
+    "MahalanobisConsistency", "OMA", "OMB", "SigmaObs2",
+    "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentOptimum",
     "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum",
     "SimulationQuantiles"].
 
index ae62c43699ec171f4597925019162c7be91b53e1..039348b54a0c9ddae921e7fdb2cc02e349b9da35 100644 (file)
@@ -72,7 +72,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             default  = [],
             typecast = tuple,
             message  = "Liste de calculs supplémentaires à stocker et/ou effectuer",
-            listval  = ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", "APosterioriVariances", "BMA", "OMA", "OMB", "CurrentState", "CostFunctionJ", "CurrentOptimum", "IndexOfOptimum", "Innovation", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum", "SimulatedObservationAtCurrentOptimum"]
+            listval  = ["APosterioriCorrelations", "APosterioriCovariance", "APosterioriStandardDeviations", "APosterioriVariances", "BMA", "OMA", "OMB", "CostFunctionJ", "CurrentState", "CurrentOptimum", "IndexOfOptimum", "Innovation", "InnovationAtCurrentState", "SigmaObs2", "MahalanobisConsistency", "SimulationQuantiles", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum", "SimulatedObservationAtCurrentOptimum"]
             )
         self.defineRequiredParameter(
             name     = "Quantiles",
@@ -165,11 +165,14 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 self.StoredVariables["CurrentState"].store( _X )
             _HX = Hm( _X )
             _HX = numpy.asmatrix(numpy.ravel( _HX )).T
+            _Innovation = Y - _HX
             if "SimulatedObservationAtCurrentState" in self._parameters["StoreSupplementaryCalculations"] or \
                "SimulatedObservationAtCurrentOptimum" in self._parameters["StoreSupplementaryCalculations"]:
                 self.StoredVariables["SimulatedObservationAtCurrentState"].store( _HX )
+            if "InnovationAtCurrentState" in self._parameters["StoreSupplementaryCalculations"]:
+                self.StoredVariables["InnovationAtCurrentState"].store( _HX )
             Jb  = 0.5 * (_X - Xb).T * BI * (_X - Xb)
-            Jo  = 0.5 * (Y - _HX).T * RI * (Y - _HX)
+            Jo  = 0.5 * _Innovation.T * RI * _Innovation
             J   = float( Jb ) + float( Jo )
             self.StoredVariables["CostFunctionJb"].store( Jb )
             self.StoredVariables["CostFunctionJo"].store( Jo )
index fdc69ccb1ec5c6aeab4f41f3bb6649f5080a5482..1d66ef745ebfd7262a58c5b750ac1bc148a79d50 100644 (file)
@@ -112,7 +112,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         #
         self.StoredVariables["Analysis"].store( Xn.A1 )
         if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
-            self.StoredVariables["APosterioriCovariance"].store( Pn )
+            self.StoredVariables["APosterioriCovariance"].store( Pn.asfullmatrix(Xn.size) )
             covarianceXa = Pn
         Xa               = Xn
         previousJMinimum = numpy.finfo(float).max
index 9695541ade123e8e54a8d588cdf2799e6a9b237f..110692f2e55aa8582362ccc63bc4b1271cad803f 100644 (file)
@@ -98,7 +98,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         #
         self.StoredVariables["Analysis"].store( Xn.A1 )
         if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
-            self.StoredVariables["APosterioriCovariance"].store( Pn )
+            self.StoredVariables["APosterioriCovariance"].store( Pn.asfullmatrix(Xn.size) )
             covarianceXa = Pn
         Xa               = Xn
         previousJMinimum = numpy.finfo(float).max
index 864070516898bef5b5d3ac345570de8c2a1d4bd7..eda0a11fabc84d7ebccb500c5c4b72c5f681ff9d 100644 (file)
@@ -286,6 +286,7 @@ class Algorithm:
             - SimulatedObservationAtCurrentState : l'état observé H(X) à l'état courant
             - SimulatedObservationAtOptimum : l'état observé H(Xa) à l'optimum
             - Innovation : l'innovation : d = Y - H(X)
+            - InnovationAtCurrentState : l'innovation à l'état courant : dn = Y - H(Xn)
             - SigmaObs2 : indicateur de correction optimale des erreurs d'observation
             - SigmaBck2 : indicateur de correction optimale des erreurs d'ébauche
             - MahalanobisConsistency : indicateur de consistance des covariances
@@ -307,32 +308,33 @@ class Algorithm:
         self.__required_parameters = {}
         self.StoredVariables = {}
         #
-        self.StoredVariables["CostFunctionJ"]                      = Persistence.OneScalar(name = "CostFunctionJ")
-        self.StoredVariables["CostFunctionJb"]                     = Persistence.OneScalar(name = "CostFunctionJb")
-        self.StoredVariables["CostFunctionJo"]                     = Persistence.OneScalar(name = "CostFunctionJo")
-        self.StoredVariables["GradientOfCostFunctionJ"]            = Persistence.OneVector(name = "GradientOfCostFunctionJ")
-        self.StoredVariables["GradientOfCostFunctionJb"]           = Persistence.OneVector(name = "GradientOfCostFunctionJb")
-        self.StoredVariables["GradientOfCostFunctionJo"]           = Persistence.OneVector(name = "GradientOfCostFunctionJo")
-        self.StoredVariables["CurrentState"]                       = Persistence.OneVector(name = "CurrentState")
-        self.StoredVariables["Analysis"]                           = Persistence.OneVector(name = "Analysis")
-        self.StoredVariables["IndexOfOptimum"]                     = Persistence.OneIndex(name = "IndexOfOptimum")
-        self.StoredVariables["CurrentOptimum"]                     = Persistence.OneVector(name = "CurrentOptimum")
-        self.StoredVariables["SimulatedObservationAtBackground"]   = Persistence.OneVector(name = "SimulatedObservationAtBackground")
-        self.StoredVariables["SimulatedObservationAtCurrentState"] = Persistence.OneVector(name = "SimulatedObservationAtCurrentState")
-        self.StoredVariables["SimulatedObservationAtOptimum"]      = Persistence.OneVector(name = "SimulatedObservationAtOptimum")
+        self.StoredVariables["CostFunctionJ"]                        = Persistence.OneScalar(name = "CostFunctionJ")
+        self.StoredVariables["CostFunctionJb"]                       = Persistence.OneScalar(name = "CostFunctionJb")
+        self.StoredVariables["CostFunctionJo"]                       = Persistence.OneScalar(name = "CostFunctionJo")
+        self.StoredVariables["GradientOfCostFunctionJ"]              = Persistence.OneVector(name = "GradientOfCostFunctionJ")
+        self.StoredVariables["GradientOfCostFunctionJb"]             = Persistence.OneVector(name = "GradientOfCostFunctionJb")
+        self.StoredVariables["GradientOfCostFunctionJo"]             = Persistence.OneVector(name = "GradientOfCostFunctionJo")
+        self.StoredVariables["CurrentState"]                         = Persistence.OneVector(name = "CurrentState")
+        self.StoredVariables["Analysis"]                             = Persistence.OneVector(name = "Analysis")
+        self.StoredVariables["IndexOfOptimum"]                       = Persistence.OneIndex(name = "IndexOfOptimum")
+        self.StoredVariables["CurrentOptimum"]                       = Persistence.OneVector(name = "CurrentOptimum")
+        self.StoredVariables["SimulatedObservationAtBackground"]     = Persistence.OneVector(name = "SimulatedObservationAtBackground")
+        self.StoredVariables["SimulatedObservationAtCurrentState"]   = Persistence.OneVector(name = "SimulatedObservationAtCurrentState")
+        self.StoredVariables["SimulatedObservationAtOptimum"]        = Persistence.OneVector(name = "SimulatedObservationAtOptimum")
         self.StoredVariables["SimulatedObservationAtCurrentOptimum"] = Persistence.OneVector(name = "SimulatedObservationAtCurrentOptimum")
-        self.StoredVariables["Innovation"]                         = Persistence.OneVector(name = "Innovation")
-        self.StoredVariables["SigmaObs2"]                          = Persistence.OneScalar(name = "SigmaObs2")
-        self.StoredVariables["SigmaBck2"]                          = Persistence.OneScalar(name = "SigmaBck2")
-        self.StoredVariables["MahalanobisConsistency"]             = Persistence.OneScalar(name = "MahalanobisConsistency")
-        self.StoredVariables["OMA"]                                = Persistence.OneVector(name = "OMA")
-        self.StoredVariables["OMB"]                                = Persistence.OneVector(name = "OMB")
-        self.StoredVariables["BMA"]                                = Persistence.OneVector(name = "BMA")
-        self.StoredVariables["APosterioriCovariance"]              = Persistence.OneMatrix(name = "APosterioriCovariance")
-        self.StoredVariables["APosterioriVariances"]               = Persistence.OneVector(name = "APosterioriVariances")
-        self.StoredVariables["APosterioriStandardDeviations"]      = Persistence.OneVector(name = "APosterioriStandardDeviations")
-        self.StoredVariables["APosterioriCorrelations"]            = Persistence.OneMatrix(name = "APosterioriCorrelations")
-        self.StoredVariables["SimulationQuantiles"]                = Persistence.OneMatrix(name = "SimulationQuantiles")
+        self.StoredVariables["Innovation"]                           = Persistence.OneVector(name = "Innovation")
+        self.StoredVariables["InnovationAtCurrentState"]             = Persistence.OneVector(name = "InnovationAtCurrentState")
+        self.StoredVariables["SigmaObs2"]                            = Persistence.OneScalar(name = "SigmaObs2")
+        self.StoredVariables["SigmaBck2"]                            = Persistence.OneScalar(name = "SigmaBck2")
+        self.StoredVariables["MahalanobisConsistency"]               = Persistence.OneScalar(name = "MahalanobisConsistency")
+        self.StoredVariables["OMA"]                                  = Persistence.OneVector(name = "OMA")
+        self.StoredVariables["OMB"]                                  = Persistence.OneVector(name = "OMB")
+        self.StoredVariables["BMA"]                                  = Persistence.OneVector(name = "BMA")
+        self.StoredVariables["APosterioriCovariance"]                = Persistence.OneMatrix(name = "APosterioriCovariance")
+        self.StoredVariables["APosterioriVariances"]                 = Persistence.OneVector(name = "APosterioriVariances")
+        self.StoredVariables["APosterioriStandardDeviations"]        = Persistence.OneVector(name = "APosterioriStandardDeviations")
+        self.StoredVariables["APosterioriCorrelations"]              = Persistence.OneMatrix(name = "APosterioriCorrelations")
+        self.StoredVariables["SimulationQuantiles"]                  = Persistence.OneMatrix(name = "SimulationQuantiles")
 
     def _pre_run(self):
         logging.debug("%s Lancement"%self._name)
@@ -340,7 +342,7 @@ class Algorithm:
         return 0
 
     def _post_run(self,_oH=None):
-        if self._parameters.has_key("StoreSupplementaryCalculations") and \
+        if ("StoreSupplementaryCalculations" in self._parameters) and \
             "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
             for _A in self.StoredVariables["APosterioriCovariance"]:
                 if "APosterioriVariances" in self._parameters["StoreSupplementaryCalculations"]:
@@ -371,11 +373,11 @@ class Algorithm:
         else:
             return self.StoredVariables
 
-    def has_key(self, key=None):
+    def __contains__(self, key=None):
         """
         Vérifie si l'une des variables stockées est identifiée par la clé.
         """
-        return self.StoredVariables.has_key(key)
+        return (key in self.StoredVariables)
 
     def keys(self):
         """
index eecba7fb357ee295588f981c92a18206fa755a59..19ab915438f640ecacde1ea37eb0f0431fe9230f 100644 (file)
@@ -146,7 +146,7 @@ class Persistence:
             for tagKey in __filteringKwTags:
                 __tmp = []
                 for i in __indexOfFilteredItems:
-                    if self.__tags[i].has_key(tagKey):
+                    if tagKey in self.__tags[i]:
                         if self.__tags[i][tagKey] == kwargs[tagKey]:
                             __tmp.append( i )
                         elif isinstance(kwargs[tagKey],(list,tuple)) and self.__tags[i][tagKey] in kwargs[tagKey]:
@@ -164,7 +164,7 @@ class Persistence:
         __indexOfFilteredItems = self.__filteredIndexes(**kwargs)
         __keys = []
         for i in __indexOfFilteredItems:
-            if self.__tags[i].has_key( keyword ):
+            if keyword in self.__tags[i]:
                 __keys.append( self.__tags[i][keyword] )
             else:
                 __keys.append( None )
@@ -174,7 +174,7 @@ class Persistence:
         __indexOfFilteredItems = self.__filteredIndexes(**kwargs)
         __pairs = []
         for i in __indexOfFilteredItems:
-            if self.__tags[i].has_key( keyword ):
+            if keyword in self.__tags[i]:
                 __pairs.append( [self.__tags[i][keyword], self.__values[i]] )
             else:
                 __pairs.append( [None, self.__values[i]] )
index 95d3693fa12325dfeb027672baf67f512c33bcba..e82a5f09ae5cedba8aec44858697ac99849cce03 100644 (file)
@@ -246,6 +246,7 @@ OptDefaultDict["UserPostAnalysis"]   = "Template"
 ObserversList = [
     "Analysis",
     "Innovation",
+    "InnovationAtCurrentState",
     "CurrentState",
     "CurrentOptimum",
     "IndexOfOptimum",