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