"CostFunctionJb",
"CostFunctionJo",
"Innovation",
+ "PredictedState",
]
)
self.defineRequiredParameter( # Pas de type
#
# Opérateurs
# ----------
- if B is None:
- raise ValueError("Background error covariance matrix has to be properly defined!")
- if R is None:
- raise ValueError("Observation error covariance matrix has to be properly defined!")
- #
H = HO["Direct"].appliedControledFormTo
#
if self._parameters["EstimationOf"] == "State":
#
# Précalcul des inversions de B et R
# ----------------------------------
- if self._parameters["StoreInternalVariables"]:
+ if self._parameters["StoreInternalVariables"] \
+ or self._toStore("CostFunctionJ") \
+ or self._toStore("CostFunctionJb") \
+ or self._toStore("CostFunctionJo"):
BI = B.getI()
RI = R.getI()
#
Pn = B
#
self.StoredVariables["Analysis"].store( Xn.A1 )
- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("APosterioriCovariance"):
self.StoredVariables["APosterioriCovariance"].store( Pn.asfullmatrix(Xn.size) )
covarianceXa = Pn
Xa = Xn
Pn = Pn_predicted - Kn * Ht * Pn_predicted
#
self.StoredVariables["Analysis"].store( Xn.A1 )
- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("APosterioriCovariance"):
self.StoredVariables["APosterioriCovariance"].store( Pn )
- if "Innovation" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("Innovation"):
self.StoredVariables["Innovation"].store( numpy.ravel( d.A1 ) )
- if self._parameters["StoreInternalVariables"] or "CurrentState" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._parameters["StoreInternalVariables"] \
+ or self._toStore("CurrentState"):
self.StoredVariables["CurrentState"].store( Xn )
if self._parameters["StoreInternalVariables"] \
- or "CostFunctionJ" in self._parameters["StoreSupplementaryCalculations"] \
- or "CostFunctionJb" in self._parameters["StoreSupplementaryCalculations"] \
- or "CostFunctionJo" in self._parameters["StoreSupplementaryCalculations"]:
+ or self._toStore("PredictedState"):
+ self.StoredVariables["PredictedState"].store( Xn_predicted )
+ if self._parameters["StoreInternalVariables"] \
+ or self._toStore("CostFunctionJ") \
+ or self._toStore("CostFunctionJb") \
+ or self._toStore("CostFunctionJo"):
Jb = 0.5 * (Xn - Xb).T * BI * (Xn - Xb)
Jo = 0.5 * d.T * RI * d
J = float( Jb ) + float( Jo )
if J < previousJMinimum:
previousJMinimum = J
Xa = Xn
- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("APosterioriCovariance"):
covarianceXa = Pn
else:
Xa = Xn
# ----------------------------------------------------------------
if self._parameters["EstimationOf"] == "Parameters":
self.StoredVariables["Analysis"].store( Xa.A1 )
- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("APosterioriCovariance"):
self.StoredVariables["APosterioriCovariance"].store( covarianceXa )
#
- if "BMA" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("BMA"):
self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
#
self._post_run(HO)
"CostFunctionJb",
"CostFunctionJo",
"Innovation",
+ "PredictedState",
]
)
self.requireInputArguments(
# Précalcul des inversions de B et R
# ----------------------------------
if self._parameters["StoreInternalVariables"] \
- or "CostFunctionJ" in self._parameters["StoreSupplementaryCalculations"] \
- or "CostFunctionJb" in self._parameters["StoreSupplementaryCalculations"] \
- or "CostFunctionJo" in self._parameters["StoreSupplementaryCalculations"]:
+ or self._toStore("CostFunctionJ") \
+ or self._toStore("CostFunctionJb") \
+ or self._toStore("CostFunctionJo"):
BI = B.getI()
RI = R.getI()
#
Pn = B
#
self.StoredVariables["Analysis"].store( Xn.A1 )
- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("APosterioriCovariance"):
self.StoredVariables["APosterioriCovariance"].store( Pn.asfullmatrix(Xn.size) )
covarianceXa = Pn
Xa = Xn
Pn = Pn_predicted - Kn * Ht * Pn_predicted
#
self.StoredVariables["Analysis"].store( Xn.A1 )
- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("APosterioriCovariance"):
self.StoredVariables["APosterioriCovariance"].store( Pn )
- if "Innovation" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("Innovation"):
self.StoredVariables["Innovation"].store( numpy.ravel( d.A1 ) )
if self._parameters["StoreInternalVariables"] \
- or "CurrentState" in self._parameters["StoreSupplementaryCalculations"]:
+ or self._toStore("CurrentState"):
self.StoredVariables["CurrentState"].store( Xn )
if self._parameters["StoreInternalVariables"] \
- or "CostFunctionJ" in self._parameters["StoreSupplementaryCalculations"] \
- or "CostFunctionJb" in self._parameters["StoreSupplementaryCalculations"] \
- or "CostFunctionJo" in self._parameters["StoreSupplementaryCalculations"]:
+ or self._toStore("PredictedState"):
+ self.StoredVariables["PredictedState"].store( Xn_predicted )
+ if self._parameters["StoreInternalVariables"] \
+ or self._toStore("CostFunctionJ") \
+ or self._toStore("CostFunctionJb") \
+ or self._toStore("CostFunctionJo"):
Jb = 0.5 * (Xn - Xb).T * BI * (Xn - Xb)
Jo = 0.5 * d.T * RI * d
J = float( Jb ) + float( Jo )
if J < previousJMinimum:
previousJMinimum = J
Xa = Xn
- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("APosterioriCovariance"):
covarianceXa = Pn
else:
Xa = Xn
# ----------------------------------------------------------------
if self._parameters["EstimationOf"] == "Parameters":
self.StoredVariables["Analysis"].store( Xa.A1 )
- if "APosterioriCovariance" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("APosterioriCovariance"):
self.StoredVariables["APosterioriCovariance"].store( covarianceXa )
#
- if "BMA" in self._parameters["StoreSupplementaryCalculations"]:
+ if self._toStore("BMA"):
self.StoredVariables["BMA"].store( numpy.ravel(Xb) - numpy.ravel(Xa) )
#
self._post_run(HO)
self.StoredVariables["GradientOfCostFunctionJb"] = Persistence.OneVector(name = "GradientOfCostFunctionJb")
self.StoredVariables["GradientOfCostFunctionJo"] = Persistence.OneVector(name = "GradientOfCostFunctionJo")
self.StoredVariables["CurrentState"] = Persistence.OneVector(name = "CurrentState")
+ self.StoredVariables["PredictedState"] = Persistence.OneVector(name = "PredictedState")
self.StoredVariables["Analysis"] = Persistence.OneVector(name = "Analysis")
self.StoredVariables["IndexOfOptimum"] = Persistence.OneIndex(name = "IndexOfOptimum")
self.StoredVariables["CurrentOptimum"] = Persistence.OneVector(name = "CurrentOptimum")
self.__setParameters(Parameters)
#
# Corrections et complements
- def __test_vvalue( argument, variable, argname):
+ def __test_vvalue(argument, variable, argname):
if argument is None:
if variable in self.__required_inputs["RequiredInputValues"]["mandatory"]:
raise ValueError("%s %s vector %s has to be properly defined!"%(self._name,argname,variable))
logging.debug("%s %s vector %s is not set, but is not required."%(self._name,argname,variable))
else:
logging.debug("%s %s vector %s is set, and its size is %i."%(self._name,argname,variable,numpy.array(argument).size))
+ return 0
__test_vvalue( Xb, "Xb", "Background or initial state" )
__test_vvalue( Y, "Y", "Observation" )
- def __test_cvalue( argument, variable, argname):
+ #
+ def __test_cvalue(argument, variable, argname):
if argument is None:
if variable in self.__required_inputs["RequiredInputValues"]["mandatory"]:
raise ValueError("%s %s error covariance matrix %s has to be properly defined!"%(self._name,argname,variable))
logging.debug("%s %s error covariance matrix %s is not set, but is not required."%(self._name,argname,variable))
else:
logging.debug("%s %s error covariance matrix %s is set."%(self._name,argname,variable))
+ return 0
__test_cvalue( R, "R", "Observation" )
__test_cvalue( B, "B", "Background" )
__test_cvalue( Q, "Q", "Evolution" )
logging.debug("%s Terminé", self._name)
return 0
+ def _toStore(self, key):
+ "True if in StoreSupplementaryCalculations, else False"
+ return key in self._parameters["StoreSupplementaryCalculations"]
+
def get(self, key=None):
"""
Renvoie l'une des variables stockées identifiée par la clé, ou le