From ed5a982cfa372e8562167ce1c59bb8ad202b7674 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Ribes?= Date: Wed, 30 Jun 2010 17:05:09 +0200 Subject: [PATCH] Ajout de AlgorithmParameters --- resources/ADAOSchemaCatalog.xml | 16 ++++++++++++++++ src/daSalome/daYacsIntegration/daStudy.py | 7 +++++++ .../daYacsSchemaCreator/infos_daComposant.py | 3 ++- src/daSalome/daYacsSchemaCreator/methods.py | 11 +++++++++++ src/tests/daSalome/test_aster_zzzz159a.py.in | 2 +- .../test_aster_zzzz159a_init_algorithm.py | 6 +++--- 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/resources/ADAOSchemaCatalog.xml b/resources/ADAOSchemaCatalog.xml index 012e83b..3bb4f28 100644 --- a/resources/ADAOSchemaCatalog.xml +++ b/resources/ADAOSchemaCatalog.xml @@ -18,6 +18,14 @@ print "Algorithm is", Algorithm from daYacsIntegration.daStudy import * assim_study = daStudy(Name, Algorithm) +# Algorithm parameters +try: + AlgorithmParameters +except NameError: + pass +else: + assim_study.setAlgorithmParameters(AlgorithmParameters) + # Data print "Data entered are:" # Background @@ -189,4 +197,12 @@ result = None + + + + + diff --git a/src/daSalome/daYacsIntegration/daStudy.py b/src/daSalome/daYacsIntegration/daStudy.py index 68db0b9..745ca25 100644 --- a/src/daSalome/daYacsIntegration/daStudy.py +++ b/src/daSalome/daYacsIntegration/daStudy.py @@ -15,14 +15,21 @@ class daStudy: self.ADD = AssimilationStudy(name) self.ADD.setControls() self.algorithm = algorithm + self.algorithm_dict = None self.Background = None # Observation Management self.ObservationOperatorType = {} self.FunctionObservationOperator = {} + def setAlgorithmParameters(self, parameters): + self.algorithm_dict = parameters + def initAlgorithm(self): + self.ADD.setAlgorithm(choice=self.algorithm) + if self.algorithm_dict != None: + self.ADD.setAlgorithmParameters(asDico=self.algorithm_dict) def getAssimilationStudy(self): diff --git a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py index 06df3c1..5253e4c 100644 --- a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py +++ b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py @@ -28,7 +28,7 @@ AnalysisFromList = ["String", "File"] # -- Infos from daCore -- AssimData = ["Background", "BackgroundError", "Observation", "ObservationError", "ObservationOperator", "ObservationOperatorAppliedToX", - "EvolutionModel", "EvolutionError"] + "EvolutionModel", "EvolutionError", "AlgorithmParameters"] AssimType = {} AssimType["Background"] = ["Vector"] @@ -37,6 +37,7 @@ AssimType["Observation"] = ["Vector"] AssimType["ObservationError"] = ["Matrix"] AssimType["ObservationOperator"] = ["Matrix", "Function"] AssimType["ObservationOperatorAppliedToX"] = ["List"] +AssimType["AlgorithmParameters"] = ["Dict"] FromNumpyList = {} FromNumpyList["Vector"] = ["String", "Script"] diff --git a/src/daSalome/daYacsSchemaCreator/methods.py b/src/daSalome/daYacsSchemaCreator/methods.py index a3c8fa6..19b9b7f 100644 --- a/src/daSalome/daYacsSchemaCreator/methods.py +++ b/src/daSalome/daYacsSchemaCreator/methods.py @@ -66,6 +66,17 @@ def create_yacs_proc(study_config): key_type = key + "Type" + if data_config["Type"] == "Dict" and data_config["From"] == "Script": + # Create node + factory_back_node = catalogAd._nodeMap["CreateDictFromScript"] + back_node = factory_back_node.cloneNode("Get" + key) + back_node.getInputPort("script").edInitPy(data_config["Data"]) + back_node.edAddOutputPort(key, t_pyobj) + proc.edAddChild(back_node) + # Connect node with CreateAssimilationStudy + CAS_node.edAddInputPort(key, t_pyobj) + proc.edAddDFLink(back_node.getOutputPort(key), CAS_node.getInputPort(key)) + if data_config["Type"] == "Vector" and data_config["From"] == "String": # Create node factory_back_node = catalogAd._nodeMap["CreateNumpyVectorFromString"] diff --git a/src/tests/daSalome/test_aster_zzzz159a.py.in b/src/tests/daSalome/test_aster_zzzz159a.py.in index b02239a..9443c29 100644 --- a/src/tests/daSalome/test_aster_zzzz159a.py.in +++ b/src/tests/daSalome/test_aster_zzzz159a.py.in @@ -14,7 +14,7 @@ Algorithm_config = {} Algorithm_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_init_algorithm.py" Algorithm_config["Type"] = "Dict" Algorithm_config["From"] = "Script" -study_config["Algorithm"] = Algorithm_config +study_config["AlgorithmParameters"] = Algorithm_config Background_config = {} Background_config["Data"] = "@prefix@/tests/daSalome/test_aster_zzzz159a_background.py" diff --git a/src/tests/daSalome/test_aster_zzzz159a_init_algorithm.py b/src/tests/daSalome/test_aster_zzzz159a_init_algorithm.py index a72431a..b3b8f54 100644 --- a/src/tests/daSalome/test_aster_zzzz159a_init_algorithm.py +++ b/src/tests/daSalome/test_aster_zzzz159a_init_algorithm.py @@ -10,6 +10,6 @@ if debug: print "Bornes = ",Bornes print -Algorithm = { "Minimizer" : "TNC", - "Bounds" : Bornes, - } +AlgorithmParameters = { "Minimizer" : "TNC", + "Bounds" : Bornes, + } -- 2.39.2