From 681750b73de81601fb527b53b380d15bdd1a243a Mon Sep 17 00:00:00 2001 From: Pascale Noyret Date: Tue, 7 Jul 2009 09:21:18 +0000 Subject: [PATCH] *** empty log message *** --- Openturns_Study/OpenTURNS_Cata_Study_V6.py | 195 +++++++++++---------- generator/OpenturnsSTD.py | 57 +++--- 2 files changed, 136 insertions(+), 116 deletions(-) diff --git a/Openturns_Study/OpenTURNS_Cata_Study_V6.py b/Openturns_Study/OpenTURNS_Cata_Study_V6.py index b16bf263..933e546c 100644 --- a/Openturns_Study/OpenTURNS_Cata_Study_V6.py +++ b/Openturns_Study/OpenTURNS_Cata_Study_V6.py @@ -34,7 +34,7 @@ JdC = JDC_CATA ( code = 'OPENTURNS_STUDY', execmodul = None, regles = ( AU_MOINS_UN ( 'CRITERIA' ), AU_MOINS_UN ( 'MODEL' ), -# A_CLASSER ( ('DISTRIBUTION', 'MODEL'), 'VARIABLE' ), + AVANT ( ('DISTRIBUTION', 'MODEL'), 'VARIABLE' ), # A_CLASSER ( 'VARIABLE', 'CORRELATION' ), # A_CLASSER ( 'VARIABLE', 'CRITERIA' ), # A_CLASSER ( 'CORRELATION', 'CRITERIA' ), @@ -99,104 +99,14 @@ LOG = PROC ( nom = "LOG", ), ) # Fin PROC LOG +# Ordre Catalogue LOG -#================================ -# 0. Definition du modele physique -#================================ - - -DETERMINISTICVARIABLE = OPER ( nom = "DETERMINISTICVARIABLE", - sd_prod = variable, - op = None, - fr = "Variable deterministe", - ang = "Deterministic variable", - - 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 - - - -import opsOT -MODEL = MACRO ( nom = "MODEL", - op = None, - UIinfo = { "groupes" : ( "Gestion du travail", ) }, - fr = "Chargement du wrapper du modele physique", - ang = "Physical model wrapper load", - sd_prod = opsOT.INCLUDE, - op_init = opsOT.INCLUDE_context, - fichier_ini = 1, - - FileName = SIMP ( statut = "o", - typ = "TXM", - fr = "Nom du modele physique", - ang = "Physical model identifier", - ), - -) # Fin PROC MODEL - - - - -VARIABLE = PROC ( nom = "VARIABLE", - op = None, - docu = "", - fr = "Variable probabiliste", - ang = "Probabilistic variable", - - ModelVariable = SIMP ( statut = "o", - typ = ( variable, ), - ), - - Distribution = SIMP ( statut = "o", - typ = ( loi, ), - ), - -) # Fin PROC VARIABLE - - -CORRELATION = PROC ( nom = 'CORRELATION', - op = None, - docu = "", - fr = "Correlation entre variables", - ang = "Variable correlation", - - Copula = SIMP ( statut = "o", - typ = "TXM", - into = ( "Independent", ), - defaut = "Independent", - fr = "Type de la copule", - ang = "Copula kind", - ), - - -) # Fin PROC CORRELATION - #================================ -# 1. Definition des LOIS +# Definition des LOIS #================================ # Nota : les variables de type OPER doivent etre en majuscules ! @@ -887,15 +797,111 @@ DISTRIBUTION = OPER ( nom = "DISTRIBUTION", ), # Fin BLOC WEIBULL ) # Fin OPER DISTRIBUTION +# Ordre Catalogue DISTRIBUTION +#================================ +# Definition du modele physique +#================================ + + +DETERMINISTICVARIABLE = OPER ( nom = "DETERMINISTICVARIABLE", + sd_prod = variable, + op = None, + fr = "Variable deterministe", + ang = "Deterministic variable", + + 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 +# Ordre Catalogue DETERMINISTICVARIABLE + + + +import opsOT +MODEL = MACRO ( nom = "MODEL", + op = None, + UIinfo = { "groupes" : ( "Gestion du travail", ) }, + fr = "Chargement du wrapper du modele physique", + ang = "Physical model wrapper load", + sd_prod = opsOT.INCLUDE, + op_init = opsOT.INCLUDE_context, + fichier_ini = 1, + + FileName = SIMP ( statut = "o", + typ = "TXM", + fr = "Nom du modele physique", + ang = "Physical model identifier", + ), + +) # Fin PROC MODEL +# Ordre Catalogue MODEL + + + + +VARIABLE = PROC ( nom = "VARIABLE", + op = None, + docu = "", + fr = "Variable probabiliste", + ang = "Probabilistic variable", + + ModelVariable = SIMP ( statut = "o", + typ = ( variable, ), + ), + + Distribution = SIMP ( statut = "o", + typ = ( loi, ), + ), + +) # Fin PROC VARIABLE +# Ordre Catalogue VARIABLE + + +CORRELATION = PROC ( nom = 'CORRELATION', + op = None, + docu = "", + fr = "Correlation entre variables", + ang = "Variable correlation", + + Copula = SIMP ( statut = "o", + typ = "TXM", + into = ( "Independent", ), + defaut = "Independent", + fr = "Type de la copule", + ang = "Copula kind", + ), + + +) # Fin PROC CORRELATION +# Ordre Catalogue CORRELATION + #================================ -# 3. Definition de l'etude +# Definition de l'etude #================================ # Nota : les variables de type PROC doivent etre en majuscules ! @@ -1667,6 +1673,7 @@ CRITERIA = PROC ( nom = "CRITERIA", ) # Fin PROC CRITERIA +# Ordre Catalogue CRITERIA diff --git a/generator/OpenturnsSTD.py b/generator/OpenturnsSTD.py index 7631a1a4..af27d068 100644 --- a/generator/OpenturnsSTD.py +++ b/generator/OpenturnsSTD.py @@ -345,7 +345,7 @@ class STDGenerateur : if loi.has_key( 'Kind' ): marginale = "%s_%d" % (self.variable["marginal"], i) txt += "# Definit la loi marginale de la composante %d\n" % i - txt += "%s = %s\n" % (marginale, apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi, i, self.variable["collection"]) )) + txt += "%s = %s\n" % (marginale, apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) )) txt += "%s.setName( '%s' )\n" % (marginale, conceptloi.get_name()) txt += "%s[ %d ] = '%s'\n" % (self.variable["description"], i, variable) txt += "%s[ %d ] = Distribution( %s )\n" % (self.variable["collection"], i, marginale) @@ -871,7 +871,7 @@ class STDGenerateur : txt += "%s = %s.drawEventProbabilitySensitivity()[0]\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["myResult"]) txt += "#Show( %s )\n" % self.variable["eventProbabilitySensitivityGraph"] txt += "%s = '%s'\n" % (self.variable["eventProbabilitySensitivityDrawing"], self.DictMCVal[ 'FORMEventProbabilitySensitivityDrawingFilename' ]) - txt += "%s.draw( %s )\n" % (self.variable["ieventProbabilitySensitivityGraph"], self.variable["eventProbabilitySensitivityDrawing"]) + txt += "%s.draw( %s )\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["eventProbabilitySensitivityDrawing"]) txt += "ViewImage( %s.getBitmap() )\n" % self.variable["eventProbabilitySensitivityGraph"] txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["eventProbabilitySensitivityGraph"] txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["eventProbabilitySensitivityGraph"] @@ -1067,7 +1067,7 @@ class STDGenerateur : txt += "\n" return txt - def Beta (self, loi, i, collection): + def Beta (self, loi): ''' Definition de la loi Beta ''' @@ -1087,7 +1087,7 @@ class STDGenerateur : txt = "Beta( %g, %g, %g, %g, %s )" % (arg1, arg2, arg3, arg4, settings[ loi[ 'Settings' ] ]) return txt - def Exponential (self, loi, i, collection): + def Exponential (self, loi): ''' Definition de la loi Exponential ''' @@ -1096,7 +1096,7 @@ class STDGenerateur : txt = "Exponential( %g, %g )" % (arg1, arg2) return txt - def Gamma (self, loi, i, collection): + def Gamma (self, loi): ''' Definition de la loi Gamma ''' @@ -1115,14 +1115,14 @@ class STDGenerateur : txt = "Gamma( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) return txt - def Geometric (self, loi, i, collection): + def Geometric (self, loi): ''' Definition de la loi Geometric ''' txt = "Geometric( %g )" % loi[ 'P' ] return txt - def Gumbel (self, loi, i, collection): + def Gumbel (self, loi): ''' Definition de la loi Gumbel ''' @@ -1140,7 +1140,7 @@ class STDGenerateur : txt = "Gumbel( %g, %g, %s )" % (arg1, arg2, settings[ loi[ 'Settings' ] ]) return txt - def Histogram (self, loi, i, collection): + def Histogram (self, loi): ''' Definition de la loi Histogram ''' @@ -1149,7 +1149,7 @@ class STDGenerateur : txt = "Histogram( %g, %s )" % (arg1, arg2) return txt - def Laplace (self, loi, i, collection): + def Laplace (self, loi): ''' Definition de la loi Laplace ''' @@ -1158,7 +1158,7 @@ class STDGenerateur : txt = "Laplace( %g, %g )" % (arg1, arg2) return txt - def Logistic (self, loi, i, collection): + def Logistic (self, loi): ''' Definition de la loi Logistic ''' @@ -1167,7 +1167,7 @@ class STDGenerateur : txt = "Logistic( %g, %g )" % (arg1, arg2) return txt - def LogNormal (self, loi, i, collection): + def LogNormal (self, loi): ''' Definition de la loi LogNormal ''' @@ -1190,7 +1190,7 @@ class STDGenerateur : txt = "LogNormal( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) return txt - def MultiNomial (self, loi, i, collection): + def MultiNomial (self, loi): ''' Definition de la loi MultiNomial ''' @@ -1199,7 +1199,7 @@ class STDGenerateur : txt = "MultiNomial( NumericalPoint( %s ) , %d)" % (arg1, arg2) return txt - def NonCentralStudent (self, loi, i, collection): + def NonCentralStudent (self, loi): ''' Definition de la loi NonCentralStudent ''' @@ -1209,7 +1209,7 @@ class STDGenerateur : txt = "NonCentralStudent( %g, %g )" % (arg1, arg2, arg3) return txt - def Normal (self, loi, i, collection): + def Normal (self, loi): ''' Definition de la loi Normal ''' @@ -1218,7 +1218,7 @@ class STDGenerateur : txt = "Normal( %g, %g )" % (arg1, arg2) return txt - def TruncatedNormal (self, loi, i, collection): + def TruncatedNormal (self, loi): ''' Definition de la loi TruncatedNormal ''' @@ -1229,14 +1229,14 @@ class STDGenerateur : txt = "TruncatedNormal( %g, %g, %g, %g )" % (arg1, arg2, arg3, arg4) return txt - def Poisson (self, loi, i, collection): + def Poisson (self, loi): ''' Definition de la loi Poisson ''' txt = "Poisson( %g )" % loi[ 'Lambda' ] return txt - def Rayleigh (self, loi, i, collection): + def Rayleigh (self, loi): ''' Definition de la loi Rayleigh ''' @@ -1245,7 +1245,7 @@ class STDGenerateur : txt = "Rayleigh( %g, %g )" % (arg1, arg2) return txt - def Student (self, loi, i, collection): + def Student (self, loi): ''' Definition de la loi Student ''' @@ -1255,7 +1255,7 @@ class STDGenerateur : txt = "Student( %g, %g, %g )" % (arg1, arg2, arg3) return txt - def Triangular (self, loi, i, collection): + def Triangular (self, loi): ''' Definition de la loi Triangular ''' @@ -1265,7 +1265,7 @@ class STDGenerateur : txt = "Triangular( %g, %g, %g )" % (arg1, arg2, arg3) return txt - def Uniform (self, loi, i, collection): + def Uniform (self, loi): ''' Definition de la loi Uniform ''' @@ -1274,14 +1274,14 @@ class STDGenerateur : txt = "Uniform( %g, %g )" % (arg1, arg2) return txt - def UserDefined (self, loi, i, collection): + def UserDefined (self, loi): ''' Definition de la loi UserDefined ''' txt = "** UserDefined not defined yet **" return txt - def Weibull (self, loi, i, collection): + def Weibull (self, loi): ''' Definition de la loi Weibull ''' @@ -1300,3 +1300,16 @@ class STDGenerateur : txt = "Weibull( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) return txt + + + def GraphiquePDF (self, loi, fichier): + ''' + Produit une image PNG representant la PDF de la loi + ''' + txt = headerSTD + txt += "dist = %s\n" % apply( STDGenerateur.__dict__[ loi[ 'Kind' ] ], (self, loi) ) + txt += "graph = dist.drawPDF()\n" + txt += "graph.draw( '%s' )\n" % fichier + txt += footerSTD + return txt + -- 2.39.2