Salome HOME
Adding checking algorithms environment
[modules/adao.git] / resources / ADAOSchemaCatalog.xml
index 64742bcf0a600cb45badb4b4a252c421d58b368b..10a9073db53222967e9c346a921f3dbafa8cc3b7 100644 (file)
@@ -1,6 +1,27 @@
 <?xml version='1.0' encoding='iso-8859-1' ?>
-<proc>
+<!--
+  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: Andre Ribes, andre.ribes@edf.fr, EDF R&D
+-->
+<proc>
+
   <objref name="computeAD" id="python:computeAD:1.0">
     <base>pyobj</base>
   </objref>
     <member type="string" name="value"></member>
   </struct>
   <sequence content="SALOME_TYPES/Parameter" name="SALOME_TYPES/ParameterList"></sequence>
-  <sequence content="double" name="Value1D"></sequence>
-  <sequence content="Value1D" name="SALOME_TYPES/Value"></sequence>
+  <sequence content="double" name="SALOME_TYPES/Variable"></sequence>
+  <sequence content="SALOME_TYPES/Variable" name="SALOME_TYPES/VariableSequence"></sequence>
+  <sequence content="SALOME_TYPES/VariableSequence" name="SALOME_TYPES/StateSequence"></sequence>
+  <sequence content="SALOME_TYPES/StateSequence" name="SALOME_TYPES/TimeSequence"></sequence>
   <sequence content="string" name="SALOME_TYPES/VarList"></sequence>
-  <sequence content="SALOME_TYPES/Value" name="SALOME_TYPES/ValueList"></sequence>
   <struct name="SALOME_TYPES/ParametricInput">
     <member type="SALOME_TYPES/VarList" name="inputVarList"></member>
     <member type="SALOME_TYPES/VarList" name="outputVarList"></member>
-    <member type="SALOME_TYPES/ValueList" name="inputValues"></member>
+    <member type="SALOME_TYPES/TimeSequence" name="inputValues"></member>
     <member type="SALOME_TYPES/ParameterList" name="specificParameters"></member>
   </struct>
   <struct name="SALOME_TYPES/ParametricOutput">
