# This file is part of SALOME ADAO module
#
# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public
+# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License.
#
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
import logging
logging.basicConfig(level=logging.WARNING)
#----------- Templates Part ---------------#
-begin_catalog_file = """# -*- coding: utf-8 -*-
+begin_catalog_file = """#-*-coding:iso-8859-1-*-
+#
+# Copyright (C) 2008-2015 EDF R&D
+#
+# This file is part of SALOME ADAO module
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
# --------------------------------------------------------
-# generated by AdaoCatalogGenerator at ${date}
+# Generated by AdaoCatalogGenerator on ${date}
# --------------------------------------------------------
import Accas
from Accas import *
-JdC = JDC_CATA (code = '%s',
- execmodul = None,
- regles = ( AU_MOINS_UN ('ASSIMILATION_STUDY','CHECKING_STUDY'), AU_PLUS_UN ('ASSIMILATION_STUDY','CHECKING_STUDY')),
- )
+JdC = JDC_CATA (
+ code = '%s',
+ execmodul = None,
+ regles = ( AU_MOINS_UN ('ASSIMILATION_STUDY','CHECKING_STUDY'), AU_PLUS_UN ('ASSIMILATION_STUDY','CHECKING_STUDY')),
+ )
VERSION_CATALOGUE='%s'
"""%(module_version.name,module_version.version)
data_method = """
-def F_${data_name}(statut) : return FACT(statut = statut,
- FROM = SIMP(statut = "o", typ = "TXM", into=(${data_into}), defaut=${data_default}),
- SCRIPT_DATA = BLOC ( condition = " FROM in ( 'Script', ) ",
-
- SCRIPT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant si nécessaire la définition d'une variable interne de même nom que le concept parent", ang="Waiting for a script file name, with or without the full path to find it, containing if necessary the definition of an internal variable of the same name as the parent concept"),
- ),
- STRING_DATA = BLOC ( condition = " FROM in ( 'String', ) ",
-
- STRING = SIMP(statut = "o", typ = "TXM",${ms_default} fr="En attente d'une chaine de caractères entre guillements. Pour construire un vecteur ou une matrice, ce doit être une suite de nombres, utilisant un espace ou une virgule pour séparer deux éléments et un point-virgule pour séparer deux lignes", ang="Waiting for a string in quotes. To build a vector or a matrix, it has to be a float serie, using a space or comma to separate two elements in a line, a semi-colon to separate rows"),
- ),
- SCRIPTWITHFUNCTIONS_DATA = BLOC ( condition = " FROM in ( 'ScriptWithFunctions', ) ",
-
- SCRIPTWITHFUNCTIONS_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant en variables internes trois fonctions de calcul nommées DirectOperator, TangentOperator et AdjointOperator", ang="Waiting for a script file name, with or without the full path to find it, containing as internal variables three computation functions named DirectOperator, TangentOperator and AdjointOperator"),
- ),
- SCRIPTWITHONEFUNCTION_DATA = BLOC ( condition = " FROM in ( 'ScriptWithOneFunction', ) ",
-
- SCRIPTWITHONEFUNCTION_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant en variable interne une seule fonction de calcul nommée DirectOperator", ang="Waiting for a script file name, with or without the full path to find it, containing as internal variable only one function named DirectOperator"),
- DifferentialIncrement = SIMP(statut="o", typ = "R", val_min=0, val_max=1, defaut=0.01, fr="Incrément de la perturbation dX pour calculer la dérivée, construite en multipliant X par l'incrément en évitant les valeurs nulles", ang="Increment of dX perturbation to calculate the derivative, build multiplying X by the increment avoiding null values"),
- CenteredFiniteDifference = SIMP(statut="o", typ = "I", into=(0, 1), defaut=0, fr="Formulation centrée (1) ou décentrée (0) pour la méthode des différences finies", ang="Centered (1) or uncentered (0) formulation for the finite differences method"),
- EnableMultiProcessing = SIMP(statut="f", typ = "I", into=(0, 1), defaut=0, fr="EXPERIMENTAL : Calculs élémentaires effectués en séquentiel (0) ou en parallèle (1) dans la méthode des différences finies", ang="EXPERIMENTAL: Elementary calculations done sequentially (0) or in parallel (1) in the finite differences method"),
- ),
- SCRIPTWITHSWITCH_DATA = BLOC ( condition = " FROM in ( 'ScriptWithSwitch', ) ",
-
- SCRIPTWITHSWITCH_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant un switch pour les calculs direct, tangent et adjoint", ang="Waiting for a script file name, with or without the full path to find it, containing a switch for direct, tangent and adjoint computations"),
- ),
- FUNCTIONDICT_DATA = BLOC ( condition = " FROM in ( 'FunctionDict', ) ",
-
- FUNCTIONDICT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="OBSOLETE : conservé pour compatibilité avec la version 6.5, sera supprimé dans le futur", ang="OBSOLETE: keeped for compatibility with the 6.5 version, will be removed in the future"),
- ),
- TEMPLATE_DATA = BLOC (condition = " FROM in ( 'Template', ) ",
- Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "AnalysisPrinter", into=("AnalysisPrinter", "AnalysisSaver", "AnalysisPrinterAndSaver")),
- AnalysisPrinter = BLOC (condition = " Template == 'AnalysisPrinter' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa" ),
- ),
- AnalysisSaver = BLOC (condition = " Template == 'AnalysisSaver' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nf='/tmp/analysis.txt'\\nprint 'Analysis saved in \\"%s\\"'%f\\nnumpy.savetxt(f,xa)" ),
- ),
- AnalysisPrinterAndSaver = BLOC (condition = " Template == 'AnalysisPrinterAndSaver' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa\\nf='/tmp/analysis.txt'\\nprint 'Analysis saved in \\"%s\\"'%f\\nnumpy.savetxt(f,xa)" ),
- ),
- ),
- )
+def F_${data_name}(statut) : return FACT(
+ statut = statut,
+ FROM = SIMP(statut = "o", typ = "TXM", into=(${data_into}), defaut=${data_default}),
+ SCRIPT_DATA = BLOC ( condition = " FROM in ( 'Script', ) ",
+ SCRIPT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant si nécessaire la définition d'une variable interne de même nom que le concept parent", ang="Waiting for a script file name, with or without the full path to find it, containing if necessary the definition of an internal variable of the same name as the parent concept"),
+ ),
+ STRING_DATA = BLOC ( condition = " FROM in ( 'String', ) ",
+ STRING = SIMP(statut = "o", typ = "TXM",${ms_default} fr="En attente d'une chaine de caractères entre guillements. Pour construire un vecteur ou une matrice, ce doit être une suite de nombres, utilisant un espace ou une virgule pour séparer deux éléments et un point-virgule pour séparer deux lignes", ang="Waiting for a string in quotes. To build a vector or a matrix, it has to be a float serie, using a space or comma to separate two elements in a line, a semi-colon to separate rows"),
+ ),
+ SCRIPTWITHFUNCTIONS_DATA = BLOC ( condition = " FROM in ( 'ScriptWithFunctions', ) ",
+ SCRIPTWITHFUNCTIONS_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant en variables internes trois fonctions de calcul nommées DirectOperator, TangentOperator et AdjointOperator", ang="Waiting for a script file name, with or without the full path to find it, containing as internal variables three computation functions named DirectOperator, TangentOperator and AdjointOperator"),
+ ),
+ SCRIPTWITHONEFUNCTION_DATA = BLOC ( condition = " FROM in ( 'ScriptWithOneFunction', ) ",
+ SCRIPTWITHONEFUNCTION_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant en variable interne une seule fonction de calcul nommée DirectOperator", ang="Waiting for a script file name, with or without the full path to find it, containing as internal variable only one function named DirectOperator"),
+ DifferentialIncrement = SIMP(statut="o", typ = "R", val_min=0, val_max=1, defaut=0.01, fr="Incrément de la perturbation dX pour calculer la dérivée, construite en multipliant X par l'incrément en évitant les valeurs nulles", ang="Increment of dX perturbation to calculate the derivative, build multiplying X by the increment avoiding null values"),
+ CenteredFiniteDifference = SIMP(statut="o", typ = "I", into=(0, 1), defaut=0, fr="Formulation centrée (1) ou décentrée (0) pour la méthode des différences finies", ang="Centered (1) or uncentered (0) formulation for the finite differences method"),
+ EnableMultiProcessing = SIMP(statut="f", typ = "I", into=(0, 1), defaut=0, fr="Calculs élémentaires effectués en séquentiel (0) ou en parallèle (1) dans la méthode des différences finies", ang="Elementary calculations done sequentially (0) or in parallel (1) in the finite differences method"),
+ ),
+ SCRIPTWITHSWITCH_DATA = BLOC ( condition = " FROM in ( 'ScriptWithSwitch', ) ",
+ SCRIPTWITHSWITCH_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()), fr="En attente d'un nom de fichier script, avec ou sans le chemin complet pour le trouver, contenant un switch pour les calculs direct, tangent et adjoint", ang="Waiting for a script file name, with or without the full path to find it, containing a switch for direct, tangent and adjoint computations"),
+ ),
+ TEMPLATE_DATA = BLOC (condition = " FROM in ( 'Template', ) ",
+ Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "AnalysisPrinter", into=("AnalysisPrinter", "AnalysisSaver", "AnalysisPrinterAndSaver")),
+ AnalysisPrinter = BLOC (condition = " Template == 'AnalysisPrinter' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa" ),
+ ),
+ AnalysisSaver = BLOC (condition = " Template == 'AnalysisSaver' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nf='/tmp/analysis.txt'\\nprint 'Analysis saved in \\"%s\\"'%f\\nnumpy.savetxt(f,xa)" ),
+ ),
+ AnalysisPrinterAndSaver = BLOC (condition = " Template == 'AnalysisPrinterAndSaver' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy\\nxa=numpy.ravel(ADD.get('Analysis')[-1])\\nprint 'Analysis:',xa\\nf='/tmp/analysis.txt'\\nprint 'Analysis saved in \\"%s\\"'%f\\nnumpy.savetxt(f,xa)" ),
+ ),
+ ),
+ )
"""
init_method = """
)
def F_Init(statut) : return FACT(statut = statut,
- INIT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr())),
- TARGET_LIST = SIMP(statut = "o", typ = "TXM", min=1, max="**", into=F_InitChoice(), validators=(VerifExiste(2))),
- )
+ INIT_FILE = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr())),
+ TARGET_LIST = SIMP(statut = "o", typ = "TXM", min=1, max="**", into=F_InitChoice(), validators=(VerifExiste(2))),
+ )
"""
assim_data_method = """
-def F_${assim_name}(statut) : return FACT(statut=statut,
+def F_${assim_name}(statut) : return FACT(
+ statut=statut,
${storage}
- INPUT_TYPE = SIMP(statut="o", typ = "TXM", into=(${choices}), defaut=${default_choice}),
-${decl_choices}
- )
+ INPUT_TYPE = SIMP(statut="o", typ = "TXM", into=(${choices}), defaut=${default_choice}),${decl_choices}
+ )
"""
assim_data_choice = """
- ${choice_name} = BLOC ( condition = " INPUT_TYPE in ( '${choice_name}', ) ",
- data = F_${choice_name}("o"),
- ),
-"""
+ ${choice_name} = BLOC ( condition = " INPUT_TYPE in ( '${choice_name}', ) ",
+ data = F_${choice_name}("o"),
+ ),"""
observers_choice = """
- ${var_name} = BLOC (condition=" '${var_name}' in set(SELECTION) ",
- ${var_name}_data = FACT(statut = "o",
- Scheduler = SIMP(statut = "f", typ = "TXM"),
- Info = SIMP(statut = "o", typ = "TXM", defaut = "${var_name}"),
- NodeType = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "Template", into=("String", "Script", "Template")),
- PythonScript = BLOC (condition = " NodeType == 'String' ",
- Value = SIMP(statut = "o", typ = "TXM")
- ),
- UserFile = BLOC (condition = " NodeType == 'Script' ",
- Value = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()))
- ),
- ObserverTemplate = 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")),
- ValuePrinter = BLOC (condition = " Template == 'ValuePrinter' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info,var[-1]" ),
- ),
- ValueSeriePrinter = BLOC (condition = " Template == 'ValueSeriePrinter' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info,var[:]" ),
- ),
- ValueSaver = BLOC (condition = " Template == 'ValueSaver' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[-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)" ),
- ),
- ValueSerieSaver = BLOC (condition = " Template == 'ValueSerieSaver' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[:])) \\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)" ),
- ),
- ValuePrinterAndSaver = BLOC (condition = " Template == 'ValuePrinterAndSaver' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[-1]))\\nprint info,v\\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)" ),
- ),
- ValueSeriePrinterAndSaver = BLOC (condition = " Template == 'ValueSeriePrinterAndSaver' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[:])) \\nprint info,v\\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)" ),
- ),
- ValueGnuPlotter = BLOC (condition = " Template == 'ValueGnuPlotter' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import 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( var[-1], with_='lines lw 2' ) )" ),
- ),
- ValueSerieGnuPlotter = BLOC (condition = " Template == 'ValueSerieGnuPlotter' ",
- ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import 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( var[:], with_='lines lw 2' ) )" ),
- ),
- ),
- ),
- ),
-"""
+ ${var_name} = BLOC (condition=" '${var_name}' in set(SELECTION) ",
+ ${var_name}_data = FACT(statut = "o",
+ Scheduler = SIMP(statut = "f", typ = "TXM"),
+ Info = SIMP(statut = "o", typ = "TXM", defaut = "${var_name}"),
+ NodeType = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "Template", into=("String", "Script", "Template")),
+ PythonScript = BLOC (condition = " NodeType == 'String' ",
+ Value = SIMP(statut = "o", typ = "TXM")
+ ),
+ UserFile = BLOC (condition = " NodeType == 'Script' ",
+ Value = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr()))
+ ),
+ ObserverTemplate = F_ObserverTemplate(),
+ ),
+ ),"""
observers_method = """
-def F_Observers(statut) : return FACT(statut=statut,
- SELECTION = SIMP(statut="o", defaut=[], typ="TXM", min=0, max="**", validators=NoRepeat(), into=(${choices})),
-${decl_choices}
- )
+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")),
+ ValuePrinter = BLOC (condition = " Template == 'ValuePrinter' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info,var[-1]" ),
+ ),
+ ValueSeriePrinter = BLOC (condition = " Template == 'ValueSeriePrinter' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "print info,var[:]" ),
+ ),
+ ValueSaver = BLOC (condition = " Template == 'ValueSaver' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[-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)" ),
+ ),
+ ValueSerieSaver = BLOC (condition = " Template == 'ValueSerieSaver' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[:])) \\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)" ),
+ ),
+ ValuePrinterAndSaver = BLOC (condition = " Template == 'ValuePrinterAndSaver' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[-1]))\\nprint info,v\\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)" ),
+ ),
+ ValueSeriePrinterAndSaver = BLOC (condition = " Template == 'ValueSeriePrinterAndSaver' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import numpy,re\\nv=numpy.array((var[:])) \\nprint info,v\\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)" ),
+ ),
+ ValueGnuPlotter = BLOC (condition = " Template == 'ValueGnuPlotter' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import 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( var[-1], with_='lines lw 2' ) )" ),
+ ),
+ ValueSerieGnuPlotter = BLOC (condition = " Template == 'ValueSerieGnuPlotter' ",
+ ValueTemplate = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "import 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( var[:], with_='lines lw 2' ) )" ),
+ ),
+ )
+
+def F_Observers(statut) : return FACT(
+ statut=statut,
+ SELECTION = SIMP(statut="o", defaut=[], typ="TXM", min=0, max="**", validators=NoRepeat(), into=(${choices})),${decl_choices}
+ )
+"""
+
+algo_choices = """
+def F_AlgorithmChoices(statut,algos_names) : return FACT(
+ statut = statut,
+ Algorithm = SIMP(statut="o", typ = "TXM", into = algos_names ),
+ Parameters = SIMP(statut="f", typ = "TXM", into=("Defaults", "Dict") ),
+ Dict = BLOC ( condition = " Parameters == 'Dict' ",
+ statut="f",
+ data = F_Dict("o"),
+ ),${all_algo_defaults}
+ )
"""
+one_algo_choices = """
+ Parameters${algo_name} = BLOC (condition = " (Parameters == 'Defaults') and (Algorithm == '${algo_name}') ",
+ statut="f",
+${algo_parameters} ),"""
assim_study = """
-def F_variables(statut) : return FACT(statut=statut,
- regles = ( MEME_NOMBRE ('NAMES', 'SIZES')),
- NAMES = SIMP(statut="o", typ="TXM", max="**", validators=NoRepeat()),
- SIZES = SIMP(statut="o", typ="I", val_min=1, max="**")
- )
+def F_variables(statut) : return FACT(
+ statut=statut,
+ regles = ( MEME_NOMBRE ('NAMES', 'SIZES')),
+ NAMES = SIMP(statut="o", typ="TXM", max="**", validators=NoRepeat()),
+ SIZES = SIMP(statut="o", typ="I", val_min=1, max="**")
+ )
ASSIMILATION_STUDY = PROC(nom="ASSIMILATION_STUDY",
- op=None,
- repetable = "n",
- Study_name = SIMP(statut="o", typ = "TXM", defaut="ADAO Calculation Case"),
- Study_repertory = SIMP(statut="f", typ = "Repertoire", min=1, max=1),
- Debug = SIMP(statut="f", typ = "I", into=(0, 1), defaut=0),
- Algorithm = SIMP(statut="o", typ = "TXM", into=(${algos_names})),
- Background = F_Background("o"),
- BackgroundError = F_BackgroundError("o"),
- Observation = F_Observation("o"),
- ObservationError = F_ObservationError("o"),
- ObservationOperator = F_ObservationOperator("o"),
- EvolutionModel = F_EvolutionModel("f"),
- EvolutionError = F_EvolutionError("f"),
- ControlInput = F_ControlInput("f"),
- AlgorithmParameters = F_AlgorithmParameters("f"),
- UserDataInit = F_Init("f"),
- UserPostAnalysis = F_UserPostAnalysis("o"),
- InputVariables = F_variables("f"),
- OutputVariables = F_variables("f"),
- Observers = F_Observers("f")
- )
+ op=None,
+ repetable = "n",
+ StudyName = SIMP(statut="o", typ = "TXM", defaut="ADAO Calculation Case"),
+ StudyRepertory = SIMP(statut="f", typ = "Repertoire", min=1, max=1),
+ Debug = SIMP(statut="f", typ = "I", into=(0, 1), defaut=0),
+ AlgorithmChoices = F_AlgorithmChoices("o",(${algos_names})),
+ Background = F_Background("o"),
+ BackgroundError = F_BackgroundError("o"),
+ Observation = F_Observation("o"),
+ ObservationError = F_ObservationError("o"),
+ ObservationOperator = F_ObservationOperator("o"),
+ EvolutionModel = F_EvolutionModel("f"),
+ EvolutionError = F_EvolutionError("f"),
+ ControlInput = F_ControlInput("f"),
+ UserDataInit = F_Init("f"),
+ UserPostAnalysis = F_UserPostAnalysis("o"),
+ InputVariables = F_variables("f"),
+ OutputVariables = F_variables("f"),
+ Observers = F_Observers("f")
+ )
CHECKING_STUDY = PROC(nom="CHECKING_STUDY",
- op=None,
- repetable = "n",
- Study_name = SIMP(statut="o", typ = "TXM", defaut="ADAO Checking Case"),
- Study_repertory = SIMP(statut="f", typ = "Repertoire", min=1, max=1),
- Debug = SIMP(statut="f", typ = "I", into=(0, 1), defaut=0),
- Algorithm = SIMP(statut="o", typ = "TXM", into=(${check_names})),
- CheckingPoint = F_CheckingPoint("o"),
- BackgroundError = F_BackgroundError("f"),
- Observation = F_Observation("f"),
- ObservationError = F_ObservationError("f"),
- ObservationOperator = F_ObservationOperator("o"),
- AlgorithmParameters = F_AlgorithmParameters("f"),
- UserDataInit = F_Init("f"),
- Observers = F_Observers("f")
- )
+ op=None,
+ repetable = "n",
+ StudyName = SIMP(statut="o", typ = "TXM", defaut="ADAO Checking Case"),
+ StudyRepertory = SIMP(statut="f", typ = "Repertoire", min=1, max=1),
+ Debug = SIMP(statut="f", typ = "I", into=(0, 1), defaut=0),
+ AlgorithmChoices = F_AlgorithmChoices("o",(${check_names})),
+ CheckingPoint = F_CheckingPoint("o"),
+ BackgroundError = F_BackgroundError("f"),
+ Observation = F_Observation("f"),
+ ObservationError = F_ObservationError("f"),
+ ObservationOperator = F_ObservationOperator("o"),
+ UserDataInit = F_Init("f"),
+ Observers = F_Observers("f")
+ )
"""
begin_catalog_file = string.Template(begin_catalog_file)
assim_study = string.Template(assim_study)
observers_method = string.Template(observers_method)
observers_choice = string.Template(observers_choice)
+algo_choices = string.Template(algo_choices)
+one_algo_choices = string.Template(one_algo_choices)
#----------- End of Templates Part ---------------#
from time import strftime
mem_file.write(begin_catalog_file.substitute(date=strftime("%Y-%m-%d %H:%M:%S")))
+# Step initial: on obtient la liste des algos
+algos_names = ""
+check_names = ""
+decl_algos = ""
+assim_study_object = daCore.AssimilationStudy.AssimilationStudy()
+algos_list = assim_study_object.get_available_algorithms()
+del assim_study_object
+for algo_name in algos_list:
+ if algo_name in infos.AssimAlgos:
+ logging.debug("An assimilation algorithm is found: " + algo_name)
+ algos_names += "\"" + algo_name + "\", "
+ elif algo_name in infos.CheckAlgos:
+ logging.debug("A checking algorithm is found: " + algo_name)
+ check_names += "\"" + algo_name + "\", "
+ else:
+ logging.debug("This algorithm is not considered: " + algo_name)
+
# Step 1: A partir des infos, on cree les fonctions qui vont permettre
# d'entrer les donnees utilisateur
for data_input_name in infos.DataTypeDict.keys():
mem_file.write(data_method.substitute(data_name = data_name,
data_into = data_into,
data_default = data_default,
- ms_default = ms_default))
+ ms_default = ms_default,
+ algos_names = algos_names+check_names))
# Step 2: On cree les fonctions qui permettent de rentrer les donnees des algorithmes
for assim_data_input_name in infos.AssimDataDict.keys():
- logging.debug("An assimilation algorithm data input is found: " + assim_data_input_name)
- assim_name = assim_data_input_name
+ logging.debug("An input function data input is found: " + assim_data_input_name)
+ # assim_name = assim_data_input_name
storage = ""
choices = ""
default_choice = ""
decl_choices = ""
decl_opts = ""
if infos.AssimDataDefaultDict[assim_data_input_name] in infos.StoredAssimData:
- storage = " Stored = SIMP(statut=\"o\", typ = \"I\", into=(0, 1), defaut=0, fr=\"Choix de stockage interne ou non du concept parent\", ang=\"Choice of the storage or not of the parent concept\"),"
+ storage = " Stored = SIMP(statut=\"o\", typ = \"I\", into=(0, 1), defaut=0, fr=\"Choix de stockage interne ou non du concept parent\", ang=\"Choice of the storage or not of the parent concept\"),"
for choice in infos.AssimDataDict[assim_data_input_name]:
choices += "\"" + choice + "\", "
decl_choices += assim_data_choice.substitute(choice_name = choice)
if choice in infos.StoredAssimData:
- storage = " Stored = SIMP(statut=\"o\", typ = \"I\", into=(0, 1), defaut=0, fr=\"Choix de stockage interne ou non du concept parent\", ang=\"Choice of the storage or not of the parent concept\"),"
+ storage = " Stored = SIMP(statut=\"o\", typ = \"I\", into=(0, 1), defaut=0, fr=\"Choix de stockage interne ou non du concept parent\", ang=\"Choice of the storage or not of the parent concept\"),"
default_choice = "\"" + infos.AssimDataDefaultDict[assim_data_input_name] + "\""
- mem_file.write(assim_data_method.substitute(assim_name = assim_name,
- storage = storage,
- choices = choices,
- decl_choices = decl_choices,
- default_choice=default_choice))
+ mem_file.write(assim_data_method.substitute(assim_name = assim_data_input_name,
+ storage = storage,
+ choices = choices,
+ decl_choices = decl_choices,
+ default_choice = default_choice))
# Step 3: On ajoute les fonctions representant les options possibles
for opt_name in infos.OptDict.keys():
mem_file.write(data_method.substitute(data_name = data_name,
data_into = data_into,
data_default = data_default,
- ms_default = ms_default))
+ ms_default = ms_default,
+ algos_names = algos_names+check_names))
# Step 4: On ajoute la methode optionnelle init
# TODO uniformiser avec le step 3
mem_file.write(observers_method.substitute(choices = infos.ObserversList,
decl_choices = decl_choices))
-# Final step: Add algorithm and assim_study
-algos_names = ""
-check_names = ""
-decl_algos = ""
-
-assim_study_object = daCore.AssimilationStudy.AssimilationStudy()
-algos_list = assim_study_object.get_available_algorithms()
-for algo_name in algos_list:
- if algo_name in infos.AssimAlgos:
- logging.debug("An assimilation algorithm is found: " + algo_name)
- algos_names += "\"" + algo_name + "\", "
- elif algo_name in infos.CheckAlgos:
- logging.debug("A checking algorithm is found: " + algo_name)
- check_names += "\"" + algo_name + "\", "
- else:
- logging.debug("This algorithm is not considered: " + algo_name)
+# Step 5: Add algorithmic choices
+
+all_names = eval((algos_names+check_names))
+all_algo_defaults = ""
+for algo in all_names:
+ assim_study_object = daCore.AssimilationStudy.AssimilationStudy()
+ assim_study_object.setAlgorithm(choice=algo)
+ par_dict = assim_study_object.getAlgorithmParameters(False)
+ par_keys = par_dict.keys()
+ par_keys.sort()
+ algo_parameters = ""
+ for pn in par_keys:
+ if pn in ("StoreInternalVariables",): continue
+ pt = par_dict[pn]["typecast"]
+ pd = par_dict[pn]["default"]
+ pm = par_dict[pn]["message"]
+ if par_dict[pn].has_key("minval") and par_dict[pn]["minval"] is not None:
+ vi = ", val_min=%s"%par_dict[pn]["minval"]
+ else:
+ vi = ""
+ if par_dict[pn].has_key("minval") and par_dict[pn]["maxval"] is not None:
+ vs = ", val_max=%s"%par_dict[pn]["maxval"]
+ else:
+ vs = ""
+ if pt is int:
+ algo_parameters += """ %s = SIMP(statut="f", typ="I"%s%s, min=1, max=1, defaut=%s, fr="%s"),\n"""%(pn,vi,vs,int(pd),pm)
+ elif pt is float:
+ algo_parameters += """ %s = SIMP(statut="f", typ="R"%s%s, min=1, max=1, defaut=%s, fr="%s"),\n"""%(pn,vi,vs,float(pd),pm)
+ elif pt is bool:
+ algo_parameters += """ %s = SIMP(statut="f", typ="I", min=1, max=1, defaut=%s, fr="%s"),\n"""%(pn,int(pd),pm)
+ elif pt is str and par_dict[pn].has_key("listval"):
+ algo_parameters += """ %s = SIMP(statut="f", typ="TXM", min=1, max=1, defaut="%s", into=%s, fr="%s"),\n"""%(pn,str(pd),par_dict[pn]["listval"],pm)
+ elif pt is tuple and par_dict[pn].has_key("listval"):
+ algo_parameters += """ %s = SIMP(statut="f", typ="TXM", max="**", into=%s, fr="%s"),\n"""%(pn,par_dict[pn]["listval"],pm)
+ else:
+ algo_parameters += """ %s = SIMP(statut="f", typ="TXM", fr="%s"),\n"""%(pn,pm)
+ del assim_study_object
+ if algo_parameters != "":
+ all_algo_defaults += one_algo_choices.substitute(
+ algo_name=algo,
+ algo_parameters=algo_parameters,
+ )
+
+mem_file.write(algo_choices.substitute(all_algo_defaults=all_algo_defaults))
+# Final step: Add algorithm and assim_study
mem_file.write(assim_study.substitute(algos_names=algos_names,
check_names=check_names,
decl_algos=decl_algos))
.. index:: single: Observers
.. index:: single: Observer Template
.. index:: single: OutputVariables
-.. index:: single: Study_name
-.. index:: single: Study_repertory
+.. index:: single: StudyName
+.. index:: single: StudyRepertory
.. index:: single: UserDataInit
.. index:: single: UserPostAnalysis
.. index:: single: UserPostAnalysis Template
physical variables that are bundled together in the output observation
vector. This information is dedicated to data processed inside an algorithm.
- Study_name
+ StudyName
*Required command*. This is an open string to describe the ADAO study by a
name or a sentence.
- Study_repertory
+ StudyRepertory
*Optional command*. If available, this directory is used as base name for
calculation, and used to find all the script files, given by name without
path, that can be used to define some other commands by scripts.
.. index:: single: Observer
.. index:: single: Observers
.. index:: single: Observer Template
-.. index:: single: Study_name
-.. index:: single: Study_repertory
+.. index:: single: StudyName
+.. index:: single: StudyRepertory
.. index:: single: UserDataInit
This set of commands is related to the description of a checking case, that is a
printing or plotting it, etc. Common templates are provided to help the user
to start or to quickly make his case.
- Study_name
+ StudyName
*Required command*. This is an open string to describe the ADAO study by a
name or a sentence.
- Study_repertory
+ StudyRepertory
*Optional command*. If available, this directory is used as base name for
calculation, and used to find all the script files, given by name without
path, that can be used to define some other commands by scripts.
.. index:: single: Observers
.. index:: single: Observer Template
.. index:: single: OutputVariables
-.. index:: single: Study_name
-.. index:: single: Study_repertory
+.. index:: single: StudyName
+.. index:: single: StudyRepertory
.. index:: single: UserDataInit
.. index:: single: UserPostAnalysis
.. index:: single: UserPostAnalysis Template
Cette information est destinée à être utilisée dans le traitement
algorithmique interne des données.
- Study_name
+ StudyName
*Commande obligatoire*. C'est une chaîne de caractères quelconque pour
décrire l'étude ADAO par un nom ou une déclaration.
- Study_repertory
+ StudyRepertory
*Commande optionnelle*. S'il existe, ce répertoire est utilisé comme base
pour les calculs, et il est utilisé pour trouver les fichiers de script,
donnés par nom sans répertoire, qui peuvent être utilisés pour définir
.. index:: single: Observer
.. index:: single: Observers
.. index:: single: Observer Template
-.. index:: single: Study_name
-.. index:: single: Study_repertory
+.. index:: single: StudyName
+.. index:: single: StudyRepertory
.. index:: single: UserDataInit
Ce jeu de commandes est lié à la description d'un cas de vérification, qui est
courants (squelettes) sont fournis pour aider l'utilisateur ou pour
faciliter l'élaboration d'un cas.
- Study_name
+ StudyName
*Commande obligatoire*. C'est une chaîne de caractères quelconque pour
décrire l'étude ADAO par un nom ou une déclaration.
- Study_repertory
+ StudyRepertory
*Commande optionnelle*. S'il existe, ce répertoire est utilisé comme base
pour les calculs, et il est utilisé pour trouver les fichiers de script,
donnés par nom sans répertoire, qui peuvent être utilisés pour définir
-ASSIMILATION_STUDY(Study_name='Test',
+ASSIMILATION_STUDY(StudyName='Test',
Debug=0,
- Algorithm='Blue',
+ AlgorithmChoices=_F(Algorithm='Blue',),
Background=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='String',
"""import numpy
xa=numpy.ravel(ADD.get('Analysis')[-1])
print 'Analysis:',xa""",),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
+#CHECKSUM:05cc41b743bfb035b9bcc0bba13f31f8 -:FIN CHECKSUM
\ No newline at end of file
-ASSIMILATION_STUDY(Study_name='Test',
+ASSIMILATION_STUDY(StudyName='Test',
Debug=0,
- Algorithm='3DVAR',
+ AlgorithmChoices=_F(Algorithm='3DVAR',),
Background=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='String',
"""import numpy
xa=numpy.ravel(ADD.get('Analysis')[-1])
print 'Analysis:',xa""",),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
+#CHECKSUM:58b5740b60d070b936a5b8952002fa5b -:FIN CHECKSUM
\ No newline at end of file
-ASSIMILATION_STUDY(Study_name='Test',
- Study_repertory='@prefix@/share/salome/adao_examples/daSalome',
- Debug=0,
- Algorithm='3DVAR',
+ASSIMILATION_STUDY(StudyName='Test',
+ StudyRepertory='@prefix@/share/salome/adao_examples/daSalome',
+ AlgorithmChoices=_F(Algorithm='3DVAR',),
Background=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='Script',
"""import numpy
xa=numpy.ravel(ADD.get('Analysis')[-1])
print 'Analysis:',xa""",),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
-ASSIMILATION_STUDY(Study_name='Test',
- Study_repertory='@prefix@/share/salome/adao_examples/daSalome',
- Debug=0,
- Algorithm='3DVAR',
+ASSIMILATION_STUDY(StudyName='Test',
+ StudyRepertory='@prefix@/share/salome/adao_examples/daSalome',
+ AlgorithmChoices=_F(Algorithm='3DVAR',),
Background=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='Script',
"""import numpy
xa=numpy.ravel(ADD.get('Analysis')[-1])
print 'Analysis:',xa""",),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
-ASSIMILATION_STUDY(Study_name='Test',
- Study_repertory='@prefix@/share/salome/adao_examples/daSalome',
- Debug=0,
- Algorithm='Blue',
+ASSIMILATION_STUDY(StudyName='Test',
+ StudyRepertory='@prefix@/share/salome/adao_examples/daSalome',
+ AlgorithmChoices=_F(Algorithm='Blue',),
Background=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='Script',
print "Min, mean, max = %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa))
print
""",),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
-ASSIMILATION_STUDY(Study_name='Test',
- Study_repertory='@prefix@/share/salome/adao_examples/daSalome',
- Debug=0,
- Algorithm='3DVAR',
+ASSIMILATION_STUDY(StudyName='Test',
+ StudyRepertory='@prefix@/share/salome/adao_examples/daSalome',
+ AlgorithmChoices=_F(Algorithm='3DVAR',),
Background=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='String',
print "Min, mean, max of Analysis...= %8.3f, %8.3f, %8.3f"%(min(Xa),numpy.mean(Xa),max(Xa))
print
""",),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
-ASSIMILATION_STUDY(Study_name='test_observers',
- Study_repertory='@prefix@/share/salome/adao_examples/daSalome',
- Debug=0,
- Algorithm='3DVAR',
+ASSIMILATION_STUDY(StudyName='test_observers',
+ StudyRepertory='@prefix@/share/salome/adao_examples/daSalome',
+ AlgorithmChoices=_F(Algorithm='3DVAR',
+ Parameters='Dict',
+ data=_F(FROM='Script',
+ SCRIPT_FILE='test006_Observers_var.py',),),
Background=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='Script',
INPUT_TYPE='Function',
data=_F(FROM='FunctionDict',
FUNCTIONDICT_FILE='test006_Observers_Observation_Operator.py',),),
- AlgorithmParameters=_F(INPUT_TYPE='Dict',
- data=_F(FROM='Script',
- SCRIPT_FILE='test006_Observers_var.py',),),
UserDataInit=_F(INIT_FILE='test006_Observers_init.py',
- TARGET_LIST=
- ('Background','BackgroundError','Observation',
- 'ObservationError','AlgorithmParameters',),),
+ TARGET_LIST=('Background','BackgroundError','Observation','ObservationError',),),
+ UserPostAnalysis=_F(FROM='Template',
+ Template='AnalysisPrinter',
+ ValueTemplate=
+ """import numpy
+xa=numpy.ravel(ADD.get('Analysis')[-1])
+print 'Analysis:',xa""",),
Observers=_F(SELECTION=('CurrentState','CostFunctionJ',),
CurrentState_data=_F(Info='CurrentState',
NodeType='Script',
gp.hardcopy(filename=filename, color=1)
numero += 1
""",),),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
study_config['Name'] = 'test_observers'
study_config['Debug'] = '0'
study_config['Algorithm'] = '3DVAR'
+AlgorithmParameters_config = {}
+AlgorithmParameters_config['Type'] = 'Dict'
+AlgorithmParameters_config['From'] = 'Script'
+AlgorithmParameters_config['Data'] = 'test006_Observers_var.py'
+study_config['AlgorithmParameters'] = AlgorithmParameters_config
Background_config = {}
Background_config['Type'] = 'Vector'
Background_config['From'] = 'Script'
outputvariables_config['adao_default'] = -1
study_config['OutputVariables'] = outputvariables_config
study_config['Repertory'] = '@prefix@/share/salome/adao_examples/daSalome'
-AlgorithmParameters_config = {}
-AlgorithmParameters_config['Type'] = 'Dict'
-AlgorithmParameters_config['From'] = 'Script'
-AlgorithmParameters_config['Data'] = 'test006_Observers_var.py'
-study_config['AlgorithmParameters'] = AlgorithmParameters_config
+Analysis_config = {}
+Analysis_config['From'] = 'String'
+Analysis_config['Data'] = """import numpy
+xa=numpy.ravel(ADD.get('Analysis')[-1])
+print 'Analysis:',xa"""
+study_config['UserPostAnalysis'] = Analysis_config
Init_config = {}
Init_config['Type'] = 'Dict'
Init_config['From'] = 'Script'
Init_config['Data'] = 'test006_Observers_init.py'
-Init_config['Target'] = ['Background','BackgroundError','Observation','ObservationError','AlgorithmParameters',]
+Init_config['Target'] = ['Background','BackgroundError','Observation','ObservationError',]
study_config['UserDataInit'] = Init_config
observers = {}
observers["CostFunctionJ"] = {}
-CHECKING_STUDY(Study_name='Elementary gradient test',
- Debug=0,
- Algorithm='GradientTest',
+CHECKING_STUDY(StudyName='Elementary gradient test',
+ AlgorithmChoices=_F(Algorithm='GradientTest',
+ Parameters='Dict',
+ data=_F(FROM='String',
+ STRING='{ "SetSeed" : 1000 }',),),
CheckingPoint=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='String',
ObservationOperator=_F(Stored=0,
INPUT_TYPE='Matrix',
data=_F(FROM='String',
- STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),
- AlgorithmParameters=_F(INPUT_TYPE='Dict',
- data=_F(FROM='String',
- STRING='{ "SetSeed" : 1000 }',),),);
+ STRING='1 0 0 ; 0 1 0 ; 0 0 1',),),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
+#CHECKSUM:1b2edbf93b6252687f4a9dc33dc25dc0 -:FIN CHECKSUM
\ No newline at end of file
study_config['Name'] = 'Elementary gradient test'
study_config['Debug'] = '0'
study_config['Algorithm'] = 'GradientTest'
+AlgorithmParameters_config = {}
+AlgorithmParameters_config['Type'] = 'Dict'
+AlgorithmParameters_config['From'] = 'String'
+AlgorithmParameters_config['Data'] = '{ "SetSeed" : 1000 }'
+study_config['AlgorithmParameters'] = AlgorithmParameters_config
CheckingPoint_config = {}
CheckingPoint_config['Type'] = 'Vector'
CheckingPoint_config['From'] = 'String'
outputvariables_config['Order'] = ['adao_default']
outputvariables_config['adao_default'] = -1
study_config['OutputVariables'] = outputvariables_config
-AlgorithmParameters_config = {}
-AlgorithmParameters_config['Type'] = 'Dict'
-AlgorithmParameters_config['From'] = 'String'
-AlgorithmParameters_config['Data'] = '{ "SetSeed" : 1000 }'
-study_config['AlgorithmParameters'] = AlgorithmParameters_config
-CHECKING_STUDY(Study_name='Test',
- Debug=0,
- Algorithm='GradientTest',
+CHECKING_STUDY(StudyName='Test',
+ AlgorithmChoices=_F(Algorithm='GradientTest',
+ Parameters='Dict',
+ data=_F(FROM='String',
+ STRING='{ "SetSeed" : 1000 }',),),
CheckingPoint=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='String',
ObservationOperator=_F(Stored=0,
INPUT_TYPE='Matrix',
data=_F(FROM='String',
- STRING='1 0 0 ; 0 1 0 ; 0 0 1 ; 1 0 0 ; 0 1 0 ; 0 0 1',),),
- AlgorithmParameters=_F(INPUT_TYPE='Dict',
- data=_F(FROM='String',
- STRING='{ "SetSeed" : 1000 }',),),);
+ STRING='1 0 0 ; 0 1 0 ; 0 0 1 ; 1 0 0 ; 0 1 0 ; 0 0 1',),),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
+#CHECKSUM:102c824e97113ec0e22b72312a5fc0d0 -:FIN CHECKSUM
\ No newline at end of file
study_config['Name'] = 'Test'
study_config['Debug'] = '0'
study_config['Algorithm'] = 'GradientTest'
+AlgorithmParameters_config = {}
+AlgorithmParameters_config['Type'] = 'Dict'
+AlgorithmParameters_config['From'] = 'String'
+AlgorithmParameters_config['Data'] = '{ "SetSeed" : 1000 }'
+study_config['AlgorithmParameters'] = AlgorithmParameters_config
CheckingPoint_config = {}
CheckingPoint_config['Type'] = 'Vector'
CheckingPoint_config['From'] = 'String'
outputvariables_config['Order'] = ['adao_default']
outputvariables_config['adao_default'] = -1
study_config['OutputVariables'] = outputvariables_config
-AlgorithmParameters_config = {}
-AlgorithmParameters_config['Type'] = 'Dict'
-AlgorithmParameters_config['From'] = 'String'
-AlgorithmParameters_config['Data'] = '{ "SetSeed" : 1000 }'
-study_config['AlgorithmParameters'] = AlgorithmParameters_config
-CHECKING_STUDY(Study_name='Test',
- Debug=0,
- Algorithm='AdjointTest',
+CHECKING_STUDY(StudyName='Test',
+ AlgorithmChoices=_F(Algorithm='AdjointTest',
+ Parameters='Dict',
+ data=_F(FROM='String',
+ STRING='{ "SetSeed" : 1000 }',),),
CheckingPoint=_F(Stored=0,
INPUT_TYPE='Vector',
data=_F(FROM='String',
ObservationOperator=_F(Stored=0,
INPUT_TYPE='Matrix',
data=_F(FROM='String',
- STRING='1 0 0 ; 0 1 0 ; 0 0 1 ; 1 0 0 ; 0 1 0 ; 0 0 1',),),
- AlgorithmParameters=_F(INPUT_TYPE='Dict',
- data=_F(FROM='String',
- STRING='{ "SetSeed" : 1000 }',),),);
+ STRING='1 0 0 ; 0 1 0 ; 0 0 1 ; 1 0 0 ; 0 1 0 ; 0 0 1',),),);
+#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE
+#CHECKSUM:4aeff874ab3d45fc7f39ed6798e33b13 -:FIN CHECKSUM
\ No newline at end of file
study_config['Name'] = 'Test'
study_config['Debug'] = '0'
study_config['Algorithm'] = 'AdjointTest'
+AlgorithmParameters_config = {}
+AlgorithmParameters_config['Type'] = 'Dict'
+AlgorithmParameters_config['From'] = 'String'
+AlgorithmParameters_config['Data'] = '{ "SetSeed" : 1000 }'
+study_config['AlgorithmParameters'] = AlgorithmParameters_config
CheckingPoint_config = {}
CheckingPoint_config['Type'] = 'Vector'
CheckingPoint_config['From'] = 'String'
outputvariables_config['Order'] = ['adao_default']
outputvariables_config['adao_default'] = -1
study_config['OutputVariables'] = outputvariables_config
-AlgorithmParameters_config = {}
-AlgorithmParameters_config['Type'] = 'Dict'
-AlgorithmParameters_config['From'] = 'String'
-AlgorithmParameters_config['Data'] = '{ "SetSeed" : 1000 }'
-study_config['AlgorithmParameters'] = AlgorithmParameters_config
message = "Type de simulation pour l'estimation des quantiles",
listval = ["Linear", "NonLinear"]
)
+ self.defineRequiredParameter( # Pas de type
+ name = "Bounds",
+ message = "Liste des valeurs de bornes",
+ )
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
self._pre_run()
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
listval = ["APosterioriCovariance", "BMA", "CurrentState", "CostFunctionJ", "Innovation"]
)
+ self.defineRequiredParameter( # Pas de type
+ name = "Bounds",
+ message = "Liste des valeurs de bornes",
+ )
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
self._pre_run()
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
listval = ["BMA", "OMA", "OMB", "CurrentState", "CostFunctionJ", "Innovation", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum"]
)
+ self.defineRequiredParameter( # Pas de type
+ name = "Bounds",
+ message = "Liste des valeurs de bornes",
+ )
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
self._pre_run()
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
listval = ["BMA", "OMA", "OMB", "CurrentState", "CostFunctionJ", "Innovation", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum"]
)
+ self.defineRequiredParameter( # Pas de type
+ name = "Bounds",
+ message = "Liste des valeurs de bornes",
+ )
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
self._pre_run()
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
listval = ["BMA", "OMA", "OMB", "CurrentState", "CostFunctionJ", "Innovation", "SimulatedObservationAtBackground", "SimulatedObservationAtCurrentState", "SimulatedObservationAtOptimum"]
)
+ self.defineRequiredParameter( # Pas de type
+ name = "Bounds",
+ message = "Liste des valeurs de bornes",
+ )
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
self._pre_run()
message = "Liste de calculs supplémentaires à stocker et/ou effectuer",
listval = ["APosterioriCovariance", "BMA", "CurrentState", "CostFunctionJ", "Innovation"]
)
+ self.defineRequiredParameter( # Pas de type
+ name = "Bounds",
+ message = "Liste des valeurs de bornes",
+ )
def run(self, Xb=None, Y=None, U=None, HO=None, EM=None, CM=None, R=None, B=None, Q=None, Parameters=None):
self._pre_run()
mypkgpythondir =$(salomepythondir)/daEficas
mypkgpython_PYTHON = \
- configuration_ADAO.py \
- convert_adao.py \
- generator_adao.py \
- __init__.py \
- prefs_ADAO.py \
- prefs.py
+ configuration_ADAO.py \
+ convert_adao.py \
+ generator_adao.py \
+ __init__.py \
+ prefs_ADAO.py \
+ prefs.py \
+ traduitADAOV7_4_0ToV7_6_0.py \
+ traduitADAOV7_5_0ToV7_6_0.py \
+ traduitADAOV7_5_1ToV7_6_0.py
EXTRA_DIST = prefs_ADAO.py.in
# -*- coding: utf-8 -*-
+#
# Copyright (C) 2008-2015 EDF R&D
#
# This file is part of SALOME ADAO module
def generate_da(self):
- if "__CHECKING_STUDY__Study_name" in self.dictMCVal.keys():
+ if "__CHECKING_STUDY__StudyName" in self.dictMCVal.keys():
self.type_of_study = "CHECKING_STUDY"
else:
self.type_of_study = "ASSIMILATION_STUDY"
# Extraction de Study_type
self.text_da += "study_config['StudyType'] = '" + self.type_of_study + "'\n"
- # Extraction de Study_name
- self.text_da += "study_config['Name'] = '" + self.dictMCVal["__"+self.type_of_study+"__Study_name"] + "'\n"
+ # Extraction de StudyName
+ self.text_da += "study_config['Name'] = '" + self.dictMCVal["__"+self.type_of_study+"__StudyName"] + "'\n"
# Extraction de Debug
if "__"+self.type_of_study+"__Debug" in self.dictMCVal.keys():
self.text_da += "study_config['Debug'] = '" + str(self.dictMCVal["__"+self.type_of_study+"__Debug"]) + "'\n"
else:
self.text_da += "study_config['Debug'] = '0'\n"
- # Extraction de Algorithm
- self.text_da += "study_config['Algorithm'] = '" + self.dictMCVal["__"+self.type_of_study+"__Algorithm"] + "'\n"
+
+ # Extraction de Algorithm et de ses parametres
+ if "__"+self.type_of_study+"__AlgorithmChoices__Algorithm" in self.dictMCVal.keys():
+ self.text_da += "study_config['Algorithm'] = '" + self.dictMCVal["__"+self.type_of_study+"__AlgorithmChoices__Algorithm"] + "'\n"
+ self.add_AlgorithmChoices()
+ elif "__"+self.type_of_study+"__Algorithm" in self.dictMCVal.keys():
+ self.text_da += "study_config['Algorithm'] = '" + self.dictMCVal["__"+self.type_of_study+"__Algorithm"] + "'\n"
if "__"+self.type_of_study+"__Background__INPUT_TYPE" in self.dictMCVal.keys():
self.add_data("Background")
self.add_variables()
# Parametres optionnels
- # Extraction du Study_repertory
- if "__"+self.type_of_study+"__Study_repertory" in self.dictMCVal.keys():
- self.text_da += "study_config['Repertory'] = '" + self.dictMCVal["__"+self.type_of_study+"__Study_repertory"] + "'\n"
+ # Extraction du StudyRepertory
+ if "__"+self.type_of_study+"__StudyRepertory" in self.dictMCVal.keys():
+ self.text_da += "study_config['Repertory'] = '" + self.dictMCVal["__"+self.type_of_study+"__StudyRepertory"] + "'\n"
# Extraction de AlgorithmParameters
if "__"+self.type_of_study+"__AlgorithmParameters__INPUT_TYPE" in self.dictMCVal.keys():
self.add_algorithm_parameters()
else:
raise Exception('From Type unknown', from_type)
+ def add_AlgorithmChoices(self):
+
+ if not self.dictMCVal.has_key("__"+self.type_of_study+"__AlgorithmChoices__Parameters"): return
+
+ data_name = "AlgorithmParameters"
+ data_type = "Dict"
+ para_type = self.dictMCVal["__"+self.type_of_study+"__AlgorithmChoices__Parameters"]
+ if para_type == "Defaults":
+ from_type = para_type
+ elif para_type == "Dict":
+ from_type = self.dictMCVal["__"+self.type_of_study+"__AlgorithmChoices__Dict__data__FROM"]
+
+ if from_type == "Script":
+ data = self.dictMCVal["__"+self.type_of_study+"__AlgorithmChoices__Dict__data__SCRIPT_DATA__SCRIPT_FILE"]
+ self.text_da += data_name + "_config = {} \n"
+ self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
+ self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
+ self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
+ self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
+ elif from_type == "String":
+ data = self.dictMCVal["__"+self.type_of_study+"__AlgorithmChoices__Dict__data__STRING_DATA__STRING"]
+ self.text_da += data_name + "_config = {} \n"
+ self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
+ self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
+ self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
+ self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
+ elif from_type == "Defaults":
+ base = "__"+self.type_of_study+"__AlgorithmChoices__Parameters"
+ keys = [k for k in self.dictMCVal.keys() if base in k]
+ keys.remove(base)
+ keys = [k.replace(base,'') for k in keys]
+ data = '{'
+ for k in keys:
+ data += '"%s":"%s",'%(k.split('__')[-1],self.dictMCVal[base+k])
+ data += '}'
+ self.text_da += data_name + "_config = {} \n"
+ self.text_da += data_name + "_config['Type'] = '" + data_type + "'\n"
+ self.text_da += data_name + "_config['From'] = '" + from_type + "'\n"
+ self.text_da += data_name + "_config['Data'] = '" + data + "'\n"
+ self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config\n"
+
def add_variables(self):
# Input variables
--- /dev/null
+#-*-coding:iso-8859-1-*-
+#
+# Copyright (C) 2008-2015 EDF R&D
+#
+# This file is part of SALOME ADAO module
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
+
+import log
+import optparse
+import sys
+import re
+
+from load import getJDC, getJDCFromTexte
+from mocles import parseKeywords
+from removemocle import *
+from renamemocle import *
+from renamemocle import *
+from inseremocle import *
+from changeValeur import *
+from movemocle import *
+from dictErreurs import *
+from regles import pasDeRegle
+
+version_out = "V7_6_0"
+
+usage="""Usage: python %prog [options]
+
+Typical use is:
+ python %prog --infile=xxxx.comm --outfile=yyyy.comm"""
+
+atraiter = (
+ "ASSIMILATION_STUDY",
+ "CHECKING_STUDY",
+ )
+
+dict_erreurs = {
+ "ASSIMILATION_STUDY":"Changements dans l'arbre et dans les noms",
+ "CHECKING_STUDY":"Changements dans l'arbre et dans les noms",
+ }
+
+sys.dict_erreurs=dict_erreurs
+
+def traduc(infile=None,outfile=None,texte=None,flog=None):
+ hdlr = log.initialise(flog)
+ if infile is not None:
+ jdc = getJDC(infile,atraiter)
+ elif texte is not None:
+ jdc = getJDCFromTexte(texte,atraiter)
+ else:
+ raise ValueError("Traduction du JDC impossible")
+
+ #Parse les mocles des commandes
+ parseKeywords(jdc.root)
+ GenereErreurPourCommande(jdc,('Algorithm','AlgorithmParameters','FunctionDict'))
+ # ==========================================================================
+
+ for command in atraiter:
+ # Renomme le MC ou en insere un nouveau s'il n'existe pas ensuite
+ renameMotCle(jdc, command, "AlgorithmParameters", "AlgorithmChoices")
+ chercheOperInsereFacteurSiRegle(jdc, command, "AlgorithmChoices",((("AlgorithmChoices",),"nexistepasMCFParmi"),))
+ # Deplace le MC
+ moveMotClefInOperToFact(jdc, command, "Algorithm", "AlgorithmChoices")
+ # Renomme le MC
+ renameMotCleInFact(jdc, command, "AlgorithmChoices", "INPUT_TYPE", "Parameters")
+ # Renomme le MC
+ renameMotCle(jdc, command, "Study_name", "StudyName")
+ renameMotCle(jdc, command, "Study_repertory", "StudyRepertory")
+
+ # ==========================================================================
+ fsrc = jdc.getSource()
+ fsrc = re.sub( "FunctionDict", "ScriptWithSwitch", fsrc )
+ fsrc = re.sub( "FUNCTIONDICT_FILE", "SCRIPTWITHSWITCH_FILE", fsrc )
+ fsrc = re.sub( "#VERSION_CATALOGUE:.*:FIN VERSION_CATALOGUE", "#VERSION_CATALOGUE:%s:FIN VERSION_CATALOGUE"%version_out, fsrc)
+ fsrc = re.sub( "#CHECKSUM.*FIN CHECKSUM", "", fsrc )
+ #
+ log.ferme(hdlr)
+ if outfile is not None:
+ f=open(outfile,'w')
+ f.write( fsrc )
+ f.close()
+ else:
+ return fsrc
+
+class MonTraducteur:
+ def __init__(self,texte):
+ self.__texte = str(texte)
+ def traduit(self):
+ return traduc(infile=None,outfile=None,texte=self.__texte,flog=None)
+
+def main():
+ parser = optparse.OptionParser(usage=usage)
+
+ parser.add_option('-i','--infile', dest="infile",
+ help="Le fichier COMM en entree, a traduire")
+ parser.add_option('-o','--outfile', dest="outfile", default='out.comm',
+ help="Le fichier COMM en sortie, traduit")
+
+ options, args = parser.parse_args()
+ if len(options.infile) == 0:
+ print
+ parser.print_help()
+ print
+ sys.exit(1)
+
+ traduc(options.infile,options.outfile)
+
+if __name__ == '__main__':
+ main()
--- /dev/null
+#-*-coding:iso-8859-1-*-
+#
+# Copyright (C) 2008-2015 EDF R&D
+#
+# This file is part of SALOME ADAO module
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
+
+import log
+import optparse
+import sys
+import re
+
+from load import getJDC, getJDCFromTexte
+from mocles import parseKeywords
+from removemocle import *
+from renamemocle import *
+from renamemocle import *
+from inseremocle import *
+from changeValeur import *
+from movemocle import *
+from dictErreurs import *
+from regles import pasDeRegle
+
+version_out = "V7_6_0"
+
+usage="""Usage: python %prog [options]
+
+Typical use is:
+ python %prog --infile=xxxx.comm --outfile=yyyy.comm"""
+
+atraiter = (
+ "ASSIMILATION_STUDY",
+ "CHECKING_STUDY",
+ )
+
+dict_erreurs = {
+ "ASSIMILATION_STUDY":"Changements dans l'arbre et dans les noms",
+ "CHECKING_STUDY":"Changements dans l'arbre et dans les noms",
+ }
+
+sys.dict_erreurs=dict_erreurs
+
+def traduc(infile=None,outfile=None,texte=None,flog=None):
+ hdlr = log.initialise(flog)
+ if infile is not None:
+ jdc = getJDC(infile,atraiter)
+ elif texte is not None:
+ jdc = getJDCFromTexte(texte,atraiter)
+ else:
+ raise ValueError("Traduction du JDC impossible")
+
+ #Parse les mocles des commandes
+ parseKeywords(jdc.root)
+ GenereErreurPourCommande(jdc,('Algorithm','AlgorithmParameters','FunctionDict'))
+ # ==========================================================================
+
+ for command in atraiter:
+ # Renomme le MC ou en insere un nouveau s'il n'existe pas ensuite
+ renameMotCle(jdc, command, "AlgorithmParameters", "AlgorithmChoices")
+ chercheOperInsereFacteurSiRegle(jdc, command, "AlgorithmChoices",((("AlgorithmChoices",),"nexistepasMCFParmi"),))
+ # Deplace le MC
+ moveMotClefInOperToFact(jdc, command, "Algorithm", "AlgorithmChoices")
+ # Renomme le MC
+ renameMotCleInFact(jdc, command, "AlgorithmChoices", "INPUT_TYPE", "Parameters")
+ # Renomme le MC
+ renameMotCle(jdc, command, "Study_name", "StudyName")
+ renameMotCle(jdc, command, "Study_repertory", "StudyRepertory")
+
+ # ==========================================================================
+ fsrc = jdc.getSource()
+ fsrc = re.sub( "FunctionDict", "ScriptWithSwitch", fsrc )
+ fsrc = re.sub( "FUNCTIONDICT_FILE", "SCRIPTWITHSWITCH_FILE", fsrc )
+ fsrc = re.sub( "#VERSION_CATALOGUE:.*:FIN VERSION_CATALOGUE", "#VERSION_CATALOGUE:%s:FIN VERSION_CATALOGUE"%version_out, fsrc)
+ fsrc = re.sub( "#CHECKSUM.*FIN CHECKSUM", "", fsrc )
+ #
+ log.ferme(hdlr)
+ if outfile is not None:
+ f=open(outfile,'w')
+ f.write( fsrc )
+ f.close()
+ else:
+ return fsrc
+
+class MonTraducteur:
+ def __init__(self,texte):
+ self.__texte = str(texte)
+ def traduit(self):
+ return traduc(infile=None,outfile=None,texte=self.__texte,flog=None)
+
+def main():
+ parser = optparse.OptionParser(usage=usage)
+
+ parser.add_option('-i','--infile', dest="infile",
+ help="Le fichier COMM en entree, a traduire")
+ parser.add_option('-o','--outfile', dest="outfile", default='out.comm',
+ help="Le fichier COMM en sortie, traduit")
+
+ options, args = parser.parse_args()
+ if len(options.infile) == 0:
+ print
+ parser.print_help()
+ print
+ sys.exit(1)
+
+ traduc(options.infile,options.outfile)
+
+if __name__ == '__main__':
+ main()
--- /dev/null
+#-*-coding:iso-8859-1-*-
+#
+# Copyright (C) 2008-2015 EDF R&D
+#
+# This file is part of SALOME ADAO module
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
+
+import log
+import optparse
+import sys
+import re
+
+from load import getJDC, getJDCFromTexte
+from mocles import parseKeywords
+from removemocle import *
+from renamemocle import *
+from renamemocle import *
+from inseremocle import *
+from changeValeur import *
+from movemocle import *
+from dictErreurs import *
+from regles import pasDeRegle
+
+version_out = "V7_6_0"
+
+usage="""Usage: python %prog [options]
+
+Typical use is:
+ python %prog --infile=xxxx.comm --outfile=yyyy.comm"""
+
+atraiter = (
+ "ASSIMILATION_STUDY",
+ "CHECKING_STUDY",
+ )
+
+dict_erreurs = {
+ "ASSIMILATION_STUDY":"Changements dans l'arbre et dans les noms",
+ "CHECKING_STUDY":"Changements dans l'arbre et dans les noms",
+ }
+
+sys.dict_erreurs=dict_erreurs
+
+def traduc(infile=None,outfile=None,texte=None,flog=None):
+ hdlr = log.initialise(flog)
+ if infile is not None:
+ jdc = getJDC(infile,atraiter)
+ elif texte is not None:
+ jdc = getJDCFromTexte(texte,atraiter)
+ else:
+ raise ValueError("Traduction du JDC impossible")
+
+ #Parse les mocles des commandes
+ parseKeywords(jdc.root)
+ GenereErreurPourCommande(jdc,('Algorithm','AlgorithmParameters','FunctionDict'))
+ # ==========================================================================
+
+ for command in atraiter:
+ # Renomme le MC ou en insere un nouveau s'il n'existe pas ensuite
+ renameMotCle(jdc, command, "AlgorithmParameters", "AlgorithmChoices")
+ chercheOperInsereFacteurSiRegle(jdc, command, "AlgorithmChoices",((("AlgorithmChoices",),"nexistepasMCFParmi"),))
+ # Deplace le MC
+ moveMotClefInOperToFact(jdc, command, "Algorithm", "AlgorithmChoices")
+ # Renomme le MC
+ renameMotCleInFact(jdc, command, "AlgorithmChoices", "INPUT_TYPE", "Parameters")
+ # Renomme le MC
+ renameMotCle(jdc, command, "Study_name", "StudyName")
+ renameMotCle(jdc, command, "Study_repertory", "StudyRepertory")
+
+ # ==========================================================================
+ fsrc = jdc.getSource()
+ fsrc = re.sub( "FunctionDict", "ScriptWithSwitch", fsrc )
+ fsrc = re.sub( "FUNCTIONDICT_FILE", "SCRIPTWITHSWITCH_FILE", fsrc )
+ fsrc = re.sub( "#VERSION_CATALOGUE:.*:FIN VERSION_CATALOGUE", "#VERSION_CATALOGUE:%s:FIN VERSION_CATALOGUE"%version_out, fsrc)
+ fsrc = re.sub( "#CHECKSUM.*FIN CHECKSUM", "", fsrc )
+ #
+ log.ferme(hdlr)
+ if outfile is not None:
+ f=open(outfile,'w')
+ f.write( fsrc )
+ f.close()
+ else:
+ return fsrc
+
+class MonTraducteur:
+ def __init__(self,texte):
+ self.__texte = str(texte)
+ def traduit(self):
+ return traduc(infile=None,outfile=None,texte=self.__texte,flog=None)
+
+def main():
+ parser = optparse.OptionParser(usage=usage)
+
+ parser.add_option('-i','--infile', dest="infile",
+ help="Le fichier COMM en entree, a traduire")
+ parser.add_option('-o','--outfile', dest="outfile", default='out.comm',
+ help="Le fichier COMM en sortie, traduit")
+
+ options, args = parser.parse_args()
+ if len(options.infile) == 0:
+ print
+ parser.print_help()
+ print
+ sys.exit(1)
+
+ traduc(options.infile,options.outfile)
+
+if __name__ == '__main__':
+ main()