#TODO --> si UserDefined et Uranie alors UserDefined
-#def creeLienVPVD(monMC):
-# if monMC.valeur == () or monMC.valeur == None : return
-# print (monMC)
-
# a faire
class infFrereMC(Valid):
def __init__(self,nomMCFrere):
self.nomMCFrere = nomMCFrere
#
-listeLoiDistribution= ( #"Beta",
- #"Exponential",
- #"Gamma",
- #"Geometric",
- #"Gumbel",
- #"Histogram",
- #"Laplace",
- #"Logistic",
- #"LogNormal",
- #"MultiNomial",
- #"NonCentralStudent",
- #"Normal",
- #"Poisson",
- #"Rayleigh",
- #"Student",
- #"Triangular",
- "TruncatedNormal",
- "Uniform",
- "UserDefined",
- #"Weibull",
- ),
+#listeLoiDistribution= ( #"Beta", #"Exponential", #"Gamma", #"Geometric", #"Gumbel", #"Histogram", #"Laplace", #"Logistic", #"LogNormal", #"MultiNomial",
+ #"NonCentralStudent", #"Normal", #"Poisson", #"Rayleigh", #"Student", #"Triangular", "TruncatedNormal", "Uniform", "UserDefined",
+ #"Weibull",),
##====
## Definition des parametres selon le type de la loi
#
#
#
-##================================
-## Definition du modele physique
-##================================
-#
-#
-#Deterministic_variable = OPER ( nom = "Deterministic_variable",
-# sd_prod = variable,
-# op = None,
-# fr = "Variable deterministe",
-# ang = "Deterministic variable",
-# UIinfo={"groupes":("UQ",)},
-#
-# N = SIMP( statut = 'o',
-# typ = "TXM",
-# fr = "Nom",
-# ang = "Name",
-# ),
-#
-# T = SIMP( statut = 'o',
-# defaut = "in",
-# into = ( "in" , "out", ),
-# typ = "TXM",
-# fr = "Type",
-# ang = "Type",
-# ),
-#
-# R = SIMP( statut = 'o',
-# defaut = 0,
-# typ = "I",
-# fr = "Rang",
-# ang = "Rank",
-# ),
-#
-#) # Fin OPER DETERMINISTICVARIABLE
-#
-#
-#
-#
#Correlation = PROC ( nom = 'Correlation',
# op = None,
# docu = "",
#
#
#
-##================================
-## Definition de l'etude
-##================================
-#
-## Nota : les variables de type PROC doivent etre en majuscules !
-#Criteria = PROC ( nom = "Criteria",
-# op = None,
-# docu = "",
-# fr = "Critère de l'étude d'incertitudes",
-# ang = "Uncertainty study criteria",
-# UIinfo={"groupes":("UQ",)},
-#
-#
-#
-# Type = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( "Min/Max", "Central Uncertainty", "Threshold Exceedence" ),
-# fr = "Type du critère",
-# ang = "Criteria type",
-# ),
-#
-#
-#
-#
-#
-#
-#
-# MinMax = BLOC( condition = " Type in ( 'Min/Max', ) ",
-#
-# Method = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( "Experiment Plane", "Random Sampling" ),
-# fr = "Methode",
-# ang = "Method",
-# ),
-# # UC 3.1.1
-# ExperimentPlaneSettings = BLOC( condition = " Method in ( 'Experiment Plane', ) ",
-#
-# ExperimentPlane = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( "Axial", "Factorial", "Composite", ),
-# fr = "Type du plan d'expérience",
-# ang = "Experiment plane type",
-# ),
-#
-# Levels = SIMP( statut = "o",
-# typ = "R",
-# val_min = 0.0,
-# max = '**',
-# fr = "Liste de niveaux dans chaque direction",
-# ang = "Levels in each direction",
-# ),
-#
-# # Scaled Vector
-# UnitPerDimension = SIMP( statut = "o",
-# typ = "R",
-# max = '**',
-# fr = "Unité par dimension (autant que de variables declarées)",
-# ang = "Units per dimension (as much as declared variables)",
-# ),
-#
-# # Translation Vector
-# Center = SIMP( statut = "o",
-# typ = "R",
-# max = '**',
-# fr = "Centre du plan d'expérience",
-# ang = "Experiment plan center",
-# ),
-#
-# ), # Fin BLOC ExperimentPlaneSettings
-#
-#
-#
-# RandomSamplingSettings = BLOC( condition = " Method in ( 'Random Sampling', ) ",
-#
-# SimulationsNumber = SIMP( statut = "o",
-# typ = "I",
-# val_min = 1,
-# fr = "Nombre de points",
-# ang = "Points number",
-# ),
-#
-# ), # Fin BLOC RandomSamplingSettings
-#
-# Result = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( "Min/Max", ),
-# defaut = "Min/Max",
-# fr = "Le minimum et le maximum de la variable d'intérêt",
-# ang = "The min and max values",
-# ),
-#
-#
-# ), # Fin BLOC MinMax
-#
-#
-#
-#
-# CentralUncertainty = BLOC( condition = " Type in ( 'Central Uncertainty', ) ",
-#
-# Method = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( "Taylor Variance Decomposition", "Random Sampling" ),
-# fr = "Methode",
-# ang = "Method",
-# ),
-#
-# # UC 3.2.
-# TaylorVarianceDecompositionSettings = BLOC( condition = " Method in ( 'Taylor Variance Decomposition', ) ",
-#
-# Result = FACT ( statut = "o",
-# min = 1,
-# max = "**",
-#
-# MeanFirstOrder = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# max = 1,
-# fr = "Moyenne au premier ordre",
-# ang = "MeanFirstOrder",
-# ),
-#
-# StandardDeviationFirstOrder = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# max = 1,
-# fr = "Ecart-type au premier ordre",
-# ang = "StandardDeviationFirstOrder",
-# ),
-#
-# MeanSecondOrder = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'no',
-# max = 1,
-# fr = "Moyenne au second ordre",
-# ang = "MeanSecondOrder",
-# ),
-#
-# ImportanceFactor = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# max = 1,
-# fr = "Facteur d'importance pour variable de sortie scalaire",
-# ang = "ImportanceFactor",
-# ),
-# ImportanceFactorSettings = BLOC( condition = " ImportanceFactor in ( 'yes', ) ",
-#
-# ImportanceFactorDrawingFilename = SIMP( statut = "o",
-# typ = "TXM",
-# max = 1,
-# fr = "Nom du fichier graphique des facteurs d'importance",
-# ang = "Importance Factor Drawing Filename",
-# ),
-#
-#
-# ), # Fin BLOC ImportanceFactorSettings
-#
-# ), # Fin FACT Result
-#
-# ), # Fin BLOC TaylorVarianceDecompositionSettings
-#
-#
-#
-# RandomSamplingSettings = BLOC( condition = " Method in ( 'Random Sampling', ) ",
-#
-# SimulationsNumber = SIMP( statut = "o",
-# typ = "I",
-# val_min = 1,
-# fr = "Nombre de points",
-# ang = "Points number",
-# ),
-#
-# Result = FACT ( statut = "o",
-# min = 1,
-# max = "**",
-#
-# EmpiricalMean = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# max = 1,
-# fr = "Moyenne empirique",
-# ang = "Empirical mean",
-# ),
-#
-# EmpiricalStandardDeviation = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# max = 1,
-# fr = "Ecart-type empirique",
-# ang = "Empirical standard deviation",
-# ),
-#
-# EmpiricalQuantile = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# max = 1,
-# fr = "Quantile empirique",
-# ang = "Empirical quantile",
-# ),
-#
-# EmpiricalQuantileSettings = BLOC( condition = " EmpiricalQuantile in ( 'yes', ) ",
-#
-# EmpiricalQuantile_Order = SIMP( statut = "o",
-# typ = 'R',
-# defaut = 0.95,
-# max = 1,
-# val_min = 0.0,
-# val_max = 1.0,
-# fr = "Ordre du quantile empirique",
-# ang = "Empirical quantile order",
-# ),
-#
-# ), # Fin BLOC EmpiricalQuantileSettings
-#
-# CorrelationAnalysis = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# max = 1,
-# fr = "Correlations analysees",
-# ang = "Analysed correlations",
-# ),
-#
-# KernelSmoothing = SIMP( statut = "o",
-# typ = 'TXM',
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# max = 1,
-# fr = "Kernel smoothing de l'echantillon",
-# ang = "Kernel smoothing of the sample",
-# ),
-#
-# KernelSmoothingSettings = BLOC( condition = " KernelSmoothing in ( 'yes', ) ",
-#
-# KernelSmoothingDrawingFilename = SIMP( statut = "o",
-# typ = "TXM",
-# max = 1,
-# fr = "Nom du fichier graphique de la reconstruction a noyau",
-# ang = "Kernel Smoothing Drawing Filename",
-# ),
-#
-#
-# ), # Fin BLOC KernelSmoothingSettings
-#
-# ), # Fin FACT Result
-#
-# ), # Fin BLOC RandomSamplingSettings
-#
-# ), # Fin BLOC CentralUncertainty
-#
-#
-#
#
# ThresholdExceedence = BLOC( condition = " Type in ( 'Threshold Exceedence', ) ",
#
#) # Fin PROC CRITERIA
#
#
-## --------------------------------------------------
-## Niveau de Journalisation
-## --------------------------------------------------
-#
-#Journalisation_Code = PROC ( nom = "Journalisation_Code",
-# docu = "",
-# UIinfo={"groupes":("UQ",)},
-#
-# DebugMessages = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( 'yes', 'no' ),
-# defaut = 'no',
-# fr = "Affichage du niveau de debug de la bibliotheque Open TURNS",
-# ang = "Open TURNS library debug level print",
-# ),
-#
-# WrapperMessages = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( 'yes', 'no' ),
-# defaut = 'no',
-# fr = "Affichage du niveau de wrapper de la bibliotheque Open TURNS",
-# ang = "Open TURNS library debug level print",
-# ),
-#
-# UserMessages = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( 'yes', 'no' ),
-# defaut = 'no',
-# fr = "Affichage du niveau de user de la bibliotheque Open TURNS",
-# ang = "Open TURNS library user level print",
-# ),
-#
-# InfoMessages = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# fr = "Affichage du niveau de info de la bibliotheque Open TURNS",
-# ang = "Open TURNS library info level print",
-# ),
-#
-# WarningMessages = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# fr = "Affichage du niveau de warning de la bibliotheque Open TURNS",
-# ang = "Open TURNS library warning level print",
-# ),
-#
-# ErrorMessages = SIMP( statut = "o",
-# typ = "TXM",
-# into = ( 'yes', 'no' ),
-# defaut = 'yes',
-# fr = "Affichage du niveau de error de la bibliotheque Open TURNS",
-# ang = "Open TURNS library error level print",
-# ),
-#
-#) # Fin Niveaux_Log_Code
-#
-#
-#
-#
-#
def affineDistribution(monDicoVarDeter,var,loi):
nomLoi=list(monDicoVarDeter[var].keys())[0]
nomBloc = 'b_Model_Variable_' + var+'_'+nomLoi
dicoDistribution[nomBloc]=bloc
lesBlocs[nomBlocVar]= BLOC(condition=laCondition, Distribution = distribution, **dicoDistribution)
- print (lesBlocs)
return lesBlocs
+def definitIntoOuput(objExpression, contexte):
+ # protege par un gros try -)
+ debug=0
+ if debug : print (objExpression)
+ jdc=objExpression.jdc
+ if not jdc : return
+ if debug : print (jdc)
+ monScenario=jdc.getEtapesByName('Scenario_data')[0]
+ if debug : print (monScenario)
+ mesPostPro=monScenario.getChildOrChildInBloc('post_processing')
+ if debug : print (mesPostPro)
+ if not mesPostPro : return
+ mesPostPro.definition.changeSiValide(changeIntoOuput)
+ changeIntoOuput(mesPostPro)
+
+
+def changeIntoOuput(objPostPro):
+ mesPostProVal=objPostPro.valeur
+ contexte=objPostPro.etape.parent.g_context
+ for (variable,fonct) in mesPostProVal :
+ if fonct == 'MED' : continue
+ nomVar=variable.split('@')[0]
+ phys=variable.split('@')[1]
+ nomAProposer= variable+'@'+fonct
+ nomBloc = 'b_physique_' + phys
+ nomBlocVar = ('b_var_'+nomVar).replace( ' ','__')
+ maDef=contexte['ExpressionIncertitude'].entites['Output'].entites['VariableDeSortie'].entites[nomBloc].entites[nomBlocVar].entites['VariablePosttraiteeAssociee']
+ maDef.addInto(nomAProposer)
+
+
def creeOutput(monDicoVarSortie):
intoVariable=list(monDicoVarSortie.keys())
- if len(intoVariable) == 1 :
- listeDesVariablesSortiePossibles = monDicoVarSortie[list(monDicoVarSortie.keys())[0]]
- output = FACT (max=1, statut ='o',
- VariableDeSortie = FACT ( max='**', statut ='o',
- Physique = SIMP (statut = "o", typ = "TXM",into = intoVariable,defaut=intoVariable[0]),
- NomDeLaVariable = SIMP ( statut = "o", typ = "TXM", into = listeDesVariablesSortiePossibles),
- FonctionDAggregation = SIMP(statut = 'o', typ= 'TXM', into = ('Max', 'Min', 'Med', 'Moy', 'Sum'),defaut=('Max'), max='**', homo='SansOrdreNiDoublon'),
- Unit = SIMP ( statut = "f", typ = "TXM", fr = "Unite", ang = "Unit",),
- Format = SIMP ( statut = "f", typ = "TXM", fr = "Format de sortie", ang = "format", into =['med', 'csv']),
- ),
- )
- return output
- else :
- lesBlocs={}
- Physique = SIMP (statut = "o", typ = "TXM",into = intoVariable,defaut=intoVariable[0])
- for phys in intoVariable :
- laCondition ="Physique == '" + phys + "'"
- NomDeLaVariable = SIMP ( statut = "o", typ = "TXM", into = monDicoVarSortie[phys], )
- nomBloc = 'b_physique_' + phys
- lesBlocs[nomBloc] = BLOC (condition=laCondition, NomDeLaVariable = NomDeLaVariable)
- FonctionDAggregation = SIMP(statut = 'o', typ= 'TXM', into = ('Max', 'Min', 'Med', 'Moy', 'Sum'),defaut=('Max'), max='**', homo='SansOrdreNiDoublon')
+ lesBlocs={}
+ Physique = SIMP (statut = "o", typ = "TXM",into = intoVariable,defaut=intoVariable[0])
+ for phys in intoVariable :
+ laCondition = "Physique == '" + phys + "'"
+ VariablePhysique = SIMP(statut = "o", typ = "TXM", into = monDicoVarSortie[phys], )
Unit = SIMP ( statut = "f", typ = "TXM", fr = "Unite", ang = "Unit",)
Format = SIMP ( statut = "f", typ = "TXM", fr = "Format de sortie", ang = "format", into =['med', 'csv'])
- VariableDeSortie = FACT ( max='**', statut ='o', Physique=Physique, **lesBlocs, FonctionDAggregation=FonctionDAggregation, Unit=Unit,Format=Format)
- output = FACT (max=1, statut ='o', VariableDeSortie=VariableDeSortie)
- return output
+ lesBlocsVar={}
+ for v in monDicoVarSortie[phys] :
+ VariablePosttraiteeAssociee = SIMP ( statut = "o", typ = "TXM", into=[])
+ Consigne = SIMP(statut="o", homo="information", typ="TXM", defaut="la Variable Post Traitée associée doit être présente dans la variable post_processing de Scenario_Data")
+ laConditionVar ="VariablePhysique == '" + v + "'"
+ nomBlocVar=('b_var_'+v).replace( ' ','__')
+ lesBlocsVar[nomBlocVar]= BLOC (condition=laConditionVar, VariablePosttraiteeAssociee=VariablePosttraiteeAssociee, Consigne=Consigne)
+ nomBloc = 'b_physique_' + phys
+ lesBlocs[nomBloc] = BLOC (condition=laCondition, VariablePhysique = VariablePhysique, **lesBlocsVar)
+ FonctionDAggregation = SIMP(statut = 'o', typ= 'TXM', into = ('Max', 'Min', 'Med', 'Moy', 'Sum'),
+ defaut=('Max'), max='**', homo='SansOrdreNiDoublon')
+ VariableDeSortie = FACT ( max='**', statut ='o', Physique=Physique, **lesBlocs, FonctionDAggregation=FonctionDAggregation, Unit=Unit,Format=Format)
+ output = FACT (max=1, statut ='o', VariableDeSortie=VariableDeSortie)
+ return output
def creeOperExpressionIncertitude(monDicoVarDeter, monDicoVarSortie):
listeDesVariablesPossibles = list(monDicoVarDeter.keys())
- monOutput = creeOutput(monDicoVarSortie)
+ #monOutput = creeOutput(monDicoVarSortie)
objectName = SIMP ( statut = "f", typ = 'TXM', into=[], fenetreIhm='menuDeroulant', homo='constant' ) # on ne met pas [] pour la projection XSD, intoXML=?
modelVariable = SIMP ( statut = "o",
typ = ( 'TXM'),
fenetreIhm='menuDeroulant',
homo='constant',
)
- laConsigne = SIMP(statut="o", homo="information", typ="TXM", defaut=' ')
+ Consigne = SIMP(statut="o", homo="information", typ="TXM", defaut=' ')
MCPath = SIMP(statut='d', typ='TXM', defaut=(), max='**', min=0,)
blocs=creeDistributionsSelonVariable(monDicoVarDeter)
# Attention
# l ordre des motclefs en 3.7 a l air de dépendre de l ordre de creation des objets
# et non d un dict ordonné. on retombe toujours sur ce pb
- return PROC ( nom = "ExpressionIncertitude", UIinfo={"groupes":("CACHE",)},
+ return PROC ( nom = "ExpressionIncertitude", UIinfo={"groupes":("CACHE",)}, op_init=definitIntoOuput,
Input = FACT( max=1, statut ='o',
VariableProbabiliste = FACT ( max='**', statut ='cache',
fr = "Variable probabiliste",
ang = "Probabilistic variable",
ObjectName = objectName,
ModelVariable = modelVariable,
- Consigne = laConsigne,
+ Consigne = Consigne,
MCPath = MCPath,
**blocs
),
Methode = SIMP( statut = "o", typ = "TXM", max=1, into = ('SRS', 'Sobol'), defaut='Sobol'),
), # fin UraniePropagation
), # fin Propagation
- Output=monOutput,
+ Output=creeOutput(monDicoVarSortie),
Execution = FACT (max=1, statut ='o',
bloc_OT = BLOC (condition = 'UncertaintyTool == "OpenTurns"',
ExecutionMode = SIMP ( statut = "o", typ = "TXM", into = ['desktop', 'cluster']),