]> SALOME platform Git repositories - modules/adao.git/blob - resources/ADAOSchemaCatalog.xml
Salome HOME
Adding init node for observers
[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
61 print "Entering in CreateAssimilationStudy"
62 print "Name is", Name
63 print "Algorithm is", Algorithm
64 print "Debug is set to", Debug
65
66 # Create Assimilation study
67 from daYacsIntegration.daStudy import *
68 assim_study = daStudy(Name, Algorithm, Debug)
69
70 # Algorithm parameters
71 try:
72   AlgorithmParameters
73 except NameError:
74   pass
75 else:
76   assim_study.setAlgorithmParameters(AlgorithmParameters)
77
78 # Data
79 print "Data entered are:"
80 # Background
81 try:
82   Background
83 except NameError:
84   pass
85 else:
86   #print "Background is", Background
87   #print "BackgroundType is", BackgroundType
88   assim_study.setBackgroundType(BackgroundType)
89   assim_study.setBackground(Background)
90
91 # BackgroundError
92 try:
93   BackgroundError
94 except NameError:
95   pass
96 else:
97   #print "BackgroundError is", BackgroundError
98   #print "BackgroundErrorType is", BackgroundErrorType
99   assim_study.setBackgroundError(BackgroundError)
100
101 # Observation
102 try:
103   Observation
104 except NameError:
105   pass
106 else:
107   #print "Observation is", Observation
108   #print "ObservationType is", ObservationType
109   assim_study.setObservationType(ObservationType)
110   assim_study.setObservation(Observation)
111
112 # ObservationError
113 try:
114   ObservationError
115 except NameError:
116   pass
117 else:
118   #print "ObservationError is", ObservationError
119   #print "ObservationErrorType is", ObservationErrorType
120   assim_study.setObservationError(ObservationError)
121
122 # ObservationOperator
123 ObservationOperatorOk = 0
124 try:
125   ObservationOperator
126 except NameError:
127   pass
128 else:
129   #print "ObservationOperator is", ObservationOperator
130   #print "ObservationOperatorType is", ObservationOperatorType
131   assim_study.setObservationOperatorType("Matrix", ObservationOperatorType)
132   assim_study.setObservationOperator("Matrix", ObservationOperator)
133   ObservationOperatorOk = 1
134
135 if ObservationOperatorOk == 0:
136   try:
137     ObservationOperatorDirect
138   except NameError:
139     pass
140   else:
141     #print "ObservationOperatorDirect is", ObservationOperatorDirect
142     assim_study.setObservationOperatorType("Direct", "Function")
143     assim_study.setObservationOperator("Direct", ObservationOperatorDirect)
144   try:
145     ObservationOperatorTangent
146   except NameError:
147     pass
148   else:
149     #print "ObservationOperatorTangent is", ObservationOperatorTangent
150     assim_study.setObservationOperatorType("Tangent", "Function")
151     assim_study.setObservationOperator("Tangent", ObservationOperatorTangent)
152   try:
153     ObservationOperatorAdjoint
154   except NameError:
155     pass
156   else:
157     #print "ObservationOperatorAdjoint is", ObservationOperatorAdjoint
158     assim_study.setObservationOperatorType("Adjoint", "Function")
159     assim_study.setObservationOperator("Adjoint", ObservationOperatorAdjoint)
160
161 # Variables
162 for name, size in zip(InputVariablesNames, InputVariablesSizes):
163   assim_study.setInputVariable(name, size)
164 for name, size in zip(OutputVariablesNames, OutputVariablesSizes):
165   assim_study.setOutputVariable(name, size)
166
167 Study = assim_study
168 ]]>
169
170 </code></script>
171     <inport name="Name" type="string"/>
172     <inport name="Algorithm" type="string"/>
173     <inport name="Debug" type="bool"/>
174     <inport name="InputVariablesNames" type="stringvec"/>
175     <inport name="InputVariablesSizes" type="intvec"/>
176     <inport name="OutputVariablesNames" type="stringvec"/>
177     <inport name="OutputVariablesSizes" type="intvec"/>
178     <inport name="has_observers" type="bool"/>
179     <inport name="observers" type="pyobj"/>
180     <outport name="Study" type="pyobj"/>
181   </inline>
182
183   <inline name="CreateNumpyMatrixFromString">
184     <script><code><![CDATA[
185 print "Entering in CreateNumpyMatrixFromString"
186 import numpy
187 matrix = numpy.matrix(matrix_in_string)
188 type = "Matrix"
189 print "Matrix is", matrix
190 ]]></code></script>
191     <inport name="matrix_in_string" type="string"/>
192     <outport name="matrix" type="pyobj"/>
193     <outport name="type" type="string"/>
194   </inline>
195
196   <inline name="CreateNumpyMatrixFromScript">
197     <script><code><![CDATA[
198 print "Entering in CreateNumpyMatrixFromScript"
199 type = "Matrix"
200
201 # Get file path and filename
202 import sys
203 import os
204 filepath = os.path.dirname(script)
205 filename = os.path.basename(script)
206 module_name = os.path.splitext(filename)[0]
207 sys.path.insert(0,filepath)
208
209 # Import script
210 __import__(module_name)
211 user_script_module = sys.modules[module_name]
212
213 # Get Data from script
214 ]]></code></script>
215     <inport name="script" type="string"/>
216     <outport name="type" type="string"/>
217   </inline>
218
219   <inline name="CreateNumpyVectorFromString">
220     <script><code><![CDATA[
221 print "Entering in CreateNumpyVectorFromString"
222 import numpy
223 vector = numpy.matrix(vector_in_string)
224 type = "Vector"
225 print "Vector is", vector
226 ]]></code></script>
227     <inport name="vector_in_string" type="string"/>
228     <outport name="vector" type="pyobj"/>
229     <outport name="type" type="string"/>
230   </inline>
231
232   <inline name="CreateNumpyVectorFromScript">
233     <script><code><![CDATA[
234 print "Entering in CreateNumpyVectorFromScript"
235 type = "Vector"
236
237 # Get file path and filename
238 import sys
239 import os
240 filepath = os.path.dirname(script)
241 filename = os.path.basename(script)
242 module_name = os.path.splitext(filename)[0]
243 sys.path.insert(0,filepath)
244
245 # Import script
246 __import__(module_name)
247 user_script_module = sys.modules[module_name]
248
249 # Get Data from script
250 ]]></code></script>
251     <inport name="script" type="string"/>
252     <outport name="type" type="string"/>
253   </inline>
254
255   <inline name="SimpleExecuteDirectAlgorithm">
256     <script><code><![CDATA[
257 print "Entering in SimpleExecuteDirectAlgorithm"
258 from daYacsIntegration.daStudy import *
259 ADD = Study.getAssimilationStudy()
260 ADD.analyze()
261 ]]></code></script>
262     <inport name="Study" type="pyobj"/>
263     <outport name="Study" type="pyobj"/>
264   </inline>
265
266   <inline name="SimpleUserAnalysis">
267     <script><code><![CDATA[
268 #-*-coding:iso-8859-1-*-
269 print "Entering in SimpleUserAnalysis"
270 from daYacsIntegration.daStudy import *
271 ADD = Study.getAssimilationStudy()
272 # User code is below
273
274 ]]></code></script>
275     <inport name="Study" type="pyobj"/>
276   </inline>
277
278   <inline name="FakeOptimizerLoopNode">
279     <script><code><![CDATA[
280 print "Entering in FakeOptimizerLoopNode"
281 result = None
282 ]]></code></script>
283     <inport name="computation" type="SALOME_TYPES/ParametricInput"/>
284     <outport name="result" type="SALOME_TYPES/ParametricOutput"/>
285   </inline>
286
287   <inline name="CreateDictFromScript">
288     <script><code><![CDATA[
289 print "Entering in CreateDictFromScript"
290
291 # Get file path and filename
292 import sys
293 import os
294 filepath = os.path.dirname(script)
295 filename = os.path.basename(script)
296 module_name = os.path.splitext(filename)[0]
297 sys.path.insert(0,filepath)
298
299 # Import script
300 __import__(module_name)
301 user_script_module = sys.modules[module_name]
302
303 # Get Data from script
304 ]]></code></script>
305     <inport name="script" type="string"/>
306   </inline>
307
308   <inline name="UserDataInitFromScript">
309     <script><code><![CDATA[
310 print "Entering in UserDataInitFromScript"
311
312 # Get file path and filename
313 import sys
314 import os
315 filepath = os.path.dirname(script)
316 filename = os.path.basename(script)
317 module_name = os.path.splitext(filename)[0]
318 sys.path.insert(0,filepath)
319
320 # Import script
321 __import__(module_name)
322 user_script_module = sys.modules[module_name]
323
324 # Get Data from script
325 ]]></code></script>
326     <inport name="script" type="string"/>
327     <outport name="init_data" type="pyobj"/>
328   </inline>
329
330   <inline name="ReadForSwitchNode">
331     <script><code><![CDATA[
332 print "Entering in ReadForSwitch"
333 switch_value = -1
334 for param in data["specificParameters"]:
335   if param["name"] == "switch_value":
336     switch_value = int(param["value"])
337 ]]></code></script>
338     <inport name="data" type="SALOME_TYPES/ParametricInput"/>
339     <outport name="data" type="SALOME_TYPES/ParametricInput"/>
340     <outport name="switch_value" type="int"/>
341   </inline>
342
343   <inline name="ExtractDataNode">
344     <script><code><![CDATA[
345 import pickle
346 print "Entering in ExtractData"
347 var = None
348 info = None
349 for param in data["specificParameters"]:
350   if param["name"] == "var":
351     var = pickle.loads(param["value"])
352   if param["name"] == "info":
353     info = pickle.loads(param["value"])
354 ]]></code></script>
355     <inport name="data" type="SALOME_TYPES/ParametricInput"/>
356     <outport name="var" type="pyobj"/>
357     <outport name="info" type="pyobj"/>
358   </inline>
359
360   <inline name="ObservationNodeString">
361     <script><code><![CDATA[
362 print "Entering in Observation"
363
364 ]]></code></script>
365     <inport name="var" type="pyobj"/>
366     <inport name="info" type="pyobj"/>
367   </inline>
368
369   <inline name="ObservationNodeFile">
370     <script><code><![CDATA[
371 print "Entering in Observation"
372 # Get file path and filename
373 import sys
374 import os
375 filepath = os.path.dirname(script)
376 filename = os.path.basename(script)
377 module_name = os.path.splitext(filename)[0]
378 sys.path.insert(0,filepath)
379 # Import script
380 __import__(module_name)
381
382 ]]></code></script>
383     <inport name="var"    type="pyobj"/>
384     <inport name="info"   type="pyobj"/>
385     <inport name="script" type="string"/>
386   </inline>
387
388   <inline name="EndObservationNode">
389     <script><code><![CDATA[
390 # Create a fake output object.
391 # An observer is always successful.
392 output = {}
393 output["outputValues"]        = [[[[]]]]
394 output["specificOutputInfos"] = []
395 output["returnCode"]          = 0
396 output["errorMessage"]        = ""
397 ]]></code></script>
398     <outport name="output" type="SALOME_TYPES/ParametricOutput"/>
399   </inline>
400
401   <inline name="SetObserversNode">
402     <script><code><![CDATA[
403 print "Setting observers"
404 ]]></code></script>
405     <outport name="has_observers" type="bool"/>
406     <outport name="observers" type="pyobj"/>
407   </inline>
408 </proc>