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' )
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()
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,
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' )
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
# -----------------------------------
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' )
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()
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,
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' )
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
# ------------------------------------
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
#
# ==============================================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
""")
#---------------------------------------------------------------------------
- from numpy import array, matrix
+ from numpy import array
from adao import adaoBuilder
case = adaoBuilder.New()
case.set( 'AlgorithmParameters', Algorithm='3DVAR' )
++++++++++++++++++++++++++++++++++++++++++++++
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' )
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' )
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,
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
# ------------------------------------
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 = []
"""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
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
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