src/tests/Makefile
src/tests/daSalome/Makefile
src/tests/daSalome/test000_Blue_AnalysisFile.py
- src/tests/daSalome/test017_3DVAR_par_fonction.py
src/tests/daSalome/test017.comm
src/tests/daSalome/test_aster_zzzz159a_init_parameters.py
- src/tests/daSalome/test_aster_zzzz159a.py
- src/tests/daSalome/test_aster_zzzz159a_LBFGSB.py
+ src/tests/daSalome/test_aster_zzzz159a_LBFGSB.comm
src/tests/daSalome/zzzz159a.export.esclave
bin/Makefile
bin/qtEficas_adao_study.py
<?xml version='1.0' encoding='iso-8859-1' ?>
<proc>
-
+
<objref name="computeAD" id="python:computeAD:1.0">
<base>pyobj</base>
</objref>
assim_study.setObservationOperatorType("Adjoint", "Function")
assim_study.setObservationOperator("Adjoint", ObservationOperatorAdjoint)
+# Variables
+for name, size in zip(InputVariablesNames, InputVariablesSizes):
+ assim_study.setInputVariable(name, size)
+for name, size in zip(OutputVariablesNames, OutputVariablesSizes):
+ assim_study.setOutputVariable(name, size)
Study = assim_study
]]>
<inport name="Name" type="string"/>
<inport name="Algorithm" type="string"/>
<inport name="Debug" type="bool"/>
+ <inport name="InputVariablesNames" type="stringvec"/>
+ <inport name="InputVariablesSizes" type="intvec"/>
+ <inport name="OutputVariablesNames" type="stringvec"/>
+ <inport name="OutputVariablesSizes" type="intvec"/>
<outport name="Study" type="pyobj"/>
</inline>
"""
adaoLogger.debug("currentSelectionChanged")
salomeStudyItem = adaoGuiHelper.getSelectedItem()
- for case_editor, adao_case in self.cases.iteritems():
- if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
- self.eficas_manager.selectCase(adao_case.eficas_editor)
- break
+ if salomeStudyItem is not None:
+ for case_editor, adao_case in self.cases.iteritems():
+ if adao_case.salome_study_item.GetID() == salomeStudyItem.GetID():
+ self.eficas_manager.selectCase(adao_case.eficas_editor)
+ break
# Depuis Eficas
def _processEficasTabChanged(self, eficasWrapper, eficasEvent):
# TODO Input, Output VarList
inputVarList = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("string"))
outputVarList = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("string"))
- inputVarList.pushBack("adao_default")
- outputVarList.pushBack("adao_default")
+ for var in self.optim_algo.da_study.InputVariables:
+ inputVarList.pushBack(var)
+ for var in self.optim_algo.da_study.OutputVariables:
+ outputVarList.pushBack(var)
sample.setEltAtRank("inputVarList", inputVarList)
sample.setEltAtRank("outputVarList", outputVarList)
parameter_1D = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
parameter_2D = pilot.SequenceAny_New(parameter_1D.getType())
parameters_3D = pilot.SequenceAny_New(parameter_2D.getType())
+
+ print "Input Data", data
if isinstance(data, type((1,2))):
- for dat in data:
- param = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
- it = dat.flat
- for val in it:
- param.pushBack(val)
- parameter_2D.pushBack(param)
+ self.add_parameters(data[0], parameter_2D)
+ self.add_parameters(data[1], parameter_2D, Output=True)
else:
- param = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
- it = data.flat
- for val in it:
- param.pushBack(val)
- parameter_2D.pushBack(param)
+ self.add_parameters(data, parameter_2D)
parameters_3D.pushBack(parameter_2D)
sample.setEltAtRank("inputValues", parameters_3D)
-
return sample
+ def add_parameters(self, data, parameter_2D, Output=False):
+ param = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
+ elt_list = 0 # index dans la liste des arguments
+ val_number = 0 # nbre dans l'argument courant
+ if not Output:
+ val_end = self.optim_algo.da_study.InputVariables[self.optim_algo.da_study.InputVariablesOrder[elt_list]] # nbr de l'argument courant (-1 == tout)
+ else:
+ val_end = self.optim_algo.da_study.OutputVariables[self.optim_algo.da_study.OutputVariablesOrder[elt_list]] # nbr de l'argument courant (-1 == tout)
+
+ it = data.flat
+ for val in it:
+ param.pushBack(val)
+ val_number += 1
+ # Test si l'argument est ok
+ if val_end != -1:
+ if val_number == val_end:
+ parameter_2D.pushBack(param)
+ param = pilot.SequenceAny_New(self.optim_algo.runtime.getTypeCode("double"))
+ val_number = 0
+ elt_list += 1
+ if not Output:
+ if elt_list < len(self.optim_algo.da_study.InputVariablesOrder):
+ val_end = self.optim_algo.da_study.InputVariables[self.optim_algo.da_study.InputVariablesOrder[elt_list]]
+ else:
+ break
+ else:
+ if elt_list < len(self.optim_algo.da_study.OutputVariablesOrder):
+ val_end = self.optim_algo.da_study.OutputVariables[self.optim_algo.da_study.OutputVariablesOrder[elt_list]]
+ else:
+ break
+ if val_end == -1:
+ parameter_2D.pushBack(param)
+
def get_data_from_any(self, any_data):
error = any_data["returnCode"].getIntValue()
if error != 0:
from daCore.AssimilationStudy import AssimilationStudy
from daCore import Logging
+import logging
class daError(Exception):
def __init__(self, value):
self.algorithm = algorithm
self.algorithm_dict = None
self.Background = None
+ self.InputVariables = {}
+ self.OutputVariables = {}
+ self.InputVariablesOrder = []
+ self.OutputVariablesOrder = []
self.debug = debug
- import logging
if self.debug:
logging.getLogger().setLevel(logging.DEBUG)
else:
logging.getLogger().setLevel(logging.INFO)
-
# Observation Management
self.ObservationOperatorType = {}
self.FunctionObservationOperator = {}
+ def setInputVariable(self, name, size):
+ self.InputVariables[name] = size
+ self.InputVariablesOrder.append(name)
+
+ def setOutputVariable(self, name, size):
+ self.OutputVariables[name] = size
+ self.OutputVariablesOrder.append(name)
+
def setAlgorithmParameters(self, parameters):
self.algorithm_dict = parameters
CAS_node.getInputPort("Debug").edInitPy(False)
else:
CAS_node.getInputPort("Debug").edInitPy(True)
+
+ # Ajout des Variables
+ InputVariablesNames = []
+ InputVariablesSizes = []
+ for var in study_config["InputVariables"]["Order"]:
+ InputVariablesNames.append(var)
+ InputVariablesSizes.append(int(study_config["InputVariables"][var]))
+ CAS_node.getInputPort("InputVariablesNames").edInitPy(InputVariablesNames)
+ CAS_node.getInputPort("InputVariablesSizes").edInitPy(InputVariablesSizes)
+ OutputVariablesNames = []
+ OutputVariablesSizes = []
+ for var in study_config["OutputVariables"]["Order"]:
+ OutputVariablesNames.append(var)
+ OutputVariablesSizes.append(int(study_config["OutputVariables"][var]))
+ CAS_node.getInputPort("OutputVariablesNames").edInitPy(OutputVariablesNames)
+ CAS_node.getInputPort("OutputVariablesSizes").edInitPy(OutputVariablesSizes)
+
proc.edAddChild(CAS_node)
# Step 0.5: Find if there is a user init node
DATA_INST = \
test000_Blue_AnalysisCode.py test000_Blue_AnalysisFile.py test000_Blue.py \
- test017_3DVAR_par_fonction.py test017_3DVAR_function_script.py test017_3DVAR_init_data.py \
+ test017_3DVAR_function_script.py test017_3DVAR_init_data.py \
test017.comm \
test_aster_zzzz159a_background_error.py \
test_aster_zzzz159a_background.py \
test_aster_zzzz159a_aster_functions.py \
test_aster_zzzz159a_init_algorithm.py \
test_aster_zzzz159a_init_parameters.py \
- test_aster_zzzz159a.py \
- test_aster_zzzz159a_LBFGSB.py \
test_aster_zzzz159a_init_algorithm_LBFGSB.py \
- zzzz159a.3 zzzz159a.export.esclave zzzz159a.mail
+ zzzz159a.3 zzzz159a.export.esclave zzzz159a.mail \
+ test_aster_zzzz159a_LBFGSB.comm
testsdasalome_DATA = ${DATA_INST}
EXTRA_DIST = test000_Blue_AnalysisCode.py test000_Blue_AnalysisFile.py.in test000_Blue.py \
- test017_3DVAR_par_fonction.py.in test017_3DVAR_function_script.py test017_3DVAR_init_data.py \
+ test017_3DVAR_function_script.py test017_3DVAR_init_data.py \
test017.comm.in \
test_aster_zzzz159a_background_error.py \
test_aster_zzzz159a_background.py \
test_aster_zzzz159a_init_algorithm.py \
test_aster_zzzz159a_init_parameters.py.in \
test_aster_zzzz159a.py.in \
- test_aster_zzzz159a_LBFGSB.py.in \
test_aster_zzzz159a_init_algorithm_LBFGSB.py \
- zzzz159a.3 zzzz159a.export.esclave.in zzzz159a.mail
+ zzzz159a.3 zzzz159a.export.esclave.in zzzz159a.mail \
+ test_aster_zzzz159a_LBFGSB.comm.in
--- /dev/null
+
+ASSIMILATION_STUDY(Study_name='test017',
+ Study_repertory='@prefix@/tests/daSalome',
+ Debug=0,
+ Algorithm='3DVAR',
+ Background=_F(INPUT_TYPE='Vector',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test017_3DVAR_init_data.py',),),
+ BackgroundError=_F(INPUT_TYPE='Matrix',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test017_3DVAR_init_data.py',),),
+ Observation=_F(INPUT_TYPE='Vector',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test017_3DVAR_init_data.py',),),
+ ObservationError=_F(INPUT_TYPE='Matrix',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test017_3DVAR_init_data.py',),),
+ ObservationOperator=_F(INPUT_TYPE='Function',
+ data=_F(FROM='FunctionDict',
+ FUNCTIONDICT_FILE=
+ 'test017_3DVAR_function_script.py',),),
+ UserPostAnalysis=_F(FROM='String',
+ STRING=
+"""import numpy
+dimension = 300
+precision = 1.e-10
+xt = numpy.matrix(numpy.arange(dimension)).T
+xb = Study.getBackground()
+xa = numpy.array(ADD.get("Analysis").valueserie(0))
+d = numpy.array(ADD.get("Innovation").valueserie(0))
+#
+# Verification du resultat
+# ------------------------
+if max(abs(xa - (xb+xt.A1)/2)) > precision:
+ raise ValueError("Resultat du test errone (1)")
+else:
+ print " Test correct, erreur maximale inferieure à %s"%precision
+""",),);
+++ /dev/null
-#-*-coding:iso-8859-1-*-
-study_config = {}
-study_config["Name"] = "test017_3DVAR"
-study_config["Algorithm"] = "3DVAR"
-
-Background_config = {}
-Background_config["Data"] = "@prefix@/tests/daSalome/test017_3DVAR_init_data.py"
-Background_config["Type"] = "Vector"
-Background_config["From"] = "Script"
-study_config["Background"] = Background_config
-
-BackgroundError_config = {}
-BackgroundError_config["Data"] = "@prefix@/tests/daSalome/test017_3DVAR_init_data.py"
-BackgroundError_config["Type"] = "Matrix"
-BackgroundError_config["From"] = "Script"
-study_config["BackgroundError"] = BackgroundError_config
-
-Observation_config = {}
-Observation_config["Data"] = "@prefix@/tests/daSalome/test017_3DVAR_init_data.py"
-Observation_config["Type"] = "Vector"
-Observation_config["From"] = "Script"
-study_config["Observation"] = Observation_config
-
-ObservationError_config = {}
-ObservationError_config["Data"] = "@prefix@/tests/daSalome/test017_3DVAR_init_data.py"
-ObservationError_config["Type"] = "Matrix"
-ObservationError_config["From"] = "Script"
-study_config["ObservationError"] = ObservationError_config
-
-FunctionDict = {}
-FunctionDict["Function"] = ["Direct", "Tangent", "Adjoint"]
-FunctionDict["Script"] = {}
-FunctionDict["Script"]["Direct"] = "@prefix@/tests/daSalome/test017_3DVAR_function_script.py"
-FunctionDict["Script"]["Tangent"] = "@prefix@/tests/daSalome/test017_3DVAR_function_script.py"
-FunctionDict["Script"]["Adjoint"] = "@prefix@/tests/daSalome/test017_3DVAR_function_script.py"
-ObservationOperator_config = {}
-ObservationOperator_config["Data"] = FunctionDict
-ObservationOperator_config["Type"] = "Function"
-ObservationOperator_config["From"] = "FunctionDict"
-study_config["ObservationOperator"] = ObservationOperator_config
-
-Analysis_config = {}
-Analysis_config["Data"] = """
-import numpy
-
-dimension = 300
-precision = 1.e-10
-xt = numpy.matrix(numpy.arange(dimension)).T
-xb = Study.getBackground()
-
-xa = numpy.array(ADD.get("Analysis").valueserie(0))
-d = numpy.array(ADD.get("Innovation").valueserie(0))
-#
-# Verification du resultat
-# ------------------------
-if max(abs(xa - (xb+xt.A1)/2)) > precision:
- raise ValueError("Resultat du test errone (1)")
-else:
- print " Test correct, erreur maximale inferieure à %s"%precision
-"""
-Analysis_config["From"] = "String"
-study_config["Analysis"] = Analysis_config
+++ /dev/null
-#-*-coding:iso-8859-1-*-
-study_config = {}
-study_config["Name"] = "test_aster_zzzz159a"
-study_config["Algorithm"] = "3DVAR"
-
-Init_config = {}
-Init_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_parameters.py"
-Init_config["Type"] = "Dict"
-Init_config["From"] = "Script"
-Init_config["Target"] = ["AlgorithmParameters", "Background", "BackgroundError",
- "Observation", "ObservationError", "ObservationOperator", "Analysis"]
-study_config["Init"] = Init_config
-
-Algorithm_config = {}
-Algorithm_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_algorithm.py"
-Algorithm_config["Type"] = "Dict"
-Algorithm_config["From"] = "Script"
-study_config["AlgorithmParameters"] = Algorithm_config
-
-Background_config = {}
-Background_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background.py"
-Background_config["Type"] = "Vector"
-Background_config["From"] = "Script"
-study_config["Background"] = Background_config
-
-BackgroundError_config = {}
-BackgroundError_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background_error.py"
-BackgroundError_config["Type"] = "Matrix"
-BackgroundError_config["From"] = "Script"
-study_config["BackgroundError"] = BackgroundError_config
-
-Observation_config = {}
-Observation_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_observation.py"
-Observation_config["Type"] = "Vector"
-Observation_config["From"] = "Script"
-study_config["Observation"] = Observation_config
-
-ObservationError_config = {}
-ObservationError_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_observation_error.py"
-ObservationError_config["Type"] = "Matrix"
-ObservationError_config["From"] = "Script"
-study_config["ObservationError"] = ObservationError_config
-
-FunctionDict = {}
-FunctionDict["Function"] = ["Direct", "Tangent", "Adjoint"]
-FunctionDict["Script"] = {}
-FunctionDict["Script"]["Direct"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
-FunctionDict["Script"]["Tangent"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
-FunctionDict["Script"]["Adjoint"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
-ObservationOperator_config = {}
-ObservationOperator_config["Data"] = FunctionDict
-ObservationOperator_config["Type"] = "Function"
-ObservationOperator_config["From"] = "FunctionDict"
-study_config["ObservationOperator"] = ObservationOperator_config
-
-Analysis_config = {}
-Analysis_config["Data"] = """
-import numpy
-
-xa = ADD.get("Analysis").valueserie(0)
-Innovation = ADD.get("Innovation").valueserie(0)
-A = []
-J = ADD.get("CostFunctionJ").valueserie()
-#
-ADD.setDiagnostic("PlotVectors", "J")
-MonPlot = ADD.get("J")
-MonPlot.calculate([J,ADD.get("CostFunctionJb").valueserie(),ADD.get("CostFunctionJo").valueserie()],
- title = "Fonctionnelles J, Jb et Jo",
- ltitle = ["J","Jb","Jo"],
- xlabel = "Pas", ylabel = "Valeur",
- filename = "recherche_xx_Fonctionnelles.ps",
- pause = False )
-
-
-nbmesures = 11 # De 0 à 1 par pas de 0.1
-instants = numpy.array([0.1*i for i in range(nbmesures)])
-yo = []
-for reponse in init_data['experience']:
- for t,v in list(reponse):
- if min(abs(t - instants)) < 1.e-8:
- yo.append(v)
-xb = []
-Bornes = []
-for parametre in init_data['parametres']:
- xb.append( parametre[1] )
- Bornes.append( parametre[2:4] )
-B = numpy.matrix(numpy.core.identity(len(xb)))
-alpha = 1.e14
-B[0,0] = alpha * 100
-B[1,1] = alpha * 10
-B[2,2] = alpha * 1
-
-# Calcul de la RMS
-# ----------------
-import test_aster_zzzz159a_aster_functions as Code_Aster
-Hxa = Code_Aster.Calcul_Aster_Ponctuel( xa )
-V1 = numpy.array(Hxa)
-V2 = numpy.array(yo)
-import math
-rms = math.sqrt( ((V2 - V1)**2).sum() / float(V1.size) )
-
-print
-print "========="
-print "Ebauche = ",xb
-print "Analyse = ",xa
-print "RMS = ",rms
-print
-print "NbSteps = ",len(J)
-print "J = ",J
-print
-print "B[0,0] = ",B[0,0]
-print "B[1,1] = ",B[1,1]
-print "B[2,2] = ",B[2,2]
-print "Bornes = ",Bornes
-print "========="
-print
-"""
-Analysis_config["From"] = "String"
-study_config["Analysis"] = Analysis_config
--- /dev/null
+
+ASSIMILATION_STUDY(Study_name='aster_zzzz159a_LBFGSB',
+ Study_repertory='@prefix@/tests/daSalome',
+ Debug=0,
+ Algorithm='3DVAR',
+ Background=_F(INPUT_TYPE='Vector',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test_aster_zzzz159a_background.py',),),
+ BackgroundError=_F(INPUT_TYPE='Matrix',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test_aster_zzzz159a_background_error.py',),),
+ Observation=_F(INPUT_TYPE='Vector',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test_aster_zzzz159a_observation.py',),),
+ ObservationError=_F(INPUT_TYPE='Matrix',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test_aster_zzzz159a_observation_error.py',),),
+ ObservationOperator=_F(INPUT_TYPE='Function',
+ data=_F(FROM='FunctionDict',
+ FUNCTIONDICT_FILE=
+ 'test_aster_zzzz159a_functions.py',),),
+ AlgorithmParameters=_F(INPUT_TYPE='Dict',
+ data=_F(FROM='Script',
+ SCRIPT_FILE=
+ 'test_aster_zzzz159a_init_algorithm_LBFGSB.py',),),
+ UserDataInit=_F(INIT_FILE=
+ 'test_aster_zzzz159a_init_parameters.py',
+ TARGET_LIST=
+ ('BackgroundError','Observation',
+ 'ObservationError','ObservationOperator','AlgorithmParameters',
+ 'UserPostAnalysis','Background',),),
+ UserPostAnalysis=_F(FROM='String',
+ STRING=
+"""import numpy
+import os
+xa = ADD.get("Analysis").valueserie(0)
+Innovation = ADD.get("Innovation").valueserie(0)
+A = []
+J = ADD.get("CostFunctionJ").valueserie()
+ADD.setDiagnostic("PlotVectors", "J")
+MonPlot = ADD.get("J")
+if os.path.isfile("recherche_xx_Fonctionnelles.ps"):
+ os.remove("recherche_xx_Fonctionnelles.ps")
+MonPlot.calculate([J,ADD.get("CostFunctionJb").valueserie(),ADD.get("CostFunctionJo").valueserie()],
+ title = "Fonctionnelles J, Jb et Jo",
+ ltitle = ["J","Jb","Jo"],
+ xlabel = "Pas", ylabel = "Valeur",
+ filename = "recherche_xx_Fonctionnelles.ps",
+ pause = False )
+nbmesures = 11 # De 0 vers 1 par pas de 0.1
+instants = numpy.array([0.1*i for i in range(nbmesures)])
+yo = []
+for reponse in init_data['experience']:
+ for t,v in list(reponse):
+ if min(abs(t - instants)) < 1.e-8:
+ yo.append(v)
+xb = []
+Bornes = []
+for parametre in init_data['parametres']:
+ xb.append( parametre[1] )
+ Bornes.append( parametre[2:4] )
+B = numpy.matrix(numpy.core.identity(len(xb)))
+alpha = 1.e14
+B[0,0] = alpha * 100
+B[1,1] = alpha * 10
+B[2,2] = alpha * 1
+# Calcul de la RMS
+# ----------------
+import test_aster_zzzz159a_aster_functions as Code_Aster
+Hxa = Code_Aster.Calcul_Aster_Ponctuel( xa )
+V1 = numpy.array(Hxa)
+V2 = numpy.array(yo)
+import math
+rms = math.sqrt( ((V2 - V1)**2).sum() / float(V1.size) )
+print
+print "========="
+print "Ebauche = ",xb
+print "Analyse = ",xa
+print "RMS = ",rms
+print
+print "NbSteps = ",len(J)
+print "J = ",J
+print
+print "B[0,0] = ",B[0,0]
+print "B[1,1] = ",B[1,1]
+print "B[2,2] = ",B[2,2]
+print "Bornes = ",Bornes
+print "========="
+print
+""",),
+ InputVariables=_F(NAMES=('YOUN__','DSDE__','SIGY__',),
+ SIZES=(1,1,1,),),
+ OutputVariables=_F(NAMES=('REPONSE1','REPONSE2',),
+ SIZES=(11,11,),),);
+++ /dev/null
-#-*-coding:iso-8859-1-*-
-study_config = {}
-study_config["Name"] = "test_aster_zzzz159a"
-study_config["Algorithm"] = "3DVAR"
-
-Init_config = {}
-Init_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_parameters.py"
-Init_config["Type"] = "Dict"
-Init_config["From"] = "Script"
-Init_config["Target"] = ["AlgorithmParameters", "Background", "BackgroundError",
- "Observation", "ObservationError", "ObservationOperator", "Analysis"]
-study_config["Init"] = Init_config
-
-Algorithm_config = {}
-Algorithm_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_algorithm_LBFGSB.py"
-Algorithm_config["Type"] = "Dict"
-Algorithm_config["From"] = "Script"
-study_config["AlgorithmParameters"] = Algorithm_config
-
-Background_config = {}
-Background_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background.py"
-Background_config["Type"] = "Vector"
-Background_config["From"] = "Script"
-study_config["Background"] = Background_config
-
-BackgroundError_config = {}
-BackgroundError_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background_error.py"
-BackgroundError_config["Type"] = "Matrix"
-BackgroundError_config["From"] = "Script"
-study_config["BackgroundError"] = BackgroundError_config
-
-Observation_config = {}
-Observation_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_observation.py"
-Observation_config["Type"] = "Vector"
-Observation_config["From"] = "Script"
-study_config["Observation"] = Observation_config
-
-ObservationError_config = {}
-ObservationError_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_observation_error.py"
-ObservationError_config["Type"] = "Matrix"
-ObservationError_config["From"] = "Script"
-study_config["ObservationError"] = ObservationError_config
-
-FunctionDict = {}
-FunctionDict["Function"] = ["Direct", "Tangent", "Adjoint"]
-FunctionDict["Script"] = {}
-FunctionDict["Script"]["Direct"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
-FunctionDict["Script"]["Tangent"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
-FunctionDict["Script"]["Adjoint"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_functions.py"
-ObservationOperator_config = {}
-ObservationOperator_config["Data"] = FunctionDict
-ObservationOperator_config["Type"] = "Function"
-ObservationOperator_config["From"] = "FunctionDict"
-study_config["ObservationOperator"] = ObservationOperator_config
-
-Analysis_config = {}
-Analysis_config["Data"] = """
-import numpy
-
-xa = ADD.get("Analysis").valueserie(0)
-Innovation = ADD.get("Innovation").valueserie(0)
-A = []
-J = ADD.get("CostFunctionJ").valueserie()
-#
-ADD.setDiagnostic("PlotVectors", "J")
-MonPlot = ADD.get("J")
-MonPlot.calculate([J,ADD.get("CostFunctionJb").valueserie(),ADD.get("CostFunctionJo").valueserie()],
- title = "Fonctionnelles J, Jb et Jo",
- ltitle = ["J","Jb","Jo"],
- xlabel = "Pas", ylabel = "Valeur",
- filename = "recherche_xx_Fonctionnelles.ps",
- pause = False )
-
-
-nbmesures = 11 # De 0 à 1 par pas de 0.1
-instants = numpy.array([0.1*i for i in range(nbmesures)])
-yo = []
-for reponse in init_data['experience']:
- for t,v in list(reponse):
- if min(abs(t - instants)) < 1.e-8:
- yo.append(v)
-xb = []
-Bornes = []
-for parametre in init_data['parametres']:
- xb.append( parametre[1] )
- Bornes.append( parametre[2:4] )
-B = numpy.matrix(numpy.core.identity(len(xb)))
-alpha = 1.e14
-B[0,0] = alpha * 100
-B[1,1] = alpha * 10
-B[2,2] = alpha * 1
-
-# Calcul de la RMS
-# ----------------
-import test_aster_zzzz159a_aster_functions as Code_Aster
-Hxa = Code_Aster.Calcul_Aster_Ponctuel( xa )
-V1 = numpy.array(Hxa)
-V2 = numpy.array(yo)
-import math
-rms = math.sqrt( ((V2 - V1)**2).sum() / float(V1.size) )
-
-print
-print "========="
-print "Ebauche = ",xb
-print "Analyse = ",xa
-print "RMS = ",rms
-print
-print "NbSteps = ",len(J)
-print "J = ",J
-print
-print "B[0,0] = ",B[0,0]
-print "B[1,1] = ",B[1,1]
-print "B[2,2] = ",B[2,2]
-print "Bornes = ",Bornes
-print "========="
-print
-"""
-Analysis_config["From"] = "String"
-study_config["Analysis"] = Analysis_config
Code_Aster.parametres = init_data["parametres"]
Code_Aster.python_version = init_data["python_version"]
-print computation["method"]
-
-if computation["method"] == "Direct":
- result = Code_Aster.Calcul_Aster_Ponctuel(computation["data"])
-
-if computation["method"] == "Tangent":
- result = Code_Aster.Calcul_Aster_Ponctuel(computation["data"])
-
-if computation["method"] == "Adjoint":
- result = Code_Aster.Calcul_Aster_Adjoint(computation["data"])
-
+print computation
+method = ""
+for param in computation["specificParameters"]:
+ if param["name"] == "method":
+ method = param["value"]
+
+# Extraction des données et remise en forme (normalement à faire
+# dans le code
+# On sait qu'on a trois variables
+input_data = []
+for i in range(3):
+ input_data.append(computation["inputValues"][0][i][0])
+
+if method == "Adjoint":
+ input_data = (input_data, [])
+ for i in range(22):
+ if i < 11:
+ input_data[1].append(computation["inputValues"][0][3][i])
+ else:
+ input_data[1].append(computation["inputValues"][0][4][i-11])
+
+if method == "Direct":
+ output_data = Code_Aster.Calcul_Aster_Ponctuel(input_data)
+
+if method == "Tangent":
+ output_data = Code_Aster.Calcul_Aster_Ponctuel(input_data)
+
+if method == "Adjoint":
+ output_data = Code_Aster.Calcul_Aster_Adjoint(input_data)
+
+outputValues = [[[]]]
+for val in output_data:
+ outputValues[0][0].append(val)
+
+result = {}
+result["outputValues"] = outputValues
+result["specificOutputInfos"] = []
+result["returnCode"] = 0
+result["errorMessage"] = ""
print "Computation end"
-