examples/daSalome/test003_ADAO_JDC_using_scripts.comm
examples/daSalome/test004_ADAO_JDC_using_scripts.comm
examples/daSalome/test005_ADAO_Operators.comm
+ examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm
examples/daSkeletons/Makefile
examples/daSkeletons/External_data_definition_by_scripts/Makefile
examples/daSkeletons/External_data_definition_by_scripts/ADAO_Case.comm
test004_ADAO_JDC_using_scripts.comm \
test004_ADAO_scripts_for_JDC.py \
test005_ADAO_Operators.comm \
- test005_ADAO_scripts_for_JDC.py
+ test005_ADAO_scripts_for_JDC.py \
+ test003_bis_ADAO_JDC_using_user_data_init.comm \
+ test003_bis_ADAO_user_data_init.py \
+ test003_bis_ADAO_scripts_for_JDC.py
examplesdasalome_DATA = ${DATA_INST}
test004_ADAO_JDC_using_scripts.comm.in \
test004_ADAO_scripts_for_JDC.py \
test005_ADAO_Operators.comm.in \
- test005_ADAO_scripts_for_JDC.py
+ test005_ADAO_scripts_for_JDC.py \
+ test003_bis_ADAO_JDC_using_user_data_init.comm.in \
+ test003_bis_ADAO_user_data_init.py \
+ test003_bis_ADAO_scripts_for_JDC.py
--- /dev/null
+
+ASSIMILATION_STUDY(Study_name='Test',
+ Study_repertory='@prefix@/share/salome/adao_examples/daSalome',
+ Debug=0,
+ Algorithm='3DVAR',
+ Background=_F(INPUT_TYPE='Vector',
+ data=_F(FROM='Script',
+ SCRIPT_FILE='test003_bis_ADAO_scripts_for_JDC.py',),),
+ BackgroundError=_F(INPUT_TYPE='Matrix',
+ data=_F(FROM='Script',
+ SCRIPT_FILE='test003_bis_ADAO_scripts_for_JDC.py',),),
+ Observation=_F(INPUT_TYPE='Vector',
+ data=_F(FROM='Script',
+ SCRIPT_FILE='test003_bis_ADAO_scripts_for_JDC.py',),),
+ ObservationError=_F(INPUT_TYPE='Matrix',
+ data=_F(FROM='Script',
+ SCRIPT_FILE='test003_bis_ADAO_scripts_for_JDC.py',),),
+ ObservationOperator=_F(INPUT_TYPE='Matrix',
+ data=_F(FROM='Script',
+ SCRIPT_FILE='test003_bis_ADAO_scripts_for_JDC.py',),),
+ UserDataInit=_F(INIT_FILE='test003_bis_ADAO_user_data_init.py',
+ TARGET_LIST=
+ ('Background','BackgroundError','Observation',
+ 'ObservationError','ObservationOperator',),),);
--- /dev/null
+#-*-coding:iso-8859-1-*-
+# Copyright (C) 2010-2011 EDF R&D
+#
+# 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: André Ribes, andre.ribes@edf.fr, EDF R&D
+
+import numpy
+#
+# Definition of the Background as a vector
+# ----------------------------------------
+Background = init_data["Background"]
+#
+# Definition of the Observation as a vector
+# -----------------------------------------
+Observation = init_data["Observation"]
+#
+# Definition of the Background Error covariance as a matrix
+# ---------------------------------------------------------
+BackgroundError = init_data["BackgroundError"]
+#
+# Definition of the Observation Error covariance as a matrix
+# ----------------------------------------------------------
+ObservationError = init_data["ObservationError"]
+#
+# Definition of the Observation Operator as a matrix
+# --------------------------------------------------
+ObservationOperator = init_data["ObservationOperator"]
--- /dev/null
+#-*-coding:iso-8859-1-*-
+# Copyright (C) 2010-2011 EDF R&D
+#
+# 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: André Ribes, andre.ribes@edf.fr, EDF R&D
+
+import numpy
+#
+# Definition of the Background as a vector
+# ----------------------------------------
+Background = [0, 0, 0]
+#
+# Definition of the Observation as a vector
+# -----------------------------------------
+Observation = "1 1 1"
+#
+# Definition of the Background Error covariance as a matrix
+# ---------------------------------------------------------
+BackgroundError = numpy.array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
+#
+# Definition of the Observation Error covariance as a matrix
+# ----------------------------------------------------------
+ObservationError = numpy.matrix("1 0 0 ; 0 1 0 ; 0 0 1")
+#
+# Definition of the Observation Operator as a matrix
+# --------------------------------------------------
+ObservationOperator = numpy.identity(3)
+
+#
+# Definition of the init_data dictionnary
+# ---------------------------------------
+init_data = {}
+init_data["Background"] = Background
+init_data["Observation"] = Observation
+init_data["BackgroundError"] = BackgroundError
+init_data["ObservationError"] = ObservationError
+init_data["ObservationOperator"] = ObservationOperator
self.text_da += "study_config = {} \n"
# Extraction de Study_name
- self.text_da += "study_config[\"Name\"] = \"" + self.dictMCVal["__ASSIMILATION_STUDY__Study_name"] + "\"\n"
+ self.text_da += "study_config['Name'] = '" + self.dictMCVal["__ASSIMILATION_STUDY__Study_name"] + "'\n"
# Extraction de Debug
- self.text_da += "study_config[\"Debug\"] = \"" + str(self.dictMCVal["__ASSIMILATION_STUDY__Debug"]) + "\"\n"
+ self.text_da += "study_config['Debug'] = '" + str(self.dictMCVal["__ASSIMILATION_STUDY__Debug"]) + "'\n"
# Extraction de Algorithm
- self.text_da += "study_config[\"Algorithm\"] = \"" + self.dictMCVal["__ASSIMILATION_STUDY__Algorithm"] + "\"\n"
+ self.text_da += "study_config['Algorithm'] = '" + self.dictMCVal["__ASSIMILATION_STUDY__Algorithm"] + "'\n"
self.add_data("Background")
self.add_data("BackgroundError")
# Extraction du Study_repertory
if "__ASSIMILATION_STUDY__Study_repertory" in self.dictMCVal.keys():
- self.text_da += "study_config[\"Repertory\"] = \"" + self.dictMCVal["__ASSIMILATION_STUDY__Study_repertory"] + "\"\n"
+ self.text_da += "study_config['Repertory'] = '" + self.dictMCVal["__ASSIMILATION_STUDY__Study_repertory"] + "'\n"
# Extraction de AlgorithmParameters
if "__ASSIMILATION_STUDY__AlgorithmParameters__INPUT_TYPE" in self.dictMCVal.keys():
self.add_algorithm_parameters()
if from_type == "String" or from_type == "Script":
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"
+ 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"
if from_type == "FunctionDict":
self.text_da += data_name + "_FunctionDict = {} \n"
- self.text_da += data_name + "_FunctionDict[\"Function\"] = [\"Direct\", \"Tangent\", \"Adjoint\"] \n"
- self.text_da += data_name + "_FunctionDict[\"Script\"] = {} \n"
- self.text_da += data_name + "_FunctionDict[\"Script\"][\"Direct\"] = \"" + data + "\" \n"
- self.text_da += data_name + "_FunctionDict[\"Script\"][\"Tangent\"] = \"" + data + "\" \n"
- self.text_da += data_name + "_FunctionDict[\"Script\"][\"Adjoint\"] = \"" + data + "\" \n"
+ self.text_da += data_name + "_FunctionDict['Function'] = ['Direct', 'Tangent', 'Adjoint'] \n"
+ self.text_da += data_name + "_FunctionDict['Script'] = {} \n"
+ self.text_da += data_name + "_FunctionDict['Script']['Direct'] = '" + data + "' \n"
+ self.text_da += data_name + "_FunctionDict['Script']['Tangent'] = '" + data + "' \n"
+ self.text_da += data_name + "_FunctionDict['Script']['Adjoint'] = '" + data + "' \n"
self.text_da += data_name + "_config = {} \n"
- self.text_da += data_name + "_config[\"Type\"] = \"Function\" \n"
- self.text_da += data_name + "_config[\"From\"] = \"FunctionDict\" \n"
- self.text_da += data_name + "_config[\"Data\"] = " + data_name + "_FunctionDict \n"
- self.text_da += "study_config[\"" + data_name + "\"] = " + data_name + "_config \n"
+ self.text_da += data_name + "_config['Type'] = 'Function' \n"
+ self.text_da += data_name + "_config['From'] = 'FunctionDict' \n"
+ self.text_da += data_name + "_config['Data'] = " + data_name + "_FunctionDict \n"
+ self.text_da += "study_config['" + data_name + "'] = " + data_name + "_config \n"
def add_algorithm_parameters(self):
data = self.dictMCVal["__ASSIMILATION_STUDY__AlgorithmParameters__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"
+ 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_init(self):
init_target_list = self.dictMCVal["__ASSIMILATION_STUDY__UserDataInit__TARGET_LIST"]
self.text_da += "Init_config = {} \n"
- self.text_da += "Init_config[\"Type\"] = \"Dict\" \n"
- self.text_da += "Init_config[\"From\"] = \"Script\" \n"
- self.text_da += "Init_config[\"Data\"] = \"" + init_file_data + "\"\n"
- self.text_da += "Init_config[\"Target\"] = ["
+ self.text_da += "Init_config['Type'] = 'Dict' \n"
+ self.text_da += "Init_config['From'] = 'Script' \n"
+ self.text_da += "Init_config['Data'] = '" + init_file_data + "'\n"
+ self.text_da += "Init_config['Target'] = ["
for target in init_target_list:
- self.text_da += "\"" + target + "\","
+ self.text_da += "'" + target + "',"
self.text_da += "] \n"
- self.text_da += "study_config[\"UserDataInit\"] = Init_config \n"
+ self.text_da += "study_config['UserDataInit'] = Init_config \n"
def add_UserPostAnalysis(self):
if from_type == "String":
data = self.dictMCVal["__ASSIMILATION_STUDY__UserPostAnalysis__STRING_DATA__STRING"]
self.text_da += "Analysis_config = {} \n"
- self.text_da += "Analysis_config[\"From\"] = \"String\" \n"
- self.text_da += "Analysis_config[\"Data\"] = \"\"\"" + data + "\"\"\" \n"
- self.text_da += "study_config[\"UserPostAnalysis\"] = Analysis_config \n"
+ self.text_da += "Analysis_config['From'] = 'String' \n"
+ self.text_da += "Analysis_config['Data'] = \"\"\"" + data + "\"\"\" \n"
+ self.text_da += "study_config['UserPostAnalysis'] = Analysis_config \n"
elif from_type == "Script":
data = self.dictMCVal["__ASSIMILATION_STUDY__UserPostAnalysis__SCRIPT_DATA__SCRIPT_FILE"]
self.text_da += "Analysis_config = {} \n"
- self.text_da += "Analysis_config[\"From\"] = \"Script\" \n"
- self.text_da += "Analysis_config[\"Data\"] = \"" + data + "\" \n"
- self.text_da += "study_config[\"UserPostAnalysis\"] = Analysis_config \n"
+ self.text_da += "Analysis_config['From'] = 'Script' \n"
+ self.text_da += "Analysis_config['Data'] = '" + data + "' \n"
+ self.text_da += "study_config['UserPostAnalysis'] = Analysis_config \n"
else:
raise Exception('From Type unknown', from_type)
sizes = self.dictMCVal["__ASSIMILATION_STUDY__InputVariables__SIZES"]
self.text_da += "inputvariables_config = {} \n"
- self.text_da += "inputvariables_config[\"Order\"] = %s \n" % list(names)
+ self.text_da += "inputvariables_config['Order'] = %s \n" % list(names)
for name, size in zip(names, sizes):
- self.text_da += "inputvariables_config[\"%s\"] = %s \n" % (name,size)
- self.text_da += "study_config[\"InputVariables\"] = inputvariables_config \n"
+ self.text_da += "inputvariables_config['%s'] = %s \n" % (name,size)
+ self.text_da += "study_config['InputVariables'] = inputvariables_config \n"
else:
self.text_da += "inputvariables_config = {} \n"
- self.text_da += "inputvariables_config[\"Order\"] =[\"adao_default\"] \n"
- self.text_da += "inputvariables_config[\"adao_default\"] = -1 \n"
- self.text_da += "study_config[\"InputVariables\"] = inputvariables_config \n"
+ self.text_da += "inputvariables_config['Order'] =['adao_default'] \n"
+ self.text_da += "inputvariables_config['adao_default'] = -1 \n"
+ self.text_da += "study_config['InputVariables'] = inputvariables_config \n"
# Output variables
if "__ASSIMILATION_STUDY__OutputVariables__NAMES" in self.dictMCVal.keys():
sizes = self.dictMCVal["__ASSIMILATION_STUDY__OutputVariables__SIZES"]
self.text_da += "outputvariables_config = {} \n"
- self.text_da += "outputvariables_config[\"Order\"] = %s \n" % list(names)
+ self.text_da += "outputvariables_config['Order'] = %s \n" % list(names)
for name, size in zip(names, sizes):
- self.text_da += "outputvariables_config[\"%s\"] = %s \n" % (name,size)
- self.text_da += "study_config[\"OutputVariables\"] = outputvariables_config \n"
+ self.text_da += "outputvariables_config['%s'] = %s \n" % (name,size)
+ self.text_da += "study_config['OutputVariables'] = outputvariables_config \n"
else:
self.text_da += "outputvariables_config = {} \n"
- self.text_da += "outputvariables_config[\"Order\"] = [\"adao_default\"] \n"
- self.text_da += "outputvariables_config[\"adao_default\"] = -1 \n"
- self.text_da += "study_config[\"OutputVariables\"] = outputvariables_config \n"
+ self.text_da += "outputvariables_config['Order'] = ['adao_default'] \n"
+ self.text_da += "outputvariables_config['adao_default'] = -1 \n"
+ self.text_da += "study_config['OutputVariables'] = outputvariables_config \n"
init_node.getInputPort("script").edInitPy(os.path.join(base_repertory, os.path.basename(init_config["Data"])))
else:
init_node.getInputPort("script").edInitPy(init_config["Data"])
+ init_node_script = init_node.getScript()
+ init_node_script += "init_data = user_script_module.init_data\n"
+ init_node.setScript(init_node_script)
proc.edAddChild(init_node)
# Step 1: get input data from user configuration
proc.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key))
# Connect node with InitUserData
if key in init_config["Target"]:
+ back_node_script = back_node.getScript()
+ back_node_script = "__builtins__[\"init_data\"] = init_data\n" + back_node_script
+ back_node.setScript(back_node_script)
back_node.edAddInputPort("init_data", t_pyobj)
proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
# Connect node with InitUserData
if key in init_config["Target"]:
+ back_node_script = back_node.getScript()
+ back_node_script = "__builtins__[\"init_data\"] = init_data\n" + back_node_script
+ back_node.setScript(back_node_script)
back_node.edAddInputPort("init_data", t_pyobj)
proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
# Connect node with InitUserData
if key in init_config["Target"]:
+ back_node_script = back_node.getScript()
+ back_node_script = "__builtins__[\"init_data\"] = init_data\n" + back_node_script
+ back_node.setScript(back_node_script)
back_node.edAddInputPort("init_data", t_pyobj)
proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
# Connect node with InitUserData
if key in init_config["Target"]:
+ back_node_script = back_node.getScript()
+ back_node_script = "__builtins__[\"init_data\"] = init_data\n" + back_node_script
+ back_node.setScript(back_node_script)
back_node.edAddInputPort("init_data", t_pyobj)
proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type))
# Connect node with InitUserData
if key in init_config["Target"]:
+ back_node_script = back_node.getScript()
+ back_node_script = "__builtins__[\"init_data\"] = init_data\n" + back_node_script
+ back_node.setScript(back_node_script)
back_node.edAddInputPort("init_data", t_pyobj)
proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data"))
# Connect node with InitUserData
if "ObservationOperator" in init_config["Target"]:
+ opt_node_script = opt_script_node.getScript()
+ opt_node_script = "__builtins__[\"init_data\"] = init_data\n" + opt_node_script
+ opt_script_node.setScript(opt_node_script)
opt_script_node.edAddInputPort("init_data", t_pyobj)
proc.edAddDFLink(init_node.getOutputPort("init_data"), opt_script_node.getInputPort("init_data"))
-
else:
factory_opt_script_node = catalogAd.getNodeFromNodeMap("FakeOptimizerLoopNode")
opt_script_node = factory_opt_script_node.cloneNode("FakeFunctionNode")
# Connect node with InitUserData
if "UserPostAnalysis" in init_config["Target"]:
+ node_script = analysis_node.getScript()
+ node_script = "__builtins__[\"init_data\"] = init_data\n" + node_script
+ analysis_node.setScript(opt_node_script)
analysis_node.edAddInputPort("init_data", t_pyobj)
proc.edAddDFLink(init_node.getOutputPort("init_data"), analysis_node.getInputPort("init_data"))
proc.edAddDFLink(execute_node.getOutputPort("Study"), analysis_node.getInputPort("Study"))
# Connect node with InitUserData
if "UserPostAnalysis" in init_config["Target"]:
+ node_script = analysis_node.getScript()
+ node_script = "__builtins__[\"init_data\"] = init_data\n" + node_script
+ analysis_node.setScript(opt_node_script)
analysis_node.edAddInputPort("init_data", t_pyobj)
proc.edAddDFLink(init_node.getOutputPort("init_data"), analysis_node.getInputPort("init_data"))