resources/Makefile
src/Makefile
src/daComposant/Makefile
+ src/daSalome/Makefile
])
AC_OUTPUT
--- /dev/null
+<?xml version='1.0' encoding='iso-8859-1' ?>
+<proc>
+
+ <objref name="computeAD" id="python:computeAD:1.0">
+ <base>pyobj</base>
+ </objref>
+
+ <inline name="CreateAssimilationStudy">
+ <script><code>
+
+<![CDATA[
+import numpy
+print "Entering in CreateAssimilationStudy"
+print "Name is", Name
+print "Algorithm is", Algorithm
+
+
+# Data
+print "Data entered are:"
+# Background
+try:
+ Background
+except NameError:
+ pass
+else:
+ print "Background is", Background
+ print "BackgroundType is", BackgroundType
+
+# BackgroundError
+try:
+ BackgroundError
+except NameError:
+ pass
+else:
+ print "BackgroundError is", BackgroundError
+ print "BackgroundErrorType is", BackgroundErrorType
+
+# Observation
+try:
+ Observation
+except NameError:
+ pass
+else:
+ print "Observation is", Observation
+ print "ObservationType is", ObservationType
+
+# ObservationError
+try:
+ ObservationError
+except NameError:
+ pass
+else:
+ print "ObservationError is", ObservationError
+ print "ObservationErrorType is", ObservationErrorType
+
+# ObservationOperator
+try:
+ ObservationOperator
+except NameError:
+ pass
+else:
+ print "ObservationOperator is", ObservationOperator
+ print "ObservationOperatorType is", ObservationOperatorType
+
+]]>
+
+</code></script>
+ <inport name="Name" type="string"/>
+ <inport name="Algorithm" type="string"/>
+ </inline>
+
+ <inline name="CreateNumpyMatrixFromString">
+ <script><code><![CDATA[
+print "Entering in CreateNumpyMatrixFromString"
+import numpy
+matrix = numpy.matrix(matrix_in_string)
+type = "Matrix"
+print "Matrix is", matrix
+]]></code></script>
+ <inport name="matrix_in_string" type="string"/>
+ <outport name="matrix" type="pyobj"/>
+ <outport name="type" type="string"/>
+ </inline>
+
+ <inline name="CreateNumpyVectorFromString">
+ <script><code><![CDATA[
+print "Entering in CreateNumpyVectorFromString"
+import numpy
+vector = numpy.matrix(vector_in_string)
+type = "Vector"
+print "Vector is", vector
+]]></code></script>
+ <inport name="vector_in_string" type="string"/>
+ <outport name="vector" type="pyobj"/>
+ <outport name="type" type="string"/>
+ </inline>
+
+</proc>
include $(top_srcdir)/adm_local/make_common_starter.am
-DATA_INST = DATASSIMCatalog.xml
+
+DATA_INST = DATASSIMCatalog.xml DATASSIMSchemaCatalog.xml
+
salomeres_DATA = ${DATA_INST}
EXTRA_DIST = ${DATA_INST}
-SUBDIRS= daComposant
+SUBDIRS= daComposant daSalome
--- /dev/null
+include $(top_srcdir)/adm_local/make_common_starter.am
+
+EXTRA_DIST = daYacsSchemaCreator
+
+DIR = $(top_srcdir)/src/daSalome/
+
+install-data-local:
+ ${mkinstalldirs} $(DESTDIR)$(salomepythondir)
+ cp -R $(DIR)daYacsSchemaCreator $(DESTDIR)$(salomepythondir)
+
+uninstall-local:
+ chmod -R +w $(DESTDIR)$(salomepythondir)
+ rm -rf $(DESTDIR)$(salomepythondir)/daYacsSchemaCreator
+
--- /dev/null
+#!/usr/bin/python
+#-*-coding:iso-8859-1-*-
+# Copyright (C) 2008-2009 EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU 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 : André RIBES (EDF R&D)
+# --
+
+import sys
+import os
+import traceback
+import logging
+from optparse import OptionParser
+from daYacsSchemaCreator.methods import *
+from daYacsSchemaCreator.help_methods import *
+
+# Variables globales
+global my_parser
+
+# Init part
+def init():
+
+ logging.basicConfig(level=logging.DEBUG, format='%(levelname)-8s %(message)s')
+ usage = "usage: %prog [options] config_file yacs_schema_filename"
+ version="%prog 0.1"
+ global my_parser
+ my_parser = OptionParser(usage=usage, version=version)
+
+# Start application
+def main():
+
+ print "-- Starting YacsSchemaCreator --"
+ (options, args) = my_parser.parse_args()
+ check_args(args)
+ config_file = args[0]
+ yacs_schema_filename = args[1]
+
+ # Import config_file
+ try:
+ execfile(config_file)
+ except:
+ logging.fatal("Exception in loading " + config_file)
+ traceback.print_exc()
+ sys.exit(1)
+
+ if "study_config" not in locals():
+ logging.fatal("Cannot found study_config in " + str(config_file))
+ sys.exit(1)
+ else:
+ globals()['study_config'] = locals()['study_config']
+
+ if "DATASSIM_ROOT_DIR" not in os.environ:
+ logging.fatal("You have to define DATASSIM_ROOT_DIR")
+ sys.exit(1)
+
+ check_study(study_config)
+ proc = create_yacs_proc(study_config)
+ write_yacs_proc(proc, yacs_schema_filename)
+
+init()
+main()
--- /dev/null
+#-*-coding:iso-8859-1-*-
+# Copyright (C) 2010 EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU 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 : André RIBES (EDF R&D)
+# --
+
+import sys
+import traceback
+import logging
+
+from daYacsSchemaCreator.infos_daComposant import *
+
+def check_args(args):
+
+ logging.debug("Arguments are :" + str(args))
+ if len(args) != 2:
+ logging.fatal("Bad number of arguments: you have to provide two arguments (%d given)" % (len(args)))
+ sys.exit(1)
+
+def check_study(study_config):
+
+ logging.debug("[check_env] study_config : " + str(study_config))
+
+ # Check study_config
+ if not isinstance(study_config, dict):
+ logging.fatal("Study configuration is not a dictionnary")
+ sys.exit(1)
+
+ # Name
+ if "Name" not in study_config:
+ logging.fatal("Cannot found Name in the study configuration")
+ sys.exit(1)
+
+ # Algorithm
+ if "Algorithm" not in study_config:
+ logging.fatal("Cannot found Algorithm in the study configuration")
+ sys.exit(1)
+ else:
+ if study_config["Algorithm"] not in AssimAlgos:
+ logging.fatal("Algorithm provided is unknow : " + str(study_config["Algorithm"]) +
+ "\n You can choose between : " + str(AssimAlgos))
+ sys.exit(1)
+
+ # Check if all the data is provided
+ for key in AlgoDataRequirements[study_config["Algorithm"]]:
+ if key not in study_config.keys():
+ logging.fatal("Cannot found " + key + " in your study configuration !" +
+ "\n This key is mandatory into a study with " + study_config["Algorithm"] + " algorithm." +
+ "\n " + study_config["Algorithm"] + " requirements are " + str(AlgoDataRequirements[study_config["Algorithm"]]))
+ sys.exit(1)
+
+ # Data
+ for key in study_config.keys():
+ if key in AssimData:
+ check_data(key, study_config[key])
+
+def check_data(data_name, data_config):
+
+ logging.debug("[check_data] " + data_name)
+ data_name_data = "Data"
+ data_name_type = "Type"
+ data_name_from = "From"
+
+ if data_name_data not in data_config:
+ logging.fatal(data_name +" found but " + data_name_data +" is not defined in the study configuration !")
+ sys.exit(1)
+
+ if data_name_type not in data_config:
+ logging.fatal(data_name +" found but " + data_name_type +" is not defined in the study configuration !")
+ sys.exit(1)
+ else:
+ if data_config[data_name_type] not in AssimType[data_name]:
+ logging.fatal(data_name_type + " defined in the study configuration does not have a correct type : " + str(data_config[data_name_type])
+ + "\n You can have : " + str(AssimType[data_name]))
+ sys.exit(1)
+ if data_name_from not in data_config:
+ logging.fatal(data_name + " found but " + data_name_from + " is not defined in the study configuration !")
+ sys.exit(1)
+ else:
+ if data_config[data_name_from] not in FromNumpyList[data_config[data_name_type]]:
+ logging.fatal(data_name_from + " defined in the study configuration does not have a correct value : " + str(data_config[data_name_from])
+ + "\n You can have : " + str(FromNumpyList[data_config[data_name_type]]))
+ sys.exit(1)
+
--- /dev/null
+#-*-coding:iso-8859-1-*-
+# Copyright (C) 2010 EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU 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 : André RIBES (EDF R&D)
+# --
+
+
+# -- Infos from daCore --
+AssimData = ["Background", "BackgroundError",
+ "Observation", "ObservationError", "ObservationOperator", "ObservationOperatorAppliedToX",
+ "EvolutionModel", "EvolutionError"]
+
+AssimType = {}
+AssimType["Background"] = ["Vector"]
+AssimType["BackgroundError"] = ["Matrix"]
+AssimType["Observation"] = ["Vector"]
+AssimType["ObservationError"] = ["Matrix"]
+AssimType["ObservationOperator"] = ["Matrix", "Function"]
+AssimType["ObservationOperatorAppliedToX"] = ["List"]
+
+FromNumpyList = {}
+FromNumpyList["Vector"] = ["string"]
+FromNumpyList["Matrix"] = ["string"]
+FromNumpyList["Function"] = ["Dict"]
+FromNumpyList["List"] = ["List"]
+
+# -- Infos from daAlgorithms --
+AssimAlgos = ["Blue", "EnsembleBlue", "Kalman", "LinearLeastSquares", "3DVAR"]
+
+AlgoDataRequirements = {}
+AlgoDataRequirements["Blue"] = ["Background", "BackgroundError",
+ "Observation", "ObservationOperator", "ObservationError"]
+
--- /dev/null
+#-*-coding:iso-8859-1-*-
+# Copyright (C) 2010 EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU 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 : André RIBES (EDF R&D)
+# --
+
+import sys
+import traceback
+import logging
+import pilot
+import loader
+import SALOMERuntime
+import os
+
+from daYacsSchemaCreator.infos_daComposant import *
+
+def create_yacs_proc(study_config):
+
+ logging.debug("[create_yacs_proc]")
+
+ # Init part
+ SALOMERuntime.RuntimeSALOME_setRuntime()
+ l = loader.YACSLoader()
+ l.registerProcCataLoader()
+ runtime = pilot.getRuntime()
+ try:
+ catalogAd = runtime.loadCatalog("proc", os.environ["DATASSIM_ROOT_DIR"] + "share/salome/resources/datassim/DATASSIMSchemaCatalog.xml")
+ except:
+ logging.fatal("Exception in loading DataAssim YACS catalog")
+ traceback.print_exc()
+ sys.exit(1)
+
+ # Starting creating proc
+ proc = runtime.createProc("proc")
+ proc.setTypeCode("pyobj", runtime.getTypeCode("pyobj"))
+ t_pyobj = proc.getTypeCode("pyobj")
+ t_string = proc.getTypeCode("string")
+
+ # Step 0: create AssimilationStudyObject
+ factory_CAS_node = catalogAd._nodeMap["CreateAssimilationStudy"]
+ CAS_node = factory_CAS_node.cloneNode("CreateAssimilationStudy")
+ CAS_node.getInputPort("Name").edInitPy(study_config["Name"])
+ CAS_node.getInputPort("Algorithm").edInitPy(study_config["Algorithm"])
+ proc.edAddChild(CAS_node)
+
+ # Step 1: get input data from user configuration
+
+ for key in study_config.keys():
+ if key in AssimData:
+ data_config = study_config[key]
+
+ key_type = key + "Type"
+
+ if data_config["Type"] == "Vector" and data_config["From"] == "string":
+ # Create node
+ factory_back_node = catalogAd._nodeMap["CreateNumpyVectorFromString"]
+ back_node = factory_back_node.cloneNode("Get" + key)
+ back_node.getInputPort("vector_in_string").edInitPy(data_config["Data"])
+ proc.edAddChild(back_node)
+ # Connect node with CreateAssimilationStudy
+ CAS_node.edAddInputPort(key, t_pyobj)
+ CAS_node.edAddInputPort(key_type, t_string)
+ proc.edAddDFLink(back_node.getOutputPort("vector"), CAS_node.getInputPort(key))
+ proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
+
+ if data_config["Type"] == "Matrix" and data_config["From"] == "string":
+ # Create node
+ factory_back_node = catalogAd._nodeMap["CreateNumpyMatrixFromString"]
+ back_node = factory_back_node.cloneNode("Get" + key)
+ back_node.getInputPort("matrix_in_string").edInitPy(data_config["Data"])
+ proc.edAddChild(back_node)
+ # Connect node with CreateAssimilationStudy
+ CAS_node.edAddInputPort(key, t_pyobj)
+ CAS_node.edAddInputPort(key_type, t_string)
+ proc.edAddDFLink(back_node.getOutputPort("matrix"), CAS_node.getInputPort(key))
+ proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
+
+
+ # Step 3: create optimizer loop
+
+ # Step 4: create post-processing from user configuration
+
+ return proc
+
+def write_yacs_proc(proc, yacs_schema_filename):
+
+ proc.saveSchema(yacs_schema_filename)
+