From: Jean-Philippe ARGAUD Date: Thu, 26 Feb 2015 19:33:48 +0000 (+0100) Subject: Modifying EFICAS tree and commands, adding case translation X-Git-Tag: V7_6_0~31 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1a191d9d42b1ad486e2532889dbc76378208006d;p=modules%2Fadao.git Modifying EFICAS tree and commands, adding case translation --- diff --git a/bin/AdaoCatalogGenerator.py b/bin/AdaoCatalogGenerator.py index 008438d..7131540 100644 --- a/bin/AdaoCatalogGenerator.py +++ b/bin/AdaoCatalogGenerator.py @@ -5,7 +5,7 @@ # 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. # @@ -18,6 +18,8 @@ # 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 @@ -31,65 +33,80 @@ import module_version 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 = """ @@ -105,122 +122,137 @@ def F_InitChoice() : return ("Background", ) 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) @@ -230,6 +262,8 @@ assim_data_choice = string.Template(assim_data_choice) 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 ---------------# @@ -273,6 +307,23 @@ mem_file = StringIO.StringIO() 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(): @@ -294,31 +345,32 @@ 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(): @@ -339,7 +391,8 @@ 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 @@ -352,23 +405,52 @@ for obs_var in infos.ObserversList: 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)) diff --git a/doc/en/images/adao_algopar_defaults.png b/doc/en/images/adao_algopar_defaults.png new file mode 100644 index 0000000..181972b Binary files /dev/null and b/doc/en/images/adao_algopar_defaults.png differ diff --git a/doc/en/images/adao_algopar_script.png b/doc/en/images/adao_algopar_script.png index e19b6ef..fb00575 100644 Binary files a/doc/en/images/adao_algopar_script.png and b/doc/en/images/adao_algopar_script.png differ diff --git a/doc/en/images/adao_algopar_string.png b/doc/en/images/adao_algopar_string.png index bc4bf2d..5d4f862 100644 Binary files a/doc/en/images/adao_algopar_string.png and b/doc/en/images/adao_algopar_string.png differ diff --git a/doc/en/ref_assimilation_keywords.rst b/doc/en/ref_assimilation_keywords.rst index f0a8c70..1c04988 100644 --- a/doc/en/ref_assimilation_keywords.rst +++ b/doc/en/ref_assimilation_keywords.rst @@ -43,8 +43,8 @@ List of commands and keywords for an ADAO calculation case .. 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 @@ -151,11 +151,11 @@ The different commands are the following: 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. diff --git a/doc/en/ref_checking_keywords.rst b/doc/en/ref_checking_keywords.rst index 4eabc70..63126aa 100644 --- a/doc/en/ref_checking_keywords.rst +++ b/doc/en/ref_checking_keywords.rst @@ -38,8 +38,8 @@ List of commands and keywords for an ADAO checking case .. 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 @@ -112,11 +112,11 @@ The different commands are the following: 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. diff --git a/doc/fr/images/adao_algopar_defaults.png b/doc/fr/images/adao_algopar_defaults.png new file mode 100644 index 0000000..05a6272 Binary files /dev/null and b/doc/fr/images/adao_algopar_defaults.png differ diff --git a/doc/fr/images/adao_algopar_script.png b/doc/fr/images/adao_algopar_script.png index e19b6ef..ecc4c4e 100644 Binary files a/doc/fr/images/adao_algopar_script.png and b/doc/fr/images/adao_algopar_script.png differ diff --git a/doc/fr/images/adao_algopar_string.png b/doc/fr/images/adao_algopar_string.png index bc4bf2d..bef0aa8 100644 Binary files a/doc/fr/images/adao_algopar_string.png and b/doc/fr/images/adao_algopar_string.png differ diff --git a/doc/fr/ref_assimilation_keywords.rst b/doc/fr/ref_assimilation_keywords.rst index fb237dd..b0a0656 100644 --- a/doc/fr/ref_assimilation_keywords.rst +++ b/doc/fr/ref_assimilation_keywords.rst @@ -43,8 +43,8 @@ Liste des commandes et mots-cl .. 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 @@ -158,11 +158,11 @@ Les diff 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 diff --git a/doc/fr/ref_checking_keywords.rst b/doc/fr/ref_checking_keywords.rst index 7ef59f9..147092f 100644 --- a/doc/fr/ref_checking_keywords.rst +++ b/doc/fr/ref_checking_keywords.rst @@ -38,8 +38,8 @@ Liste des commandes et mots-cl .. 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 @@ -116,11 +116,11 @@ Les diff 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 diff --git a/examples/daSalome/test001_ADAO_JDC_using_strings.comm b/examples/daSalome/test001_ADAO_JDC_using_strings.comm index 81133f3..26c4d74 100644 --- a/examples/daSalome/test001_ADAO_JDC_using_strings.comm +++ b/examples/daSalome/test001_ADAO_JDC_using_strings.comm @@ -1,7 +1,7 @@ -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', @@ -28,3 +28,5 @@ ASSIMILATION_STUDY(Study_name='Test', """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 diff --git a/examples/daSalome/test002_ADAO_JDC_using_strings.comm b/examples/daSalome/test002_ADAO_JDC_using_strings.comm index 010f40f..407d76e 100644 --- a/examples/daSalome/test002_ADAO_JDC_using_strings.comm +++ b/examples/daSalome/test002_ADAO_JDC_using_strings.comm @@ -1,7 +1,7 @@ -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', @@ -28,3 +28,5 @@ ASSIMILATION_STUDY(Study_name='Test', """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 diff --git a/examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in b/examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in index c41dcd7..744b878 100644 --- a/examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in +++ b/examples/daSalome/test003_ADAO_JDC_using_scripts.comm.in @@ -1,8 +1,7 @@ -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', @@ -29,3 +28,4 @@ ASSIMILATION_STUDY(Study_name='Test', """import numpy xa=numpy.ravel(ADD.get('Analysis')[-1]) print 'Analysis:',xa""",),); +#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE diff --git a/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in b/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in index bc03a7b..b0f3868 100644 --- a/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in +++ b/examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in @@ -1,8 +1,7 @@ -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', @@ -33,3 +32,4 @@ ASSIMILATION_STUDY(Study_name='Test', """import numpy xa=numpy.ravel(ADD.get('Analysis')[-1]) print 'Analysis:',xa""",),); +#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE diff --git a/examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in b/examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in index f400c52..35a6feb 100644 --- a/examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in +++ b/examples/daSalome/test004_ADAO_JDC_using_scripts.comm.in @@ -1,8 +1,7 @@ -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', @@ -32,3 +31,4 @@ print "Size of Analysis = %i"%len(Xa) 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 diff --git a/examples/daSalome/test005_ADAO_Operators.comm.in b/examples/daSalome/test005_ADAO_Operators.comm.in index 76f2c94..d2f71c6 100644 --- a/examples/daSalome/test005_ADAO_Operators.comm.in +++ b/examples/daSalome/test005_ADAO_Operators.comm.in @@ -1,8 +1,7 @@ -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', @@ -34,3 +33,4 @@ print "Size of Analysis.............= %i"%len(Xa) 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 diff --git a/examples/daSalome/test006_Observers.comm.in b/examples/daSalome/test006_Observers.comm.in index 97bcd4e..62df329 100644 --- a/examples/daSalome/test006_Observers.comm.in +++ b/examples/daSalome/test006_Observers.comm.in @@ -1,8 +1,10 @@ -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', @@ -23,13 +25,14 @@ ASSIMILATION_STUDY(Study_name='test_observers', 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', @@ -56,3 +59,4 @@ print " imageCost %s"%filename gp.hardcopy(filename=filename, color=1) numero += 1 """,),),); +#VERSION_CATALOGUE:V7_6_0:FIN VERSION_CATALOGUE diff --git a/examples/daSalome/test006_Observers.py.in b/examples/daSalome/test006_Observers.py.in index da76ded..16b717e 100644 --- a/examples/daSalome/test006_Observers.py.in +++ b/examples/daSalome/test006_Observers.py.in @@ -4,6 +4,11 @@ study_config['StudyType'] = 'ASSIMILATION_STUDY' 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' @@ -48,16 +53,17 @@ outputvariables_config['Order'] = ['adao_default'] 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"] = {} diff --git a/examples/daSalome/test008_ADAO_Elementary_GradientTest.comm b/examples/daSalome/test008_ADAO_Elementary_GradientTest.comm index 73973a0..cef9bdf 100644 --- a/examples/daSalome/test008_ADAO_Elementary_GradientTest.comm +++ b/examples/daSalome/test008_ADAO_Elementary_GradientTest.comm @@ -1,7 +1,9 @@ -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', @@ -9,7 +11,6 @@ CHECKING_STUDY(Study_name='Elementary gradient test', 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 diff --git a/examples/daSalome/test008_ADAO_Elementary_GradientTest.py b/examples/daSalome/test008_ADAO_Elementary_GradientTest.py index 4d15507..715d312 100644 --- a/examples/daSalome/test008_ADAO_Elementary_GradientTest.py +++ b/examples/daSalome/test008_ADAO_Elementary_GradientTest.py @@ -4,6 +4,11 @@ study_config['StudyType'] = 'CHECKING_STUDY' 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' @@ -24,8 +29,3 @@ outputvariables_config = {} 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 diff --git a/examples/daSalome/test009_ADAO_Simple_GradientTest.comm b/examples/daSalome/test009_ADAO_Simple_GradientTest.comm index 56da492..e1746e5 100644 --- a/examples/daSalome/test009_ADAO_Simple_GradientTest.comm +++ b/examples/daSalome/test009_ADAO_Simple_GradientTest.comm @@ -1,7 +1,9 @@ -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', @@ -9,7 +11,6 @@ CHECKING_STUDY(Study_name='Test', 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 diff --git a/examples/daSalome/test009_ADAO_Simple_GradientTest.py b/examples/daSalome/test009_ADAO_Simple_GradientTest.py index 4349c4e..ddb46dc 100644 --- a/examples/daSalome/test009_ADAO_Simple_GradientTest.py +++ b/examples/daSalome/test009_ADAO_Simple_GradientTest.py @@ -4,6 +4,11 @@ study_config['StudyType'] = 'CHECKING_STUDY' 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' @@ -24,8 +29,3 @@ outputvariables_config = {} 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 diff --git a/examples/daSalome/test010_ADAO_Simple_AdjointTest.comm b/examples/daSalome/test010_ADAO_Simple_AdjointTest.comm index af87379..35415c2 100644 --- a/examples/daSalome/test010_ADAO_Simple_AdjointTest.comm +++ b/examples/daSalome/test010_ADAO_Simple_AdjointTest.comm @@ -1,7 +1,9 @@ -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', @@ -9,7 +11,6 @@ CHECKING_STUDY(Study_name='Test', 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 diff --git a/examples/daSalome/test010_ADAO_Simple_AdjointTest.py b/examples/daSalome/test010_ADAO_Simple_AdjointTest.py index 1d60dc8..e141f6e 100644 --- a/examples/daSalome/test010_ADAO_Simple_AdjointTest.py +++ b/examples/daSalome/test010_ADAO_Simple_AdjointTest.py @@ -4,6 +4,11 @@ study_config['StudyType'] = 'CHECKING_STUDY' 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' @@ -24,8 +29,3 @@ outputvariables_config = {} 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 diff --git a/src/daComposant/daAlgorithms/3DVAR.py b/src/daComposant/daAlgorithms/3DVAR.py index ba53af8..cd3bedd 100644 --- a/src/daComposant/daAlgorithms/3DVAR.py +++ b/src/daComposant/daAlgorithms/3DVAR.py @@ -101,6 +101,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): 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() diff --git a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py index 7811630..b0b4670 100644 --- a/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/ExtendedKalmanFilter.py @@ -55,6 +55,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): 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() diff --git a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py index c894d51..9a934ff 100644 --- a/src/daComposant/daAlgorithms/NonLinearLeastSquares.py +++ b/src/daComposant/daAlgorithms/NonLinearLeastSquares.py @@ -74,6 +74,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): 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() diff --git a/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py b/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py index 215d7d7..c9ab24f 100644 --- a/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py +++ b/src/daComposant/daAlgorithms/ParticleSwarmOptimization.py @@ -86,6 +86,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): 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() diff --git a/src/daComposant/daAlgorithms/QuantileRegression.py b/src/daComposant/daAlgorithms/QuantileRegression.py index b6a8504..218efb4 100644 --- a/src/daComposant/daAlgorithms/QuantileRegression.py +++ b/src/daComposant/daAlgorithms/QuantileRegression.py @@ -69,6 +69,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): 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() diff --git a/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py b/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py index 9cbd4f5..d0f9590 100644 --- a/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py +++ b/src/daComposant/daAlgorithms/UnscentedKalmanFilter.py @@ -84,6 +84,10 @@ class ElementaryAlgorithm(BasicObjects.Algorithm): 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() diff --git a/src/daEficas/Makefile.am b/src/daEficas/Makefile.am index 744f1ef..7f70e93 100644 --- a/src/daEficas/Makefile.am +++ b/src/daEficas/Makefile.am @@ -26,11 +26,14 @@ include $(top_srcdir)/adm_local/make_common_starter.am 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 diff --git a/src/daEficas/generator_adao.py b/src/daEficas/generator_adao.py index 3a24399..0a321bd 100644 --- a/src/daEficas/generator_adao.py +++ b/src/daEficas/generator_adao.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +# # Copyright (C) 2008-2015 EDF R&D # # This file is part of SALOME ADAO module @@ -93,7 +94,7 @@ class AdaoGenerator(PythonGenerator): 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" @@ -103,15 +104,20 @@ class AdaoGenerator(PythonGenerator): # 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") @@ -135,9 +141,9 @@ class AdaoGenerator(PythonGenerator): 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() @@ -303,6 +309,47 @@ class AdaoGenerator(PythonGenerator): 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 diff --git a/src/daEficas/traduitADAOV7_4_0ToV7_6_0.py b/src/daEficas/traduitADAOV7_4_0ToV7_6_0.py new file mode 100644 index 0000000..1c88139 --- /dev/null +++ b/src/daEficas/traduitADAOV7_4_0ToV7_6_0.py @@ -0,0 +1,123 @@ +#-*-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() diff --git a/src/daEficas/traduitADAOV7_5_0ToV7_6_0.py b/src/daEficas/traduitADAOV7_5_0ToV7_6_0.py new file mode 100644 index 0000000..1c88139 --- /dev/null +++ b/src/daEficas/traduitADAOV7_5_0ToV7_6_0.py @@ -0,0 +1,123 @@ +#-*-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() diff --git a/src/daEficas/traduitADAOV7_5_1ToV7_6_0.py b/src/daEficas/traduitADAOV7_5_1ToV7_6_0.py new file mode 100644 index 0000000..1c88139 --- /dev/null +++ b/src/daEficas/traduitADAOV7_5_1ToV7_6_0.py @@ -0,0 +1,123 @@ +#-*-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()