observers_method = """
def F_ObserverTemplate() : return BLOC(condition = " NodeType == 'Template' ",
- Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "ValuePrinter", into=("ValuePrinter", "ValueSeriePrinter", "ValueSaver", "ValueSerieSaver", "ValuePrinterAndSaver", "ValueSeriePrinterAndSaver", "ValueGnuPlotter", "ValueSerieGnuPlotter", "ValuePrinterAndGnuPlotter", "ValueSeriePrinterAndGnuPlotter", "ValuePrinterSaverAndGnuPlotter", "ValueSeriePrinterSaverAndGnuPlotter")),
+ Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "ValuePrinter", into=("ValuePrinter", "ValueSeriePrinter", "ValueSaver", "ValueSerieSaver", "ValuePrinterAndSaver", "ValueSeriePrinterAndSaver", "ValueGnuPlotter", "ValueSerieGnuPlotter", "ValuePrinterAndGnuPlotter", "ValueSeriePrinterAndGnuPlotter", "ValuePrinterSaverAndGnuPlotter", "ValueSeriePrinterSaverAndGnuPlotter", "ValueMean", "ValueStandardError", "ValueVariance", "ValueRMS")),
ValuePrinter = BLOC (condition = " Template == 'ValuePrinter' ",
ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info, var[-1]" ),
),
ValueSeriePrinterSaverAndGnuPlotter = BLOC (condition = " Template == 'ValueSeriePrinterSaverAndGnuPlotter' ",
ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info, var[:] \\nimport numpy, re\\nv=numpy.array(var[:], ndmin=1)\\nglobal istep\\ntry:\\n istep += 1\\nexcept:\\n istep = 0\\nf='/tmp/value_%s_%05i.txt'%(info,istep)\\nf=re.sub('\s','_',f)\\nprint 'Value saved in \\"%s\\"'%f\\nnumpy.savetxt(f,v)\\nimport Gnuplot\\nglobal ifig,gp\\ntry:\\n ifig += 1\\n gp('set style data lines')\\nexcept:\\n ifig = 0\\n gp = Gnuplot.Gnuplot(persist=1)\\n gp('set style data lines')\\ngp('set title \\"%s (Figure %i)\\"'%(info,ifig))\\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )" ),
),
+ ValuePrinter = BLOC (condition = " Template == 'ValueMean' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nprint info, numpy.nanmean(var[-1])" ),
+ ),
+ ValuePrinter = BLOC (condition = " Template == 'ValueStandardError' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nprint info, numpy.nanstd(var[-1])" ),
+ ),
+ ValuePrinter = BLOC (condition = " Template == 'ValueVariance' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nprint info, numpy.nanvar(var[-1])" ),
+ ),
+ ValuePrinter = BLOC (condition = " Template == 'ValueRMS' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nv = numpy.matrix( numpy.ravel( var[-1] ) )\\nprint info, float( numpy.sqrt((1./v.size)*(v*v.T)) )" ),
+ ),
)
def F_Observers(statut) : return FACT(
Keyword to indicate the covariance matrix of *a posteriori* analysis
errors.
+ APosterioriCorrelations
+ Keyword to indicate the correlation matrix of *a posteriori* analysis
+ errors.
+
+ APosterioriVariances
+ Keyword to indicate the variances diagonal matrix of *a posteriori*
+ analysis errors.
+
+ APosterioriStandardDeviations
+ Keyword to indicate the standard errors diagonal matrix of *a posteriori*
+ analysis errors.
+
BMA (Background minus Analysis)
Difference between the background state and the optimal state estimation,
noted as :math:`\mathbf{x}^b - \mathbf{x}^a`.
CostFunctionJb
Keyword to indicate the background part of the minimization function,
noted as :math:`J^b`.
+
+ CurrentState
+ Keyword to indicate the current state used during an optimization
+ algorithm procedure.
Example : ``d = ADD.get("Innovation")[-1]``
+ InnovationAtCurrentState
+ *List of vectors*. Each element is an innovation vector at current state.
+
+ Example : ``ds = ADD.get("InnovationAtCurrentState")[-1]``
+
MahalanobisConsistency
*List of values*. Each element is a value of the Mahalanobis quality
indicator.
matrix of the optimal state, coming from the :math:`\mathbf{A}*` covariance
matrix.
- Exemple : ``C = ADD.get("APosterioriCorrelations")[-1]``
+ Example : ``C = ADD.get("APosterioriCorrelations")[-1]``
APosterioriCovariance
*List of matrices*. Each element is an *a posteriori* error covariance
diagonal matrix of the optimal state, coming from the :math:`\mathbf{A}*`
covariance matrix.
- Exemple : ``S = ADD.get("APosterioriStandardDeviations")[-1]``
+ Example : ``S = ADD.get("APosterioriStandardDeviations")[-1]``
APosterioriVariances
*List of matrices*. Each element is an *a posteriori* error variances
diagonal matrix of the optimal state, coming from the :math:`\mathbf{A}*`
covariance matrix.
- Exemple : ``V = ADD.get("APosterioriVariances")[-1]``
+ Example : ``V = ADD.get("APosterioriVariances")[-1]``
BMA
*List of vectors*. Each element is a vector of difference between the
*List of vectors*. Each element is the optimal state obtained at the current
step of the optimization algorithm. It is not necessarely the last state.
- Exemple : ``Xo = ADD.get("CurrentOptimum")[:]``
+ Example : ``Xo = ADD.get("CurrentOptimum")[:]``
CurrentState
*List of vectors*. Each element is a usual state vector used during the
obtained at the current step the optimization algorithm. It is not
necessarely the number of the last iteration.
- Exemple : ``i = ADD.get("MahalanobisConsistency")[-1]``
+ Example : ``i = ADD.get("MahalanobisConsistency")[-1]``
Innovation
*List of vectors*. Each element is an innovation vector, which is in static
Example : ``d = ADD.get("Innovation")[-1]``
+ InnovationAtCurrentState
+ *List of vectors*. Each element is an innovation vector at current state.
+
+ Example : ``ds = ADD.get("InnovationAtCurrentState")[-1]``
+
MahalanobisConsistency
*List of values*. Each element is a value of the Mahalanobis quality
indicator.
the optimal state obtained at the current step the optimization algorithm,
that is, in the observation space.
- Exemple : ``hxo = ADD.get("SimulatedObservationAtCurrentOptimum")[-1]``
+ Example : ``hxo = ADD.get("SimulatedObservationAtCurrentOptimum")[-1]``
SimulatedObservationAtCurrentState
*List of vectors*. Each element is an observed vector at the current state,
.. index:: single: setDebug
**setDebug** ()
- This command enables the detailed information mode when running.
+ This command enables the detailed information mode when running.
.. index:: single: setNoDebug
**setNoDebug** ()
- This command disables the detailed information mode when running.
+ This command disables the detailed information mode when running.
.. index:: single: setObserver
**setObserver** (*Variable, Template, String, Script, Info*)
- This command allows to set an *observer* on the current or final
- calculation variable. Reference should be made to the description of the
- way of ':ref:`section_advanced_observer`, and to the
- :ref:`section_reference` to know what are the observable quantities. One
- defines as "*String*" the *observer* body, using a string including if
- necessary line breaks. It is recommended to use the patterns available by
- the argument "*Template*". There exist the following simple patterns:
- "ValuePrinter", "ValueSeriePrinter", "ValueSaver", "ValueSerieSaver",
- "ValuePrinterAndSaver", "ValueSeriePrinterAndSaver", "ValueGnuPlotter",
- "ValueSerieGnuPlotter", "ValuePrinterAndGnuPlotter",
- "ValueSeriePrinterAndGnuPlotter", "ValuePrinterSaverAndGnuPlotter",
- "ValueSeriePrinterSaverAndGnuPlotter". In the case of a definition as
- "*Script*", the file must contain only the body of the function, as
- described in the way of :ref:`section_advanced_observer`.
+ This command allows to set an *observer* on the current or final calculation
+ variable. Reference should be made to the description of the way of
+ ':ref:`section_advanced_observer`, and to the :ref:`section_reference` to
+ know what are the observable quantities. One defines as "*String*" the
+ *observer* body, using a string including if necessary line breaks. It is
+ recommended to use the patterns available by the argument "*Template*".
+ There exist the following simple patterns: "ValuePrinter",
+ "ValueSeriePrinter", "ValueSaver", "ValueSerieSaver",
+ "ValuePrinterAndSaver", "ValueSeriePrinterAndSaver", "ValueGnuPlotter",
+ "ValueSerieGnuPlotter", "ValuePrinterAndGnuPlotter",
+ "ValueSeriePrinterAndGnuPlotter", "ValuePrinterSaverAndGnuPlotter",
+ "ValueSeriePrinterSaverAndGnuPlotter", "ValueMean", "ValueStandardError",
+ "ValueVariance", "ValueRMS". In the case of a definition as "*Script*", the
+ file must contain only the body of the function, as described in the way of
+ :ref:`section_advanced_observer`.
Perform the calculation
+++++++++++++++++++++++
Mot-clé indiquant la matrice de covariance des erreurs *a posteriori*
d'analyse.
+ APosterioriCorrelations
+ Mot-clé indiquant la matrice de corrélation des erreurs *a posteriori*
+ d'analyse.
+
+ APosterioriVariances
+ Mot-clé indiquant la matrice diagonale des variances des erreurs *a
+ posteriori* d'analyse.
+
+ APosterioriStandardDeviations
+ Mot-clé indiquant la matrice diagonale des écarts-types des erreurs *a
+ posteriori* d'analyse.
+
BMA (Background minus Analysis)
Différence entre l'état d'ébauche et l'état optimal estimé, notée
:math:`\mathbf{x}^b - \mathbf{x}^a`.
CostFunctionJb
Mot-clé indiquant la partie due à l'ébauche dans la fonction de
minimisation, notée :math:`J^b`.
+
+ CurrentState
+ Mot-clé indiquant l'état courant utilisé au cours du déroulement d'un
+ algorithme d'optimisation.
Exemple : ``d = ADD.get("Innovation")[-1]``
+ InnovationAtCurrentState
+ *Liste de vecteurs*. Chaque élément est un vecteur d'innovation à l'état
+ courant.
+
+ Exemple : ``ds = ADD.get("InnovationAtCurrentState")[-1]``
+
MahalanobisConsistency
*Liste de valeurs*. Chaque élément est une valeur de l'indicateur de
qualité de Mahalanobis.
Exemple : ``d = ADD.get("Innovation")[-1]``
+ InnovationAtCurrentState
+ *Liste de vecteurs*. Chaque élément est un vecteur d'innovation à l'état
+ courant.
+
+ Exemple : ``ds = ADD.get("InnovationAtCurrentState")[-1]``
+
MahalanobisConsistency
*Liste de valeurs*. Chaque élément est une valeur de l'indicateur de
qualité de Mahalanobis.
"ValueSerieSaver", "ValuePrinterAndSaver", "ValueSeriePrinterAndSaver",
"ValueGnuPlotter", "ValueSerieGnuPlotter", "ValuePrinterAndGnuPlotter",
"ValueSeriePrinterAndGnuPlotter", "ValuePrinterSaverAndGnuPlotter",
- "ValueSeriePrinterSaverAndGnuPlotter". Dans le cas d'une définition par
- "*Script*", le fichier indiqué doit contenir uniquement le corps de la
- fonction, comme décrit dans la manière d':ref:`section_advanced_observer`.
+ "ValueSeriePrinterSaverAndGnuPlotter", "ValueMean", "ValueStandardError",
+ "ValueVariance", "ValueRMS". Dans le cas d'une définition par "*Script*", le
+ fichier indiqué doit contenir uniquement le corps de la fonction, comme
+ décrit dans la manière d':ref:`section_advanced_observer`.
Effectuer le calcul
+++++++++++++++++++
return version.date
def getPythonVersion(self):
- "Retourne la version de python utilisée"
+ "Retourne la version de python disponible"
import sys
return ".".join(map(str,sys.version_info[0:3]))
def getNumpyVersion(self):
- "Retourne la version de numpy utilisée"
+ "Retourne la version de numpy disponible"
import numpy.version
return numpy.version.version
def getScipyVersion(self):
- "Retourne la version de scipy utilisée"
+ "Retourne la version de scipy disponible"
import scipy.version
return scipy.version.version
def getMatplotlibVersion(self):
- "Retourne la version de matplotlib utilisée"
+ "Retourne la version de matplotlib disponible"
try:
import matplotlib
return matplotlib.__version__
return "0.0.0"
def getGnuplotVersion(self):
- "Retourne la version de gnuplotpy utilisée"
+ "Retourne la version de gnuplotpy disponible"
try:
import Gnuplot
return Gnuplot.__version__
except:
return "0.0"
+ def getSphinxVersion(self):
+ "Retourne la version de sphinx disponible"
+ try:
+ import sphinx
+ return sphinx.__version__
+ except:
+ return "0.0.0"
+
def getCurrentMemorySize(self):
"Retourne la taille mémoire courante utilisée"
return 1
__FunctionText = """print info, var[-1]\nimport numpy, re\nv=numpy.array(var[-1], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint 'Value saved in \"%s\"'%f\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig += 1\n gp('set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )"""
if Template == "ValueSeriePrinterSaverAndGnuPlotter":
__FunctionText = """print info, var[:] \nimport numpy, re\nv=numpy.array(var[:], ndmin=1)\nglobal istep\ntry:\n istep += 1\nexcept:\n istep = 0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub('\\s','_',f)\nprint 'Value saved in \"%s\"'%f\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal ifig,gp\ntry:\n ifig += 1\n gp('set style data lines')\nexcept:\n ifig = 0\n gp = Gnuplot.Gnuplot(persist=1)\n gp('set style data lines')\ngp('set title \"%s (Figure %i)\"'%(info,ifig))\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )"""
+ if Template == "ValueMean":
+ __FunctionText = """import numpy\nprint info, numpy.nanmean(var[-1])"""
+ if Template == "ValueStandardError":
+ __FunctionText = """import numpy\nprint info, numpy.nanstd(var[-1])"""
+ if Template == "ValueVariance":
+ __FunctionText = """import numpy\nprint info, numpy.nanvar(var[-1])"""
+ if Template == "ValueRMS":
+ __FunctionText = """import numpy\nv = numpy.matrix( numpy.ravel( var[-1] ) )\nprint info, float( numpy.sqrt((1./v.size)*(v*v.T)) )"""
elif Script is not None:
__FunctionText = _ImportFromScript(Script).getstring()
else: