]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Adding new example for the use of user init data node
authorAndré Ribes <andre.ribes@edf.fr>
Thu, 17 Nov 2011 08:35:01 +0000 (09:35 +0100)
committerAndré Ribes <andre.ribes@edf.fr>
Thu, 17 Nov 2011 08:35:01 +0000 (09:35 +0100)
configure.ac
examples/daSalome/Makefile.am
examples/daSalome/test003_bis_ADAO_JDC_using_user_data_init.comm.in [new file with mode: 0644]
examples/daSalome/test003_bis_ADAO_scripts_for_JDC.py [new file with mode: 0644]
examples/daSalome/test003_bis_ADAO_user_data_init.py [new file with mode: 0644]
src/daEficas/generator_adao.py
src/daSalome/daYacsSchemaCreator/methods.py

index 4b32280ff8606b27e99133f5d916a2802d683a98..fcd747a4836ec3fe55569d60c6f7222b4897f32b 100644 (file)
@@ -127,6 +127,7 @@ AC_CONFIG_FILES([
         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
index 9e268c21cee2e91b3fff1222b7258ff6c30ed0d3..981ac536713788cac976fce73ce67b000373b605 100644 (file)
@@ -28,7 +28,10 @@ DATA_INST = \
            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}
 
@@ -40,4 +43,7 @@ EXTRA_DIST = \
             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
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
new file mode 100644 (file)
index 0000000..1e14f8a
--- /dev/null
@@ -0,0 +1,24 @@
+
+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',),),);
diff --git a/examples/daSalome/test003_bis_ADAO_scripts_for_JDC.py b/examples/daSalome/test003_bis_ADAO_scripts_for_JDC.py
new file mode 100644 (file)
index 0000000..7bb3fc7
--- /dev/null
@@ -0,0 +1,42 @@
+#-*-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"]
diff --git a/examples/daSalome/test003_bis_ADAO_user_data_init.py b/examples/daSalome/test003_bis_ADAO_user_data_init.py
new file mode 100644 (file)
index 0000000..e133d01
--- /dev/null
@@ -0,0 +1,52 @@
+#-*-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
index 3098a138f13e550d5a2c3d80baf3ffc8d6bb05e5..791e72470d91d41ff9d9d194e5c3a2383e0f045b 100644 (file)
@@ -97,11 +97,11 @@ class AdaoGenerator(PythonGenerator):
     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")
@@ -114,7 +114,7 @@ class AdaoGenerator(PythonGenerator):
 
     # 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()
@@ -143,23 +143,23 @@ class AdaoGenerator(PythonGenerator):
 
     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):
 
@@ -169,10 +169,10 @@ class AdaoGenerator(PythonGenerator):
     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):
 
@@ -180,14 +180,14 @@ class AdaoGenerator(PythonGenerator):
       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):
 
@@ -196,15 +196,15 @@ class AdaoGenerator(PythonGenerator):
     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)
 
@@ -224,15 +224,15 @@ class AdaoGenerator(PythonGenerator):
         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():
@@ -248,12 +248,12 @@ class AdaoGenerator(PythonGenerator):
         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"
index 373603f44bc042e334d2130b4e0b2cd8fbd198b5..3c845248524a5ff8e30fdf0816495c8ab8ddb0ac 100644 (file)
@@ -100,6 +100,9 @@ def create_yacs_proc(study_config):
       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
@@ -128,6 +131,9 @@ def create_yacs_proc(study_config):
         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"))
 
@@ -144,6 +150,9 @@ def create_yacs_proc(study_config):
         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"))
 
@@ -167,6 +176,9 @@ def create_yacs_proc(study_config):
         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"))
 
@@ -183,6 +195,9 @@ def create_yacs_proc(study_config):
         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"))
 
@@ -206,6 +221,9 @@ def create_yacs_proc(study_config):
         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"))
 
@@ -277,9 +295,11 @@ def create_yacs_proc(study_config):
 
       # 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")
@@ -311,6 +331,9 @@ def create_yacs_proc(study_config):
 
       # 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"))
 
@@ -345,6 +368,9 @@ def create_yacs_proc(study_config):
         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"))