From: André Ribes Date: Thu, 1 Jul 2010 14:22:07 +0000 (+0200) Subject: Test TNC ok :-) X-Git-Tag: V6_4_0rc3~125 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a0300db9ca9df95364ac3c39f1d72295c07de473;p=modules%2Fadao.git Test TNC ok :-) --- diff --git a/resources/ADAOSchemaCatalog.xml b/resources/ADAOSchemaCatalog.xml index 3bb4f28..85688d0 100644 --- a/resources/ADAOSchemaCatalog.xml +++ b/resources/ADAOSchemaCatalog.xml @@ -205,4 +205,13 @@ execfile(script) + + + + + + diff --git a/src/daSalome/daYacsSchemaCreator/methods.py b/src/daSalome/daYacsSchemaCreator/methods.py index 19b9b7f..c4f8eef 100644 --- a/src/daSalome/daYacsSchemaCreator/methods.py +++ b/src/daSalome/daYacsSchemaCreator/methods.py @@ -58,6 +58,16 @@ def create_yacs_proc(study_config): CAS_node.getInputPort("Algorithm").edInitPy(study_config["Algorithm"]) proc.edAddChild(CAS_node) + # Step 0.5: Find if there is a user init node + init_config = {} + init_config["Target"] = [] + if "Init" in study_config.keys(): + init_config = study_config["Init"] + factory_init_node = catalogAd._nodeMap["InitUserDataFromScript"] + init_node = factory_init_node.cloneNode("InitUserData") + init_node.getInputPort("script").edInitPy(init_config["Data"]) + proc.edAddChild(init_node) + # Step 1: get input data from user configuration for key in study_config.keys(): @@ -76,6 +86,10 @@ def create_yacs_proc(study_config): # Connect node with CreateAssimilationStudy CAS_node.edAddInputPort(key, t_pyobj) proc.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key)) + # Connect node with InitUserData + if key in init_config["Target"]: + back_node.edAddInputPort("init_data", t_pyobj) + proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data")) if data_config["Type"] == "Vector" and data_config["From"] == "String": # Create node @@ -88,6 +102,10 @@ def create_yacs_proc(study_config): CAS_node.edAddInputPort(key_type, t_string) proc.edAddDFLink(back_node.getOutputPort("vector"), CAS_node.getInputPort(key)) proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type)) + # Connect node with InitUserData + if key in init_config["Target"]: + back_node.edAddInputPort("init_data", t_pyobj) + proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data")) if data_config["Type"] == "Vector" and data_config["From"] == "Script": # Create node @@ -101,6 +119,10 @@ def create_yacs_proc(study_config): CAS_node.edAddInputPort(key_type, t_string) proc.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key)) proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type)) + # Connect node with InitUserData + if key in init_config["Target"]: + back_node.edAddInputPort("init_data", t_pyobj) + proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data")) if data_config["Type"] == "Matrix" and data_config["From"] == "String": # Create node @@ -113,6 +135,10 @@ def create_yacs_proc(study_config): CAS_node.edAddInputPort(key_type, t_string) proc.edAddDFLink(back_node.getOutputPort("matrix"), CAS_node.getInputPort(key)) proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type)) + # Connect node with InitUserData + if key in init_config["Target"]: + back_node.edAddInputPort("init_data", t_pyobj) + proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data")) if data_config["Type"] == "Matrix" and data_config["From"] == "Script": # Create node @@ -126,6 +152,10 @@ def create_yacs_proc(study_config): CAS_node.edAddInputPort(key_type, t_string) proc.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key)) proc.edAddDFLink(back_node.getOutputPort("type"), CAS_node.getInputPort(key_type)) + # Connect node with InitUserData + if key in init_config["Target"]: + back_node.edAddInputPort("init_data", t_pyobj) + proc.edAddDFLink(init_node.getOutputPort("init_data"), back_node.getInputPort("init_data")) if data_config["Type"] == "Function" and data_config["From"] == "Dict" and key == "ObservationOperator": FunctionDict = data_config["Data"] @@ -190,6 +220,11 @@ def create_yacs_proc(study_config): proc.edAddDFLink(optimizer_node.edGetSamplePort(), opt_script_node.getInputPort("computation")) proc.edAddDFLink(opt_script_node.getOutputPort("result"), optimizer_node.edGetPortForOutPool()) + # Connect node with InitUserData + if "ObservationOperator" in init_config["Target"]: + opt_script_node.edAddInputPort("init_data", t_pyobj) + proc.edAddDFLink(init_node.getOutputPort("init_data"), opt_script_node.getInputPort("init_data")) + else: factory_opt_script_node = catalogAd._nodeMap["FakeOptimizerLoopNode"] opt_script_node = factory_opt_script_node.cloneNode("FakeFunctionNode") diff --git a/src/tests/daSalome/test_aster_zzzz159a.py.in b/src/tests/daSalome/test_aster_zzzz159a.py.in index 9443c29..98246f3 100644 --- a/src/tests/daSalome/test_aster_zzzz159a.py.in +++ b/src/tests/daSalome/test_aster_zzzz159a.py.in @@ -7,7 +7,8 @@ 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"] = ["Algorithm"] +Init_config["Target"] = ["AlgorithmParameters", "Background", "BackgroundError", + "Observation", "ObservationError", "ObservationOperator"] study_config["Init"] = Init_config Algorithm_config = {} @@ -52,3 +53,12 @@ ObservationOperator_config["Type"] = "Function" ObservationOperator_config["From"] = "Dict" study_config["ObservationOperator"] = ObservationOperator_config +Analysis_config = {} +Analysis_config["Data"] = """ +import numpy + +Xa = ADD.get("Analysis").valueserie(0) +print "Analyse = ",Xa +""" +Analysis_config["From"] = "String" +study_config["Analysis"] = Analysis_config diff --git a/src/tests/daSalome/test_aster_zzzz159a_aster_functions.py b/src/tests/daSalome/test_aster_zzzz159a_aster_functions.py index 817aae9..412af9e 100644 --- a/src/tests/daSalome/test_aster_zzzz159a_aster_functions.py +++ b/src/tests/daSalome/test_aster_zzzz159a_aster_functions.py @@ -22,6 +22,7 @@ def UTMESS(code='I', txt=''): def get_tables(tables_calc,tmp_repe_table,prof): """ Recupere les resultats Aster (Table Aster -> Numeric Python) """ + global debug import Numeric assert (tables_calc is not None) assert (tmp_repe_table is not None) @@ -76,7 +77,6 @@ def get_tables(tables_calc,tmp_repe_table,prof): message = "Erreur 3!\n" + str(err) UTMESS('F', message) resu_calc = Lrep - from N_Parameters import debug if debug: print 'resu_calc:', resu_calc return resu_calc @@ -86,6 +86,14 @@ def get_tables(tables_calc,tmp_repe_table,prof): #=============================================================================== def Calcul_Aster_Ponctuel( X0 = None ): # + global ASTER_ROOT + global debug + global SOURCES_ROOT + global export + global calcul + global parametres + global python_version + import numpy if type(X0) is type(numpy.matrix([])): X0 = X0.A1.tolist() @@ -93,11 +101,13 @@ def Calcul_Aster_Ponctuel( X0 = None ): X0 = list(X0) # ---------------------------------------------------------------------------- # Parametres - isFromYacs = globals().get('ASTER_ROOT', None) # execution via YACS ou en externe - if not isFromYacs: - from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY - from N_Study_Parameters import export - from N_MR_Parameters import calcul, parametres + #isFromYacs = globals().get('ASTER_ROOT', None) # execution via YACS ou en externe + #isFromYacs = ASTER_ROOT + #print "isFromYacs:", isFromYacs + #if not isFromYacs: + # from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY + # from N_Study_Parameters import export + # from N_MR_Parameters import calcul, parametres os.environ['ASTER_ROOT'] = ASTER_ROOT # ---------------------------------------------------------------------------- @@ -280,6 +290,13 @@ def Calcul_Aster_Ponctuel( X0 = None ): #=============================================================================== def Calcul_Aster_Jacobienne( X0 = None ): + global ASTER_ROOT + global debug + global SOURCES_ROOT + global export + global calcul + global parametres + global python_version # import numpy if type(X0) is type(numpy.matrix([])): @@ -292,11 +309,11 @@ def Calcul_Aster_Jacobienne( X0 = None ): # dX = globals().get('dX', [ 0.1, 0.1, 0.001]) # execution via YACS ou en externe # ---------------------------------------------------------------------------- # Parametres - isFromYacs = globals().get('ASTER_ROOT', None) # execution via YACS ou en externe - if not isFromYacs: - from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY - from N_Study_Parameters import export - from N_MR_Parameters import calcul, parametres + #isFromYacs = globals().get('ASTER_ROOT', None) # execution via YACS ou en externe + #if not isFromYacs: + # from N_Parameters import ASTER_ROOT, debug, SOURCES_ROOT, DISPLAY + # from N_Study_Parameters import export + # from N_MR_Parameters import calcul, parametres os.environ['ASTER_ROOT'] = ASTER_ROOT # ---------------------------------------------------------------------------- diff --git a/src/tests/daSalome/test_aster_zzzz159a_background.py b/src/tests/daSalome/test_aster_zzzz159a_background.py index 40b0449..d348e29 100644 --- a/src/tests/daSalome/test_aster_zzzz159a_background.py +++ b/src/tests/daSalome/test_aster_zzzz159a_background.py @@ -1,3 +1,5 @@ +#-*-coding:iso-8859-1-*- +import numpy debug = init_data["debug"] parametres = init_data["parametres"] diff --git a/src/tests/daSalome/test_aster_zzzz159a_background_error.py b/src/tests/daSalome/test_aster_zzzz159a_background_error.py index 98ced54..2eec022 100644 --- a/src/tests/daSalome/test_aster_zzzz159a_background_error.py +++ b/src/tests/daSalome/test_aster_zzzz159a_background_error.py @@ -1,3 +1,5 @@ +#-*-coding:iso-8859-1-*- +import numpy parametres = init_data["parametres"] xb = [] @@ -9,7 +11,7 @@ alpha = 1.e14 B[0,0] = alpha * 100 B[1,1] = alpha * 10 B[2,2] = alpha * 1 -dimensionXb = len( Xb ) +dimensionXb = len( xb ) B = numpy.matrix( B, numpy.float ).reshape((dimensionXb,dimensionXb)) BackgroundError = B diff --git a/src/tests/daSalome/test_aster_zzzz159a_functions.py b/src/tests/daSalome/test_aster_zzzz159a_functions.py index f1e1e64..aa95b29 100644 --- a/src/tests/daSalome/test_aster_zzzz159a_functions.py +++ b/src/tests/daSalome/test_aster_zzzz159a_functions.py @@ -1,5 +1,8 @@ import numpy import pickle +import sys + +sys.path.insert(0, init_data['SOURCES_ROOT']) import test_aster_zzzz159a_aster_functions as Code_Aster # Configuration du module diff --git a/src/tests/daSalome/test_aster_zzzz159a_init_parameters.py.in b/src/tests/daSalome/test_aster_zzzz159a_init_parameters.py.in index e7ccbb9..64e1660 100644 --- a/src/tests/daSalome/test_aster_zzzz159a_init_parameters.py.in +++ b/src/tests/daSalome/test_aster_zzzz159a_init_parameters.py.in @@ -12,9 +12,10 @@ init_data = {} init_data['ASTER_ROOT'] = os.environ['ASTER_ROOT'] init_data['debug'] = False init_data['python_version'] = "python@PYTHON_VERSION@" +init_data['SOURCES_ROOT'] = "@prefix@" + '/tests/daSalome' # Partie contenant les parametres de l'étude -export=os.environ["ADAO_ROOT_DIR"] + '/tests/daSalome/zzzz159a.export.esclave' +init_data['export'] = "@prefix@" + '/tests/daSalome/zzzz159a.export.esclave' import Numeric parametres =[['YOUN__',100000.,50000.,500000.],['DSDE__',1000.,500.,10000.],['SIGY__',30.,5.,500.]] diff --git a/src/tests/daSalome/test_aster_zzzz159a_observation.py b/src/tests/daSalome/test_aster_zzzz159a_observation.py index a3b5a49..2cb623c 100644 --- a/src/tests/daSalome/test_aster_zzzz159a_observation.py +++ b/src/tests/daSalome/test_aster_zzzz159a_observation.py @@ -1,3 +1,5 @@ +#-*-coding:iso-8859-1-*- +import numpy debug = init_data["debug"] experience = init_data["experience"] diff --git a/src/tests/daSalome/test_aster_zzzz159a_observation_error.py b/src/tests/daSalome/test_aster_zzzz159a_observation_error.py index deaae3a..1942200 100644 --- a/src/tests/daSalome/test_aster_zzzz159a_observation_error.py +++ b/src/tests/daSalome/test_aster_zzzz159a_observation_error.py @@ -1,3 +1,5 @@ +#-*-coding:iso-8859-1-*- +import numpy experience = init_data["experience"] nbmesures = 11 # De 0 à 1 par pas de 0.1 instants = numpy.array([0.1*i for i in range(nbmesures)]) @@ -8,5 +10,7 @@ for reponse in experience: yo.append(v) R = numpy.matrix(numpy.core.identity(len(yo))) -dimensionYo = len( Yo ) +dimensionYo = len( yo ) R = numpy.matrix( R, numpy.float ).reshape((dimensionYo,dimensionYo)) + +ObservationError = R