]> SALOME platform Git repositories - modules/adao.git/blob - resources/ADAOSchemaCatalog.xml
Salome HOME
Allowing diagonal sparse matrices to be entered
[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
327 logging.debug("CREATE Entering in CreateNumpyMatrixFromScript")
328 type = "Matrix"
329
330 # Get file path and filename
331 import sys
332 import os
333 filepath = os.path.dirname(script)
334 filename = os.path.basename(script)
335 module_name = os.path.splitext(filename)[0]
336 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
337     sys.path.insert(0,filepath)
338
339 # Import script
340 __import__(module_name)
341 user_script_module = sys.modules[module_name]
342
343 # Get Data from script
344 ]]></code></script>
345     <inport name="script" type="string"/>
346     <outport name="type" type="string"/>
347     <outport name="stored" type="bool"/>
348   </inline>
349
350   <inline name="CreateNumpyScalarSparseMatrixFromScript">
351     <script><code><![CDATA[
352 import logging
353 logging.debug("CREATE Entering in CreateNumpyScalarSparseMatrixFromScript")
354 type = "ScalarSparseMatrix"
355
356 # Get file path and filename
357 import sys
358 import os
359 filepath = os.path.dirname(script)
360 filename = os.path.basename(script)
361 module_name = os.path.splitext(filename)[0]
362 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
363     sys.path.insert(0,filepath)
364
365 # Import script
366 __import__(module_name)
367 user_script_module = sys.modules[module_name]
368
369 # Get Data from script
370 ]]></code></script>
371     <inport name="script" type="string"/>
372     <outport name="type" type="string"/>
373     <outport name="stored" type="bool"/>
374   </inline>
375
376   <inline name="CreateNumpyDiagonalSparseMatrixFromScript">
377     <script><code><![CDATA[
378 import logging
379 logging.debug("CREATE Entering in CreateNumpyDiagonalSparseMatrixFromScript")
380 type = "DiagonalSparseMatrix"
381
382 # Get file path and filename
383 import sys
384 import os
385 filepath = os.path.dirname(script)
386 filename = os.path.basename(script)
387 module_name = os.path.splitext(filename)[0]
388 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
389     sys.path.insert(0,filepath)
390
391 # Import script
392 __import__(module_name)
393 user_script_module = sys.modules[module_name]
394
395 # Get Data from script
396 ]]></code></script>
397     <inport name="script" type="string"/>
398     <outport name="type" type="string"/>
399     <outport name="stored" type="bool"/>
400   </inline>
401
402   <inline name="CreateNumpyVectorFromString">
403     <script><code><![CDATA[
404 import numpy, logging
405 logging.debug("CREATE Entering in CreateNumpyVectorFromString")
406 vector = numpy.matrix(vector_in_string)
407 type = "Vector"
408 logging.debug("Vector is %s"%vector)
409 ]]></code></script>
410     <inport name="vector_in_string" type="string"/>
411     <outport name="vector" type="pyobj"/>
412     <outport name="type" type="string"/>
413     <outport name="stored" type="bool"/>
414   </inline>
415
416   <inline name="CreateNumpyVectorFromScript">
417     <script><code><![CDATA[
418 import logging
419 logging.debug("CREATE Entering in CreateNumpyVectorFromScript")
420 type = "Vector"
421
422 # Get file path and filename
423 import sys
424 import os
425 filepath = os.path.dirname(script)
426 filename = os.path.basename(script)
427 module_name = os.path.splitext(filename)[0]
428 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
429     sys.path.insert(0,filepath)
430
431 # Import script
432 __import__(module_name)
433 user_script_module = sys.modules[module_name]
434
435 # Get Data from script
436 ]]></code></script>
437     <inport name="script" type="string"/>
438     <outport name="type" type="string"/>
439     <outport name="stored" type="bool"/>
440   </inline>
441
442   <inline name="CreateNumpyVectorSerieFromString">
443     <script><code><![CDATA[
444 import numpy, logging
445 logging.debug("CREATE Entering in CreateNumpyVectorSerieFromString")
446 vector_in_list = eval(str(vector_in_string),{},{})
447 vector = numpy.matrix(vector_in_list)
448 type = "VectorSerie"
449 logging.debug("VectorSerie is %s"%vector)
450 ]]></code></script>
451     <inport name="vector_in_string" type="string"/>
452     <outport name="vector" type="pyobj"/>
453     <outport name="type" type="string"/>
454     <outport name="stored" type="bool"/>
455   </inline>
456
457   <inline name="CreateNumpyVectorSerieFromScript">
458     <script><code><![CDATA[
459 import logging
460 logging.debug("CREATE Entering in CreateNumpyVectorSerieFromScript")
461 type = "VectorSerie"
462
463 # Get file path and filename
464 import sys
465 import os
466 filepath = os.path.dirname(script)
467 filename = os.path.basename(script)
468 module_name = os.path.splitext(filename)[0]
469 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
470     sys.path.insert(0,filepath)
471
472 # Import script
473 __import__(module_name)
474 user_script_module = sys.modules[module_name]
475
476 # Get Data from script
477 ]]></code></script>
478     <inport name="script" type="string"/>
479     <outport name="type" type="string"/>
480     <outport name="stored" type="bool"/>
481   </inline>
482
483   <inline name="SimpleExecuteDirectAlgorithm">
484     <script><code><![CDATA[
485 import logging
486 logging.debug("EXECUTE Entering in SimpleExecuteDirectAlgorithm")
487 from daYacsIntegration.daStudy import *
488 ADD = Study.getAssimilationStudy()
489 ADD.analyze()
490 ]]></code></script>
491     <inport name="Study" type="pyobj"/>
492     <outport name="Study" type="pyobj"/>
493   </inline>
494
495   <inline name="SimpleUserAnalysis">
496     <script><code><![CDATA[
497 #-*-coding:iso-8859-1-*-
498 import logging
499 logging.debug("TERMINATE Entering in SimpleUserAnalysis")
500 from daYacsIntegration.daStudy import *
501 ADD = Study.getAssimilationStudy()
502 # User code is below
503
504 ]]></code></script>
505     <inport name="Study" type="pyobj"/>
506   </inline>
507
508   <inline name="FakeOptimizerLoopNode">
509     <script><code><![CDATA[
510 import logging
511 logging.debug("EXECUTE Entering in FakeOptimizerLoopNode")
512 result = None
513 ]]></code></script>
514     <inport name="computation" type="SALOME_TYPES/ParametricInput"/>
515     <outport name="result" type="SALOME_TYPES/ParametricOutput"/>
516   </inline>
517
518   <inline name="CreateDictFromScript">
519     <script><code><![CDATA[
520 import logging
521 logging.debug("CREATE Entering in CreateDictFromScript")
522
523 # Get file path and filename
524 import sys
525 import os
526 filepath = os.path.dirname(script)
527 filename = os.path.basename(script)
528 module_name = os.path.splitext(filename)[0]
529 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
530     sys.path.insert(0,filepath)
531
532 # Import script
533 __import__(module_name)
534 user_script_module = sys.modules[module_name]
535
536 # Get Data from script
537 ]]></code></script>
538     <inport name="script" type="string"/>
539   </inline>
540
541   <inline name="UserDataInitFromScript">
542     <script><code><![CDATA[
543 import logging
544 logging.debug("CREATE Entering in UserDataInitFromScript")
545
546 # Get file path and filename
547 import sys
548 import os
549 filepath = os.path.dirname(script)
550 filename = os.path.basename(script)
551 module_name = os.path.splitext(filename)[0]
552 if sys.path.count(filepath)==0 or (sys.path.count(filepath)>0 and sys.path.index(filepath)>0):
553     sys.path.insert(0,filepath)
554
555 # Import script
556 __import__(module_name)
557 user_script_module = sys.modules[module_name]
558
559 # Get Data from script
560 ]]></code></script>
561     <inport name="script" type="string"/>
562     <outport name="init_data" type="pyobj"/>
563   </inline>
564
565   <inline name="ReadForSwitchNode">
566     <script><code><![CDATA[
567 import logging
568 logging.debug("CREATE Entering in ReadForSwitchNode")
569 logging.debug("       with input data : "+str(data["specificParameters"]))
570 switch_value = -1
571 for param in data["specificParameters"]:
572   if param["name"] == "switch_value":
573     switch_value = int(param["value"])
574 logging.debug("       switching to value : "+str(switch_value))
575 ]]></code></script>
576     <inport name="data" type="SALOME_TYPES/ParametricInput"/>
577     <outport name="data" type="SALOME_TYPES/ParametricInput"/>
578     <outport name="switch_value" type="int"/>
579   </inline>
580
581   <inline name="ExtractDataNode">
582     <script><code><![CDATA[
583 import logging
584 logging.debug("TERMINATE Entering in ExtractDataNode")
585 import cPickle
586 from daCore.AssimilationStudy import AssimilationStudy
587 var = None
588 info = None
589 for param in data["specificParameters"]:
590   if param["name"] == "var":
591     var = cPickle.loads(param["value"])
592   if param["name"] == "info":
593     info = param["value"]
594 ]]></code></script>
595     <inport name="data" type="SALOME_TYPES/ParametricInput"/>
596     <outport name="var" type="pyobj"/>
597     <outport name="info" type="pyobj"/>
598   </inline>
599
600   <inline name="ObservationNodeString">
601     <script><code><![CDATA[
602 #print "Entering in Observation"
603
604 ]]></code></script>
605     <inport name="var" type="pyobj"/>
606     <inport name="info" type="pyobj"/>
607   </inline>
608
609   <inline name="ObservationNodeFile">
610     <script><code><![CDATA[
611 #print "Entering in Observation"
612 execfile(script)
613
614 ]]></code></script>
615     <inport name="var"    type="pyobj"/>
616     <inport name="info"   type="pyobj"/>
617     <inport name="script" type="string"/>
618   </inline>
619
620   <inline name="EndObservationNode">
621     <script><code><![CDATA[
622 # Create a fake output object.
623 # An observer is always successful.
624 output = {}
625 output["outputValues"]        = [[[[]]]]
626 output["specificOutputInfos"] = []
627 output["returnCode"]          = 0
628 output["errorMessage"]        = ""
629 ]]></code></script>
630     <outport name="output" type="SALOME_TYPES/ParametricOutput"/>
631   </inline>
632
633   <inline name="SetObserversNode">
634     <script><code><![CDATA[
635 #print "Setting observers"
636 ]]></code></script>
637     <outport name="has_observers" type="bool"/>
638     <outport name="observers" type="pyobj"/>
639   </inline>
640 </proc>