]> SALOME platform Git repositories - modules/adao.git/commitdiff
Salome HOME
Premier test ok !
authorAndré <andre.ribes@edf.fr>
Thu, 22 Apr 2010 13:51:37 +0000 (15:51 +0200)
committerAndré <andre.ribes@edf.fr>
Thu, 22 Apr 2010 13:51:37 +0000 (15:51 +0200)
resources/DATASSIMSchemaCatalog.xml
src/daSalome/daYacsSchemaCreator/help_methods.py
src/daSalome/daYacsSchemaCreator/methods.py
src/tests/daSalome/test000_Blue.py

index 18077f5071c3bc8bafdff6c01e4dfd54f77dddf5..44f5fc56c2faee1bf92d6f86c2e2f9b26323b3fa 100644 (file)
@@ -118,4 +118,16 @@ ADD.analyze()
     <inport name="Study" type="pyobj"/>
     <outport name="Study" type="pyobj"/>
   </inline>
+
+  <inline name="SimpleUserAnalysis">
+    <script><code><![CDATA[
+#-*-coding:iso-8859-1-*-
+print "Entering in SimpleUserAnalysis"
+from daYacsIntegration.daStudy import *
+ADD = Study.getAssimilationStudy()
+# User code is below
+
+]]></code></script>
+    <inport name="Study" type="pyobj"/>
+  </inline>
 </proc>
index b61588b9b6285c3782be27b252c6b7bed5a19ef5..9621af3bffffd2b6bb97b453df82b746c1020b0a 100644 (file)
@@ -69,6 +69,22 @@ def check_study(study_config):
     if key in AssimData:
       check_data(key, study_config[key])
 
+  # Analyse
+  if "Analysis" in study_config.keys():
+    analysis_config = study_config["Analysis"]
+    if "From" not in analysis_config:
+      logging.fatal("Analysis found but From is not defined in the analysis configuration !")
+      sys.exit(1)
+    else:
+      if analysis_config["From"] != "string":
+        logging.fatal("Analysis From defined in the study configuration does not have a correct type : " + str(analysis_config["From"])
+                      + "\n You can have : string")
+        sys.exit(1)
+    if "Data" not in analysis_config:
+      logging.fatal("Analysis found but Data is not defined in the analysis configuration !")
+      sys.exit(1)
+
+
 def check_data(data_name, data_config):
 
   logging.debug("[check_data] " + data_name)
index b07119f61d0fbeecccf8c02a9f4d52e4da6508f5..5071ae08e06d09111b89a277aa4c99cc848de699 100644 (file)
@@ -104,6 +104,17 @@ def create_yacs_proc(study_config):
     proc.edAddDFLink(CAS_node.getOutputPort("Study"), execute_node.getInputPort("Study"))
 
   # Step 4: create post-processing from user configuration
+  if "Analysis" in study_config.keys():
+    analysis_config = study_config["Analysis"]
+    if analysis_config["From"] == "string":
+      factory_analysis_node = catalogAd._nodeMap["SimpleUserAnalysis"]
+      analysis_node = factory_analysis_node.cloneNode("User Analysis")
+      default_script = analysis_node.getScript()
+      final_script = default_script + analysis_config["Data"]
+      analysis_node.setScript(final_script)
+      proc.edAddChild(analysis_node)
+      proc.edAddCFLink(compute_bloc, analysis_node)
+      proc.edAddDFLink(execute_node.getOutputPort("Study"), analysis_node.getInputPort("Study"))
 
   return proc
 
index 1ad17216dace42671f5791d1e5bfd0a211fe6934..0e994daf29112e0ae8c38fbf5f23e89d074e4ce7 100644 (file)
@@ -1,3 +1,4 @@
+#-*-coding:iso-8859-1-*-
 study_config = {}
 study_config["Name"] = "test000_Blue"
 study_config["Algorithm"] = "Blue"
@@ -31,3 +32,24 @@ ObservationOperator_config["Data"] = "1 0 0;0 1 0;0 0 1"
 ObservationOperator_config["Type"] = "Matrix"
 ObservationOperator_config["From"] = "string"
 study_config["ObservationOperator"] = ObservationOperator_config
+
+Analysis_config = {}
+Analysis_config["Data"] = """
+import numpy
+precision = 1.e-13
+
+Xa = ADD.get("Analysis")
+print
+print "    Nombre d'analyses  :",Xa.stepnumber()
+print "    Analyse résultante :",Xa.valueserie(0)
+#
+# Vérification du résultat
+# ------------------------
+if max(numpy.array(Xa.valueserie(0))-numpy.array([0.25, 1.25, 2.25])) > precision:
+  raise ValueError("Résultat du test erroné")
+else:
+  print "    Test correct, erreur maximale inférieure à %s"%precision
+  print
+"""
+Analysis_config["From"] = "string"
+study_config["Analysis"] = Analysis_config