-    <member type="SALOME_TYPES/ValueList" name="outputValues"></member>
+    <member type="SALOME_TYPES/TimeSequence" name="outputValues"></member>
     <member type="SALOME_TYPES/ParameterList" name="specificOutputInfos"></member>
     <member type="long" name="returnCode"></member>
     <member type="string" name="errorMessage"></member>
     <script><code>
 
 <![CDATA[
-import numpy
-print "Entering in CreateAssimilationStudy"
-print "Name is", Name
-print "Algorithm is", Algorithm
-print "Debug is set to", Debug
+import numpy, logging
+logging.debug("CREATE Entering in CreateAssimilationStudy")
+print "Entering in the assimilation study"
+print "Name is set to........:", Name
+print "Algorithm is set to...:", Algorithm
+print "Debug is set to.......:", Debug
 
 # Create Assimilation study
 from daYacsIntegration.daStudy import *
@@ -54,26 +77,38 @@ else:
   assim_study.setAlgorithmParameters(AlgorithmParameters)
 
 # Data
-print "Data entered are:"
+# print "Data entered are:"
+
 # Background
 try:
   Background
 except NameError:
   pass
 else:
-  #print "Background is", Background
-  #print "BackgroundType is", BackgroundType
+  logging.debug("CREATE Background is %s"%Background)
+  logging.debug("CREATE BackgroundType is %s"%BackgroundType)
   assim_study.setBackgroundType(BackgroundType)
   assim_study.setBackground(Background)
 
+# CheckingPoint
+try:
+  CheckingPoint
+except NameError:
+  pass
+else:
+  logging.debug("CREATE CheckingPoint is %s"%CheckingPoint)
+  logging.debug("CREATE CheckingPointType is %s"%CheckingPointType)
+  assim_study.setCheckingPointType(CheckingPointType)
+  assim_study.setCheckingPoint(CheckingPoint)
+
 # BackgroundError
 try:
   BackgroundError
 except NameError:
   pass
 else:
-  #print "BackgroundError is", BackgroundError
-  #print "BackgroundErrorType is", BackgroundErrorType
+  logging.debug("CREATE BackgroundError is %s"%BackgroundError)
+  logging.debug("CREATE BackgroundErrorType is %s"%BackgroundErrorType)
   assim_study.setBackgroundError(BackgroundError)
 
 # Observation
@@ -82,8 +117,8 @@ try:
 except NameError:
   pass
 else:
-  #print "Observation is", Observation
-  #print "ObservationType is", ObservationType
+  logging.debug("CREATE Observation is %s"%Observation)
+  logging.debug("CREATE ObservationType is %s"%ObservationType)
   assim_study.setObservationType(ObservationType)
   assim_study.setObservation(Observation)
 
@@ -93,8 +128,8 @@ try:
 except NameError:
   pass
 else:
-  #print "ObservationError is", ObservationError
-  #print "ObservationErrorType is", ObservationErrorType
+  logging.debug("CREATE ObservationError is %s"%ObservationError)
+  logging.debug("CREATE ObservationErrorType is %s"%ObservationErrorType)
   assim_study.setObservationError(ObservationError)
 
 # ObservationOperator
@@ -104,8 +139,8 @@ try:
 except NameError:
   pass
 else:
-  #print "ObservationOperator is", ObservationOperator
-  #print "ObservationOperatorType is", ObservationOperatorType
+  logging.debug("CREATE ObservationOperator is %s"%ObservationOperator)
+  logging.debug("CREATE ObservationOperatorType is %s"%ObservationOperatorType)
   assim_study.setObservationOperatorType("Matrix", ObservationOperatorType)
   assim_study.setObservationOperator("Matrix", ObservationOperator)
   ObservationOperatorOk = 1
@@ -116,7 +151,7 @@ if ObservationOperatorOk == 0:
   except NameError:
     pass
   else:
-    #print "ObservationOperatorDirect is", ObservationOperatorDirect
+    logging.debug("CREATE ObservationOperatorDirect is %s"%ObservationOperatorDirect)
     assim_study.setObservationOperatorType("Direct", "Function")
     assim_study.setObservationOperator("Direct", ObservationOperatorDirect)
   try:
@@ -124,7 +159,7 @@ if ObservationOperatorOk == 0:
   except NameError:
     pass
   else:
-    #print "ObservationOperatorTangent is", ObservationOperatorTangent
+    logging.debug("CREATE ObservationOperatorTangent is %s"%ObservationOperatorTangent)
     assim_study.setObservationOperatorType("Tangent", "Function")
     assim_study.setObservationOperator("Tangent", ObservationOperatorTangent)
   try:
@@ -132,11 +167,28 @@ if ObservationOperatorOk == 0:
   except NameError:
     pass
   else:
-    #print "ObservationOperatorAdjoint is", ObservationOperatorAdjoint
+    logging.debug("CREATE ObservationOperatorAdjoint is %s"%ObservationOperatorAdjoint)
     assim_study.setObservationOperatorType("Adjoint", "Function")
     assim_study.setObservationOperator("Adjoint", ObservationOperatorAdjoint)
 
+# Variables
+for name, size in zip(InputVariablesNames, InputVariablesSizes):
+  assim_study.setInputVariable(name, size)
+for name, size in zip(OutputVariablesNames, OutputVariablesSizes):
+  assim_study.setOutputVariable(name, size)
 
+if has_observers:
+  logging.debug("CREATE Observers is %s"%observers.keys())
+  # Adding observers to the study
+  for observer_name in observers.keys():
+    scheduler = ""
+    info = ""
+    number = str(observers[observer_name]["number"])
+    if "scheduler" in observers[observer_name].keys():
+      scheduler = observers[observer_name]["scheduler"]
+    if "info" in observers[observer_name].keys():
+      info = observers[observer_name]["info"]
+    assim_study.addObserver(observer_name, scheduler, info, number)
 Study = assim_study
 ]]>
 
@@ -144,16 +196,22 @@ Study = assim_study
     <inport name="Name" type="string"/>
     <inport name="Algorithm" type="string"/>
     <inport name="Debug" type="bool"/>
