]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Minor improvements for internal method variables
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Sat, 23 Jan 2021 15:10:07 +0000 (16:10 +0100)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Sat, 23 Jan 2021 15:10:07 +0000 (16:10 +0100)
src/daComposant/daAlgorithms/EnsembleKalmanFilter.py
src/daComposant/daCore/NumericObjects.py

index add3480fd37013ec3ab61fbee9c83b8aed101fff..6b35a9d357c1f86c3def473253e35d7dbdf571cc 100644 (file)
@@ -43,11 +43,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             listadv  = [
                 "ETKF-KFF",
                 "ETKF-VAR",
-                "EnKF-N",
-                "ETKF-N-11", "EnKF-N-11",
-                "ETKF-N-15", "EnKF-N-15",
-                "ETKF-N-16", "EnKF-N-16",
-                "MLEF-B",
+                "ETKF-N-11",
+                "ETKF-N-15",
+                "ETKF-N-16",
                 "MLEF-T",
                 ],
             )
@@ -174,21 +172,21 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         #--------------------------
         # Default ETKF = ETKF-KFF
         elif self._parameters["Minimizer"] in ["ETKF-KFF", "ETKF"]:
-            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula")
+            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="KalmanFilterFormula")
         #
         elif self._parameters["Minimizer"] == "ETKF-VAR":
-            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="Variational")
+            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="Variational")
         #
         #--------------------------
         # Default ETKF-N = ETKF-N-16
         elif self._parameters["Minimizer"] == "ETKF-N-11":
-            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="FiniteSize11")
+            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="FiniteSize11")
         #
         elif self._parameters["Minimizer"] == "ETKF-N-15":
-            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="FiniteSize15")
+            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="FiniteSize15")
         #
         elif self._parameters["Minimizer"] in ["ETKF-N-16", "ETKF-N"]:
-            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="FiniteSize16")
+            NumericObjects.etkf(self, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="FiniteSize16")
         #
         #--------------------------
         # Default MLEF = MLEF-B
index 836400dbf6baea18f14be9f7eb98d6dfefab58b3..fa72bb35acc690e4036c972818fb517a85b549b9 100644 (file)
@@ -849,7 +849,7 @@ def senkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q):
     return 0
 
 # ==============================================================================
