From: Eric Fayolle Date: Mon, 27 Jun 2022 14:29:32 +0000 (+0200) Subject: Gestion des nouveaux noms de variables X-Git-Tag: merge_uncertainty_odysee_1210~47 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3c1cf7534a3476e812f91a41de0d1a1a4b5db0ed;p=tools%2Feficas.git Gestion des nouveaux noms de variables --- diff --git a/generator/generator_UQ.py b/generator/generator_UQ.py index 2e5861de..0c457e1c 100644 --- a/generator/generator_UQ.py +++ b/generator/generator_UQ.py @@ -35,6 +35,7 @@ import Accas from .generator_python import PythonGenerator from .textePersalys import headerScriptPersalys, fonctionPersalys, etudeScript, codePersalys from .textePersalys import mainPersalys, inputHeaderPersalys, outputHeaderPersalys +from .textePersalys import getResult from .textePersalys import centralTendencyTaylor, resultTaylor from .textePersalys import optionalResultTaylor, optionalPrintResultTaylor from .textePersalys import centralTendencyMC, resultMC @@ -121,7 +122,7 @@ class UQGenerator(PythonGenerator): def generMCSIMP(self,obj) : # inutile tant que FACT et BLOC ne sont pas surcharges - if self.nom=='Consigne' : return + if obj.nom=='Consigne' : return if not self.inGenerUQ : return PythonGenerator.generMCSIMP(self,obj) if not obj in self.mcIncertains : return PythonGenerator.generMCSIMP(self,obj) else : @@ -174,18 +175,30 @@ class UQGenerator(PythonGenerator): self.lesVariablesOutput = sectionOutput.getChildOrChildInBloc('VariableDeSortie') self.variablesOutput = {} - self.chaineDesVariablesOutput='' - listeDesVariablesOutput=[] # pour ordre en 3.5 + self.chaineDesVariablesOutputEncodee='' + #listeDesVariablesOutput=[] self.txtOutputVariableInitList='' + self.txtGetResults = "" for mc in self.lesVariablesOutput : - nomVar = mc.getChildOrChildInBloc('NomDeLaVariable').valeur - listeDesVariablesOutput.append(nomVar) - self.chaineDesVariablesOutput+=nomVar+ ', ' - Fonctions = mc.getChildOrChildInBloc('FonctionDAggregation').valeur - self.variablesOutput [nomVar]=Fonctions - self.txtOutputVariableInitList += self.indent1 + nomVar + " = persalys.Output('"+ nomVar + "', '"+nomVar + "')\n" + nomVar = mc.getChildOrChildInBloc('VariablePhysique').valeur + nomVarEncode = nomVar.replace(' ','__') + #listeDesVariablesOutput.append(nomVar) + self.chaineDesVariablesOutputEncodee+=nomVarEncode+ ', ' + nomVarPostraite = mc.getChildOrChildInBloc('VariablePosttraiteeAssociee').valeur + ##TODO : Check [0], liste ou non de fonctions d'agrégation + fonctions = mc.getChildOrChildInBloc('FonctionDAggregation').valeur[0] + ##TODO : Gerer Mean, Med? + tmpFonctionAggregation = fonctions.lower() + self.variablesOutput [nomVar]=fonctions + tmpGetResult =getResult.format( + variablesOutput = nomVarEncode, + variablePostraitee = nomVarPostraite, + fonctionAggregation = tmpFonctionAggregation + ) + self.txtGetResults += tmpGetResult + self.txtOutputVariableInitList += self.indent1 + nomVarEncode + " = persalys.Output('"+ nomVar + "', '"+nomVar + "')\n" print (self.variablesOutput) - self.chaineDesVariablesOutput=self.chaineDesVariablesOutput[0:-2] + self.chaineDesVariablesOutputEncodee=self.chaineDesVariablesOutputEncodee[0:-2] sectionExecution = etapeIncertitude.getChildOrChildInBloc('Execution')[0] self.ExecutionMode = sectionExecution.getChildOrChildInBloc('ExecutionMode').valeur @@ -262,16 +275,18 @@ class UQGenerator(PythonGenerator): replaceDataList = getStrReplaceVar(self.nomsDesVariablesInput) ) + txtFonctionPersalys = fonctionPersalys.format( currentFile = self.fichierUQModule, chaineDesVariablesInput = self.chaineDesVariablesInput, - chaineDesVariablesOutput = self.chaineDesVariablesOutput + getResults = self.txtGetResults, + chaineDesVariablesOutput = self.chaineDesVariablesOutputEncodee ) self.txtScriptPersalys += codePersalys.format( fonctionPersalys =txtFonctionPersalys ) - ## Propagation des inceritudes : Choix de la méthode et de ses paramètres + ## Propagation des incertitudes : Choix de la méthode et de ses paramètres if (self.Methode == 'Taylor' ): txtCentralTendencyPersalys = centralTendencyTaylor optionalResult = optionalResultTaylor @@ -353,7 +368,7 @@ class UQGenerator(PythonGenerator): inputHeaderPersalys = inputHeaderPersalys.format(indent=self.indent1), chaineDesVariablesInput = self.chaineDesVariablesInput, outputHeaderPersalys = outputHeaderPersalys.format(indent=self.indent1), - chaineDesVariablesOutput = self.chaineDesVariablesOutput, + chaineDesVariablesOutput = self.chaineDesVariablesOutputEncodee, yacsJobParameters = txtYacsJobParameters, centralTendencyPersalys = txtCentralTendencyPersalys, resultPersalys = txtResult diff --git a/generator/textePersalys.py b/generator/textePersalys.py index 9e835fd8..e325450a 100644 --- a/generator/textePersalys.py +++ b/generator/textePersalys.py @@ -97,8 +97,9 @@ class Study: pass - def get_results(self): - import random + def get_result(self): + from post_cvs import get_result_from_csv + import random print('--------------------------------------- 4 ---------------------------------------') # return self.extract_probe(2,2), self.extract_balance(2, 2) return 1.0 +random.random() @@ -117,7 +118,10 @@ class Study: # /home/C65845/VIMMP/Banc_integration.newer_odysee/environment/bin/python3 /home/C65845/VIMMP/Banc_integration.newer_odysee/environment/bin/ib-run --cocagne-neutro-solver SPN --cocagne-thermo-solver THERMOMI/TRMIC -- /home/C65845/VIMMP/Banc_integration.newer_odysee/integration_bench/tests/control_rod_ejection_small_core_cathare3_cocagne.comm /home/C65845/VIMMP/Banc_integration.newer_odysee/integration_bench/tests/control_rod_ejection_small_core_cathare3_cocagne_spn_thermomi-trmic_serial -# ------------------------ +getResult=""" {variablesOutput} = study.get_result('{variablePostraitee}', {fonctionAggregation} ) +""" + +#------------------------- # fonctionPersalys # ------------------------ fonctionPersalys = """ @@ -131,7 +135,8 @@ def _exec({chaineDesVariablesInput}): if not study.case_exists(): study.prepare_case() study.run_case() - {chaineDesVariablesOutput} = study.get_results() + +{getResults} return {chaineDesVariablesOutput} """