1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2008-2021 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é",
43 self.defineRequiredParameter(
44 name = "NumberOfMembers",
47 message = "Nombre de membres dans l'ensemble",
50 self.defineRequiredParameter(
51 name = "EstimationOf",
54 message = "Estimation d'etat ou de parametres",
55 listval = ["State", "Parameters"],
57 self.defineRequiredParameter(
58 name = "InflationType",
59 default = "MultiplicativeOnAnalysisCovariance",
61 message = "Méthode d'inflation d'ensemble",
63 "MultiplicativeOnAnalysisCovariance",
64 "MultiplicativeOnBackgroundCovariance",
65 "MultiplicativeOnAnalysisAnomalies",
66 "MultiplicativeOnBackgroundAnomalies",
67 "AdditiveOnBackgroundCovariance",
68 "AdditiveOnAnalysisCovariance",
69 "HybridOnBackgroundCovariance",
72 self.defineRequiredParameter(
73 name = "InflationFactor",
76 message = "Facteur d'inflation",
79 self.defineRequiredParameter(
80 name = "LocalizationType",
81 default = "SchurLocalization",
83 message = "Méthode d'inflation d'ensemble",
85 "CovarianceLocalization",
88 "GaspariCohnLocalization",
91 self.defineRequiredParameter(
92 name = "LocalizationFactor",
95 message = "Facteur de localisation",
98 self.defineRequiredParameter( # Pas de type
99 name = "LocalizationMatrix",
100 message = "Matrice de localisation ou de distances",
102 self.defineRequiredParameter(
104 typecast = numpy.random.seed,
105 message = "Graine fixée pour le générateur aléatoire",
107 self.defineRequiredParameter(
108 name = "StoreInternalVariables",
111 message = "Stockage des variables internes ou intermédiaires du calcul",
113 self.defineRequiredParameter(
114 name = "StoreSupplementaryCalculations",
117 message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
120 "APosterioriCorrelations",
121 "APosterioriCovariance",
122 "APosterioriStandardDeviations",
123 "APosterioriVariances",
126 "CostFunctionJAtCurrentOptimum",
128 "CostFunctionJbAtCurrentOptimum",
130 "CostFunctionJoAtCurrentOptimum",
131 "CurrentIterationNumber",
136 "InnovationAtCurrentAnalysis",
137 "InnovationAtCurrentState",
138 "SimulatedObservationAtCurrentAnalysis",
139 "SimulatedObservationAtCurrentOptimum",
140 "SimulatedObservationAtCurrentState",
143 self.requireInputArguments(
144 mandatory= ("Xb", "Y", "HO", "R", "B"),
145 optional = ("U", "EM", "CM", "Q"),
147 self.setAttributes(tags=(
155 def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
156 self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q)
158 if self._parameters["Minimizer"] == "StochasticEnKF":
159 NumericObjects.senkf(self, Xb, Y, U, HO, EM, CM, R, B, Q)
160 elif self._parameters["Minimizer"] in ["ETKF", "ETKF-KFF"]:
161 NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula")
162 elif self._parameters["Minimizer"] == "ETKF-VAR":
163 NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="Variational")
165 raise ValueError("Error in Minimizer name: %s"%self._parameters["Minimizer"])
170 # ==============================================================================
171 if __name__ == "__main__":
172 print('\n AUTODIAGNOSTIC\n')