-def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
+def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="KalmanFilterFormula"):
     """
     Ensemble-Transform EnKF (ETKF or Deterministic EnKF: Bishop 2001, Hunt 2007)
 
@@ -890,22 +890,22 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
         or selfA._toStore("APosterioriCovariance"):
         BI = B.getI()
         RI = R.getI()
-    elif KorV != "KalmanFilterFormula":
+    elif VariantM != "KalmanFilterFormula":
         RI = R.getI()
-    if KorV == "KalmanFilterFormula":
+    if VariantM == "KalmanFilterFormula":
         RIdemi = R.choleskyI()
     #
     # Initialisation
     # --------------
     __n = Xb.size
     __m = selfA._parameters["NumberOfMembers"]
-    Xn = numpy.asmatrix(numpy.dot( Xb.reshape(__n,1), numpy.ones((1,__m)) ))
     if hasattr(B,"asfullmatrix"): Pn = B.asfullmatrix(__n)
     else:                         Pn = B
     if hasattr(R,"asfullmatrix"): Rn = R.asfullmatrix(__p)
     else:                         Rn = R
     if hasattr(Q,"asfullmatrix"): Qn = Q.asfullmatrix(__n)
     else:                         Qn = Q
+    Xn = numpy.asmatrix(numpy.dot( Xb.reshape((__n,1)), numpy.ones((1,__m)) ))
     #
     if len(selfA.StoredVariables["Analysis"])==0 or not selfA._parameters["nextStep"]:
         selfA.StoredVariables["Analysis"].store( numpy.ravel(Xb) )
@@ -917,7 +917,6 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
     #
     # Predimensionnement
     Xn_predicted = numpy.asmatrix(numpy.zeros((__n,__m)))
-    HX_predicted = numpy.asmatrix(numpy.zeros((__p,__m)))
     #
     for step in range(duration-1):
         if hasattr(Y,"store"):
@@ -963,11 +962,12 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
         Xfm  = Xn_predicted.mean(axis=1, dtype=mfp).astype('float')
         Hfm  = HX_predicted.mean(axis=1, dtype=mfp).astype('float')
         #
+        # Anomalies
         EaX   = numpy.matrix(Xn_predicted - Xfm.reshape((__n,-1)))
         EaHX  = numpy.matrix(HX_predicted - Hfm.reshape((__p,-1)))
         #
         #--------------------------
-        if KorV == "KalmanFilterFormula":
+        if VariantM == "KalmanFilterFormula":
             EaX    = EaX / numpy.sqrt(__m-1)
             mS    = RIdemi * EaHX / numpy.sqrt(__m-1)
             delta = RIdemi * ( Ynpu.reshape((__p,-1)) - Hfm.reshape((__p,-1)) )
@@ -979,7 +979,7 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
             #
             Xn = Xfm.reshape((__n,-1)) + EaX @ ( vw.reshape((__m,-1)) + numpy.sqrt(__m-1) * Tdemi @ mU )
         #--------------------------
-        elif KorV == "Variational":
+        elif VariantM == "Variational":
             HXfm = H((Xfm, Un)) # Eventuellement Hfm
             def CostFunction(w):
                 _A  = Ynpu.reshape((__p,-1)) - HXfm.reshape((__p,-1)) - (EaHX @ w).reshape((__p,-1))
@@ -1010,7 +1010,7 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
             #
             Xn = Xfm.reshape((__n,-1)) + EaX @ (vw.reshape((__m,-1)) + EWa)
         #--------------------------
-        elif KorV == "FiniteSize11": # Jauge Boc2011
+        elif VariantM == "FiniteSize11": # Jauge Boc2011
             HXfm = H((Xfm, Un)) # Eventuellement Hfm
             def CostFunction(w):
                 _A  = Ynpu.reshape((__p,-1)) - HXfm.reshape((__p,-1)) - (EaHX @ w).reshape((__p,-1))
@@ -1043,7 +1043,7 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
             #
             Xn = Xfm.reshape((__n,-1)) + EaX @ (vw.reshape((__m,-1)) + EWa)
         #--------------------------
-        elif KorV == "FiniteSize15": # Jauge Boc2015
+        elif VariantM == "FiniteSize15": # Jauge Boc2015
             HXfm = H((Xfm, Un)) # Eventuellement Hfm
             def CostFunction(w):
                 _A  = Ynpu.reshape((__p,-1)) - HXfm.reshape((__p,-1)) - (EaHX @ w).reshape((__p,-1))
@@ -1076,7 +1076,7 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
             #
             Xn = Xfm.reshape((__n,-1)) + EaX @ (vw.reshape((__m,-1)) + EWa)
         #--------------------------
-        elif KorV == "FiniteSize16": # Jauge Boc2016
+        elif VariantM == "FiniteSize16": # Jauge Boc2016
             HXfm = H((Xfm, Un)) # Eventuellement Hfm
             def CostFunction(w):
                 _A  = Ynpu.reshape((__p,-1)) - HXfm.reshape((__p,-1)) - (EaHX @ w).reshape((__p,-1))
@@ -1110,7 +1110,7 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, KorV="KalmanFilterFormula"):
             Xn = Xfm.reshape((__n,-1)) + EaX @ (vw.reshape((__m,-1)) + EWa)
         #--------------------------
         else:
-            raise ValueError("KorV has to be chosen in the authorized methods list.")
+            raise ValueError("VariantM has to be chosen in the authorized methods list.")
         #
         if selfA._parameters["InflationType"] == "MultiplicativeOnAnalysisAnomalies":
             Xn = CovarianceInflation( Xn,