Salome HOME
Minor correction for raised error messages
[modules/adao.git] / resources / ADAOSchemaCatalog.xml
1 <?xml version='1.0' encoding='iso-8859-1' ?>
2 <!--
3   Copyright (C) 2008-2017 EDF R&D
4
5   This file is part of SALOME ADAO module
6
7   This library is free software; you can redistribute it and/or
8   modify it under the terms of the GNU Lesser General Public
9   License as published by the Free Software Foundation; either
10   version 2.1 of the License.
11
12   This library is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   Lesser General Public License for more details.
16
17   You should have received a copy of the GNU Lesser General Public
18   License along with this library; if not, write to the Free Software
19   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20
21   See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22   
23   Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D
24 -->
25 <proc>
26
27   <objref name="computeAD" id="python:computeAD:1.0">
28     <base>pyobj</base>
29   </objref>
30
31   <!-- Types for parametric computations -->
32   <!-- TODO On devrait pouvoir le lire depuis le KERNEL !!!-->
33   <type name="long" kind="int"/>
34   <struct name="SALOME_TYPES/Parameter">
35     <member type="string" name="name"></member>
36     <member type="string" name="value"></member>
37   </struct>
38   <sequence content="SALOME_TYPES/Parameter" name="SALOME_TYPES/ParameterList"></sequence>
39   <sequence content="double" name="SALOME_TYPES/Variable"></sequence>
40   <sequence content="SALOME_TYPES/Variable" name="SALOME_TYPES/VariableSequence"></sequence>
41   <sequence content="SALOME_TYPES/VariableSequence" name="SALOME_TYPES/StateSequence"></sequence>
42   <sequence content="SALOME_TYPES/StateSequence" name="SALOME_TYPES/TimeSequence"></sequence>
43   <sequence content="string" name="SALOME_TYPES/VarList"></sequence>
44   <struct name="SALOME_TYPES/ParametricInput">
45     <member type="SALOME_TYPES/VarList" name="inputVarList"></member>
46     <member type="SALOME_TYPES/VarList" name="outputVarList"></member>
47     <member type="SALOME_TYPES/TimeSequence" name="inputValues"></member>
48     <member type="SALOME_TYPES/ParameterList" name="specificParameters"></member>
49   </struct>
50   <struct name="SALOME_TYPES/ParametricOutput">
51     <member type="SALOME_TYPES/TimeSequence" name="outputValues"></member>
52     <member type="SALOME_TYPES/ParameterList" name="specificOutputInfos"></member>
53     <member type="long" name="returnCode"></member>
54     <member type="string" name="errorMessage"></member>
55   </struct>
56
57
58   <inline name="CreateAssimilationStudy">
59     <script><code>
60
61 <![CDATA[
62 import numpy, logging
63 logging.debug("CREATE Entering in CreateAssimilationStudy")
64 print "Entering in the assimilation study"
65 print "Name is set to........:", Name
66 print "Algorithm is set to...:", Algorithm
67
68 try:
69     # Create Assimilation study
70     from daYacsIntegration.daStudy import *
71     assim_study = daStudy(Name, Algorithm, Debug)
72
73     logging.debug("CREATE Data entered are:")
74
75     # Algorithm parameters
76     if "AlgorithmParameters" in locals():
77       logging.debug("CREATE AlgorithmParameters is %s"%AlgorithmParameters)
78       assim_study.setAlgorithmParameters(AlgorithmParameters)
79
80     # Background
81     if "Background" in locals():
82       logging.debug("CREATE Background is set")
83       logging.debug("CREATE BackgroundType is %s"%BackgroundType)
84       logging.debug("CREATE BackgroundStored is %s"%BackgroundStored)
85       assim_study.setBackgroundType(BackgroundType)
86       assim_study.setBackgroundStored(BackgroundStored)
87       assim_study.setBackground(Background)
88
89     # CheckingPoint
90     if "CheckingPoint" in locals():
91       logging.debug("CREATE CheckingPoint is set")
92       logging.debug("CREATE CheckingPointType is %s"%CheckingPointType)
93       logging.debug("CREATE CheckingPointStored is %s"%CheckingPointStored)
94       assim_study.setCheckingPointType(CheckingPointType)
95       assim_study.setCheckingPointStored(CheckingPointStored)
96       assim_study.setCheckingPoint(CheckingPoint)
97
98     # ControlInput
99     if "ControlInput" in locals():
100       logging.debug("CREATE ControlInput is set")
101       logging.debug("CREATE ControlInputType is %s"%ControlInputType)
102       logging.debug("CREATE ControlInputStored is %s"%ControlInputStored)
103       assim_study.setControlInputType(ControlInputType)
104       assim_study.setControlInputStored(ControlInputStored)
105       assim_study.setControlInput(ControlInput)
106
107     # Observation
108     if "Observation" in locals():
109       logging.debug("CREATE Observation is set")
110       logging.debug("CREATE ObservationType is %s"%ObservationType)
111       logging.debug("CREATE ObservationStored is %s"%ObservationStored)
112       assim_study.setObservationType(ObservationType)
113       assim_study.setObservationStored(ObservationStored)
114       assim_study.setObservation(Observation)
115
116     # BackgroundError
117     if "BackgroundError" in locals():
118       logging.debug("CREATE BackgroundError is set")
119       logging.debug("CREATE BackgroundErrorType is %s"%BackgroundErrorType)
120       logging.debug("CREATE BackgroundErrorStored is %s"%BackgroundErrorStored)
121       assim_study.setBackgroundErrorType(BackgroundErrorType)
122       assim_study.setBackgroundErrorStored(BackgroundErrorStored)
123       assim_study.setBackgroundError(BackgroundError)
124
125     # ObservationError
126     if "ObservationError" in locals():
127       logging.debug("CREATE ObservationError is set")
128       logging.debug("CREATE ObservationErrorType is %s"%ObservationErrorType)
129       logging.debug("CREATE ObservationErrorStored is %s"%ObservationErrorStored)
130       assim_study.setObservationErrorType(ObservationErrorType)
131       assim_study.setObservationErrorStored(ObservationErrorStored)
132       assim_study.setObservationError(ObservationError)
133
134     # EvolutionError
135     if "EvolutionError" in locals():
136       logging.debug("CREATE EvolutionError is set")
137       logging.debug("CREATE EvolutionErrorType is %s"%EvolutionErrorType)
138       logging.debug("CREATE EvolutionErrorStored is %s"%EvolutionErrorStored)
139       assim_study.setEvolutionErrorType(EvolutionErrorType)
140       assim_study.setEvolutionErrorStored(EvolutionErrorStored)
141       assim_study.setEvolutionError(EvolutionError)
142
143     # ObservationOperator
144     ObservationOperatorOk = 0
145     if "ObservationOperator" in locals():
146       logging.debug("CREATE ObservationOperator is set")
147       logging.debug("CREATE ObservationOperatorType is %s"%ObservationOperatorType)
148       assim_study.setObservationOperatorType("Matrix", ObservationOperatorType)
149       assim_study.setObservationOperator("Matrix", ObservationOperator)
150       ObservationOperatorOk = 1
151
152     if ObservationOperatorOk == 0:
153       if "ObservationOperatorDirect" in locals():
154         logging.debug("CREATE ObservationOperatorDirect is %s"%ObservationOperatorDirect)
155         assim_study.setObservationOperatorType("Direct", "Function")
156         assim_study.setObservationOperator("Direct", ObservationOperatorDirect)
157       if "ObservationOperatorTangent" in locals():
158         logging.debug("CREATE ObservationOperatorTangent is %s"%ObservationOperatorTangent)
159         assim_study.setObservationOperatorType("Tangent", "Function")
160         assim_study.setObservationOperator("Tangent", ObservationOperatorTangent)
161       if "ObservationOperatorAdjoint" in locals():
162         logging.debug("CREATE ObservationOperatorAdjoint is %s"%ObservationOperatorAdjoint)
163         assim_study.setObservationOperatorType("Adjoint", "Function")
164         assim_study.setObservationOperator("Adjoint", ObservationOperatorAdjoint)
165
166     # EvolutionModel
167     EvolutionModelOk = 0
168     if "EvolutionModel" in locals():
169       logging.debug("CREATE EvolutionModel is set")
170       logging.debug("CREATE EvolutionModelType is %s"%EvolutionModelType)
171       assim_study.setEvolutionModelType("Matrix", EvolutionModelType)
172       assim_study.setEvolutionModel("Matrix", EvolutionModel)
173       EvolutionModelOk = 1
174
175     if EvolutionModelOk == 0:
176       if "EvolutionModelDirect" in locals():
177         logging.debug("CREATE EvolutionModelDirect is %s"%EvolutionModelDirect)
178         assim_study.setEvolutionModelType("Direct", "Function")
179         assim_study.setEvolutionModel("Direct", EvolutionModelDirect)
180       if "EvolutionModelTangent" in locals():
181         logging.debug("CREATE EvolutionModelTangent is %s"%EvolutionModelTangent)
182         assim_study.setEvolutionModelType("Tangent", "Function")
183         assim_study.setEvolutionModel("Tangent", EvolutionModelTangent)
184       if "EvolutionModelAdjoint" in locals():
185         logging.debug("CREATE EvolutionModelAdjoint is %s"%EvolutionModelAdjoint)
186         assim_study.setEvolutionModelType("Adjoint", "Function")
187         assim_study.setEvolutionModel("Adjoint", EvolutionModelAdjoint)
188
189     # Variables
190     for name, size in zip(InputVariablesNames, InputVariablesSizes):
191       assim_study.setInputVariable(name, size)
192     for name, size in zip(OutputVariablesNames, OutputVariablesSizes):
193       assim_study.setOutputVariable(name, size)
194
195     if has_observers:
196       logging.debug("CREATE Observers keys are %s"%observers.keys())
197       # Adding observers to the study
198       for observer_name in observers.keys():
199         scheduler = ""
200         info = ""
201         number = str(observers[observer_name]["number"])
202         if "scheduler" in observers[observer_name].keys():
203           scheduler = observers[observer_name]["scheduler"]
204         if "info" in observers[observer_name].keys():
205           info = observers[observer_name]["info"]
206         assim_study.addObserver(observer_name, scheduler, info, number)
207
208 except Exception as e:
209     if isinstance(e, SyntaxError): msg = "at %s: %s"%(e.offset, e.text)
210     else: msg = ""
211     raise ValueError("during execution, the following error occurs:\n\n%s %s\n\nSee also the potential messages, which can show the origin of the above error, in the launching terminal."%(str(e),msg))
212
213 Study = assim_study
214 ]]>
215
216 </code></script>
217     <inport name="Name" type="string"/>
218     <inport name="Algorithm" type="string"/>
219     <inport name="Debug" type="bool"/>
220     <inport name="InputVariablesNames" type="stringvec"/>
221     <inport name="InputVariablesSizes" type="intvec"/>
222     <inport name="OutputVariablesNames" type="stringvec"/>
223     <inport name="OutputVariablesSizes" type="intvec"/>
224     <inport name="has_observers" type="bool"/>
225     <inport name="observers" type="pyobj"/>
226     <outport name="Study" type="pyobj"/>
227   </inline>
228
229   <inline name="CreateNumpyMatrixFromString">
230     <script><code><![CDATA[
231 import numpy, logging
232 logging.debug("CREATE Entering in CreateNumpyMatrixFromString")
233 matrix = numpy.matrix(matrix_in_string)
234 type = "Matrix"
235 logging.debug("CREATE Matrix is %s"%matrix)
236 ]]></code></script>
237     <inport name="matrix_in_string" type="string"/>
238     <outport name="matrix" type="pyobj"/>
239     <outport name="type" type="string"/>
240     <outport name="stored" type="bool"/>
241   </inline>
242
243   <inline name="CreateNumpyScalarSparseMatrixFromString">
244     <script><code><![CDATA[
245 import numpy, logging
246 logging.debug("CREATE Entering in CreateNumpyScalarSparseMatrixFromString")
247 matrix = numpy.matrix(matrix_in_string)
248 type = "ScalarSparseMatrix"
249 logging.debug("CREATE ScalarSparseMatrix is %s"%matrix)
250 ]]></code></script>
251     <inport name="matrix_in_string" type="string"/>
252     <outport name="matrix" type="pyobj"/>
253     <outport name="type" type="string"/>
254     <outport name="stored" type="bool"/>
255   </inline>
256
257   <inline name="CreateNumpyDiagonalSparseMatrixFromString">
258     <script><code><![CDATA[
259 import numpy, logging
260 logging.debug("CREATE Entering in CreateNumpyDiagonalSparseMatrixFromString")
261 matrix = numpy.matrix(matrix_in_string)
262 type = "DiagonalSparseMatrix"
263 logging.debug("CREATE DiagonalSparseMatrix is %s"%matrix)
264 ]]></code></script>
265     <inport name="matrix_in_string" type="string"/>
266     <outport name="matrix" type="pyobj"/>
267     <outport name="type" type="string"/>
268     <outport name="stored" type="bool"/>
269   </inline>
270
271   <inline name="CreateNumpyMatrixFromScript">
272     <script><code><![CDATA[
273 import logging, sys, os
274 logging.debug("CREATE Entering in CreateNumpyMatrixFromScript")
275 type = "Matrix"
276
277 # Get file path and filename
278 try:
279     if sys.path.count(studydir)==0 or (sys.path.count(studydir)>0 and sys.path.index(studydir)>0):
280         sys.path.insert(0,studydir)
281 except:
282     pass
283 filepath = os.path.dirname(script)
284 filename = os.path.basename(script)
285 module_name = os.path.splitext(filename)[0]
286 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
287     sys.path.insert(0,filepath)
288
289 ]]></code></script>
290     <inport name="script" type="string"/>
291     <outport name="type" type="string"/>
292     <outport name="stored" type="bool"/>
293   </inline>
294
295   <inline name="CreateNumpyScalarSparseMatrixFromScript">
296     <script><code><![CDATA[
297 import logging, sys, os
298 logging.debug("CREATE Entering in CreateNumpyScalarSparseMatrixFromScript")
299 type = "ScalarSparseMatrix"
300
301 # Get file path and filename
302 try:
303     if sys.path.count(studydir)==0 or (sys.path.count(studydir)>0 and sys.path.index(studydir)>0):
304         sys.path.insert(0,studydir)
305 except:
306     pass
307 filepath = os.path.dirname(script)
308 filename = os.path.basename(script)
309 module_name = os.path.splitext(filename)[0]
310 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
311     sys.path.insert(0,filepath)
312
313 ]]></code></script>
314     <inport name="script" type="string"/>
315     <outport name="type" type="string"/>
316     <outport name="stored" type="bool"/>
317   </inline>
318
319   <inline name="CreateNumpyDiagonalSparseMatrixFromScript">
320     <script><code><![CDATA[
321 import logging, sys, os
322 logging.debug("CREATE Entering in CreateNumpyDiagonalSparseMatrixFromScript")
323 type = "DiagonalSparseMatrix"
324
325 # Get file path and filename
326 try:
327     if sys.path.count(studydir)==0 or (sys.path.count(studydir)>0 and sys.path.index(studydir)>0):
328         sys.path.insert(0,studydir)
329 except:
330     pass
331 filepath = os.path.dirname(script)
332 filename = os.path.basename(script)
333 module_name = os.path.splitext(filename)[0]
334 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
335     sys.path.insert(0,filepath)
336
337 ]]></code></script>
338     <inport name="script" type="string"/>
339     <outport name="type" type="string"/>
340     <outport name="stored" type="bool"/>
341   </inline>
342
343   <inline name="CreateNumpyVectorFromString">
344     <script><code><![CDATA[
345 import numpy, logging
346 logging.debug("CREATE Entering in CreateNumpyVectorFromString")
347 vector = numpy.matrix(vector_in_string)
348 type = "Vector"
349 logging.debug("Vector is %s"%vector)
350 ]]></code></script>
351     <inport name="vector_in_string" type="string"/>
352     <outport name="vector" type="pyobj"/>
353     <outport name="type" type="string"/>
354     <outport name="stored" type="bool"/>
355   </inline>
356
357   <inline name="CreateNumpyVectorFromScript">
358     <script><code><![CDATA[
359 import logging, sys, os
360 logging.debug("CREATE Entering in CreateNumpyVectorFromScript")
361 type = "Vector"
362
363 # Get file path and filename
364 try:
365     if sys.path.count(studydir)==0 or (sys.path.count(studydir)>0 and sys.path.index(studydir)>0):
366         sys.path.insert(0,studydir)
367 except:
368     pass
369 filepath = os.path.dirname(script)
370 filename = os.path.basename(script)
371 module_name = os.path.splitext(filename)[0]
372 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
373     sys.path.insert(0,filepath)
374
375 ]]></code></script>
376     <inport name="script" type="string"/>
377     <outport name="type" type="string"/>
378     <outport name="stored" type="bool"/>
379   </inline>
380
381   <inline name="CreateNumpyVectorSerieFromString">
382     <script><code><![CDATA[
383 import numpy, logging
384 logging.debug("CREATE Entering in CreateNumpyVectorSerieFromString")
385 vector_in_list = eval(str(vector_in_string),{},{})
386 vector = numpy.matrix(vector_in_list)
387 type = "VectorSerie"
388 logging.debug("VectorSerie is %s"%vector)
389 ]]></code></script>
390     <inport name="vector_in_string" type="string"/>
391     <outport name="vector" type="pyobj"/>
392     <outport name="type" type="string"/>
393     <outport name="stored" type="bool"/>
394   </inline>
395
396   <inline name="CreateNumpyVectorSerieFromScript">
397     <script><code><![CDATA[
398 import logging, sys, os
399 logging.debug("CREATE Entering in CreateNumpyVectorSerieFromScript")
400 type = "VectorSerie"
401
402 # Get file path and filename
403 try:
404     if sys.path.count(studydir)==0 or (sys.path.count(studydir)>0 and sys.path.index(studydir)>0):
405         sys.path.insert(0,studydir)
406 except:
407     pass
408 filepath = os.path.dirname(script)
409 filename = os.path.basename(script)
410 module_name = os.path.splitext(filename)[0]
411 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
412     sys.path.insert(0,filepath)
413
414 ]]></code></script>
415     <inport name="script" type="string"/>
416     <outport name="type" type="string"/>
417     <outport name="stored" type="bool"/>
418   </inline>
419
420   <inline name="SimpleExecuteDirectAlgorithm">
421     <script><code><![CDATA[
422 import logging
423 logging.debug("EXECUTE Entering in SimpleExecuteDirectAlgorithm")
424 from daYacsIntegration.daStudy import *
425 ADD = Study.getResults()
426 ADD.analyze()
427 ]]></code></script>
428     <inport name="Study" type="pyobj"/>
429     <outport name="Study" type="pyobj"/>
430   </inline>
431
432   <inline name="SimpleUserAnalysis">
433     <script><code><![CDATA[
434 #-*-coding:iso-8859-1-*-
435 import logging
436 logging.debug("TERMINATE Entering in SimpleUserAnalysis")
437 ADD = Study.getResults()
438 # User code is below
439
440 ]]></code></script>
441     <inport name="Study" type="pyobj"/>
442   </inline>
443
444   <inline name="FakeOptimizerLoopNode">
445     <script><code><![CDATA[
446 import logging
447 logging.debug("EXECUTE Entering in FakeOptimizerLoopNode")
448 result = None
449 ]]></code></script>
450     <inport name="computation" type="SALOME_TYPES/ParametricInput"/>
451     <outport name="result" type="SALOME_TYPES/ParametricOutput"/>
452   </inline>
453
454   <inline name="CreateDictFromString">
455     <script><code><![CDATA[
456 import logging, sys, os
457 logging.debug("CREATE Entering in CreateDictFromString")
458 dico = eval(dict_in_string)
459 ]]></code></script>
460     <inport name="dict_in_string" type="string"/>
461   </inline>
462
463   <inline name="CreateDictFromScript">
464     <script><code><![CDATA[
465 import logging, sys, os
466 logging.debug("CREATE Entering in CreateDictFromScript")
467
468 # Get file path and filename
469 try:
470     if sys.path.count(studydir)==0 or (sys.path.count(studydir)>0 and sys.path.index(studydir)>0):
471         sys.path.insert(0,studydir)
472 except:
473     pass
474 filepath = os.path.dirname(script)
475 filename = os.path.basename(script)
476 module_name = os.path.splitext(filename)[0]
477 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
478     sys.path.insert(0,filepath)
479
480 ]]></code></script>
481     <inport name="script" type="string"/>
482   </inline>
483
484   <inline name="UserDataInitFromScript">
485     <script><code><![CDATA[
486 import logging, sys, os
487 logging.debug("CREATE Entering in UserDataInitFromScript")
488
489 # Get file path and filename
490 try:
491     if sys.path.count(studydir)==0 or (sys.path.count(studydir)>0 and sys.path.index(studydir)>0):
492         sys.path.insert(0,studydir)
493 except:
494     pass
495 filepath = os.path.dirname(script)
496 filename = os.path.basename(script)
497 module_name = os.path.splitext(filename)[0]
498 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
499     sys.path.insert(0,filepath)
500
501 ]]></code></script>
502     <inport name="script" type="string"/>
503     <outport name="init_data" type="pyobj"/>
504   </inline>
505
506   <inline name="ReadForSwitchNode">
507     <script><code><![CDATA[
508 import logging
509 logging.debug("CREATE Entering in ReadForSwitchNode")
510 logging.debug("       with input data : "+str(data["specificParameters"]))
511 switch_value = -1
512 for param in data["specificParameters"]:
513   if param["name"] == "switch_value":
514     switch_value = int(param["value"])
515 logging.debug("       switching to value : "+str(switch_value))
516 ]]></code></script>
517     <inport name="data" type="SALOME_TYPES/ParametricInput"/>
518     <outport name="data" type="SALOME_TYPES/ParametricInput"/>
519     <outport name="switch_value" type="int"/>
520   </inline>
521
522   <inline name="ExtractDataNode">
523     <script><code><![CDATA[
524 import logging
525 logging.debug("TERMINATE Entering in ExtractDataNode")
526 import cPickle
527 from daCore.AssimilationStudy import AssimilationStudy
528 var = None
529 info = None
530 for param in data["specificParameters"]:
531   if param["name"] == "var":
532     var = cPickle.loads(param["value"])
533   if param["name"] == "info":
534     info = param["value"]
535 ]]></code></script>
536     <inport name="data" type="SALOME_TYPES/ParametricInput"/>
537     <outport name="var" type="pyobj"/>
538     <outport name="info" type="pyobj"/>
539   </inline>
540
541   <inline name="ObservationNodeString">
542     <script><code><![CDATA[]]></code></script>
543     <inport name="var" type="pyobj"/>
544     <inport name="info" type="pyobj"/>
545   </inline>
546
547   <inline name="ObservationNodeFile">
548     <script><code><![CDATA[execfile(script)]]></code></script>
549     <inport name="var"    type="pyobj"/>
550     <inport name="info"   type="pyobj"/>
551     <inport name="script" type="string"/>
552   </inline>
553
554   <inline name="EndObservationNode">
555     <script><code><![CDATA[
556 # Create a fake output object.
557 # An observer is always successful.
558 output = {}
559 output["outputValues"]        = [[[[]]]]
560 output["specificOutputInfos"] = []
561 output["returnCode"]          = 0
562 output["errorMessage"]        = ""
563 ]]></code></script>
564     <outport name="output" type="SALOME_TYPES/ParametricOutput"/>
565   </inline>
566
567   <inline name="SetObserversNode">
568     <script><code><![CDATA[
569 #print "Setting observers"
570 ]]></code></script>
571     <outport name="has_observers" type="bool"/>
572     <outport name="observers" type="pyobj"/>
573   </inline>
574 </proc>