X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=bin%2FAdaoCatalogGenerator.py;h=b7ff1cebfb361205e4bac250546c4b90992d2805;hb=38f445a5d6ef73ccb309423dfb700a1095b727a4;hp=d5425dfe3a4c7cd58293ec6d69a26b30295bca76;hpb=0e0535d5ec2bf558c8b2df85837718b87c9acee9;p=modules%2Fadao.git diff --git a/bin/AdaoCatalogGenerator.py b/bin/AdaoCatalogGenerator.py index d5425df..b7ff1ce 100644 --- a/bin/AdaoCatalogGenerator.py +++ b/bin/AdaoCatalogGenerator.py @@ -1,6 +1,6 @@ #-*-coding:iso-8859-1-*- # -# Copyright (C) 2008-2013 EDF R&D +# Copyright (C) 2008-2014 EDF R&D # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public @@ -24,6 +24,8 @@ import sys import string import StringIO +import module_version + logging.basicConfig(level=logging.WARNING) #----------- Templates Part ---------------# @@ -36,11 +38,12 @@ begin_catalog_file = """# -*- coding: utf-8 -*- import Accas from Accas import * -JdC = JDC_CATA (code = 'ADAO', +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, @@ -61,7 +64,8 @@ def F_${data_name}(statut) : return FACT(statut = statut, 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 difference method"), + 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', ) ", @@ -71,6 +75,18 @@ def F_${data_name}(statut) : return FACT(statut = statut, 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)" ), + ), + ), ) """ @@ -110,8 +126,8 @@ 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 = "f", typ = "TXM", defaut = "${var_name}"), - NodeType = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "", into=("String", "Script", "Template")), + 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") ), @@ -119,18 +135,30 @@ observers_choice = """ Value = SIMP(statut = "o", typ = "FichierNoAbs", validators=(OnlyStr())) ), ObserverTemplate = BLOC (condition = " NodeType == 'Template' ", - Template = SIMP(statut = "o", typ = "TXM", min=1, max=1, defaut = "", into=("ValuePrinter", "ValueSeriePrinter", "ValueGnuPlotter", "ValueSerieGnuPlotter")), + 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 nfig,gp\\ntry:\\n nfig += 1\\n gp('set style data lines')\\nexcept:\\n nfig = 0\\n gp = Gnuplot.Gnuplot(persist=1)\\n gp('set style data lines')\\ngp('set title \\"'+str(info)+' (Figure %i)\\"'%nfig)\\ngp.plot( Gnuplot.Data( var[-1], with_='lines lw 2' ) )" ), + 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 nfig,gp\\ntry:\\n nfig += 1\\n gp('set style data lines')\\nexcept:\\n nfig = 0\\n gp = Gnuplot.Gnuplot(persist=1)\\n gp('set style data lines')\\ngp('set title \\"'+str(info)+' (Figure %i)\\"'%nfig)\\ngp.plot( Gnuplot.Data( var[:], with_='lines lw 2' ) )" ), + 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' ) )" ), ), ), ), @@ -157,7 +185,7 @@ ASSIMILATION_STUDY = PROC(nom="ASSIMILATION_STUDY", 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="o", typ = "I", into=(0, 1), defaut=0), + 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"), @@ -169,7 +197,7 @@ ASSIMILATION_STUDY = PROC(nom="ASSIMILATION_STUDY", ControlInput = F_ControlInput("f"), AlgorithmParameters = F_AlgorithmParameters("f"), UserDataInit = F_Init("f"), - UserPostAnalysis = F_UserPostAnalysis("f"), + UserPostAnalysis = F_UserPostAnalysis("o"), InputVariables = F_variables("f"), OutputVariables = F_variables("f"), Observers = F_Observers("f") @@ -180,12 +208,16 @@ CHECKING_STUDY = PROC(nom="CHECKING_STUDY", 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="o", typ = "I", into=(0, 1), defaut=0), + 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") ) """