From: Jean-Philippe ARGAUD Date: Wed, 3 Mar 2021 21:18:21 +0000 (+0100) Subject: Improvement and extension of 3DVAR algorithm X-Git-Tag: V9_7_0b1~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d4df180b8094af2cfeee7533aaee4bf27529cc4a;p=modules%2Fadao.git Improvement and extension of 3DVAR algorithm --- diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index e8b0033..5024f7e 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -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: diff --git a/src/daComposant/daAlgorithms/4DVAR.py b/src/daComposant/daAlgorithms/4DVAR.py index 75aeff3..1f65d95 100644 --- a/src/daComposant/daAlgorithms/4DVAR.py +++ b/src/daComposant/daAlgorithms/4DVAR.py @@ -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( diff --git a/src/daComposant/daCore/NumericObjects.py b/src/daComposant/daCore/NumericObjects.py index ba21836..bac05ba 100644 --- a/src/daComposant/daCore/NumericObjects.py +++ b/src/daComposant/daCore/NumericObjects.py @@ -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): """