.. include:: snippets/SimulationQuantiles.rst
+.. ------------------------------------ ..
+.. include:: snippets/Header2Algo09.rst
+
+.. literalinclude:: scripts/simple_3DVAR.py
+
+.. include:: snippets/Header2Algo10.rst
+
+.. literalinclude:: scripts/simple_3DVAR.res
+
.. ------------------------------------ ..
.. include:: snippets/Header2Algo06.rst
.. include:: snippets/SimulationQuantiles.rst
+.. ------------------------------------ ..
+.. include:: snippets/Header2Algo09.rst
+
+.. literalinclude:: scripts/simple_Blue.py
+
+.. include:: snippets/Header2Algo10.rst
+
+.. literalinclude:: scripts/simple_Blue.res
+
.. ------------------------------------ ..
.. include:: snippets/Header2Algo06.rst
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+from numpy import array, ravel
+def QuadFunction( coefficients ):
+ """
+ Function : y = a x^2 + b x + c
+ """
+ a, b, c = list(ravel(coefficients))
+ x_points = (-5, 0, 1, 3, 10)
+ y_points = []
+ for x in x_points:
+ y_points.append( a*x*x + b*x + c )
+ return array(y_points)
+#
+print("Iterative resolution of the calibration problem")
+print("-----------------------.-----------------------")
+print("")
+from adao import adaoBuilder
+case = adaoBuilder.New('')
+case.setBackground( Vector = array([1., 1., 1.]), Stored=True )
+case.setBackgroundError( ScalarSparseMatrix = 1.e6 )
+case.setObservation( Vector=array([57, 2, 3, 17, 192]), Stored=True )
+case.setObservationError( ScalarSparseMatrix = 1. )
+case.setObservationOperator( OneFunction = QuadFunction )
+case.setAlgorithmParameters(
+ Algorithm='3DVAR',
+ Parameters={
+ 'StoreSupplementaryCalculations': [
+ 'CurrentState',
+ ],
+ },
+ )
+case.setObserver(
+ Info=" Intermediate state at the current iteration:",
+ Template='ValuePrinter',
+ Variable='CurrentState',
+ )
+case.execute()
+print("")
+#
+#-------------------------------------------------------------------------------
+#
+print("Calibration of %i coefficients in a 1D quadratic function on %i measures"%(
+ len(case.get('Background')),
+ len(case.get('Observation')),
+ ))
+print("---------------------------------------------------------------------")
+print("")
+print("Observation vector.................:", ravel(case.get('Observation')))
+print("A priori background state..........:", ravel(case.get('Background')))
+print("")
+print("Expected theoretical coefficients..:", ravel((2,-1,2)))
+print("")
+print("Calibration resulting coefficients.:", ravel(case.get('Analysis')[-1]))
--- /dev/null
+Iterative resolution of the calibration problem
+-----------------------.-----------------------
+
+ Intermediate state at the current iteration: [1. 1. 1.]
+ Intermediate state at the current iteration: [1.99739508 1.07086406 1.01346638]
+ Intermediate state at the current iteration: [1.83891966 1.04815981 1.01208385]
+ Intermediate state at the current iteration: [1.8390702 1.03667176 1.01284797]
+ Intermediate state at the current iteration: [1.83967236 0.99071957 1.01590445]
+ Intermediate state at the current iteration: [1.84208099 0.8069108 1.02813037]
+ Intermediate state at the current iteration: [ 1.93711599 -0.56383145 1.12097995]
+ Intermediate state at the current iteration: [ 1.99838848 -1.00480573 1.1563713 ]
+ Intermediate state at the current iteration: [ 2.0135905 -1.04815933 1.16155285]
+ Intermediate state at the current iteration: [ 2.01385679 -1.03874809 1.16129657]
+ Intermediate state at the current iteration: [ 2.01377856 -1.03700044 1.16157611]
+ Intermediate state at the current iteration: [ 2.01338902 -1.02943736 1.16528951]
+ Intermediate state at the current iteration: [ 2.01265633 -1.0170847 1.17793974]
+ Intermediate state at the current iteration: [ 2.0112487 -0.99745509 1.21485091]
+ Intermediate state at the current iteration: [ 2.00863696 -0.96943284 1.30917045]
+ Intermediate state at the current iteration: [ 2.00453385 -0.94011716 1.51021882]
+ Intermediate state at the current iteration: [ 2.00013539 -0.93313893 1.80539433]
+ Intermediate state at the current iteration: [ 1.95437244 -0.76890418 2.04566856]
+ Intermediate state at the current iteration: [ 1.99797362 -0.92538074 1.81674451]
+ Intermediate state at the current iteration: [ 1.99760514 -0.95929669 2.01402091]
+ Intermediate state at the current iteration: [ 1.99917565 -0.99152672 2.03171791]
+ Intermediate state at the current iteration: [ 1.99990376 -0.99963123 2.00671578]
+ Intermediate state at the current iteration: [ 1.99999841 -1.00005285 2.00039699]
+ Intermediate state at the current iteration: [ 2.00000014 -1.00000307 2.00000221]
+ Intermediate state at the current iteration: [ 2. -0.99999992 1.99999987]
+
+Calibration of 3 coefficients in a 1D quadratic function on 5 measures
+---------------------------------------------------------------------
+
+Observation vector.................: [ 57. 2. 3. 17. 192.]
+A priori background state..........: [1. 1. 1.]
+
+Expected theoretical coefficients..: [ 2 -1 2]
+
+Calibration resulting coefficients.: [ 2. -0.99999992 1.99999987]
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+from numpy import array, ravel
+from adao import adaoBuilder
+case = adaoBuilder.New('')
+case.setBackground( Vector = array([0., 1., 2.]), Stored=True )
+case.setBackgroundError( ScalarSparseMatrix = 1. )
+case.setObservation( Vector=array([10., 11., 12.]), Stored=True )
+case.setObservationError( ScalarSparseMatrix = 1. )
+case.setObservationOperator( Matrix=array([[1., 0., 0.],
+ [0., 1., 0.],
+ [0., 0., 1.]]), )
+case.setAlgorithmParameters(
+ Algorithm='Blue',
+ Parameters={
+ 'StoreSupplementaryCalculations': [
+ 'APosterioriCovariance',
+ ],
+ },
+ )
+case.execute()
+#
+#-------------------------------------------------------------------------------
+#
+print("Interpolation between two vectors, of observation and background")
+print("----------------------------------------------------------------")
+print("")
+print("Observation vector............:", ravel(case.get('Observation')))
+print("A priori background vector....:", ravel(case.get('Background')))
+print("")
+print("Expected theoretical state....:", ravel([5., 6., 7.]))
+print("")
+print("Interpolation result..........:", ravel(case.get('Analysis')[-1]))
+print("A posteriori covariance.......:\n", case.get('APosterioriCovariance')[-1])
--- /dev/null
+Interpolation between two vectors, of observation and background
+----------------------------------------------------------------
+
+Observation vector............: [10. 11. 12.]
+A priori background vector....: [0. 1. 2.]
+
+Expected theoretical state....: [5. 6. 7.]
+
+Interpolation result..........: [5. 6. 7.]
+A posteriori covariance.......:
+ [[0.5 0. 0. ]
+ [0. 0.5 0. ]
+ [0. 0. 0.5]]
.. include:: snippets/SimulationQuantiles.rst
+.. ------------------------------------ ..
+.. include:: snippets/Header2Algo09.rst
+
+.. literalinclude:: scripts/simple_3DVAR.py
+
+.. include:: snippets/Header2Algo10.rst
+
+.. literalinclude:: scripts/simple_3DVAR.res
+
.. ------------------------------------ ..
.. include:: snippets/Header2Algo06.rst
.. include:: snippets/SimulationQuantiles.rst
+.. ------------------------------------ ..
+.. include:: snippets/Header2Algo09.rst
+
+.. literalinclude:: scripts/simple_Blue.py
+
+.. include:: snippets/Header2Algo10.rst
+
+.. literalinclude:: scripts/simple_Blue.res
+
.. ------------------------------------ ..
.. include:: snippets/Header2Algo06.rst
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+from numpy import array, ravel
+def QuadFunction( coefficients ):
+ """
+ Fonction : y = a x^2 + b x + c
+ """
+ a, b, c = list(ravel(coefficients))
+ x_points = (-5, 0, 1, 3, 10)
+ y_points = []
+ for x in x_points:
+ y_points.append( a*x*x + b*x + c )
+ return array(y_points)
+#
+print("Résolution itérative du problème de calibration")
+print("-----------------------.-----------------------")
+print("")
+from adao import adaoBuilder
+case = adaoBuilder.New('')
+case.setBackground( Vector = array([1., 1., 1.]), Stored=True )
+case.setBackgroundError( ScalarSparseMatrix = 1.e6 )
+case.setObservation( Vector=array([57, 2, 3, 17, 192]), Stored=True )
+case.setObservationError( ScalarSparseMatrix = 1. )
+case.setObservationOperator( OneFunction = QuadFunction )
+case.setAlgorithmParameters(
+ Algorithm='3DVAR',
+ Parameters={
+ 'StoreSupplementaryCalculations': [
+ 'CurrentState',
+ ],
+ },
+ )
+case.setObserver(
+ Info=" État intermédiaire en itération courante :",
+ Template='ValuePrinter',
+ Variable='CurrentState',
+ )
+case.execute()
+print("")
+#
+#-------------------------------------------------------------------------------
+#
+print("Calibration de %i coefficients pour une forme quadratique 1D sur %i mesures"%(
+ len(case.get('Background')),
+ len(case.get('Observation')),
+ ))
+print("------------------------------------------------------------------------")
+print("")
+print("Vecteur observation.......................:", ravel(case.get('Observation')))
+print("État ébauche a priori.....................:", ravel(case.get('Background')))
+print("")
+print("Coefficients théoriques attendus..........:", ravel((2,-1,2)))
+print("")
+print("Coefficients résultants de la calibration.:", ravel(case.get('Analysis')[-1]))
--- /dev/null
+Résolution itérative du problème de calibration
+-----------------------.-----------------------
+
+ État intermédiaire en itération courante : [1. 1. 1.]
+ État intermédiaire en itération courante : [1.99739508 1.07086406 1.01346638]
+ État intermédiaire en itération courante : [1.83891966 1.04815981 1.01208385]
+ État intermédiaire en itération courante : [1.8390702 1.03667176 1.01284797]
+ État intermédiaire en itération courante : [1.83967236 0.99071957 1.01590445]
+ État intermédiaire en itération courante : [1.84208099 0.8069108 1.02813037]
+ État intermédiaire en itération courante : [ 1.93711599 -0.56383145 1.12097995]
+ État intermédiaire en itération courante : [ 1.99838848 -1.00480573 1.1563713 ]
+ État intermédiaire en itération courante : [ 2.0135905 -1.04815933 1.16155285]
+ État intermédiaire en itération courante : [ 2.01385679 -1.03874809 1.16129657]
+ État intermédiaire en itération courante : [ 2.01377856 -1.03700044 1.16157611]
+ État intermédiaire en itération courante : [ 2.01338902 -1.02943736 1.16528951]
+ État intermédiaire en itération courante : [ 2.01265633 -1.0170847 1.17793974]
+ État intermédiaire en itération courante : [ 2.0112487 -0.99745509 1.21485091]
+ État intermédiaire en itération courante : [ 2.00863696 -0.96943284 1.30917045]
+ État intermédiaire en itération courante : [ 2.00453385 -0.94011716 1.51021882]
+ État intermédiaire en itération courante : [ 2.00013539 -0.93313893 1.80539433]
+ État intermédiaire en itération courante : [ 1.95437244 -0.76890418 2.04566856]
+ État intermédiaire en itération courante : [ 1.99797362 -0.92538074 1.81674451]
+ État intermédiaire en itération courante : [ 1.99760514 -0.95929669 2.01402091]
+ État intermédiaire en itération courante : [ 1.99917565 -0.99152672 2.03171791]
+ État intermédiaire en itération courante : [ 1.99990376 -0.99963123 2.00671578]
+ État intermédiaire en itération courante : [ 1.99999841 -1.00005285 2.00039699]
+ État intermédiaire en itération courante : [ 2.00000014 -1.00000307 2.00000221]
+ État intermédiaire en itération courante : [ 2. -0.99999992 1.99999987]
+
+Calibration de 3 coefficients pour une forme quadratique 1D sur 5 mesures
+------------------------------------------------------------------------
+
+Vecteur observation.......................: [ 57. 2. 3. 17. 192.]
+État ébauche a priori.....................: [1. 1. 1.]
+
+Coefficients théoriques attendus..........: [ 2 -1 2]
+
+Coefficients résultants de la calibration.: [ 2. -0.99999992 1.99999987]
--- /dev/null
+# -*- coding: utf-8 -*-
+#
+from numpy import array, ravel
+from adao import adaoBuilder
+case = adaoBuilder.New('')
+case.setBackground( Vector = array([0., 1., 2.]), Stored=True )
+case.setBackgroundError( ScalarSparseMatrix = 1. )
+case.setObservation( Vector=array([10., 11., 12.]), Stored=True )
+case.setObservationError( ScalarSparseMatrix = 1. )
+case.setObservationOperator( Matrix=array([[1., 0., 0.],
+ [0., 1., 0.],
+ [0., 0., 1.]]), )
+case.setAlgorithmParameters(
+ Algorithm='Blue',
+ Parameters={
+ 'StoreSupplementaryCalculations': [
+ 'APosterioriCovariance',
+ ],
+ },
+ )
+case.execute()
+#
+#-------------------------------------------------------------------------------
+#
+print("Interpolation entre deux états vectoriels, observation et ébauche")
+print("-----------------------------------------------------------------")
+print("")
+print("Vecteur observation...........:", ravel(case.get('Observation')))
+print("Vecteur ébauche a priori......:", ravel(case.get('Background')))
+print("")
+print("État théorique attendu........:", ravel([5., 6., 7.]))
+print("")
+print("Résultat par interpolation....:", ravel(case.get('Analysis')[-1]))
+print("Covariance a posteriori.......:\n", case.get('APosterioriCovariance')[-1])
--- /dev/null
+Interpolation entre deux états vectoriels, observation et ébauche
+-----------------------------------------------------------------
+
+Vecteur observation...........: [10. 11. 12.]
+Vecteur ébauche a priori......: [0. 1. 2.]
+
+État théorique attendu........: [5. 6. 7.]
+
+Résultat par interpolation....: [5. 6. 7.]
+Covariance a posteriori.......:
+ [[0.5 0. 0. ]
+ [0. 0.5 0. ]
+ [0. 0. 0.5]]