]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Minor improvements and fixes for internal variables
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Thu, 1 Apr 2021 04:44:18 +0000 (06:44 +0200)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Thu, 1 Apr 2021 04:44:18 +0000 (06:44 +0200)
src/daComposant/daAlgorithms/Blue.py
src/daComposant/daAlgorithms/ExtendedBlue.py
src/daComposant/daCore/BasicObjects.py
src/daComposant/daCore/ExtendedLogging.py
src/daComposant/daCore/NumericObjects.py
src/daComposant/daCore/PlatformInfo.py

index 5c95446cd2858b0ceb4c2505aff7af1def42ad42..c6284daf591cc507a84cc40afb9f84bd2f91db06 100644 (file)
@@ -58,6 +58,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 "MahalanobisConsistency",
                 "OMA",
                 "OMB",
+                "SampledStateForQuantiles",
                 "SigmaBck2",
                 "SigmaObs2",
                 "SimulatedObservationAtBackground",
@@ -215,19 +216,23 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             self.StoredVariables["MahalanobisConsistency"].store( float( 2.*J/d.size ) )
         if self._toStore("SimulationQuantiles"):
             nech = self._parameters["NumberOfSamplesForQuantiles"]
+            EXr  = None
             YfQ  = None
             for i in range(nech):
                 if self._parameters["SimulationForQuantiles"] == "Linear":
                     dXr = numpy.matrix(numpy.random.multivariate_normal(Xa.A1,A) - Xa.A1).T
                     dYr = numpy.matrix(numpy.ravel( Hm * dXr )).T
                     Yr = HXa + dYr
+                    if selfA._toStore("SampledStateForQuantiles"): Xr = Xa+dXr
                 elif self._parameters["SimulationForQuantiles"] == "NonLinear":
                     Xr = numpy.matrix(numpy.random.multivariate_normal(Xa.A1,A)).T
                     Yr = numpy.matrix(numpy.ravel( Hm * Xr )).T
                 if YfQ is None:
                     YfQ = Yr
+                    if selfA._toStore("SampledStateForQuantiles"): EXr = numpy.ravel(Xr)
                 else:
                     YfQ = numpy.hstack((YfQ,Yr))
+                    if selfA._toStore("SampledStateForQuantiles"): EXr = numpy.vstack((EXr,numpy.ravel(Xr)))
             YfQ.sort(axis=-1)
             YQ = None
             for quantile in self._parameters["Quantiles"]:
@@ -236,6 +241,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 if YQ is None: YQ = YfQ[:,indice]
                 else:          YQ = numpy.hstack((YQ,YfQ[:,indice]))
             self.StoredVariables["SimulationQuantiles"].store( YQ )
+            if selfA._toStore("SampledStateForQuantiles"):
+                selfA.StoredVariables["SampledStateForQuantiles"].store( EXr.T )
         if self._toStore("SimulatedObservationAtBackground"):
             self.StoredVariables["SimulatedObservationAtBackground"].store( numpy.ravel(HXb) )
         if self._toStore("SimulatedObservationAtCurrentState"):
index 10fadc26fc732ae51a4cd2d182ece64aba01aaae..c0f9892605483d73eb679c426fa151a12b7c258f 100644 (file)
@@ -58,6 +58,7 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 "MahalanobisConsistency",
                 "OMA",
                 "OMB",
+                "SampledStateForQuantiles",
                 "SigmaBck2",
                 "SigmaObs2",
                 "SimulatedObservationAtBackground",
@@ -218,19 +219,23 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
             nech = self._parameters["NumberOfSamplesForQuantiles"]
             HtM  = HO["Tangent"].asMatrix(ValueForMethodForm = Xa)
             HtM  = HtM.reshape(Y.size,Xa.size) # ADAO & check shape
+            EXr  = None
             YfQ  = None
             for i in range(nech):
                 if self._parameters["SimulationForQuantiles"] == "Linear":
                     dXr = numpy.matrix(numpy.random.multivariate_normal(Xa.A1,A) - Xa.A1).T
                     dYr = numpy.matrix(numpy.ravel( HtM * dXr )).T
                     Yr = HXa + dYr
+                    if selfA._toStore("SampledStateForQuantiles"): Xr = Xa+dXr
                 elif self._parameters["SimulationForQuantiles"] == "NonLinear":
                     Xr = numpy.matrix(numpy.random.multivariate_normal(Xa.A1,A)).T
                     Yr = numpy.matrix(numpy.ravel( H( Xr ) )).T
                 if YfQ is None:
                     YfQ = Yr
+                    if selfA._toStore("SampledStateForQuantiles"): EXr = numpy.ravel(Xr)
                 else:
                     YfQ = numpy.hstack((YfQ,Yr))
+                    if selfA._toStore("SampledStateForQuantiles"): EXr = numpy.vstack((EXr,numpy.ravel(Xr)))
             YfQ.sort(axis=-1)
             YQ = None
             for quantile in self._parameters["Quantiles"]:
@@ -239,6 +244,8 @@ class ElementaryAlgorithm(BasicObjects.Algorithm):
                 if YQ is None: YQ = YfQ[:,indice]
                 else:          YQ = numpy.hstack((YQ,YfQ[:,indice]))
             self.StoredVariables["SimulationQuantiles"].store( YQ )
+            if selfA._toStore("SampledStateForQuantiles"):
+                selfA.StoredVariables["SampledStateForQuantiles"].store( EXr.T )
         if self._toStore("SimulatedObservationAtBackground"):
             self.StoredVariables["SimulatedObservationAtBackground"].store( numpy.ravel(HXb) )
         if self._toStore("SimulatedObservationAtCurrentState"):
