]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Improvement and extension of 3DVAR algorithm
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 3 Mar 2021 21:18:21 +0000 (22:18 +0100)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Wed, 3 Mar 2021 21:18:21 +0000 (22:18 +0100)
src/daComposant/daAlgorithms/3DVAR.py
src/daComposant/daAlgorithms/4DVAR.py
src/daComposant/daCore/NumericObjects.py

index e8b0033714ee74ad3c6a1de909611ddd9d3f7e26..5024f7e1c0420d516763c3b497392209714c4517 100644 (file)
@@ -53,9 +53,15 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 ],
             listadv  = [
                 "3DVAR-Std",
-                "Incr3DVAR",
                 ],
             )
+        self.defineRequiredParameter(
+            name     = "EstimationOf",
+            default  = "Parameters",
+            typecast = str,
+            message  = "Estimation d'état ou de paramètres",
+            listval  = ["State", "Parameters"],
+            )
         self.defineRequiredParameter(
             name     = "MaximumNumberOfSteps",
             default  = 15000,
@@ -111,6 +117,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 "CurrentIterationNumber",
                 "CurrentOptimum",
                 "CurrentState",
+                "ForecastState",
                 "IndexOfOptimum",
                 "Innovation",
                 "InnovationAtCurrentState",
@@ -179,16 +186,17 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
         #--------------------------
         # Default 3DVAR
         if   self._parameters["Variant"] in ["3DVAR", "3DVAR-Std"]:
-            NumericObjects.std3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q)
+            NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.std3dvar)
         #
         elif self._parameters["Variant"] == "3DVAR-VAN":
-            NumericObjects.van3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q)
+            NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.van3dvar)
         #
         elif self._parameters["Variant"] in ["3DVAR-Incr", "Incr3DVAR"]:
-            NumericObjects.incr3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q)
+            NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.incr3dvar)
         #
         elif self._parameters["Variant"] == "3DVAR-PSAS":
-            NumericObjects.psas3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q)
+            NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.psas3dvar)
+        #
         #
         #--------------------------
         else:
index 75aeff340f96ccf3e7e379f72dc690d2cfa8f6ec..1f65d95f0391645cda456d392985205cd1048d0a 100644 (file)
@@ -39,7 +39,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             name     = "EstimationOf",
             default  = "State",
             typecast = str,
-            message  = "Estimation d'etat ou de parametres",
+            message  = "Estimation d'état ou de paramètres",
             listval  = ["State", "Parameters"],
             )
         self.defineRequiredParameter(
index ba218365f0a14a2b0474b874b81dda1b4714ec8a..bac05baacbf877e8ff1deafc191c7cfd300d6044 100644 (file)
@@ -642,6 +642,55 @@ def CovarianceInflation(
     #
     return OutputCovOrEns
 
+# ==============================================================================
+def multi3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, oneCycle):
+    """
+    Chapeau : 3DVAR multi-pas et multi-méthodes
+    """
+    #
+    # Initialisation
+    # --------------
+    Xn = numpy.ravel(Xb).reshape((-1,1))
+    #
+    if selfA._parameters["EstimationOf"] == "State":
+        M = EM["Direct"].appliedTo
+        #
+        if len(selfA.StoredVariables["Analysis"])==0 or not selfA._parameters["nextStep"]:
+            selfA.StoredVariables["Analysis"].store( Xn )
+            if selfA._toStore("APosterioriCovariance"):
+                if hasattr(B,"asfullmatrix"): Pn = B.asfullmatrix(Xn.size)
+                else:                         Pn = B
+                selfA.StoredVariables["APosterioriCovariance"].store( Pn )
+            if selfA._toStore("ForecastState"):
+                selfA.StoredVariables["ForecastState"].store( Xn )
+    #
+    if hasattr(Y,"stepnumber"):
+        duration = Y.stepnumber()
+    else:
+        duration = 2
+    #
+    # Multi-pas
+    # ---------
+    for step in range(duration-1):
+        if hasattr(Y,"store"):
+            Ynpu = numpy.ravel( Y[step+1] ).reshape((-1,1))
+        else:
+            Ynpu = numpy.ravel( Y ).reshape((-1,1))
+        #
+        if selfA._parameters["EstimationOf"] == "State": # Forecast
+            Xn = selfA.StoredVariables["Analysis"][-1]
+            Xn_predicted = M( Xn )
+            if selfA._toStore("ForecastState"):
+                selfA.StoredVariables["ForecastState"].store( Xn_predicted )
+        elif selfA._parameters["EstimationOf"] == "Parameters": # No forecast
+            # --- > Par principe, M = Id, Q = 0
+            Xn_predicted = Xn
+        Xn_predicted = numpy.ravel(Xn_predicted).reshape((-1,1))
+        #
+        oneCycle(selfA, Xn_predicted, Ynpu, U, HO, None, None, R, B, None)
+    #
+    return 0
+
 # ==============================================================================
 def std3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q):
     """