],
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,
"CurrentIterationNumber",
"CurrentOptimum",
"CurrentState",
+ "ForecastState",
"IndexOfOptimum",
"Innovation",
"InnovationAtCurrentState",
#--------------------------
# 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:
#
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):
"""