index 1a37c00ad32382a8305f1e9aee4cec5539d09ad4..a4867f91ab2e11f1320eef6c6654f4fd4b051769 100644 (file)
@@ -624,6 +624,7 @@ class Algorithm(object):
             - OMB : Observation moins Background : Y - Xb
             - ForecastState : état prédit courant lors d'itérations
             - Residu : dans le cas des algorithmes de vérification
+            - SampledStateForQuantiles : échantillons d'états pour l'estimation des quantiles
             - SigmaBck2 : indicateur de correction optimale des erreurs d'ébauche
             - SigmaObs2 : indicateur de correction optimale des erreurs d'observation
             - SimulatedObservationAtBackground : l'état observé H(Xb) à l'ébauche
@@ -681,6 +682,7 @@ class Algorithm(object):
         self.StoredVariables["OMA"]                                  = Persistence.OneVector(name = "OMA")
         self.StoredVariables["OMB"]                                  = Persistence.OneVector(name = "OMB")
         self.StoredVariables["Residu"]                               = Persistence.OneScalar(name = "Residu")
+        self.StoredVariables["SampledStateForQuantiles"]             = Persistence.OneMatrix(name = "SampledStateForQuantiles")
         self.StoredVariables["SigmaBck2"]                            = Persistence.OneScalar(name = "SigmaBck2")
         self.StoredVariables["SigmaObs2"]                            = Persistence.OneScalar(name = "SigmaObs2")
         self.StoredVariables["SimulatedObservationAtBackground"]     = Persistence.OneVector(name = "SimulatedObservationAtBackground")
index c67f0308290c16e5afdb48bdb6a3cade37cff9f3..5349e144e52f2d2db18f9c83fc5a8258db901308 100644 (file)
@@ -34,7 +34,7 @@
         import ExtendedLogging ; ExtendedLogging.ExtendedLogging(level=20)
 
     On peut éventuellement demander à l'objet de sortir aussi les messages dans
-    un fichier (noms par défaut : Aidsm.log, niveau NOTSET) :
+    un fichier (noms par défaut : AdaoOutputLogfile.log, niveau NOTSET) :
         import ExtendedLogging ; ExtendedLogging.ExtendedLogging().setLogfile()
 
     Si on veut changer le nom du fichier ou le niveau global de message, il faut
@@ -79,7 +79,7 @@ import functools
 import time
 from daCore import PlatformInfo
 
-LOGFILE = os.path.join(os.path.abspath(os.curdir),"AssimilationStudy.log")
+LOGFILE = os.path.join(os.path.abspath(os.curdir),"AdaoOutputLogfile.log")
 
 # ==============================================================================
 class ExtendedLogging(object):
index 5089c21f3ef060896e8739797cad63995898096f..e9e274d79e61f07a9ccb31d7d3c5d9cefb3bf567 100644 (file)
@@ -599,9 +599,6 @@ def enks(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="EnKS16-KalmanFilterForm
     EnKS
     """
     #
-    # Initialisations
-    # ---------------
-    #
     # Opérateurs
     H = HO["Direct"].appliedControledFormTo
     #
@@ -616,6 +613,7 @@ def enks(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="EnKS16-KalmanFilterForm
     # Précalcul des inversions de B et R
     RIdemi = R.sqrtmI()
     #
+    # Durée d'observation et tailles
     LagL = selfA._parameters["SmootherLagL"]
     if (not hasattr(Y,"store")) or (not hasattr(Y,"stepnumber")):
         raise ValueError("Fixed-lag smoother requires a series of observation")
@@ -723,6 +721,7 @@ def enks(selfA, Xb, Y, U, HO, EM, CM, R, B, Q, VariantM="EnKS16-KalmanFilterForm
             raise ValueError("VariantM has to be chosen in the authorized methods list.")
         #
         selfA.StoredVariables["CurrentIterationNumber"].store( len(selfA.StoredVariables["Analysis"]) )
+        # ---> avec analysis
         selfA.StoredVariables["Analysis"].store( Xa )
         if selfA._toStore("APosterioriCovariance"):
             selfA.StoredVariables["APosterioriCovariance"].store( EnsembleErrorCovariance(EXn) )
index 45eafeeaa6d4f73372ea4177f446920aaca1581d..950e0bbb53fb528dba60d61ebab5bb2a642e3509 100644 (file)
@@ -116,6 +116,12 @@ class PlatformInfo(object):
         __msg += "\n%s%30s : %s" %(__prefix,"sys.getfilesystemencoding",str(sys.getfilesystemencoding()))
         __msg += "\n%s%30s : %s" %(__prefix,"locale.getdefaultlocale",str(locale.getdefaultlocale()))
         __msg += "\n"
+        __msg += "\n%s%30s : %s" %(__prefix,"os.cpu_count",os.cpu_count())
+        if hasattr(os, 'sched_getaffinity'):
+            __msg += "\n%s%30s : %s" %(__prefix,"len(os.sched_getaffinity(0))",len(os.sched_getaffinity(0)))
+        else:
+            __msg += "\n%s%30s : %s" %(__prefix,"len(os.sched_getaffinity(0))","Unsupported on this platform")
+        __msg += "\n"
         __msg += "\n%s%30s : %s" %(__prefix,"platform.node",platform.node())
         __msg += "\n%s%30s : %s" %(__prefix,"os.path.expanduser",os.path.expanduser('~'))
         return __msg