From c7e69d202d1133cf8bc95b2e07b52b0db8bdb252 Mon Sep 17 00:00:00 2001 From: Jean-Philippe ARGAUD Date: Fri, 1 Oct 2021 20:50:38 +0200 Subject: [PATCH] Minor internal modifications --- .../daAlgorithms/NonLinearLeastSquares.py | 13 ++++--------- src/daComposant/daCore/Aidsm.py | 4 ++++ src/daComposant/daCore/Interfaces.py | 4 ++-- src/daComposant/daCore/NumericObjects.py | 18 +----------------- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py index d0afe68..61a2613 100644 --- a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py +++ b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py @@ -107,8 +107,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): message = "État initial imposé (par défaut, c'est l'ébauche si None)", ) self.requireInputArguments( - mandatory= ("Xb", "Y", "HO"), - optional = ("R"), + mandatory= ("Xb", "Y", "HO", "R"), ) self.setAttributes(tags=( "Optimization", @@ -136,13 +135,9 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): if max(Y.shape) != max(HXb.shape): raise ValueError("The shapes %s of observations Y and %s of observed calculation H(X) are different, they have to be identical."%(Y.shape,HXb.shape)) # - if R is None: - RI = 1. - RdemiI = 1. - else: - RI = R.getI() - if self._parameters["Minimizer"] == "LM": - RdemiI = R.choleskyI() + RI = R.getI() + if self._parameters["Minimizer"] == "LM": + RdemiI = R.choleskyI() # # Définition de la fonction-coût # ------------------------------ diff --git a/src/daComposant/daCore/Aidsm.py b/src/daComposant/daCore/Aidsm.py index 79ddef2..6937f32 100644 --- a/src/daComposant/daCore/Aidsm.py +++ b/src/daComposant/daCore/Aidsm.py @@ -78,6 +78,10 @@ class Aidsm(object): self.__adaoObject[ename] = None for ename in ("ObservationOperator", "EvolutionModel", "ControlModel"): self.__adaoObject[ename] = {} + for ename in ("BackgroundError", "ObservationError"): + self.__adaoObject[ename] = Covariance(ename, asEyeByScalar = 1.) + for ename in ("EvolutionError",): + self.__adaoObject[ename] = Covariance(ename, asEyeByScalar = 1.e-16) for ename in ("Observer", "UserPostAnalysis"): self.__adaoObject[ename] = [] self.__StoredInputs[ename] = [] # Vide par defaut diff --git a/src/daComposant/daCore/Interfaces.py b/src/daComposant/daCore/Interfaces.py index f567763..3a6895c 100644 --- a/src/daComposant/daCore/Interfaces.py +++ b/src/daComposant/daCore/Interfaces.py @@ -66,7 +66,7 @@ class GenericCaseViewer(object): if __hasNotExecute: self._lineSerie.append("%s.execute()"%(self._objname,)) if __upa is not None and len(__upa)>0: - __upa = __upa.replace("ADD.",str(self._objname)+".") + __upa = __upa.replace("ADD",str(self._objname)) self._lineSerie.append(__upa) def _addLine(self, line=""): "Ajoute un enregistrement individuel" @@ -233,7 +233,7 @@ class _COMViewer(GenericCaseViewer): # elif __command == "UserPostAnalysis" and type(r) is dict: if 'STRING' in r: - __UserPostAnalysis = r['STRING'].replace("ADD.",str(self._objname)+".") + __UserPostAnalysis = r['STRING'].replace("ADD",str(self._objname)) __commands.append( "set( Concept='UserPostAnalysis', String=\"\"\"%s\"\"\" )"%(__UserPostAnalysis,) ) elif 'SCRIPT_FILE' in r and os.path.exists(r['SCRIPT_FILE']): __UserPostAnalysis = open(r['SCRIPT_FILE'],'r').read() diff --git a/src/daComposant/daCore/NumericObjects.py b/src/daComposant/daCore/NumericObjects.py index 85ecff2..1a34b32 100644 --- a/src/daComposant/daCore/NumericObjects.py +++ b/src/daComposant/daCore/NumericObjects.py @@ -2171,15 +2171,11 @@ def incr3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): # # Initialisations # --------------- - # - # Opérateur non-linéaire pour la boucle externe Hm = HO["Direct"].appliedTo # - # Précalcul des inversions de B et R BI = B.getI() RI = R.getI() # - # Point de démarrage de l'optimisation Xini = selfA._parameters["InitializationPoint"] # HXb = numpy.asmatrix(numpy.ravel( Hm( Xb ) )).T @@ -2729,6 +2725,7 @@ def multi3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, oneCycle): """ # # Initialisation + # -------------- if selfA._parameters["EstimationOf"] == "State": M = EM["Direct"].appliedTo # @@ -2784,11 +2781,8 @@ def psas3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): # # Initialisations # --------------- - # - # Opérateurs Hm = HO["Direct"].appliedTo # - # Utilisation éventuelle d'un vecteur H(Xb) précalculé if HO["AppliedInX"] is not None and "HXb" in HO["AppliedInX"]: HXb = Hm( Xb, HO["AppliedInX"]["HXb"] ) else: @@ -2809,7 +2803,6 @@ def psas3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): HBHTpR = R + Ht * BHT Innovation = Y - HXb # - # Point de démarrage de l'optimisation Xini = numpy.zeros(Xb.shape) # # Définition de la fonction-coût @@ -3255,12 +3248,9 @@ def std3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): # # Initialisations # --------------- - # - # Opérateurs Hm = HO["Direct"].appliedTo Ha = HO["Adjoint"].appliedInXTo # - # Utilisation éventuelle d'un vecteur H(Xb) précalculé if HO["AppliedInX"] is not None and "HXb" in HO["AppliedInX"]: HXb = Hm( Xb, HO["AppliedInX"]["HXb"] ) else: @@ -3276,11 +3266,9 @@ def std3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): HtMb = HtMb.reshape(Y.size,Xb.size) # ADAO & check shape selfA.StoredVariables["JacobianMatrixAtBackground"].store( HtMb ) # - # Précalcul des inversions de B et R BI = B.getI() RI = R.getI() # - # Point de démarrage de l'optimisation Xini = selfA._parameters["InitializationPoint"] # # Définition de la fonction-coût @@ -4138,16 +4126,12 @@ def van3dvar(selfA, Xb, Y, U, HO, EM, CM, R, B, Q): # # Initialisations # --------------- - # - # Opérateurs Hm = HO["Direct"].appliedTo Ha = HO["Adjoint"].appliedInXTo # - # Précalcul des inversions de B et R BT = B.getT() RI = R.getI() # - # Point de démarrage de l'optimisation Xini = numpy.zeros(Xb.shape) # # Définition de la fonction-coût -- 2.39.2