+    <inport name="InputVariablesNames" type="stringvec"/>
+    <inport name="InputVariablesSizes" type="intvec"/>
+    <inport name="OutputVariablesNames" type="stringvec"/>
+    <inport name="OutputVariablesSizes" type="intvec"/>
+    <inport name="has_observers" type="bool"/>
+    <inport name="observers" type="pyobj"/>
     <outport name="Study" type="pyobj"/>
   </inline>
 
   <inline name="CreateNumpyMatrixFromString">
     <script><code><![CDATA[
-print "Entering in CreateNumpyMatrixFromString"
-import numpy
+import numpy, logging
+logging.debug("CREATE Entering in CreateNumpyMatrixFromString")
 matrix = numpy.matrix(matrix_in_string)
 type = "Matrix"
-print "Matrix is", matrix
+logging.debug("CREATE Matrix is %s"%matrix)
 ]]></code></script>
     <inport name="matrix_in_string" type="string"/>
     <outport name="matrix" type="pyobj"/>
@@ -162,9 +220,23 @@ print "Matrix is", matrix
 
   <inline name="CreateNumpyMatrixFromScript">
     <script><code><![CDATA[
-print "Entering in CreateNumpyMatrixFromScript"
-execfile(script)
+import logging
+logging.debug("CREATE Entering in CreateNumpyMatrixFromScript")
 type = "Matrix"
+
+# Get file path and filename
+import sys
+import os
+filepath = os.path.dirname(script)
+filename = os.path.basename(script)
+module_name = os.path.splitext(filename)[0]
+sys.path.insert(0,filepath)
+
+# Import script
+__import__(module_name)
+user_script_module = sys.modules[module_name]
+
+# Get Data from script
 ]]></code></script>
     <inport name="script" type="string"/>
     <outport name="type" type="string"/>
@@ -172,11 +244,11 @@ type = "Matrix"
 
   <inline name="CreateNumpyVectorFromString">
     <script><code><![CDATA[
-print "Entering in CreateNumpyVectorFromString"
-import numpy
+import numpy, logging
+logging.debug("CREATE Entering in CreateNumpyVectorFromString")
 vector = numpy.matrix(vector_in_string)
 type = "Vector"
-print "Vector is", vector
+logging.debug("Vector is %s"%vector)
 ]]></code></script>
     <inport name="vector_in_string" type="string"/>
     <outport name="vector" type="pyobj"/>
@@ -185,9 +257,23 @@ print "Vector is", vector
 
   <inline name="CreateNumpyVectorFromScript">
     <script><code><![CDATA[
-print "Entering in CreateNumpyVectorFromScript"
-execfile(script)
+import logging
+logging.debug("CREATE Entering in CreateNumpyVectorFromScript")
 type = "Vector"
+
+# Get file path and filename
+import sys
+import os
+filepath = os.path.dirname(script)
+filename = os.path.basename(script)
+module_name = os.path.splitext(filename)[0]
+sys.path.insert(0,filepath)
+
+# Import script
+__import__(module_name)
+user_script_module = sys.modules[module_name]
+
+# Get Data from script
 ]]></code></script>
     <inport name="script" type="string"/>
     <outport name="type" type="string"/>
