From: André Date: Thu, 22 Apr 2010 14:27:01 +0000 (+0200) Subject: Permet d'ajouter un code d'analyse à partir d'un fichier X-Git-Tag: V6_4_0rc3~165 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6b855ab959b7fa968af6d200153558e77cbf84a1;p=modules%2Fadao.git Permet d'ajouter un code d'analyse à partir d'un fichier --- diff --git a/src/daSalome/daYacsSchemaCreator/help_methods.py b/src/daSalome/daYacsSchemaCreator/help_methods.py index 9621af3..eecd291 100644 --- a/src/daSalome/daYacsSchemaCreator/help_methods.py +++ b/src/daSalome/daYacsSchemaCreator/help_methods.py @@ -76,9 +76,9 @@ def check_study(study_config): logging.fatal("Analysis found but From is not defined in the analysis configuration !") sys.exit(1) else: - if analysis_config["From"] != "string": + if analysis_config["From"] not in AnalysisFromList: logging.fatal("Analysis From defined in the study configuration does not have a correct type : " + str(analysis_config["From"]) - + "\n You can have : string") + + "\n You can have : " + str(AnalysisFromList)) sys.exit(1) if "Data" not in analysis_config: logging.fatal("Analysis found but Data is not defined in the analysis configuration !") diff --git a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py index 019cea3..d957c07 100644 --- a/src/daSalome/daYacsSchemaCreator/infos_daComposant.py +++ b/src/daSalome/daYacsSchemaCreator/infos_daComposant.py @@ -20,6 +20,11 @@ # -- +# -- Infos pour le parser -- + +AnalysisData = {} +AnalysisFromList = ["string", "file"] + # -- Infos from daCore -- AssimData = ["Background", "BackgroundError", "Observation", "ObservationError", "ObservationOperator", "ObservationOperatorAppliedToX", diff --git a/src/daSalome/daYacsSchemaCreator/methods.py b/src/daSalome/daYacsSchemaCreator/methods.py index 5071ae0..fdcd045 100644 --- a/src/daSalome/daYacsSchemaCreator/methods.py +++ b/src/daSalome/daYacsSchemaCreator/methods.py @@ -116,6 +116,28 @@ def create_yacs_proc(study_config): proc.edAddCFLink(compute_bloc, analysis_node) proc.edAddDFLink(execute_node.getOutputPort("Study"), analysis_node.getInputPort("Study")) + elif analysis_config["From"] == "file": + factory_analysis_node = catalogAd._nodeMap["SimpleUserAnalysis"] + analysis_node = factory_analysis_node.cloneNode("User Analysis") + default_script = analysis_node.getScript() + if not os.path.exists(analysis_config["Data"]): + logging.fatal("Analysis source file does not exists ! :" + str(analysis_config["Data"])) + sys.exit(1) + try: + analysis_file = open(analysis_config["Data"], 'r') + except: + logging.fatal("Exception in openng analysis file : " + str(analysis_config["Data"])) + traceback.print_exc() + sys.exit(1) + file_text = analysis_file.read() + final_script = default_script + file_text + analysis_node.setScript(final_script) + proc.edAddChild(analysis_node) + proc.edAddCFLink(compute_bloc, analysis_node) + proc.edAddDFLink(execute_node.getOutputPort("Study"), analysis_node.getInputPort("Study")) + + pass + return proc def write_yacs_proc(proc, yacs_schema_filename): diff --git a/src/tests/daSalome/test000_Blue_AnalysisCode.py b/src/tests/daSalome/test000_Blue_AnalysisCode.py new file mode 100644 index 0000000..8a27a3d --- /dev/null +++ b/src/tests/daSalome/test000_Blue_AnalysisCode.py @@ -0,0 +1,17 @@ +#-*-coding:iso-8859-1-*- +import numpy +precision = 1.e-13 + +Xa = ADD.get("Analysis") +print +print " Nombre d'analyses :",Xa.stepnumber() +print " Analyse résultante :",Xa.valueserie(0) +# +# Vérification du résultat +# ------------------------ +if max(numpy.array(Xa.valueserie(0))-numpy.array([0.25, 1.25, 2.25])) > precision: + raise ValueError("Résultat du test erroné") +else: + print " Test correct, erreur maximale inférieure à %s"%precision + print + diff --git a/src/tests/daSalome/test000_Blue_AnalysisFile.py b/src/tests/daSalome/test000_Blue_AnalysisFile.py new file mode 100644 index 0000000..5d75d0f --- /dev/null +++ b/src/tests/daSalome/test000_Blue_AnalysisFile.py @@ -0,0 +1,40 @@ +#-*-coding:iso-8859-1-*- +study_config = {} +study_config["Name"] = "test000_Blue" +study_config["Algorithm"] = "Blue" + +Background_config = {} +Background_config["Data"] = "0,1,2" +Background_config["Type"] = "Vector" +Background_config["From"] = "string" +study_config["Background"] = Background_config + +BackgroundError_config = {} +BackgroundError_config["Data"] = "1 0 0;0 1 0;0 0 1" +BackgroundError_config["Type"] = "Matrix" +BackgroundError_config["From"] = "string" +study_config["BackgroundError"] = BackgroundError_config + +Observation_config = {} +Observation_config["Data"] = "0.5,1.5,2.5" +Observation_config["Type"] = "Vector" +Observation_config["From"] = "string" +study_config["Observation"] = Observation_config + +ObservationError_config = {} +ObservationError_config["Data"] = "1 0 0;0 1 0;0 0 1" +ObservationError_config["Type"] = "Matrix" +ObservationError_config["From"] = "string" +study_config["ObservationError"] = ObservationError_config + +ObservationOperator_config = {} +ObservationOperator_config["Data"] = "1 0 0;0 1 0;0 0 1" +ObservationOperator_config["Type"] = "Matrix" +ObservationOperator_config["From"] = "string" +study_config["ObservationOperator"] = ObservationOperator_config + +Analysis_config = {} +Analysis_config["Data"] = "/home/aribes/Projets/DATASSIM_SRC/src/tests/daSalome/test000_Blue_AnalysisCode.py" +Analysis_config["From"] = "file" +study_config["Analysis"] = Analysis_config +