From: Jean-Philippe ARGAUD Date: Wed, 9 Sep 2015 19:55:14 +0000 (+0200) Subject: Adding user variable and minor corrections X-Git-Tag: V7_7_0rc1~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6af0d30e581d4dd8365ff9e1bf5a51d34e5ad28d;p=modules%2Fadao.git Adding user variable and minor corrections --- diff --git a/doc/en/ref_algorithm_3DVAR.rst b/doc/en/ref_algorithm_3DVAR.rst index ed3ef44..660ba8a 100644 --- a/doc/en/ref_algorithm_3DVAR.rst +++ b/doc/en/ref_algorithm_3DVAR.rst @@ -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"]. diff --git a/doc/fr/ref_algorithm_3DVAR.rst b/doc/fr/ref_algorithm_3DVAR.rst index b6b3b97..d1b550c 100644 --- a/doc/fr/ref_algorithm_3DVAR.rst +++ b/doc/fr/ref_algorithm_3DVAR.rst @@ -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"]. diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index ae62c43..039348b 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -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 ) diff --git a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py index fdc69cc..1d66ef7 100644 --- a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py @@ -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 diff --git a/src/daComposant/daAlgorithms/KalmanFilter.py b/src/daComposant/daAlgorithms/KalmanFilter.py index 9695541..110692f 100644 --- a/src/daComposant/daAlgorithms/KalmanFilter.py +++ b/src/daComposant/daAlgorithms/KalmanFilter.py @@ -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 diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 8640705..eda0a11 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -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): """ diff --git a/src/daComposant/daCore/Persistence.py b/src/daComposant/daCore/Persistence.py index eecba7f..19ab915 100644 --- a/src/daComposant/daCore/Persistence.py +++ b/src/daComposant/daCore/Persistence.py @@ -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]] ) diff --git a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py index 95d3693..e82a5f0 100644 --- a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py +++ b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py @@ -246,6 +246,7 @@ OptDefaultDict["UserPostAnalysis"] = "Template" ObserversList = [ "Analysis", "Innovation", + "InnovationAtCurrentState", "CurrentState", "CurrentOptimum", "IndexOfOptimum",