@@ -195,7 +281,8 @@ type = "Vector"
 
   <inline name="SimpleExecuteDirectAlgorithm">
     <script><code><![CDATA[
-print "Entering in SimpleExecuteDirectAlgorithm"
+import logging
+logging.debug("EXECUTE Entering in SimpleExecuteDirectAlgorithm")
 from daYacsIntegration.daStudy import *
 ADD = Study.getAssimilationStudy()
 ADD.analyze()
@@ -207,7 +294,8 @@ ADD.analyze()
   <inline name="SimpleUserAnalysis">
     <script><code><![CDATA[
 #-*-coding:iso-8859-1-*-
-print "Entering in SimpleUserAnalysis"
+import logging
+logging.debug("TERMINATE Entering in SimpleUserAnalysis")
 from daYacsIntegration.daStudy import *
 ADD = Study.getAssimilationStudy()
 # User code is below
@@ -218,28 +306,130 @@ ADD = Study.getAssimilationStudy()
 
   <inline name="FakeOptimizerLoopNode">
     <script><code><![CDATA[
-print "Entering in FakeOptimizerLoopNode"
+import logging
+logging.debug("EXECUTE Entering in FakeOptimizerLoopNode")
 result = None
 ]]></code></script>
     <inport name="computation" type="SALOME_TYPES/ParametricInput"/>
-    <outport name="result" type="pyobj"/>
+    <outport name="result" type="SALOME_TYPES/ParametricOutput"/>
   </inline>
 
   <inline name="CreateDictFromScript">
     <script><code><![CDATA[
-print "Entering in CreateDictFromScript"
-execfile(script)
+import logging
+logging.debug("CREATE Entering in CreateDictFromScript")
+
+# Get file path and filename
+import sys
+import os
+filepath = os.path.dirname(script)
+filename = os.path.basename(script)
+module_name = os.path.splitext(filename)[0]
+sys.path.insert(0,filepath)
+
+# Import script
+__import__(module_name)
+user_script_module = sys.modules[module_name]
+
+# Get Data from script
 ]]></code></script>
     <inport name="script" type="string"/>
   </inline>
 
   <inline name="UserDataInitFromScript">
     <script><code><![CDATA[
-print "Entering in UserDataInitFromScript"
-execfile(script)
+import logging
+logging.debug("CREATE Entering in UserDataInitFromScript")
+
+# Get file path and filename
+import sys
+import os
+filepath = os.path.dirname(script)
+filename = os.path.basename(script)
+module_name = os.path.splitext(filename)[0]
+sys.path.insert(0,filepath)
+
+# Import script
+__import__(module_name)
+user_script_module = sys.modules[module_name]
+
+# Get Data from script
 ]]></code></script>
     <inport name="script" type="string"/>
     <outport name="init_data" type="pyobj"/>
   </inline>
 
+  <inline name="ReadForSwitchNode">
+    <script><code><![CDATA[
+import logging
+logging.debug("CREATE Entering in ReadForSwitchNode")
+switch_value = -1
+for param in data["specificParameters"]:
+  if param["name"] == "switch_value":
+    switch_value = int(param["value"])
+]]></code></script>
+    <inport name="data" type="SALOME_TYPES/ParametricInput"/>
+    <outport name="data" type="SALOME_TYPES/ParametricInput"/>
+    <outport name="switch_value" type="int"/>
+  </inline>
+
+  <inline name="ExtractDataNode">
+    <script><code><![CDATA[
+import logging
+logging.debug("TERMINATE Entering in ExtractDataNode")
+import pickle
+from daCore.AssimilationStudy import AssimilationStudy
+var = None
+info = None
+for param in data["specificParameters"]:
+  if param["name"] == "var":
+    var = pickle.loads(param["value"])
+  if param["name"] == "info":
+    info = param["value"]
+]]></code></script>
+    <inport name="data" type="SALOME_TYPES/ParametricInput"/>
+    <outport name="var" type="pyobj"/>
+    <outport name="info" type="pyobj"/>
+  </inline>
+
+  <inline name="ObservationNodeString">
+    <script><code><![CDATA[
+#print "Entering in Observation"
+
+]]></code></script>
+    <inport name="var" type="pyobj"/>
+    <inport name="info" type="pyobj"/>
+  </inline>
+
+  <inline name="ObservationNodeFile">
+    <script><code><![CDATA[
+#print "Entering in Observation"
+execfile(script)
+
+]]></code></script>
+    <inport name="var"    type="pyobj"/>
+    <inport name="info"   type="pyobj"/>
+    <inport name="script" type="string"/>
+  </inline>
+
+  <inline name="EndObservationNode">
+    <script><code><![CDATA[
+# Create a fake output object.
+# An observer is always successful.
+output = {}
+output["outputValues"]        = [[[[]]]]
+output["specificOutputInfos"] = []
+output["returnCode"]          = 0
+output["errorMessage"]        = ""
+]]></code></script>
+    <outport name="output" type="SALOME_TYPES/ParametricOutput"/>
+  </inline>
+
+  <inline name="SetObserversNode">
+    <script><code><![CDATA[
+#print "Setting observers"
+]]></code></script>
+    <outport name="has_observers" type="bool"/>
+    <outport name="observers" type="pyobj"/>
+  </inline>
 </proc>