]> SALOME platform Git repositories - modules/adao.git/blob - resources/ADAOSchemaCatalog.xml
Salome HOME
Performance improvements by reducing logging and flatten
[modules/adao.git] / resources / ADAOSchemaCatalog.xml
1 <?xml version='1.0' encoding='iso-8859-1' ?>
2 <!--
3   Copyright (C) 2010-2011 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: Andre Ribes, andre.ribes@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 print "Debug is set to.......:", Debug
66
67 # Create Assimilation study
68 from daYacsIntegration.daStudy import *
69 assim_study = daStudy(Name, Algorithm, Debug)
70
71 # Algorithm parameters
72 try:
73   AlgorithmParameters
74 except NameError:
75   pass
76 else:
77   assim_study.setAlgorithmParameters(AlgorithmParameters)
78
79 # Data
80 # print "Data entered are:"
81
82 # Background
83 try:
84   Background
85 except NameError:
86   pass
87 else:
88   logging.debug("CREATE Background is %s"%Background)
89   logging.debug("CREATE BackgroundType is %s"%BackgroundType)
90   logging.debug("CREATE BackgroundStored is %s"%BackgroundStored)
91   assim_study.setBackgroundType(BackgroundType)
92   assim_study.setBackgroundStored(BackgroundStored)
93   assim_study.setBackground(Background)
94
95 # CheckingPoint
96 try:
97   CheckingPoint
98 except NameError:
99   pass
100 else:
101   logging.debug("CREATE CheckingPoint is %s"%CheckingPoint)
102   logging.debug("CREATE CheckingPointType is %s"%CheckingPointType)
103   logging.debug("CREATE CheckingPointStored is %s"%CheckingPointStored)
104   assim_study.setCheckingPointType(CheckingPointType)
105   assim_study.setCheckingPointStored(CheckingPointStored)
106   assim_study.setCheckingPoint(CheckingPoint)
107
108 # BackgroundError
109 try:
110   BackgroundError
111 except NameError:
112   pass
113 else:
114   logging.debug("CREATE BackgroundError is %s"%BackgroundError)
115   logging.debug("CREATE BackgroundErrorStored is %s"%BackgroundErrorStored)
116   assim_study.setBackgroundErrorStored(BackgroundErrorStored)
117   assim_study.setBackgroundError(BackgroundError)
118
119 # Observation
120 try:
121   Observation
122 except NameError:
123   pass
124 else:
125   logging.debug("CREATE Observation is %s"%Observation)
126   logging.debug("CREATE ObservationType is %s"%ObservationType)
127   logging.debug("CREATE ObservationStored is %s"%ObservationStored)
128   assim_study.setObservationType(ObservationType)
129   assim_study.setObservationStored(ObservationStored)
130   assim_study.setObservation(Observation)
131
132 # ObservationError
133 try:
134   ObservationError
135 except NameError:
136   pass
137 else:
138   logging.debug("CREATE ObservationError is %s"%ObservationError)
139   logging.debug("CREATE ObservationErrorStored is %s"%ObservationErrorStored)
140   assim_study.setObservationErrorStored(ObservationErrorStored)
141   assim_study.setObservationError(ObservationError)
142
143 # EvolutionError
144 try:
145   EvolutionError
146 except NameError:
147   pass
148 else:
149   logging.debug("CREATE EvolutionError is %s"%EvolutionError)
150   logging.debug("CREATE EvolutionErrorStored is %s"%EvolutionErrorStored)
151   assim_study.setEvolutionErrorStored(EvolutionErrorStored)
152   assim_study.setEvolutionError(EvolutionError)
153
154 # ObservationOperator
155 ObservationOperatorOk = 0
156 try:
157   ObservationOperator
158 except NameError:
159   pass
160 else:
161   logging.debug("CREATE ObservationOperator is %s"%ObservationOperator)
162   logging.debug("CREATE ObservationOperatorType is %s"%ObservationOperatorType)
163   assim_study.setObservationOperatorType("Matrix", ObservationOperatorType)
164   assim_study.setObservationOperator("Matrix", ObservationOperator)
165   ObservationOperatorOk = 1
166
167 if ObservationOperatorOk == 0:
168   try:
169     ObservationOperatorDirect
170   except NameError:
171     pass
172   else:
173     logging.debug("CREATE ObservationOperatorDirect is %s"%ObservationOperatorDirect)
174     assim_study.setObservationOperatorType("Direct", "Function")
175     assim_study.setObservationOperator("Direct", ObservationOperatorDirect)
176   try:
177     ObservationOperatorTangent
178   except NameError:
179     pass
180   else:
181     logging.debug("CREATE ObservationOperatorTangent is %s"%ObservationOperatorTangent)
182     assim_study.setObservationOperatorType("Tangent", "Function")
183     assim_study.setObservationOperator("Tangent", ObservationOperatorTangent)
184   try:
185     ObservationOperatorAdjoint
186   except NameError:
187     pass
188   else:
189     logging.debug("CREATE ObservationOperatorAdjoint is %s"%ObservationOperatorAdjoint)
190     assim_study.setObservationOperatorType("Adjoint", "Function")
191     assim_study.setObservationOperator("Adjoint", ObservationOperatorAdjoint)
192
193 # EvolutionModel
194 EvolutionModelOk = 0
195 try:
196   EvolutionModel
197 except NameError:
198   pass
199 else:
200   logging.debug("CREATE EvolutionModel is %s"%EvolutionModel)
201   logging.debug("CREATE EvolutionModelType is %s"%EvolutionModelType)
202   assim_study.setEvolutionModelType("Matrix", EvolutionModelType)
203   assim_study.setEvolutionModel("Matrix", EvolutionModel)
204   EvolutionModelOk = 1
205
206 if EvolutionModelOk == 0:
207   try:
208     EvolutionModelDirect
209   except NameError:
210     pass
211   else:
212     logging.debug("CREATE EvolutionModelDirect is %s"%EvolutionModelDirect)
213     assim_study.setEvolutionModelType("Direct", "Function")
214     assim_study.setEvolutionModel("Direct", EvolutionModelDirect)
215   try:
216     EvolutionModelTangent
217   except NameError:
218     pass
219   else:
220     logging.debug("CREATE EvolutionModelTangent is %s"%EvolutionModelTangent)
221     assim_study.setEvolutionModelType("Tangent", "Function")
222     assim_study.setEvolutionModel("Tangent", EvolutionModelTangent)
223   try:
224     EvolutionModelAdjoint
225   except NameError:
226     pass
227   else:
228     logging.debug("CREATE EvolutionModelAdjoint is %s"%EvolutionModelAdjoint)
229     assim_study.setEvolutionModelType("Adjoint", "Function")
230     assim_study.setEvolutionModel("Adjoint", EvolutionModelAdjoint)
231
232 # Variables
233 for name, size in zip(InputVariablesNames, InputVariablesSizes):
234   assim_study.setInputVariable(name, size)
235 for name, size in zip(OutputVariablesNames, OutputVariablesSizes):
236   assim_study.setOutputVariable(name, size)
237
238 if has_observers:
239   logging.debug("CREATE Observers is %s"%observers.keys())
240   # Adding observers to the study
241   for observer_name in observers.keys():
242     scheduler = ""
243     info = ""
244     number = str(observers[observer_name]["number"])
245     if "scheduler" in observers[observer_name].keys():
246       scheduler = observers[observer_name]["scheduler"]
247     if "info" in observers[observer_name].keys():
248       info = observers[observer_name]["info"]
249     assim_study.addObserver(observer_name, scheduler, info, number)
250 Study = assim_study
251 ]]>
252
253 </code></script>
254     <inport name="Name" type="string"/>
255     <inport name="Algorithm" type="string"/>
256     <inport name="Debug" type="bool"/>
257     <inport name="InputVariablesNames" type="stringvec"/>
258     <inport name="InputVariablesSizes" type="intvec"/>
259     <inport name="OutputVariablesNames" type="stringvec"/>
260     <inport name="OutputVariablesSizes" type="intvec"/>
261     <inport name="has_observers" type="bool"/>
262     <inport name="observers" type="pyobj"/>
263     <outport name="Study" type="pyobj"/>
264   </inline>
265
266   <inline name="CreateNumpyMatrixFromString">
267     <script><code><![CDATA[
268 import numpy, logging
269 logging.debug("CREATE Entering in CreateNumpyMatrixFromString")
270 matrix = numpy.matrix(matrix_in_string)
271 type = "Matrix"
272 logging.debug("CREATE Matrix is %s"%matrix)
273 ]]></code></script>
274     <inport name="matrix_in_string" type="string"/>
275     <outport name="matrix" type="pyobj"/>
276     <outport name="type" type="string"/>
277     <outport name="stored" type="bool"/>
278   </inline>
279
280   <inline name="CreateNumpyMatrixFromScript">
281     <script><code><![CDATA[
282 import logging
283 logging.debug("CREATE Entering in CreateNumpyMatrixFromScript")
284 type = "Matrix"
285
286 # Get file path and filename
287 import sys
288 import os
289 filepath = os.path.dirname(script)
290 filename = os.path.basename(script)
291 module_name = os.path.splitext(filename)[0]
292 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath,0,1)>0):
293     sys.path.insert(0,filepath)
294
295 # Import script
296 __import__(module_name)
297 user_script_module = sys.modules[module_name]
298
299 # Get Data from script
300 ]]></code></script>
301     <inport name="script" type="string"/>
302     <outport name="type" type="string"/>
303     <outport name="stored" type="bool"/>
304   </inline>
305
306   <inline name="CreateNumpyVectorFromString">
307     <script><code><![CDATA[
308 import numpy, logging
309 logging.debug("CREATE Entering in CreateNumpyVectorFromString")
310 vector = numpy.matrix(vector_in_string)
311 type = "Vector"
312 logging.debug("Vector is %s"%vector)
313 ]]></code></script>
314     <inport name="vector_in_string" type="string"/>
315     <outport name="vector" type="pyobj"/>
316     <outport name="type" type="string"/>
317     <outport name="stored" type="bool"/>
318   </inline>
319
320   <inline name="CreateNumpyVectorFromScript">
321     <script><code><![CDATA[
322 import logging
323 logging.debug("CREATE Entering in CreateNumpyVectorFromScript")
324 type = "Vector"
325
326 # Get file path and filename
327 import sys
328 import os
329 filepath = os.path.dirname(script)
330 filename = os.path.basename(script)
331 module_name = os.path.splitext(filename)[0]
332 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath,0,1)>0):
333     sys.path.insert(0,filepath)
334
335 # Import script
336 __import__(module_name)
337 user_script_module = sys.modules[module_name]
338
339 # Get Data from script
340 ]]></code></script>
341     <inport name="script" type="string"/>
342     <outport name="type" type="string"/>
343     <outport name="stored" type="bool"/>
344   </inline>
345
346   <inline name="CreateNumpyVectorSerieFromString">
347     <script><code><![CDATA[
348 import numpy, logging
349 logging.debug("CREATE Entering in CreateNumpyVectorSerieFromString")
350 vector = numpy.matrix(vector_in_string)
351 type = "VectorSerie"
352 logging.debug("VectorSerie is %s"%vector)
353 ]]></code></script>
354     <inport name="vector_in_string" type="string"/>
355     <outport name="vector" type="pyobj"/>
356     <outport name="type" type="string"/>
357     <outport name="stored" type="bool"/>
358   </inline>
359
360   <inline name="CreateNumpyVectorSerieFromScript">
361     <script><code><![CDATA[
362 import logging
363 logging.debug("CREATE Entering in CreateNumpyVectorSerieFromScript")
364 type = "VectorSerie"
365
366 # Get file path and filename
367 import sys
368 import os
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,1)>0):
373     sys.path.insert(0,filepath)
374
375 # Import script
376 __import__(module_name)
377 user_script_module = sys.modules[module_name]
378
379 # Get Data from script
380 ]]></code></script>
381     <inport name="script" type="string"/>
382     <outport name="type" type="string"/>
383     <outport name="stored" type="bool"/>
384   </inline>
385
386   <inline name="SimpleExecuteDirectAlgorithm">
387     <script><code><![CDATA[
388 import logging
389 logging.debug("EXECUTE Entering in SimpleExecuteDirectAlgorithm")
390 from daYacsIntegration.daStudy import *
391 ADD = Study.getAssimilationStudy()
392 ADD.analyze()
393 ]]></code></script>
394     <inport name="Study" type="pyobj"/>
395     <outport name="Study" type="pyobj"/>
396   </inline>
397
398   <inline name="SimpleUserAnalysis">
399     <script><code><![CDATA[
400 #-*-coding:iso-8859-1-*-
401 import logging
402 logging.debug("TERMINATE Entering in SimpleUserAnalysis")
403 from daYacsIntegration.daStudy import *
404 ADD = Study.getAssimilationStudy()
405 # User code is below
406
407 ]]></code></script>
408     <inport name="Study" type="pyobj"/>
409   </inline>
410
411   <inline name="FakeOptimizerLoopNode">
412     <script><code><![CDATA[
413 import logging
414 logging.debug("EXECUTE Entering in FakeOptimizerLoopNode")
415 result = None
416 ]]></code></script>
417     <inport name="computation" type="SALOME_TYPES/ParametricInput"/>
418     <outport name="result" type="SALOME_TYPES/ParametricOutput"/>
419   </inline>
420
421   <inline name="CreateDictFromScript">
422     <script><code><![CDATA[
423 import logging
424 logging.debug("CREATE Entering in CreateDictFromScript")
425
426 # Get file path and filename
427 import sys
428 import os
429 filepath = os.path.dirname(script)
430 filename = os.path.basename(script)
431 module_name = os.path.splitext(filename)[0]
432 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath,0,1)>0):
433     sys.path.insert(0,filepath)
434
435 # Import script
436 __import__(module_name)
437 user_script_module = sys.modules[module_name]
438
439 # Get Data from script
440 ]]></code></script>
441     <inport name="script" type="string"/>
442   </inline>
443
444   <inline name="UserDataInitFromScript">
445     <script><code><![CDATA[
446 import logging
447 logging.debug("CREATE Entering in UserDataInitFromScript")
448
449 # Get file path and filename
450 import sys
451 import os
452 filepath = os.path.dirname(script)
453 filename = os.path.basename(script)
454 module_name = os.path.splitext(filename)[0]
455 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath,0,1)>0):
456     sys.path.insert(0,filepath)
457
458 # Import script
459 __import__(module_name)
460 user_script_module = sys.modules[module_name]
461
462 # Get Data from script
463 ]]></code></script>
464     <inport name="script" type="string"/>
465     <outport name="init_data" type="pyobj"/>
466   </inline>
467
468   <inline name="ReadForSwitchNode">
469     <script><code><![CDATA[
470 import logging
471 logging.debug("CREATE Entering in ReadForSwitchNode")
472 logging.debug("       with input data : "+str(data["specificParameters"]))
473 switch_value = -1
474 for param in data["specificParameters"]:
475   if param["name"] == "switch_value":
476     switch_value = int(param["value"])
477 logging.debug("       switching to value : "+str(switch_value))
478 ]]></code></script>
479     <inport name="data" type="SALOME_TYPES/ParametricInput"/>
480     <outport name="data" type="SALOME_TYPES/ParametricInput"/>
481     <outport name="switch_value" type="int"/>
482   </inline>
483
484   <inline name="ExtractDataNode">
485     <script><code><![CDATA[
486 import logging
487 logging.debug("TERMINATE Entering in ExtractDataNode")
488 import cPickle
489 from daCore.AssimilationStudy import AssimilationStudy
490 var = None
491 info = None
492 for param in data["specificParameters"]:
493   if param["name"] == "var":
494     var = cPickle.loads(param["value"])
495   if param["name"] == "info":
496     info = param["value"]
497 ]]></code></script>
498     <inport name="data" type="SALOME_TYPES/ParametricInput"/>
499     <outport name="var" type="pyobj"/>
500     <outport name="info" type="pyobj"/>
501   </inline>
502
503   <inline name="ObservationNodeString">
504     <script><code><![CDATA[
505 #print "Entering in Observation"
506
507 ]]></code></script>
508     <inport name="var" type="pyobj"/>
509     <inport name="info" type="pyobj"/>
510   </inline>
511
512   <inline name="ObservationNodeFile">
513     <script><code><![CDATA[
514 #print "Entering in Observation"
515 execfile(script)
516
517 ]]></code></script>
518     <inport name="var"    type="pyobj"/>
519     <inport name="info"   type="pyobj"/>
520     <inport name="script" type="string"/>
521   </inline>
522
523   <inline name="EndObservationNode">
524     <script><code><![CDATA[
525 # Create a fake output object.
526 # An observer is always successful.
527 output = {}
528 output["outputValues"]        = [[[[]]]]
529 output["specificOutputInfos"] = []
530 output["returnCode"]          = 0
531 output["errorMessage"]        = ""
532 ]]></code></script>
533     <outport name="output" type="SALOME_TYPES/ParametricOutput"/>
534   </inline>
535
536   <inline name="SetObserversNode">
537     <script><code><![CDATA[
538 #print "Setting observers"
539 ]]></code></script>
540     <outport name="has_observers" type="bool"/>
541     <outport name="observers" type="pyobj"/>
542   </inline>
543 </proc>