Salome HOME
Minor source update for OM compatibility
[modules/adao.git] / src / daComposant / daCore / Templates.py
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (C) 2008-2024 EDF R&D
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21 # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
22 """
23     Modèles généraux pour les observers, le post-processing.
24 """
25 __author__ = "Jean-Philippe ARGAUD"
26 __all__ = ["ObserverTemplates"]
27
28 # flake8: noqa
29
30 import numpy
31
32 # ==============================================================================
33 class TemplateStorage(object):
34     """
35     Classe générale de stockage de type dictionnaire étendu
36     (Template)
37     """
38     __slots__ = ("__preferedLanguage", "__values", "__order")
39
40     def __init__( self, language = "fr_FR" ):
41         self.__preferedLanguage = language
42         self.__values           = {}
43         self.__order            = -1
44
45     def store( self, name = None, content = None, fr_FR = "", en_EN = "", order = "next" ):
46         "D.store(k, c,  fr_FR, en_EN, o) -> Store template k and its main characteristics"
47         if name is None or content is None:
48             raise ValueError("To be consistent, the storage of a template must provide a name and a content.")
49         if order == "next":
50             self.__order += 1
51         else:
52             self.__order = int(order)
53         self.__values[str(name)] = {
54             'content': str(content),
55             'fr_FR'  : str(fr_FR),         # noqa: E203
56             'en_EN'  : str(en_EN),         # noqa: E203
57             'order'  : int(self.__order),  # noqa: E203
58         }
59
60     def keys(self):
61         "D.keys() -> list of D's keys"
62         __keys = sorted(self.__values.keys())
63         return __keys
64
65     def __contains__(self, name):
66         "D.__contains__(k) -> True if D has a key k, else False"
67         return name in self.__values
68
69     def __len__(self):
70         "x.__len__() <==> len(x)"
71         return len(self.__values)
72
73     def __getitem__(self, name=None ):
74         "x.__getitem__(y) <==> x[y]"
75         return self.__values[name]['content']
76
77     def getdoc(self, name = None, lang = "fr_FR"):
78         "D.getdoc(k, l) -> Return documentation of key k in language l"
79         if lang not in self.__values[name]:
80             lang = self.__preferedLanguage
81         return self.__values[name][lang]
82
83     def keys_in_presentation_order(self):
84         "D.keys_in_presentation_order() -> list of D's keys in presentation order"
85         __orders = []
86         for ik in self.keys():
87             __orders.append( self.__values[ik]['order'] )
88         __reorder = numpy.array(__orders).argsort()
89         return (numpy.array(self.keys())[__reorder]).tolist()
90
91 # ==============================================================================
92 ObserverTemplates = TemplateStorage()
93
94 ObserverTemplates.store(
95     name    = "ValuePrinter",
96     content = """print(str(info)+" "+str(var[-1]))""",
97     fr_FR   = "Imprime sur la sortie standard la valeur courante de la variable",
98     en_EN   = "Print on standard output the current value of the variable",
99     order   = "next",
100 )
101 ObserverTemplates.store(
102     name    = "ValueAndIndexPrinter",
103     content = """print(str(info)+(" index %i:"%(len(var)-1))+" "+str(var[-1]))""",
104     fr_FR   = "Imprime sur la sortie standard la valeur courante de la variable, en ajoutant son index",
105     en_EN   = "Print on standard output the current value of the variable, adding its index",
106     order   = "next",
107 )
108 ObserverTemplates.store(
109     name    = "ValueSeriePrinter",
110     content = """print(str(info)+" "+str(var[:]))""",
111     fr_FR   = "Imprime sur la sortie standard la série des valeurs de la variable",
112     en_EN   = "Print on standard output the value series of the variable",
113     order   = "next",
114 )
115 ObserverTemplates.store(
116     name    = "ValueSaver",
117     content = """import 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(r'\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""",
118     fr_FR   = "Enregistre la valeur courante de la variable dans un fichier du répertoire '/tmp' nommé 'value...txt' selon le nom de la variable et l'étape d'enregistrement",
119     en_EN   = "Save the current value of the variable in a file of the '/tmp' directory named 'value...txt' from the variable name and the saving step",
120     order   = "next",
121 )
122 ObserverTemplates.store(
123     name    = "ValueSerieSaver",
124     content = """import 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(r'\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""",
125     fr_FR   = "Enregistre la série des valeurs de la variable dans un fichier du répertoire '/tmp' nommé 'value...txt' selon le nom de la variable et l'étape",
126     en_EN   = "Save the value series of the variable in a file of the '/tmp' directory named 'value...txt' from the variable name and the saving step",
127     order   = "next",
128 )
129 ObserverTemplates.store(
130     name    = "ValuePrinterAndSaver",
131     content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nprint(str(info)+" "+str(v))\nglobal istep\ntry:\n    istep+=1\nexcept:\n    istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub(r'\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""",
132     fr_FR   = "Imprime sur la sortie standard et, en même temps enregistre dans un fichier du répertoire '/tmp', la valeur courante de la variable",
133     en_EN   = "Print on standard output and, in the same time save in a file of the '/tmp' directory, the current value of the variable",
134     order   = "next",
135 )
136 ObserverTemplates.store(
137     name    = "ValueIndexPrinterAndSaver",
138     content = """import numpy, re\nv=numpy.array(var[-1], ndmin=1)\nprint(str(info)+(" index %i:"%(len(var)-1))+" "+str(v))\nglobal istep\ntry:\n    istep+=1\nexcept:\n    istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub(r'\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""",
139     fr_FR   = "Imprime sur la sortie standard et, en même temps enregistre dans un fichier du répertoire '/tmp', la valeur courante de la variable, en ajoutant son index",
140     en_EN   = "Print on standard output and, in the same time save in a file of the '/tmp' directory, the current value of the variable, adding its index",
141     order   = "next",
142 )
143 ObserverTemplates.store(
144     name    = "ValueSeriePrinterAndSaver",
145     content = """import numpy, re\nv=numpy.array(var[:], ndmin=1)\nprint(str(info)+" "+str(v))\nglobal istep\ntry:\n    istep+=1\nexcept:\n    istep=0\nf='/tmp/value_%s_%05i.txt'%(info,istep)\nf=re.sub(r'\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)""",
146     fr_FR   = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier du répertoire '/tmp', la série des valeurs de la variable",
147     en_EN   = "Print on standard output and, in the same time, save in a file of the '/tmp' directory, the value series of the variable",
148     order   = "next",
149 )
150 ObserverTemplates.store(
151     name    = "ValueGnuPlotter",
152     content = """import numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal igfig, gp\ntry:\n    igfig+=1\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\nexcept:\n    igfig=0\n    gp=Gnuplot.Gnuplot(persist=1)\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\n    gp('set style data lines')\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""",
153     fr_FR   = "Affiche graphiquement avec Gnuplot la valeur courante de la variable (affichage persistant)",
154     en_EN   = "Graphically plot with Gnuplot the current value of the variable (persistent plot)",
155     order   = "next",
156 )
157 ObserverTemplates.store(
158     name    = "ValueSerieGnuPlotter",
159     content = """import numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal igfig, gp\ntry:\n    igfig+=1\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\nexcept:\n    igfig=0\n    gp=Gnuplot.Gnuplot(persist=1)\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\n    gp('set style data lines')\n    gp('set xlabel \"Step\"')\n    gp('set ylabel \"Variable\"')\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""",
160     fr_FR   = "Affiche graphiquement avec Gnuplot la série des valeurs de la variable (affichage persistant)",
161     en_EN   = "Graphically plot with Gnuplot the value series of the variable (persistent plot)",
162     order   = "next",
163 )
164 ObserverTemplates.store(
165     name    = "ValuePrinterAndGnuPlotter",
166     content = """print(str(info)+' '+str(var[-1]))\nimport numpy, Gnuplot\nv=numpy.array(var[-1], ndmin=1)\nglobal igfig, gp\ntry:\n    igfig+=1\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\nexcept:\n    igfig=0\n    gp=Gnuplot.Gnuplot(persist=1)\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\n    gp('set style data lines')\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""",
167     fr_FR   = "Imprime sur la sortie standard et, en même temps, affiche graphiquement avec Gnuplot la valeur courante de la variable (affichage persistant)",
168     en_EN   = "Print on standard output and, in the same time, graphically plot with Gnuplot the current value of the variable (persistent plot)",
169     order   = "next",
170 )
171 ObserverTemplates.store(
172     name    = "ValueSeriePrinterAndGnuPlotter",
173     content = """print(str(info)+' '+str(var[:]))\nimport numpy, Gnuplot\nv=numpy.array(var[:], ndmin=1)\nglobal igfig, gp\ntry:\n    igfig+=1\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\nexcept:\n    igfig=0\n    gp=Gnuplot.Gnuplot(persist=1)\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\n    gp('set style data lines')\n    gp('set xlabel \"Step\"')\n    gp('set ylabel \"Variable\"')\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""",
174     fr_FR   = "Imprime sur la sortie standard et, en même temps, affiche graphiquement avec Gnuplot la série des valeurs de la variable (affichage persistant)",
175     en_EN   = "Print on standard output and, in the same time, graphically plot with Gnuplot the value series of the variable (persistent plot)",
176     order   = "next",
177 )
178 ObserverTemplates.store(
179     name    = "ValuePrinterSaverAndGnuPlotter",
180     content = """print(str(info)+' '+str(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(r'\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal igfig, gp\ntry:\n    igfig+=1\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\nexcept:\n    igfig=0\n    gp=Gnuplot.Gnuplot(persist=1)\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\n    gp('set style data lines')\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""",
181     fr_FR   = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier du répertoire '/tmp' et affiche graphiquement la valeur courante de la variable (affichage persistant)",
182     en_EN   = "Print on standard output and, in the same, time save in a file of the '/tmp' directory and graphically plot the current value of the variable (persistent plot)",
183     order   = "next",
184 )
185 ObserverTemplates.store(
186     name    = "ValueSeriePrinterSaverAndGnuPlotter",
187     content = """print(str(info)+' '+str(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(r'\\s','_',f)\nprint('Value saved in \"%s\"'%f)\nnumpy.savetxt(f,v)\nimport Gnuplot\nglobal igfig, gp\ntry:\n    igfig+=1\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\nexcept:\n    igfig=0\n    gp=Gnuplot.Gnuplot(persist=1)\n    gp('set title \"%s (Figure %i)\"'%(info,igfig))\n    gp('set style data lines')\n    gp('set xlabel \"Step\"')\n    gp('set ylabel \"Variable\"')\ngp.plot( Gnuplot.Data( v, with_='lines lw 2' ) )""",
188     fr_FR   = "Imprime sur la sortie standard et, en même temps, enregistre dans un fichier du répertoire '/tmp' et affiche graphiquement la série des valeurs de la variable (affichage persistant)",
189     en_EN   = "Print on standard output and, in the same, time save in a file of the '/tmp' directory and graphically plot the value series of the variable (persistent plot)",
190     order   = "next",
191 )
192 ObserverTemplates.store(
193     name    = "ValueMatPlotter",
194     content = """import numpy\nimport matplotlib.pyplot as plt\nv=numpy.array(var[-1], ndmin=1)\nglobal imfig, mp, ax\nplt.ion()\ntry:\n    imfig+=1\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nexcept:\n    imfig=0\n    mp = plt.figure()\n    ax = mp.add_subplot(1, 1, 1)\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nax.plot(v)\nplt.show()""",
195     fr_FR   = "Affiche graphiquement avec Matplolib la valeur courante de la variable (affichage non persistant)",
196     en_EN   = "Graphically plot with Matplolib the current value of the variable (non persistent plot)",
197     order   = "next",
198 )
199 ObserverTemplates.store(
200     name    = "ValueMatPlotterSaver",
201     content = """import numpy, re\nimport matplotlib.pyplot as plt\nv=numpy.array(var[-1], ndmin=1)\nglobal imfig, mp, ax\nplt.ion()\ntry:\n    imfig+=1\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nexcept:\n    imfig=0\n    mp = plt.figure()\n    ax = mp.add_subplot(1, 1, 1)\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nax.plot(v)\nf='/tmp/figure_%s_%05i.pdf'%(info,imfig)\nf=re.sub(r'\\s','_',f)\nplt.savefig(f)\nplt.show()""",
202     fr_FR   = "Affiche graphiquement avec Matplolib la valeur courante de la variable, et enregistre la figure dans un fichier du répertoire '/tmp' (figure persistante)",
203     en_EN   = "Graphically plot with Matplolib the current value of the variable, and save the figure in a file of the '/tmp' directory (persistant figure)",
204     order   = "next",
205 )
206 ObserverTemplates.store(
207     name    = "ValueSerieMatPlotter",
208     content = """import numpy\nimport matplotlib.pyplot as plt\nv=numpy.array(var[:], ndmin=1)\nglobal imfig, mp, ax\nplt.ion()\ntry:\n    imfig+=1\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nexcept:\n    imfig=0\n    mp = plt.figure()\n    ax = mp.add_subplot(1, 1, 1)\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\n    ax.set_xlabel('Step')\n    ax.set_ylabel('Variable')\nax.plot(v)\nplt.show()""",
209     fr_FR   = "Affiche graphiquement avec Matplolib la série des valeurs de la variable (affichage non persistant)",
210     en_EN   = "Graphically plot with Matplolib the value series of the variable (non persistent plot)",
211     order   = "next",
212 )
213 ObserverTemplates.store(
214     name    = "ValueSerieMatPlotterSaver",
215     content = """import numpy, re\nimport matplotlib.pyplot as plt\nv=numpy.array(var[:], ndmin=1)\nglobal imfig, mp, ax\nplt.ion()\ntry:\n    imfig+=1\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nexcept:\n    imfig=0\n    mp = plt.figure()\n    ax = mp.add_subplot(1, 1, 1)\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\n    ax.set_xlabel('Step')\n    ax.set_ylabel('Variable')\nax.plot(v)\nf='/tmp/figure_%s_%05i.pdf'%(info,imfig)\nf=re.sub(r'\\s','_',f)\nplt.savefig(f)\nplt.show()""",
216     fr_FR   = "Affiche graphiquement avec Matplolib la série des valeurs de la variable, et enregistre la figure dans un fichier du répertoire '/tmp' (figure persistante)",
217     en_EN   = "Graphically plot with Matplolib the value series of the variable, and save the figure in a file of the '/tmp' directory (persistant figure)",
218     order   = "next",
219 )
220 ObserverTemplates.store(
221     name    = "ValuePrinterAndMatPlotter",
222     content = """print(str(info)+' '+str(var[-1]))\nimport numpy\nimport matplotlib.pyplot as plt\nv=numpy.array(var[-1], ndmin=1)\nglobal imfig, mp, ax\nplt.ion()\ntry:\n    imfig+=1\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nexcept:\n    imfig=0\n    mp = plt.figure()\n    ax = mp.add_subplot(1, 1, 1)\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nax.plot(v)\nplt.show()""",
223     fr_FR   = "Affiche graphiquement avec Matplolib la valeur courante de la variable (affichage non persistant)",
224     en_EN   = "Graphically plot with Matplolib the current value of the variable (non persistent plot)",
225     order   = "next",
226 )
227 ObserverTemplates.store(
228     name    = "ValuePrinterAndMatPlotterSaver",
229     content = """print(str(info)+' '+str(var[-1]))\nimport numpy, re\nimport matplotlib.pyplot as plt\nv=numpy.array(var[-1], ndmin=1)\nglobal imfig, mp, ax\nplt.ion()\ntry:\n    imfig+=1\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nexcept:\n    imfig=0\n    mp = plt.figure()\n    ax = mp.add_subplot(1, 1, 1)\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nax.plot(v)\nf='/tmp/figure_%s_%05i.pdf'%(info,imfig)\nf=re.sub(r'\\s','_',f)\nplt.savefig(f)\nplt.show()""",
230     fr_FR   = "Affiche graphiquement avec Matplolib la valeur courante de la variable, et enregistre la figure dans un fichier du répertoire '/tmp' (figure persistante)",
231     en_EN   = "Graphically plot with Matplolib the current value of the variable, and save the figure in a file of the '/tmp' directory (persistant figure)",
232     order   = "next",
233 )
234 ObserverTemplates.store(
235     name    = "ValueSeriePrinterAndMatPlotter",
236     content = """print(str(info)+' '+str(var[:]))\nimport numpy\nimport matplotlib.pyplot as plt\nv=numpy.array(var[:], ndmin=1)\nglobal imfig, mp, ax\nplt.ion()\ntry:\n    imfig+=1\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nexcept:\n    imfig=0\n    mp = plt.figure()\n    ax = mp.add_subplot(1, 1, 1)\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\n    ax.set_xlabel('Step')\n    ax.set_ylabel('Variable')\nax.plot(v)\nplt.show()""",
237     fr_FR   = "Affiche graphiquement avec Matplolib la série des valeurs de la variable (affichage non persistant)",
238     en_EN   = "Graphically plot with Matplolib the value series of the variable (non persistent plot)",
239     order   = "next",
240 )
241 ObserverTemplates.store(
242     name    = "ValueSeriePrinterAndMatPlotterSaver",
243     content = """print(str(info)+' '+str(var[:]))\nimport numpy, re\nimport matplotlib.pyplot as plt\nv=numpy.array(var[:], ndmin=1)\nglobal imfig, mp, ax\nplt.ion()\ntry:\n    imfig+=1\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\nexcept:\n    imfig=0\n    mp = plt.figure()\n    ax = mp.add_subplot(1, 1, 1)\n    mp.suptitle('%s (Figure %i)'%(info,imfig))\n    ax.set_xlabel('Step')\n    ax.set_ylabel('Variable')\nax.plot(v)\nf='/tmp/figure_%s_%05i.pdf'%(info,imfig)\nf=re.sub(r'\\s','_',f)\nplt.savefig(f)\nplt.show()""",
244     fr_FR   = "Affiche graphiquement avec Matplolib la série des valeurs de la variable, et enregistre la figure dans un fichier du répertoire '/tmp' (figure persistante)",
245     en_EN   = "Graphically plot with Matplolib the value series of the variable, and save the figure in a file of the '/tmp' directory (persistant figure)",
246     order   = "next",
247 )
248 ObserverTemplates.store(
249     name    = "ValueMean",
250     content = """import numpy\nprint(str(info)+' '+str(numpy.nanmean(var[-1])))""",
251     fr_FR   = "Imprime sur la sortie standard la moyenne de la valeur courante de la variable",
252     en_EN   = "Print on standard output the mean of the current value of the variable",
253     order   = "next",
254 )
255 ObserverTemplates.store(
256     name    = "ValueStandardError",
257     content = """import numpy\nprint(str(info)+' '+str(numpy.nanstd(var[-1])))""",
258     fr_FR   = "Imprime sur la sortie standard l'écart-type de la valeur courante de la variable",
259     en_EN   = "Print on standard output the standard error of the current value of the variable",
260     order   = "next",
261 )
262 ObserverTemplates.store(
263     name    = "ValueVariance",
264     content = """import numpy\nprint(str(info)+' '+str(numpy.nanvar(var[-1])))""",
265     fr_FR   = "Imprime sur la sortie standard la variance de la valeur courante de la variable",
266     en_EN   = "Print on standard output the variance of the current value of the variable",
267     order   = "next",
268 )
269 ObserverTemplates.store(
270     name    = "ValueL2Norm",
271     content = """import numpy\nv = numpy.ravel( var[-1] )\nprint(str(info)+' '+str(float( numpy.linalg.norm(v) )))""",
272     fr_FR   = "Imprime sur la sortie standard la norme L2 de la valeur courante de la variable",
273     en_EN   = "Print on standard output the L2 norm of the current value of the variable",
274     order   = "next",
275 )
276 ObserverTemplates.store(
277     name    = "ValueRMS",
278     content = """import numpy\nv = numpy.ravel( var[-1] )\nprint(str(info)+' '+str(float( numpy.sqrt((1./v.size)*numpy.dot(v,v)) )))""",
279     fr_FR   = "Imprime sur la sortie standard la racine de la moyenne des carrés (RMS), ou moyenne quadratique, de la valeur courante de la variable",
280     en_EN   = "Print on standard output the root mean square (RMS), or quadratic mean, of the current value of the variable",
281     order   = "next",
282 )
283
284 # ==============================================================================
285 UserPostAnalysisTemplates = TemplateStorage()
286
287 UserPostAnalysisTemplates.store(
288     name    = "AnalysisPrinter",
289     content = """print('# Post-analysis')\nimport numpy\nxa=ADD.get('Analysis')[-1]\nprint('Analysis',xa)""",
290     fr_FR   = "Imprime sur la sortie standard la valeur optimale",
291     en_EN   = "Print on standard output the optimal value",
292     order   = "next",
293 )
294 UserPostAnalysisTemplates.store(
295     name    = "AnalysisSaver",
296     content = """print('# Post-analysis')\nimport numpy\nxa=ADD.get('Analysis')[-1]\nf='/tmp/analysis.txt'\nprint('Analysis saved in \"%s\"'%f)\nnumpy.savetxt(f,xa)""",
297     fr_FR   = "Enregistre la valeur optimale dans un fichier du répertoire '/tmp' nommé 'analysis.txt'",
298     en_EN   = "Save the optimal value in a file of the '/tmp' directory named 'analysis.txt'",
299     order   = "next",
300 )
301 UserPostAnalysisTemplates.store(
302     name    = "AnalysisPrinterAndSaver",
303     content = """print('# Post-analysis')\nimport numpy\nxa=ADD.get('Analysis')[-1]\nprint('Analysis',xa)\nf='/tmp/analysis.txt'\nprint('Analysis saved in \"%s\"'%f)\nnumpy.savetxt(f,xa)""",
304     fr_FR   = "Imprime sur la sortie standard et, en même temps enregistre dans un fichier du répertoire '/tmp', la valeur optimale",
305     en_EN   = "Print on standard output and, in the same time save in a file of the '/tmp' directory, the optimal value",
306     order   = "next",
307 )
308 UserPostAnalysisTemplates.store(
309     name    = "AnalysisSeriePrinter",
310     content = """print('# Post-analysis')\nimport numpy\nxa=ADD.get('Analysis')\nprint('Analysis',xa)""",
311     fr_FR   = "Imprime sur la sortie standard la série des valeurs optimales",
312     en_EN   = "Print on standard output the optimal value series",
313     order   = "next",
314 )
315 UserPostAnalysisTemplates.store(
316     name    = "AnalysisSerieSaver",
317     content = """print('# Post-analysis')\nimport numpy\nxa=ADD.get('Analysis')\nf='/tmp/analysis.txt'\nprint('Analysis saved in \"%s\"'%f)\nnumpy.savetxt(f,xa)""",
318     fr_FR   = "Enregistre la série des valeurs optimales dans un fichier du répertoire '/tmp' nommé 'analysis.txt'",
319     en_EN   = "Save the optimal value series in a file of the '/tmp' directory named 'analysis.txt'",
320     order   = "next",
321 )
322 UserPostAnalysisTemplates.store(
323     name    = "AnalysisSeriePrinterAndSaver",
324     content = """print('# Post-analysis')\nimport numpy\nxa=ADD.get('Analysis')\nprint('Analysis',xa)\nf='/tmp/analysis.txt'\nprint('Analysis saved in \"%s\"'%f)\nnumpy.savetxt(f,xa)""",
325     fr_FR   = "Imprime sur la sortie standard et, en même temps enregistre dans un fichier du répertoire '/tmp', la série des valeurs optimales",
326     en_EN   = "Print on standard output and, in the same time save in a file of the '/tmp' directory, the optimal value series",
327     order   = "next",
328 )
329
330 # ==============================================================================
331 if __name__ == "__main__":
332     print("\n AUTODIAGNOSTIC\n")