Salome HOME
Minor documentation and code review corrections (24)
authorJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Thu, 24 Feb 2022 05:57:33 +0000 (06:57 +0100)
committerJean-Philippe ARGAUD <jean-philippe.argaud@edf.fr>
Thu, 24 Feb 2022 05:57:33 +0000 (06:57 +0100)
doc/en/tui.rst
doc/fr/tui.rst
examples/daSkeletons/External_data_definition_by_scripts/Physical_data_and_covariance_matrices.py
test/test6701/Doc_TUI_Exemple_01.py
test/test6702/Doc_TUI_Exemple_02.py
test/test6703/Doc_TUI_Exemple_03.py
test/test6704/Doc_TUI_Exemple_03_en_multifonction.py
test/test6901/Verification_des_Assimilation_Algorithms.py

index a9dd5f6fdd6fa3d2e3bfacf52260aa0efecbdf7d..40e1a66f55c38c781824038cca900ff711a6b6a6 100644 (file)
@@ -63,7 +63,7 @@ ADAO calculation case. All the data are explicitly defined inside the script in
 order to make the reading easier. The whole set of commands is the following
 one::
 
-    from numpy import array, matrix
+    from numpy import array
     from adao import adaoBuilder
     case = adaoBuilder.New()
     case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
@@ -92,7 +92,7 @@ The creation and initialization of a study are done using the following
 commands, the ``case`` object name of the ADAO TUI calculation case being let
 free to the user choice::
 
-    from numpy import array, matrix
+    from numpy import array
     from adao import adaoBuilder
     case = adaoBuilder.New()
 
@@ -146,9 +146,10 @@ case::
     import numpy
     def simulation(x):
         "Simulation function H to perform Y=H(X)"
-        __x = numpy.matrix(numpy.ravel(numpy.matrix(x))).T
-        __H = numpy.matrix("1 0 0;0 2 0;0 0 3")
-        return __H * __x
+        import numpy
+        __x = numpy.ravel(x)
+        __H = numpy.diag([1.,2.,3.])
+        return __H @ __x
     #
     case.set( 'ObservationOperator',
         OneFunction = simulation,
@@ -646,7 +647,7 @@ In addition, simple information about the case study as defined by the user can
 be obtained by using the Python "*print*" command directly on the case, at any
 stage during its design. For example::
 
-    from numpy import array, matrix
+    from numpy import array
     from adao import adaoBuilder
     case = adaoBuilder.New()
     case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
@@ -707,9 +708,9 @@ information, see the approach :ref:`section_methodology_twin`)::
     def simulation(x):
         "Simulation function H to perform Y=H(X)"
         import numpy
-        __x = numpy.matrix(numpy.ravel(numpy.matrix(x))).T
-        __H = numpy.matrix("1 0 0;0 2 0;0 0 3; 1 2 3")
-        return __H * __x
+        __x = numpy.ravel(x)
+        __H = numpy.diag([1.,2.,3.])
+        return __H @ __x
     #
     # Observations obtained by simulation
     # -----------------------------------
index f3b894b7b1f1656a693e84fb11338ada9693c72b..dac6e4daf68e6cb0acad8efb212bb4564f9c363f 100644 (file)
@@ -64,7 +64,7 @@ de cas de calcul ADAO. Toutes les données sont explicitement définies dans le
 corps du script pour faciliter la lecture. L'ensemble des commandes est le
 suivant::
 
-    from numpy import array, matrix
+    from numpy import array
     from adao import adaoBuilder
     case = adaoBuilder.New()
     case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
@@ -93,7 +93,7 @@ La création et l'initialisation d'une étude se font par les commandes
 suivantes, le nom ``case`` de l'objet du cas de calcul TUI ADAO étant
 quelconque, au choix de l'utilisateur::
 
-    from numpy import array, matrix
+    from numpy import array
     from adao import adaoBuilder
     case = adaoBuilder.New()
 
@@ -149,9 +149,10 @@ ci-dessus) et l'enregistre dans le cas ADAO::
     import numpy
     def simulation(x):
         "Fonction de simulation H pour effectuer Y=H(X)"
-        __x = numpy.matrix(numpy.ravel(numpy.matrix(x))).T
-        __H = numpy.matrix("1 0 0;0 2 0;0 0 3")
-        return __H * __x
+        import numpy
+        __x = numpy.ravel(x)
+        __H = numpy.diag([1.,2.,3.])
+        return __H @ __x
     #
     case.set( 'ObservationOperator',
         OneFunction = simulation,
@@ -674,7 +675,7 @@ De plus, on peut obtenir une information simple sur le cas d'étude tel que
 défini par l'utilisateur en utilisant directement la commande "*print*" de Python
 sur le cas, à toute étape lors de sa construction. Par exemple::
 
-    from numpy import array, matrix
+    from numpy import array
     from adao import adaoBuilder
     case = adaoBuilder.New()
     case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
@@ -736,9 +737,9 @@ jumelles (pour mémoire, voir la démarche :ref:`section_methodology_twin`)::
     def simulation(x):
         "Fonction de simulation H pour effectuer Y=H(X)"
         import numpy
-        __x = numpy.matrix(numpy.ravel(numpy.matrix(x))).T
-        __H = numpy.matrix("1 0 0;0 2 0;0 0 3; 1 2 3")
-        return __H * __x
+        __x = numpy.ravel(x)
+        __H = numpy.diag([1.,2.,3.])
+        return __H @ __x
     #
     # Observations obtenues par simulation
     # ------------------------------------
index 53618a90b984ada95196d0fdf9c8214c28680515..b646e4c02d0265961745f0fd035a421eea9dcfc2 100644 (file)
@@ -43,9 +43,9 @@ def Simple_Matrix( size, diagonal=None ):
     Diagonal matrix, with either 1 or a given vector on the diagonal
     """
     if diagonal is not None:
-        S = numpy.diag( diagonal )
+        S = numpy.diagflat( diagonal )
     else:
-        S = numpy.matrix(numpy.identity(int(size)))
+        S = numpy.identity(int(size))
     return S
 #
 # ==============================================================================
index ce8d209c5daedb2c93e1af02bf104ad7e807cd00..4d4ae8abdb666a034aea82c295c89f2d90810756 100644 (file)
@@ -34,7 +34,7 @@ class Test_Adao(unittest.TestCase):
         +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         """)
         #---------------------------------------------------------------------------
