1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2020 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 from daCore import BasicObjects, NumericObjects
27 # ==============================================================================
28 class ElementaryAlgorithm(BasicObjects.Algorithm):
30 BasicObjects.Algorithm.__init__(self, "ENSEMBLEKALMANFILTER")
31 self.defineRequiredParameter(
33 default = "StochasticEnKF",
35 message = "Minimiseur utilisé",
42 self.defineRequiredParameter(
43 name = "NumberOfMembers",
46 message = "Nombre de membres dans l'ensemble",
49 self.defineRequiredParameter(
50 name = "EstimationOf",
53 message = "Estimation d'etat ou de parametres",
54 listval = ["State", "Parameters"],
56 self.defineRequiredParameter(
57 name = "InflationType",
58 default = "MultiplicativeOnAnalysisCovariance",
60 message = "Méthode d'inflation d'ensemble",
62 "MultiplicativeOnAnalysisCovariance",
63 "MultiplicativeOnBackgroundCovariance",
64 "MultiplicativeOnAnalysisAnomalies",
65 "MultiplicativeOnBackgroundAnomalies",
66 "AdditiveOnBackgroundCovariance",
67 "AdditiveOnAnalysisCovariance",
68 "HybridOnBackgroundCovariance",
71 self.defineRequiredParameter(
72 name = "InflationFactor",
75 message = "Facteur d'inflation",
78 self.defineRequiredParameter(
79 name = "LocalizationType",
80 default = "SchurLocalization",
82 message = "Méthode d'inflation d'ensemble",
84 "CovarianceLocalization",
87 "GaspariCohnLocalization",
90 self.defineRequiredParameter(
91 name = "LocalizationFactor",
94 message = "Facteur de localisation",
97 self.defineRequiredParameter( # Pas de type
98 name = "LocalizationMatrix",
99 message = "Matrice de localisation ou de distances",
101 self.defineRequiredParameter(
103 typecast = numpy.random.seed,
104 message = "Graine fixée pour le générateur aléatoire",
106 self.defineRequiredParameter(
107 name = "StoreInternalVariables",
110 message = "Stockage des variables internes ou intermédiaires du calcul",
112 self.defineRequiredParameter(
113 name = "StoreSupplementaryCalculations",
116 message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
119 "APosterioriCorrelations",
120 "APosterioriCovariance",
121 "APosterioriStandardDeviations",
122 "APosterioriVariances",
125 "CostFunctionJAtCurrentOptimum",
127 "CostFunctionJbAtCurrentOptimum",
129 "CostFunctionJoAtCurrentOptimum",
130 "CurrentIterationNumber",
135 "InnovationAtCurrentAnalysis",
136 "InnovationAtCurrentState",
137 "SimulatedObservationAtCurrentAnalysis",
138 "SimulatedObservationAtCurrentOptimum",
139 "SimulatedObservationAtCurrentState",
142 self.requireInputArguments(
143 mandatory= ("Xb", "Y", "HO", "R", "B"),
144 optional = ("U", "EM", "CM", "Q"),
146 self.setAttributes(tags=(
154 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
155 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
157 if self._parameters["Minimizer"] == "StochasticEnKF":
158 NumericObjects.senkf(self, Xb, Y, U, HO, EM, CM, R, B, Q)
159 elif self._parameters["Minimizer"] in ["ETKF", "ETKF-KFF"]:
160 NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula")
162 raise ValueError("Error in Minimizer name: %s"%self._parameters["Minimizer"])
167 # ==============================================================================
168 if __name__ == "__main__":
169 print('\n AUTODIAGNOSTIC\n')