From: Jean-Philippe ARGAUD Date: Sat, 16 Oct 2021 15:37:45 +0000 (+0200) Subject: Documentation examples update X-Git-Tag: V9_8_0b1~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1d76596dbc3827f452dc4bf00025c183882ac660;p=modules%2Fadao.git Documentation examples update --- diff --git a/doc/en/ref_algorithm_3DVAR.rst b/doc/en/ref_algorithm_3DVAR.rst index 6d893a2..7aae57a 100644 --- a/doc/en/ref_algorithm_3DVAR.rst +++ b/doc/en/ref_algorithm_3DVAR.rst @@ -234,6 +234,13 @@ StoreSupplementaryCalculations .. literalinclude:: scripts/simple_3DVAR.res +.. include:: snippets/Header2Algo11.rst + +.. _simple_3DVAR: +.. image:: scripts/simple_3DVAR.png + :align: center + :width: 90% + .. ------------------------------------ .. .. include:: snippets/Header2Algo06.rst diff --git a/doc/en/ref_algorithm_NonLinearLeastSquares.rst b/doc/en/ref_algorithm_NonLinearLeastSquares.rst index fa71f4d..dc96fda 100644 --- a/doc/en/ref_algorithm_NonLinearLeastSquares.rst +++ b/doc/en/ref_algorithm_NonLinearLeastSquares.rst @@ -177,10 +177,19 @@ StoreSupplementaryCalculations .. literalinclude:: scripts/simple_NonLinearLeastSquares.res +.. include:: snippets/Header2Algo11.rst + +.. _simple_NonLinearLeastSquares: +.. image:: scripts/simple_NonLinearLeastSquares.png + :align: center + :width: 90% + .. ------------------------------------ .. .. include:: snippets/Header2Algo06.rst +- :ref:`section_ref_algorithm_LinearLeastSquares` - :ref:`section_ref_algorithm_3DVAR` +- :ref:`section_ref_algorithm_LinearityTest` .. ------------------------------------ .. .. include:: snippets/Header2Algo07.rst diff --git a/doc/en/scripts/simple_3DVAR.png b/doc/en/scripts/simple_3DVAR.png new file mode 100644 index 0000000..91565f7 Binary files /dev/null and b/doc/en/scripts/simple_3DVAR.png differ diff --git a/doc/en/scripts/simple_3DVAR.py b/doc/en/scripts/simple_3DVAR.py index f13bb73..59e41f6 100644 --- a/doc/en/scripts/simple_3DVAR.py +++ b/doc/en/scripts/simple_3DVAR.py @@ -3,7 +3,7 @@ from numpy import array, ravel def QuadFunction( coefficients ): """ - Simulation : y = a x^2 + b x + c + Quadratic simulation in x: y = a x^2 + b x + c """ a, b, c = list(ravel(coefficients)) x_points = (-5, 0, 1, 3, 10) @@ -15,8 +15,8 @@ def QuadFunction( coefficients ): Xb = array([1., 1., 1.]) Yobs = array([57, 2, 3, 17, 192]) # -print("Variational resolution of the calibration problem") -print("-------------------------------------------------") +print("Resolution of the calibration problem") +print("-------------------------------------") print("") from adao import adaoBuilder case = adaoBuilder.New('') @@ -56,3 +56,17 @@ print("") print("Expected theoretical coefficients..:", ravel((2,-1,2))) print("") print("Calibration resulting coefficients.:", ravel(case.get('Analysis')[-1])) +# +Xa = case.get('Analysis')[-1] +import matplotlib.pyplot as plt +plt.rcParams['figure.figsize'] = (10, 4) +# +plt.figure() +plt.plot((-5,0,1,3,10),QuadFunction(Xb),'b-',label="Simulation at background") +plt.plot((-5,0,1,3,10),Yobs, 'kX',label='Observation',markersize=10) +plt.plot((-5,0,1,3,10),QuadFunction(Xa),'r-',label="Simulation at optimum") +plt.legend() +plt.title('Coefficients calibration', fontweight='bold') +plt.xlabel('Arbitrary coordinate') +plt.ylabel('Observation Yobs') +plt.savefig("simple_3DVAR.png") diff --git a/doc/en/scripts/simple_3DVAR.res b/doc/en/scripts/simple_3DVAR.res index 2e8537a..aaa1c4c 100644 --- a/doc/en/scripts/simple_3DVAR.res +++ b/doc/en/scripts/simple_3DVAR.res @@ -1,5 +1,5 @@ -Variational resolution of the calibration problem -------------------------------------------------- +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] diff --git a/doc/en/scripts/simple_3DVAR.rst b/doc/en/scripts/simple_3DVAR.rst index 326ec70..cb47c74 100644 --- a/doc/en/scripts/simple_3DVAR.rst +++ b/doc/en/scripts/simple_3DVAR.rst @@ -8,9 +8,10 @@ vector :math:`\mathbf{x}`, and return as output the evaluation vector points. The calibration is done using an initial coefficient set (background state specified by ``Xb`` in the code), and with the information :math:`\mathbf{y}^o` (specified by ``Yobs`` in the code) of 5 measures obtained -in these same internal control points. We choose to emphasize the observations -versus the background by setting a great variance for the background error, -here of :math:`10^{6}`. +in these same internal control points. We set twin experiments (see +:ref:`section_methodology_twin`) and the measurements are supposed to be +perfect. We choose to emphasize the observations versus the background by +setting a great variance for the background error, here of :math:`10^{6}`. The adjustment is carried out by displaying intermediate results during iterative optimization. diff --git a/doc/en/scripts/simple_NonLinearLeastSquares.png b/doc/en/scripts/simple_NonLinearLeastSquares.png new file mode 100644 index 0000000..91565f7 Binary files /dev/null and b/doc/en/scripts/simple_NonLinearLeastSquares.png differ diff --git a/doc/en/scripts/simple_NonLinearLeastSquares.py b/doc/en/scripts/simple_NonLinearLeastSquares.py index 601bd6a..6ac8873 100644 --- a/doc/en/scripts/simple_NonLinearLeastSquares.py +++ b/doc/en/scripts/simple_NonLinearLeastSquares.py @@ -3,7 +3,7 @@ from numpy import array, ravel def QuadFunction( coefficients ): """ - Simulation : y = a x^2 + b x + c + Quadratic simulation in x: y = a x^2 + b x + c """ a, b, c = list(ravel(coefficients)) x_points = (-5, 0, 1, 3, 10) @@ -15,8 +15,8 @@ def QuadFunction( coefficients ): Xb = array([1., 1., 1.]) Yobs = array([57, 2, 3, 17, 192]) # -print("Iterative resolution of the calibration problem") -print("-----------------------------------------------") +print("Resolution of the calibration problem") +print("-------------------------------------") print("") from adao import adaoBuilder case = adaoBuilder.New('') @@ -55,3 +55,17 @@ print("") print("Expected theoretical coefficients..:", ravel((2,-1,2))) print("") print("Calibration resulting coefficients.:", ravel(case.get('Analysis')[-1])) +# +Xa = case.get('Analysis')[-1] +import matplotlib.pyplot as plt +plt.rcParams['figure.figsize'] = (10, 4) +# +plt.figure() +plt.plot((-5,0,1,3,10),QuadFunction(Xb),'b-',label="Simulation at background") +plt.plot((-5,0,1,3,10),Yobs, 'kX',label='Observation',markersize=10) +plt.plot((-5,0,1,3,10),QuadFunction(Xa),'r-',label="Simulation at optimum") +plt.legend() +plt.title('Coefficients calibration', fontweight='bold') +plt.xlabel('Arbitrary coordinate') +plt.ylabel('Observation Yobs') +plt.savefig("simple_NonLinearLeastSquares.png") diff --git a/doc/en/scripts/simple_NonLinearLeastSquares.res b/doc/en/scripts/simple_NonLinearLeastSquares.res index 0668ec4..17cc93f 100644 --- a/doc/en/scripts/simple_NonLinearLeastSquares.res +++ b/doc/en/scripts/simple_NonLinearLeastSquares.res @@ -1,5 +1,5 @@ -Iterative resolution of the calibration problem ------------------------------------------------ +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] diff --git a/doc/en/scripts/simple_NonLinearLeastSquares.rst b/doc/en/scripts/simple_NonLinearLeastSquares.rst index 1aefa58..6e3a94a 100644 --- a/doc/en/scripts/simple_NonLinearLeastSquares.rst +++ b/doc/en/scripts/simple_NonLinearLeastSquares.rst @@ -8,7 +8,9 @@ vector :math:`\mathbf{x}`, and return as output the evaluation vector points. The calibration is done using an initial coefficient set (background state specified by ``Xb`` in the code), and with the information :math:`\mathbf{y}^o` (specified by ``Yobs`` in the code) of 5 measures obtained -in these same internal control points. +in these same internal control points. We set twin experiments (see +:ref:`section_methodology_twin`) and the measurements are supposed to be +perfect. The adjustment is carried out by displaying intermediate results during iterative optimization. diff --git a/doc/fr/ref_algorithm_3DVAR.rst b/doc/fr/ref_algorithm_3DVAR.rst index faf5b49..38e60f4 100644 --- a/doc/fr/ref_algorithm_3DVAR.rst +++ b/doc/fr/ref_algorithm_3DVAR.rst @@ -237,6 +237,13 @@ StoreSupplementaryCalculations .. literalinclude:: scripts/simple_3DVAR.res +.. include:: snippets/Header2Algo11.rst + +.. _simple_3DVAR: +.. image:: scripts/simple_3DVAR.png + :align: center + :width: 90% + .. ------------------------------------ .. .. include:: snippets/Header2Algo06.rst diff --git a/doc/fr/ref_algorithm_NonLinearLeastSquares.rst b/doc/fr/ref_algorithm_NonLinearLeastSquares.rst index 4bc6c60..39b305b 100644 --- a/doc/fr/ref_algorithm_NonLinearLeastSquares.rst +++ b/doc/fr/ref_algorithm_NonLinearLeastSquares.rst @@ -180,10 +180,19 @@ StoreSupplementaryCalculations .. literalinclude:: scripts/simple_NonLinearLeastSquares.res +.. include:: snippets/Header2Algo11.rst + +.. _simple_NonLinearLeastSquares: +.. image:: scripts/simple_NonLinearLeastSquares.png + :align: center + :width: 90% + .. ------------------------------------ .. .. include:: snippets/Header2Algo06.rst +- :ref:`section_ref_algorithm_LinearLeastSquares` - :ref:`section_ref_algorithm_3DVAR` +- :ref:`section_ref_algorithm_LinearityTest` .. ------------------------------------ .. .. include:: snippets/Header2Algo07.rst diff --git a/doc/fr/scripts/simple_3DVAR.png b/doc/fr/scripts/simple_3DVAR.png new file mode 100644 index 0000000..a12d902 Binary files /dev/null and b/doc/fr/scripts/simple_3DVAR.png differ diff --git a/doc/fr/scripts/simple_3DVAR.py b/doc/fr/scripts/simple_3DVAR.py index 04dcf56..3e98561 100644 --- a/doc/fr/scripts/simple_3DVAR.py +++ b/doc/fr/scripts/simple_3DVAR.py @@ -3,7 +3,7 @@ from numpy import array, ravel def QuadFunction( coefficients ): """ - Simulation : y = a x^2 + b x + c + Simulation quadratique aux points x : y = a x^2 + b x + c """ a, b, c = list(ravel(coefficients)) x_points = (-5, 0, 1, 3, 10) @@ -15,8 +15,8 @@ def QuadFunction( coefficients ): Xb = array([1., 1., 1.]) Yobs = array([57, 2, 3, 17, 192]) # -print("Résolution variationnelle du problème de calage") -print("-----------------------------------------------") +print("Résolution du problème de calage") +print("--------------------------------") print("") from adao import adaoBuilder case = adaoBuilder.New('') @@ -56,3 +56,17 @@ print("") print("Coefficients théoriques attendus..:", ravel((2,-1,2))) print("") print("Coefficients résultants du calage.:", ravel(case.get('Analysis')[-1])) +# +Xa = case.get('Analysis')[-1] +import matplotlib.pyplot as plt +plt.rcParams['figure.figsize'] = (10, 4) +# +plt.figure() +plt.plot((-5,0,1,3,10),QuadFunction(Xb),'b-',label="Simulation à l'ébauche") +plt.plot((-5,0,1,3,10),Yobs, 'kX',label='Observation',markersize=10) +plt.plot((-5,0,1,3,10),QuadFunction(Xa),'r-',label="Simulation à l'optimum") +plt.legend() +plt.title('Calage de coefficients', fontweight='bold') +plt.xlabel('Coordonnée arbitraire') +plt.ylabel('Observation Yobs') +plt.savefig("simple_3DVAR.png") diff --git a/doc/fr/scripts/simple_3DVAR.res b/doc/fr/scripts/simple_3DVAR.res index 04c0edd..a50796a 100644 --- a/doc/fr/scripts/simple_3DVAR.res +++ b/doc/fr/scripts/simple_3DVAR.res @@ -1,5 +1,5 @@ -Résolution variationnelle du problème de calage ------------------------------------------------ +Résolution du problème de calage +-------------------------------- État intermédiaire en itération courante : [1. 1. 1.] État intermédiaire en itération courante : [1.99739508 1.07086406 1.01346638] diff --git a/doc/fr/scripts/simple_3DVAR.rst b/doc/fr/scripts/simple_3DVAR.rst index 1e1f43d..c2c2c29 100644 --- a/doc/fr/scripts/simple_3DVAR.rst +++ b/doc/fr/scripts/simple_3DVAR.rst @@ -8,9 +8,11 @@ de coefficients :math:`\mathbf{x}`, et fournit en sortie le vecteur internes prédéfinis dans le modèle. Le calage s'effectue sur la base d'un jeu initial de coefficients (état d'ébauche désigné par ``Xb`` dans l'exemple), et avec l'information :math:`\mathbf{y}^o` (désignée par ``Yobs`` dans l'exemple) -de 5 mesures obtenues à ces mêmes points de contrôle internes. On privilégie -les observations au détriment de l'ébauche par l'indication d'une très -importante variance d'erreur d'ébauche, ici de :math:`10^{6}`. +de 5 mesures obtenues à ces mêmes points de contrôle internes. On se place en +expériences jumelles (voir :ref:`section_methodology_twin`) et les mesures sont +parfaites. On privilégie les observations au détriment de l'ébauche par +l'indication d'une très importante variance d'erreur d'ébauche, ici de +:math:`10^{6}`. L'ajustement s'effectue en affichant des résultats intermédiaires lors de l'optimisation itérative. diff --git a/doc/fr/scripts/simple_NonLinearLeastSquares.png b/doc/fr/scripts/simple_NonLinearLeastSquares.png new file mode 100644 index 0000000..a12d902 Binary files /dev/null and b/doc/fr/scripts/simple_NonLinearLeastSquares.png differ diff --git a/doc/fr/scripts/simple_NonLinearLeastSquares.py b/doc/fr/scripts/simple_NonLinearLeastSquares.py index 72d8f3b..8de1623 100644 --- a/doc/fr/scripts/simple_NonLinearLeastSquares.py +++ b/doc/fr/scripts/simple_NonLinearLeastSquares.py @@ -3,7 +3,7 @@ from numpy import array, ravel def QuadFunction( coefficients ): """ - Simulation : y = a x^2 + b x + c + Simulation quadratique aux points x : y = a x^2 + b x + c """ a, b, c = list(ravel(coefficients)) x_points = (-5, 0, 1, 3, 10) @@ -15,8 +15,8 @@ def QuadFunction( coefficients ): Xb = array([1., 1., 1.]) Yobs = array([57, 2, 3, 17, 192]) # -print("Résolution itérative du problème de calage") -print("------------------------------------------") +print("Résolution du problème de calage") +print("--------------------------------") print("") from adao import adaoBuilder case = adaoBuilder.New('') @@ -55,3 +55,17 @@ print("") print("Coefficients théoriques attendus..:", ravel((2,-1,2))) print("") print("Coefficients résultants du calage.:", ravel(case.get('Analysis')[-1])) +# +Xa = case.get('Analysis')[-1] +import matplotlib.pyplot as plt +plt.rcParams['figure.figsize'] = (10, 4) +# +plt.figure() +plt.plot((-5,0,1,3,10),QuadFunction(Xb),'b-',label="Simulation à l'ébauche") +plt.plot((-5,0,1,3,10),Yobs, 'kX',label='Observation',markersize=10) +plt.plot((-5,0,1,3,10),QuadFunction(Xa),'r-',label="Simulation à l'optimum") +plt.legend() +plt.title('Calage de coefficients', fontweight='bold') +plt.xlabel('Coordonnée arbitraire') +plt.ylabel('Observation Yobs') +plt.savefig("simple_NonLinearLeastSquares.png") diff --git a/doc/fr/scripts/simple_NonLinearLeastSquares.res b/doc/fr/scripts/simple_NonLinearLeastSquares.res index 04402fd..d98630a 100644 --- a/doc/fr/scripts/simple_NonLinearLeastSquares.res +++ b/doc/fr/scripts/simple_NonLinearLeastSquares.res @@ -1,5 +1,5 @@ -Résolution itérative du problème de calage ------------------------------------------- +Résolution du problème de calage +-------------------------------- État intermédiaire en itération courante : [1. 1. 1.] État intermédiaire en itération courante : [1.99739508 1.07086406 1.01346638] diff --git a/doc/fr/scripts/simple_NonLinearLeastSquares.rst b/doc/fr/scripts/simple_NonLinearLeastSquares.rst index 32bf45a..b661b3a 100644 --- a/doc/fr/scripts/simple_NonLinearLeastSquares.rst +++ b/doc/fr/scripts/simple_NonLinearLeastSquares.rst @@ -8,7 +8,9 @@ de coefficients :math:`\mathbf{x}`, et fournit en sortie le vecteur internes prédéfinis dans le modèle. Le calage s'effectue sur la base d'un jeu initial de coefficients (état d'ébauche désigné par ``Xb`` dans l'exemple), et avec l'information :math:`\mathbf{y}^o` (désignée par ``Yobs`` dans l'exemple) -de 5 mesures obtenues à ces mêmes points de contrôle internes. +de 5 mesures obtenues à ces mêmes points de contrôle internes. On se place en +expériences jumelles (voir :ref:`section_methodology_twin`) et les mesures sont +parfaites. L'ajustement s'effectue en affichant des résultats intermédiaires lors de l'optimisation itérative.