-        from numpy import array, matrix
+        from numpy import array
         from adao import adaoBuilder
         case = adaoBuilder.New()
         case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
index a43a49c3fbda353132d57c4d0b0a1296b26c1506..877c01e12a629401877148e64802d6fc6078ad31 100644 (file)
@@ -35,7 +35,7 @@ class Test_Adao(unittest.TestCase):
         ++++++++++++++++++++++++++++++++++++++++++++++
         Les deux resultats sont testes pour etre identiques.
         """)
-        from numpy import array, matrix
+        from numpy import array
         from adao import adaoBuilder
         case = adaoBuilder.New()
         case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
@@ -53,7 +53,7 @@ class Test_Adao(unittest.TestCase):
 
     def test2(self):
         """Test"""
-        from numpy import array, matrix
+        from numpy import array
         from adao import adaoBuilder
         case = adaoBuilder.New()
         case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
@@ -63,9 +63,9 @@ class Test_Adao(unittest.TestCase):
         case.set( 'ObservationError',    DiagonalSparseMatrix='1 1 1' )
         def simulation(x):
             import numpy
-            __x = numpy.matrix(numpy.ravel(numpy.matrix(x))).T
-            __H = numpy.matrix("1 0 0;0 2 0;0 0 3")
-            return __H * __x
+            __x = numpy.ravel(x)
+            __H = numpy.diag([1.,2.,3.])
+            return __H @ __x
         #
         case.set( 'ObservationOperator',
             OneFunction = simulation,
index 91f59018f6ac041d8e3e3cc8841e48244502f832..976145aef7ea609e3614a024cd4edbb5bb00fb10 100644 (file)
@@ -39,9 +39,9 @@ gammamin, gammamax = 1.5, 15.5
 def simulation(x):
     "Fonction de simulation H pour effectuer Y=H(X)"
     import numpy
-    __x = numpy.matrix(numpy.ravel(numpy.matrix(x))).T
-    __H = numpy.matrix("1 0 0;0 2 0;0 0 3; 1 2 3")
-    return __H * __x
+    __x = numpy.ravel(x)
+    __H = numpy.diag([1.,2.,3.])
+    return __H @ __x
 #
 # Observations obtenues par simulation
 # ------------------------------------
index de87ec65b97d85d13979f6c1c2f0785cedc5a12d..184a7b76810c6664b0f04f78a328cfcfbc7fb342 100644 (file)
@@ -39,9 +39,9 @@ gammamin, gammamax = 1.5, 15.5
 def simulation(x):
     "Fonction de simulation H pour effectuer Y=H(X)"
     import numpy
-    __x = numpy.matrix(numpy.ravel(numpy.matrix(x))).T
-    __H = numpy.matrix("1 0 0;0 2 0;0 0 3; 1 2 3")
-    return __H * __x
+    __x = numpy.ravel(x)
+    __H = numpy.diag([1.,2.,3.])
+    return __H @ __x
 #
 def multisimulation( xserie ):
     yserie = []
index ec6ed2e2dc8469b4b9346f9bf8eff1e4abc48b41..223590bd81db8cf8b077d9dafe46bd5af02a6d0e 100644 (file)
@@ -118,8 +118,8 @@ class Test_Adao(unittest.TestCase):
         """Verification de la disponibilite de l'ensemble des algorithmes\n(Utilisation d'un operateur fonctionnel)"""
         print(self.test2.__doc__)
         Xa = {}
-        M = numpy.matrix("1 0 0;0 2 0;0 0 3")
-        def H(x): return M * numpy.asmatrix(numpy.ravel( x )).T
+        M = numpy.diag([1.,2.,3.])
+        def H(x): return M @ numpy.ravel( x )
         for algo in ("3DVAR", "Blue", "ExtendedBlue", "NonLinearLeastSquares", "DerivativeFreeOptimization"):
             print("")
             msg = "Algorithme en test : %s"%algo
@@ -137,8 +137,8 @@ class Test_Adao(unittest.TestCase):
             Xa[algo] = adaopy.get("Analysis")[-1]
             del adaopy
         #
-        M = numpy.matrix("1 0 0;0 2 0;0 0 3")
-        def H(x): return M * numpy.asmatrix(numpy.ravel( x )).T
+        M = numpy.diag([1.,2.,3.])
+        def H(x): return M @ numpy.ravel( x )
         for algo in ("ExtendedKalmanFilter", "KalmanFilter", "EnsembleKalmanFilter", "UnscentedKalmanFilter", "4DVAR"):
             print("")
             msg = "Algorithme en test : %s"%algo
@@ -158,8 +158,8 @@ class Test_Adao(unittest.TestCase):
             Xa[algo] = adaopy.get("Analysis")[-1]
             del adaopy
         #
-        M = numpy.matrix("1 0 0;0 1 0;0 0 1")
-        def H(x): return M * numpy.asmatrix(numpy.ravel( x )).T
+        M = numpy.identity(3)
+        def H(x): return M @ numpy.ravel( x )
         for algo in ("ParticleSwarmOptimization", "QuantileRegression", ):
             print("")
             msg = "Algorithme en test : %s"%algo