From: Jean-Philippe ARGAUD Date: Fri, 5 Mar 2021 05:27:29 +0000 (+0100) Subject: Minor improvements and fixes for internal variables X-Git-Tag: V9_7_0b1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1d58ac2bea1b52b8cbca81320ddbf9f5ca9ccaf5;p=modules%2Fadao.git Minor improvements and fixes for internal variables --- diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index 5024f7e..5606dfe 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -53,6 +53,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): ], listadv = [ "3DVAR-Std", + "OneCycle3DVAR-Std", ], ) self.defineRequiredParameter( @@ -197,6 +198,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): elif self._parameters["Variant"] == "3DVAR-PSAS": NumericObjects.multi3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q, NumericObjects.psas3dvar) # + #-------------------------- + elif self._parameters["Variant"] == "OneCycle3DVAR-Std": + NumericObjects.std3dvar(self, Xb, Y, U, HO, EM, CM, R, B, Q) # #-------------------------- else: diff --git a/src/daComposant/daAlgorithms/4DVAR.py b/src/daComposant/daAlgorithms/4DVAR.py index 1f65d95..da643e6 100644 --- a/src/daComposant/daAlgorithms/4DVAR.py +++ b/src/daComposant/daAlgorithms/4DVAR.py @@ -126,10 +126,6 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None): self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q) # - # Correction pour pallier a un bug de TNC sur le retour du Minimum - if "Minimizer" in self._parameters and self._parameters["Minimizer"] == "TNC": - self.setParameterValue("StoreInternalVariables",True) - # # Opérateurs # ---------- Hm = HO["Direct"].appliedControledFormTo diff --git a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py index 65b6fe4..aad66fc 100644 --- a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py +++ b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py @@ -118,10 +118,6 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None): self._pre_run(Parameters, Xb, Y, U, HO, EM, CM, R, B, Q) # - # Correction pour pallier a un bug de TNC sur le retour du Minimum - if "Minimizer" in self._parameters and self._parameters["Minimizer"] == "TNC": - self.setParameterValue("StoreInternalVariables",True) - # # Opérateurs # ---------- Hm = HO["Direct"].appliedTo diff --git a/src/daComposant/daCore/BasicObjects.py b/src/daComposant/daCore/BasicObjects.py index 66e9ab9..3406124 100644 --- a/src/daComposant/daCore/BasicObjects.py +++ b/src/daComposant/daCore/BasicObjects.py @@ -759,6 +759,7 @@ class Algorithm(object): __test_ovalue( EM, "EM", "Evolution", "M" ) __test_ovalue( CM, "CM", "Control Model", "C" ) # + # Corrections et compléments des bornes if ("Bounds" in self._parameters) and isinstance(self._parameters["Bounds"], (list, tuple)) and (len(self._parameters["Bounds"]) > 0): logging.debug("%s Prise en compte des bornes effectuee"%(self._name,)) else: @@ -777,6 +778,12 @@ class Algorithm(object): else: if self._parameters["InitializationPoint"] is None: raise ValueError("Forced initial point can not be set without any given Background or required value") + # + # Correction pour pallier a un bug de TNC sur le retour du Minimum + if "Minimizer" in self._parameters and self._parameters["Minimizer"] == "TNC": + self.setParameterValue("StoreInternalVariables",True) + # + # Verbosité et logging if logging.getLogger().level < logging.WARNING: self._parameters["optiprint"], self._parameters["optdisp"] = 1, 1 if PlatformInfo.has_scipy: diff --git a/src/daComposant/daCore/NumericObjects.py b/src/daComposant/daCore/NumericObjects.py index bac05ba..cb91764 100644 --- a/src/daComposant/daCore/NumericObjects.py +++ b/src/daComposant/daCore/NumericObjects.py @@ -700,10 +700,6 @@ def std3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): valeurs. """ # - # Correction pour pallier a un bug de TNC sur le retour du Minimum - if "Minimizer" in selfA._parameters and selfA._parameters["Minimizer"] == "TNC": - selfA.setParameterValue("StoreInternalVariables",True) - # # Opérateurs # ---------- Hm = HO["Direct"].appliedTo @@ -872,7 +868,7 @@ def std3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): # ---------------------- Xa = numpy.asmatrix(numpy.ravel( Minimum )).T # - selfA.StoredVariables["Analysis"].store( Xa.A1 ) + selfA.StoredVariables["Analysis"].store( Xa ) # if selfA._toStore("OMA") or \ selfA._toStore("SigmaObs2") or \ @@ -988,10 +984,6 @@ def van3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): valeurs. """ # - # Correction pour pallier a un bug de TNC sur le retour du Minimum - if "Minimizer" in selfA._parameters and selfA._parameters["Minimizer"] == "TNC": - selfA.setParameterValue("StoreInternalVariables",True) - # # Initialisations # --------------- Hm = HO["Direct"].appliedTo @@ -1263,10 +1255,6 @@ def incr3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): valeurs. """ # - # Correction pour pallier a un bug de TNC sur le retour du Minimum - if "Minimizer" in selfA._parameters and selfA._parameters["Minimizer"] == "TNC": - selfA.setParameterValue("StoreInternalVariables",True) - # # Initialisations # --------------- # @@ -1556,10 +1544,6 @@ def psas3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): valeurs. """ # - # Correction pour pallier a un bug de TNC sur le retour du Minimum - if "Minimizer" in selfA._parameters and selfA._parameters["Minimizer"] == "TNC": - selfA.setParameterValue("StoreInternalVariables",True) - # # Initialisations # --------------- # @@ -1891,7 +1875,7 @@ def senkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="KalmanFilterFormula"): Xn = EnsembleOfBackgroundPerturbations( Xb, None, __m ) # if len(selfA.StoredVariables["Analysis"])==0 or not selfA._parameters["nextStep"]: - selfA.StoredVariables["Analysis"].store( numpy.ravel(Xb) ) + selfA.StoredVariables["Analysis"].store( Xb ) if selfA._toStore("APosterioriCovariance"): selfA.StoredVariables["APosterioriCovariance"].store( Pn ) covarianceXa = Pn @@ -2132,7 +2116,7 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="KalmanFilterFormula"): Xn = EnsembleOfBackgroundPerturbations( Xb, None, __m ) # if len(selfA.StoredVariables["Analysis"])==0 or not selfA._parameters["nextStep"]: - selfA.StoredVariables["Analysis"].store( numpy.ravel(Xb) ) + selfA.StoredVariables["Analysis"].store( Xb ) if selfA._toStore("APosterioriCovariance"): selfA.StoredVariables["APosterioriCovariance"].store( Pn ) covarianceXa = Pn @@ -2182,7 +2166,7 @@ def etkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="KalmanFilterFormula"): # # Mean of forecast and observation of forecast Xfm = Xn_predicted.mean(axis=1, dtype=mfp).astype('float').reshape((__n,-1)) - Hfm = HX_predicted.mean(axis=1, dtype=mfp).astype('float').reshape((__p,1)) + Hfm = HX_predicted.mean(axis=1, dtype=mfp).astype('float').reshape((__p,-1)) # # Anomalies EaX = EnsembleOfAnomalies( Xn_predicted ) @@ -2488,7 +2472,7 @@ def mlef(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="MLEF13", Xn = EnsembleOfBackgroundPerturbations( Xb, None, __m ) # if len(selfA.StoredVariables["Analysis"])==0 or not selfA._parameters["nextStep"]: - selfA.StoredVariables["Analysis"].store( numpy.ravel(Xb) ) + selfA.StoredVariables["Analysis"].store( Xb ) if selfA._toStore("APosterioriCovariance"): selfA.StoredVariables["APosterioriCovariance"].store( Pn ) covarianceXa = Pn @@ -2731,7 +2715,7 @@ def ienkf(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="IEnKF12", Xn = EnsembleOfBackgroundPerturbations( Xb, Pn, __m ) # if len(selfA.StoredVariables["Analysis"])==0 or not selfA._parameters["nextStep"]: - selfA.StoredVariables["Analysis"].store( numpy.ravel(Xb) ) + selfA.StoredVariables["Analysis"].store( Xb ) if selfA._toStore("APosterioriCovariance"): selfA.StoredVariables["APosterioriCovariance"].store( Pn ) covarianceXa = Pn