From 698a26971b60964ef10d5d54fe5796e2a425e98c Mon Sep 17 00:00:00 2001 From: Pascale Noyret Date: Fri, 3 Jul 2009 08:57:21 +0000 Subject: [PATCH] *** empty log message *** --- Accas/A_AVANT.py | 29 ++ Accas/__init__.py | 3 +- Aster/configuration_ASTER.py | 361 ++++++++++++++++++ Aster/editeur.ini | 28 +- Aster/editeur_salome.ini | 28 +- Aster/prefs.py | 114 ------ Aster/prefs_ASTER.py | 112 ++++++ Aster/qtEficas_aster.py | 7 +- Editeur/analyse_catalogue_initial.py | 76 ++++ Editeur/comploader.py | 6 +- Editeur/import_code.py | 24 +- Editeur/listePatrons.py | 3 +- Editeur/styles.py | 4 +- Ihm/I_AVANT.py | 78 ++++ InterfaceQT4/componiveau.py | 8 +- InterfaceQT4/monMCListAjoutPanel.py | 1 + InterfaceQT4/monUniqueBasePanel.py | 4 +- .../configuration_OPENTURNS_STUDY.py | 196 ++++++++++ Openturns_Study/opsOT.py | 21 + Openturns_Study/prefs_OPENTURNS_STUDY.py | 52 +++ UiQT4/OptionsEditeur.py | 2 +- UiQT4/OptionsPdf.py | 2 +- UiQT4/aideQT.py | 2 +- UiQT4/desChoixCata.py | 2 +- UiQT4/desCommande.py | 2 +- UiQT4/desCommentaire.py | 2 +- UiQT4/desError.py | 2 +- UiQT4/desFormule.py | 2 +- UiQT4/desInactif.py | 2 +- UiQT4/desInclude.py | 2 +- UiQT4/desListeParam.py | 2 +- UiQT4/desMCFact.py | 2 +- UiQT4/desMCListAjout.py | 2 +- UiQT4/desParam.py | 2 +- UiQT4/desPlusieursBase.py | 2 +- UiQT4/desPlusieursInto.py | 2 +- UiQT4/desPoursuite.py | 2 +- UiQT4/desRacine.py | 2 +- UiQT4/desSelectVal.py | 2 +- UiQT4/desUniqueASSD.py | 2 +- UiQT4/desUniqueBase.py | 2 +- UiQT4/desUniqueComp.py | 2 +- UiQT4/desUniqueInto.py | 2 +- UiQT4/desUniqueSDCO.py | 2 +- UiQT4/desUniqueSDCOInto.py | 2 +- UiQT4/desViewTexte.py | 2 +- UiQT4/desVisu.py | 2 +- UiQT4/myMain.py | 2 +- generator/OpenturnsBase.py | 11 +- generator/OpenturnsSTD.py | 332 ++++++++++------ generator/OpenturnsXML.py | 7 +- generator/generator_python.py | 19 +- 52 files changed, 1261 insertions(+), 319 deletions(-) create mode 100644 Accas/A_AVANT.py create mode 100644 Aster/configuration_ASTER.py create mode 100644 Aster/prefs_ASTER.py create mode 100644 Editeur/analyse_catalogue_initial.py create mode 100644 Ihm/I_AVANT.py create mode 100644 Openturns_Study/configuration_OPENTURNS_STUDY.py create mode 100644 Openturns_Study/opsOT.py create mode 100644 Openturns_Study/prefs_OPENTURNS_STUDY.py diff --git a/Accas/A_AVANT.py b/Accas/A_AVANT.py new file mode 100644 index 00000000..35f4741c --- /dev/null +++ b/Accas/A_AVANT.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +from Noyau import N_REGLE +from Ihm import I_REGLE, I_AVANT + +class AVANT(I_AVANT.I_AVANT,I_REGLE.REGLE,N_REGLE.REGLE): + """ + La classe utilise l'initialiseur de REGLE. Il n'est pas + nécessaire d'expliciter son initialiseur car + I_AVANT.I_AVANT n'en a pas + """ diff --git a/Accas/__init__.py b/Accas/__init__.py index 67de064c..324ed712 100644 --- a/Accas/__init__.py +++ b/Accas/__init__.py @@ -65,6 +65,7 @@ from A_PRESENT_ABSENT import PRESENT_ABSENT from A_EXCLUS import EXCLUS from A_ENSEMBLE import ENSEMBLE from A_A_CLASSER import A_CLASSER +from A_AVANT import AVANT from A_ASSD import ASSD,assd from A_ASSD import GEOM,geom @@ -83,7 +84,7 @@ from A_VALIDATOR import OrVal,AndVal from A_VALIDATOR import OrdList,NoRepeat,LongStr,Compulsory from A_VALIDATOR import RangeVal, EnumVal, TypeVal, PairVal from A_VALIDATOR import CardVal, InstanceVal -#from A_VALIDATOR import VerifTypeTuple +from A_VALIDATOR import VerifTypeTuple # On remplace la factory des validateurs initialement dans Noyau par celle # de A_VALIDATOR diff --git a/Aster/configuration_ASTER.py b/Aster/configuration_ASTER.py new file mode 100644 index 00000000..3894373f --- /dev/null +++ b/Aster/configuration_ASTER.py @@ -0,0 +1,361 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +""" + Ce module sert pour charger les paramètres de configuration d'EFICAS +""" +# Modules Python +import os, sys, string, types, re +import traceback + + +# Modules Eficas +from Editeur import utils + +class CONFIGbase: + + #----------------------------------- + def __init__(self,appli): + #----------------------------------- + + # Classe de base permettant de lire, afficher + # et sauvegarder les fichiers utilisateurs editeur.ini + # et style.py + # Classe Mere de : class CONFIG(CONFIGbase) + # class CONFIGStyle(CONFIGbase): + self.appli = appli + self.salome = appli.salome + self.dRepMat={} + if self.appli: + self.parent=appli.top + else: + self.parent=None + self.rep_user = utils.get_rep_user() + self.lecture_fichier_ini_standard() + self.lecture_catalogues_standard() + self.lecture_fichier_ini_utilisateur() + self.init_liste_param() + + #-------------------------------------- + def lecture_fichier_ini_standard(self): + #-------------------------------------- + # Verifie l'existence du fichier "standard" + # appelle la lecture de ce fichier + if not os.path.isfile(self.fic_ini): + if self.appli.ihm=="TK" : + from widgets import showerror + showerror("Erreur","Pas de fichier de configuration" + self.fic_ini+"\n") + print "Erreur à la lecture du fichier de configuration : %s" % self.fic_ini + sys.exit(0) + self.lecture_fichier(self.fic_ini) + + #----------------------------- + def lecture_fichier(self,fic): + #------------------------------ + # lit les paramètres du fichier eficas.ini ou style.py + # les transforme en attribut de l 'objet + # utilisation du dictionnaire local pour récuperer style + txt = utils.read_file(fic) + from styles import style + d=locals() + try: + exec txt in d + except: + l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) + if self.appli.ihm=="TK" : + from widgets import showerror + showerror("Erreur","Une erreur s'est produite lors de la lecture du fichier : " + fic + "\n") + print ("Erreur","Une erreur s'est produite lors de la lecture du fichier : " + fic + "\n") + sys.exit() + + for k in d.keys() : + if k in self.labels.keys() : + setattr(self,k,d[k]) + # Glut horrible pour les repertoires materiau... + elif k[0:9]=="rep_mat_v" : + setattr(self,k,d[k]) + + for k in d['style'].__dict__.keys() : + setattr(self,k,d['style'].__dict__[k]) + + if hasattr(self,"catalogues") : + for ligne in self.catalogues : + version=ligne[1] + codeSansPoint=re.sub("\.","",version) + chaine="rep_mat_"+codeSansPoint + if hasattr(self,chaine): + rep_mat=getattr(self,chaine) + self.dRepMat[version]=str(rep_mat) + + + #-------------------------------------- + def lecture_fichier_ini_utilisateur(self): + #-------------------------------------- + # Surcharge les paramètres standards par les paramètres utilisateur s'ils existent + self.fic_ini_utilisateur = os.path.join(self.rep_user,self.fichier) + if not os.path.isfile(self.fic_ini_utilisateur): + return + self.lecture_fichier(self.fic_ini_utilisateur) + + #-------------------------------------- + def lecture_catalogues_standard(self): + #-------------------------------------- + # repertoires Materiau + if hasattr(self,"catalogues") : + for ligne in self.catalogues : + version=ligne[1] + cata=ligne[2] + self.dRepMat[version]=os.path.join(cata,'materiau') + + #-------------------------------------- + def affichage_fichier_ini(self): + #-------------------------------------- + """ + Affichage des valeurs des paramètres relus par Eficas + """ + import widgets + result = widgets.Formulaire(self.parent, + obj_pere = self, + titre = self.titre, + texte = self.texte_ini, + items = self.l_param, + mode='display', + commande=('Modifier',self.commande)) + if result.resultat : + #print 'on sauvegarde les nouveaux paramètres :',result.resultat + self.save_param_ini(result.resultat) + + #-------------------------------------- + def save_param_ini(self,dico): + #-------------------------------------- + # sauvegarde + # les nouveaux paramètres dans le fichier de configuration utilisateur + # + f=open(self.fic_ini_utilisateur,'w+') + for k,v in dico.items(): + if self.types[k] in ('mot2','mot3','mot4'): + v1=v[1:-1] + val=v1.split(",") + p = "(" + listeval="" + for valeur in val: + listeval = listeval+ p + str(valeur) + p=" , " + listeval = listeval + ")" + f.write(str(self.pref)+str(k) + '=' + str(listeval) + '\n') + elif k == 'catalogues' : + f.write(k + '\t=\t' + str(v) + '\n') + else: + f.write(str(self.pref)+str(k) + '\t=\t"' + str(v) + '"\n') + f.close() + self.lecture_fichier_ini_utilisateur() + + #------------------------------------------- + def creation_fichier_ini_si_possible(self): + #------------------------------------------- + return self.creation_fichier_ini(mode='ignorer_annuler') + + #-------------------------------------------------------- + def creation_fichier_ini(self,mode='considerer_annuler'): + #--------------------------------------------------------- + # Récupération des valeurs des paramétres requis pour la création du fichier + # eficas.ini + # + import widgets + items = self.l_param + result = widgets.Formulaire(self.parent, + obj_pere = self, + titre = "Saisie des donnees indispensables a la configuration d'EFICAS", + texte = self.texte, + items = items, + mode='query') + if not result.resultat : + if mode == 'considerer_annuler': + test=0 + if self.appli.ihm=="TK" : + from widgets import showerror,askretrycancel + test = askretrycancel("Erreur","Données incorrectes !") + if not test: + # XXX On sort d'EFICAS, je suppose + self.appli.exitEFICAS() + else: + self.creation_fichier_ini() + else: + return None + else : + self.save_param_ini(result.resultat) + return result.resultat + + #-------------------------- + def init_liste_param (self): + #-------------------------- + # construit self.l_param + # a partir de self.labels et des attributs + # de l objet (mis a jour lors de la lecture du fichier) + # l_param est une liste de tuples où chaque tuple est de la forme : + # (label,nature,nom_var,defaut) + + self.l_param=[] + for k in self.labels.keys() : + if hasattr(self,k) : + if k in self.YesNo.keys(): + self.l_param.append((self.labels[k],self.types[k],k,self.__dict__[k], + self.YesNo[k][0],self.YesNo[k][1])) + else : + self.l_param.append((self.labels[k],self.types[k],k,self.__dict__[k])) + self.l_param = tuple(self.l_param) + + +class CONFIG(CONFIGbase): + def __init__(self,appli,repIni): + + self.dFichierEditeur={"ASTER" : "editeur.ini", + "ASTER_SALOME" : "editeur_salome.ini"} + self.texte = "EFICAS a besoin de certains renseignements pour se configurer\n"+\ + "Veuillez remplir TOUS les champs ci-dessous et appuyer sur 'Valider'\n"+\ + "Si vous annulez, EFICAS ne se lancera pas !!" + + self.salome=appli.salome + self.code=appli.code + clef=self.code + if self.salome != 0 : + clef = clef + "_SALOME" + self.fichier=self.dFichierEditeur[clef] + self.repIni = repIni + self.rep_ini = repIni + self.fic_ini = os.path.join(self.repIni,self.fichier) + self.titre = 'Parametres necessaires a la configuration d\'EFICAS' + self.texte_ini = "Voici les paramètres que requiert Eficas" + self.commande = self.creation_fichier_ini_si_possible + self.labels={"savedir" : "Répertoire initial pour Open/Save des fichiers", + "rep_travail" : "Répertoire de travail", + "rep_mat" : "Répertoire materiaux", + "path_doc" : "Chemin d'accès à la doc Aster", + "exec_acrobat" : "Ligne de commande Acrobat Reader", + "catalogues" : "Versions du code ", + "isdeveloppeur" : "Niveau de message ", + "path_cata_dev" : "Chemin d'accès aux catalogues développeurs"} + + + self.types ={"savedir":"rep", "rep_travail":"rep","rep_mat":"rep", + "path_doc": "rep","exec_acrobat":"file","exec_acrobat":"file", + "catalogues" :"cata","isdeveloppeur":"YesNo","path_cata_dev":"rep", + "DTDDirectory":"rep"} + + self.YesNo={} + self.YesNo['isdeveloppeur']=('Deboggage','Utilisation') + + # Valeurs par defaut + self.rep_user = utils.get_rep_user() + self.initialdir=self.rep_user + self.savedir = os.environ['HOME'] + self.rep_travail=os.path.join(self.rep_user,'uaster','tmp_eficas') + self.rep_mat="" + self.path_doc=self.rep_user + self.exec_acrobat=self.rep_user + self.isdeveloppeur='NON' + self.path_cata_dev=os.path.join(self.rep_user,'cata') + CONFIGbase.__init__ (self,appli) + self.pref="" + + #-------------------------------------- + def save_params(self): + #-------------------------------------- + # sauvegarde + # les nouveaux paramètres dans le fichier de configuration utilisateur + # + l_param=('exec_acrobat', 'repIni','catalogues','rep_travail','rep_mat','path_doc','savedir') + texte="" + for clef in l_param : + if hasattr(self,clef): + valeur=getattr(self,clef) + texte= texte + clef+" = " + repr(valeur) +"\n" + + + # recuperation des repertoires materiaux + try : + for item in self.catalogues : + try : + (code,version,cata,format,defaut)=item + except : + (code,version,cata,format)=item + codeSansPoint=re.sub("\.","",version) + chaine="rep_mat_"+codeSansPoint + if hasattr(self,chaine): + valeur=getattr(self,chaine) + texte= texte + chaine+" = '" + str(valeur) +"'\n" + except : + pass + + f=open(self.fic_ini_utilisateur,'w+') + f.write(texte) + f.close() + + +class CONFIGStyle(CONFIGbase): + def __init__(self,appli,repIni): + self.salome=appli.salome + self.texte = "Pour prendre en compte les modifications \n"+\ + " RELANCER EFICAS" + self.fichier="style.py" + self.repIni = repIni + self.rep_ini = repIni + self.fic_ini = os.path.join(self.repIni,self.fichier) + self.titre = "Parametres d affichage" + self.texte_ini = "Voici les paramètres configurables : " + self.commande = self.creation_fichier_ini_si_possible + self.labels={"background":"couleur du fonds", + "foreground":"couleur de la police standard" , + "standard":" police et taille standard", + "standard_italique":"police utilisée pour l'arbre ", + "standard_gras_souligne":"police utilisée pour le gras souligné", + "canvas_italique":"police italique", + "standard_gras":"gras", + } + self.types ={"background":"mot", + "foreground":"mot" , + "standard":"mot2", + "standard_italique":"mot3", + "standard_gras":"mot3", + "standard_gras_souligne":"mot4", + "canvas":"mot2", + "canvas_italique":"mot3", + "canvas_gras":"mot3", + "canvas_gras_italique":"mot4", + "standard12":"mot2", + "standard12_gras":"mot3", + "standard12_gras_italique":"mot4", + "statusfont":"mot2", + "standardcourier10":"mot2"} + self.YesNo={} + self.l_param=[] + CONFIGbase.__init__ (self,appli) + self.pref="style." + + def affichage_style_ini(self): + self.affichage_fichier_ini() + +def make_config(appli,rep): + return CONFIG(appli,rep) + +def make_config_style(appli,rep): + return CONFIGStyle(appli,rep) + + diff --git a/Aster/editeur.ini b/Aster/editeur.ini index bc1df286..b33e6d4a 100644 --- a/Aster/editeur.ini +++ b/Aster/editeur.ini @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # CONFIGURATION MANAGEMENT OF EDF VERSION # ====================================================================== # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG @@ -17,31 +18,30 @@ # # # ====================================================================== - import os -from Aster import prefs - -rep_cata = os.path.join(prefs.REPINI,'Cata') -rep_Pmw = os.path.join(prefs.REPINI,'../Pmw') +# Répertoire initial +#initialdir=os.curdir +from prefs_ASTER import REPINI +initialdir=prefs_ASTER.REPINI +rep_cata = os.path.join(initialdir,'Cata') +rep_Pmw = os.path.join(initialdir,'../Pmw') # Accès à la documentation Aster path_doc = os.path.join(rep_cata,'..','Doc') -exec_acrobat = "/usr/bin/xpdf" +exec_acrobat = "acroread" + # Utilisateur/Développeur isdeveloppeur = "NON" path_cata_dev = "/tmp/cata" # Répertoire temporaire rep_travail = "/tmp" -# Répertoire initial -initialdir=os.curdir # Choix des catalogues rep_mat_v88=os.path.join(rep_cata,'cataSTA8','materiau') rep_mat_v95=os.path.join(rep_cata,'cataSTA9','materiau') - -catalogues = ( - ('ASTER','v8.8',os.path.join(rep_cata,'cataSTA8'),'python'), - ('ASTER','v9.5',os.path.join(rep_cata,'cataSTA9'),'python','defaut'), - ) - +# +catalogues=( +('ASTER','v8.8',os.path.join(rep_cata,'cataSTA8'),'python'), +('ASTER','v9.5',os.path.join(rep_cata,'cataSTA9'),'python','defaut'), +) diff --git a/Aster/editeur_salome.ini b/Aster/editeur_salome.ini index bc1df286..c140195b 100644 --- a/Aster/editeur_salome.ini +++ b/Aster/editeur_salome.ini @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # CONFIGURATION MANAGEMENT OF EDF VERSION # ====================================================================== # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG @@ -17,31 +18,30 @@ # # # ====================================================================== - import os -from Aster import prefs - -rep_cata = os.path.join(prefs.REPINI,'Cata') -rep_Pmw = os.path.join(prefs.REPINI,'../Pmw') +# Répertoire initial +#initialdir=os.curdir +from prefs_ASTER import REPINI +initialdir=REPINI +rep_cata = os.path.join(initialdir,'Cata') +rep_Pmw = os.path.join(initialdir,'../Pmw') # Accès à la documentation Aster path_doc = os.path.join(rep_cata,'..','Doc') -exec_acrobat = "/usr/bin/xpdf" +exec_acrobat = "acroread" + # Utilisateur/Développeur isdeveloppeur = "NON" path_cata_dev = "/tmp/cata" # Répertoire temporaire rep_travail = "/tmp" -# Répertoire initial -initialdir=os.curdir # Choix des catalogues rep_mat_v88=os.path.join(rep_cata,'cataSTA8','materiau') rep_mat_v95=os.path.join(rep_cata,'cataSTA9','materiau') - -catalogues = ( - ('ASTER','v8.8',os.path.join(rep_cata,'cataSTA8'),'python'), - ('ASTER','v9.5',os.path.join(rep_cata,'cataSTA9'),'python','defaut'), - ) - +# +catalogues=( +('ASTER','v8.8',os.path.join(rep_cata,'cataSTA8'),'python'), +('ASTER','v9.5',os.path.join(rep_cata,'cataSTA9'),'python','defaut'), +) diff --git a/Aster/prefs.py b/Aster/prefs.py index 5786a287..484e857c 100644 --- a/Aster/prefs.py +++ b/Aster/prefs.py @@ -1,115 +1 @@ -# -*- coding: utf-8 -*- -# CONFIGURATION MANAGEMENT OF EDF VERSION -# ====================================================================== -# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG -# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY -# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY -# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR -# (AT YOUR OPTION) ANY LATER VERSION. -# -# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT -# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF -# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU -# GENERAL PUBLIC LICENSE FOR MORE DETAILS. -# -# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE -# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, -# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. -# -# -# ====================================================================== - -import os,sys - -# REPINI sert à localiser le fichier editeur.ini -# Obligatoire -REPINI=os.path.dirname(os.path.abspath(__file__)) -repIni=REPINI - -# INSTALLDIR sert à localiser l'installation d'Eficas -# Obligatoire -INSTALLDIR=os.path.join(REPINI,'..') - -# CODE_PATH sert à localiser Noyau et Validation éventuellement -# non contenus dans la distribution EFICAS -# Par défaut on utilise les modules de INSTALLDIR -# Peut valoir None (defaut) -CODE_PATH = None - -# la variable code donne le nom du code a selectionner code="ASTER" - -# lang indique la langue utilisée pour les chaines d'aide : fr ou ang -lang='fr' - -# Codage des strings qui accepte les accents (en remplacement de 'ascii') -encoding='iso-8859-1' - - -EditeurDir=INSTALLDIR+"/Editeur" -sys.path[:0]=[INSTALLDIR] - -ICONDIR=os.path.join(INSTALLDIR,'Editeur','icons') - -# Preference -if os.name == 'nt': - userprefs = os.sep.join( [ os.environ['HOMEDRIVE'], os.environ['HOMEPATH'], 'Eficas_install', 'prefs.py' ]) -else : - userprefs=os.path.expanduser("~/.Eficas_install/prefs.py") - -if os.path.isfile(userprefs): - try: - execfile(userprefs) - except: - pass - - -#------------------------------------------------------------------- -# Partie pour TK -#------------------------------------------------------------------- - -labels= ('Fichier','Edition','Jeu de commandes', - 'Options', - 'Aide', - 'Traduction', - ) - -appli_composants=['readercata','bureau', - 'options', - ] - -menu_defs={ 'bureau': [ - ('Fichier',[ - ('Nouveau','newJDC','','Ctrl+N'), - ('Nouvel INCLUDE','newJDC_include'), - ('Ouvrir','openJDC','','Ctrl+O'), - ('Enregistrer','saveJDC','','Ctrl+S'), - ('Enregistrer sous','saveasJDC','','Ctrl+E'), - None, - ('Fermer','closeJDC','','Ctrl+W'), - ('Quitter','exitEFICAS','','Ctrl+Q'), - ] - ), - ('Edition',[ - ('Copier','copy','','Ctrl+C'), - ('Couper','cut','','Ctrl+X'), - ('Coller','paste','','Ctrl+V'), - ] - ), - ('Jeu de commandes',[ - ('Rapport de validation','visuCRJDC','','Ctrl+R'), - ('Fichier source','visu_txt_brut_JDC','','Ctrl+B'), - #('Paramètres Eficas','affichage_fichier_ini'), - ] - ), - ('Traduction',[ - ('Traduction v7 en v8','TraduitFichier7'), - ('Traduction v8 en v9','TraduitFichier8','','Ctrl+T'), - ] - ), - ('Aide',[ - ('Aide EFICAS','aideEFICAS','','Ctrl+A'), - ] - ), - ] - } diff --git a/Aster/prefs_ASTER.py b/Aster/prefs_ASTER.py new file mode 100644 index 00000000..46c9e9c8 --- /dev/null +++ b/Aster/prefs_ASTER.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== + +import os,sys + +# REPINI sert à localiser le fichier editeur.ini +# Obligatoire +REPINI=os.path.dirname(os.path.abspath(__file__)) +repIni=REPINI + +# INSTALLDIR sert à localiser l'installation d'Eficas +# Obligatoire +INSTALLDIR=os.path.join(REPINI,'..') + +# CODE_PATH sert à localiser Noyau et Validation éventuellement +# non contenus dans la distribution EFICAS +# Par défaut on utilise les modules de INSTALLDIR +# Peut valoir None (defaut) +CODE_PATH = None + +# lang indique la langue utilisée pour les chaines d'aide : fr ou ang +lang='fr' + +# Codage des strings qui accepte les accents (en remplacement de 'ascii') +encoding='iso-8859-1' + + +EditeurDir=INSTALLDIR+"/Editeur" +sys.path[:0]=[INSTALLDIR] + +ICONDIR=os.path.join(INSTALLDIR,'Editeur','icons') + +# Preference +if os.name == 'nt': + userprefs = os.sep.join( [ os.environ['HOMEDRIVE'], os.environ['HOMEPATH'], 'Eficas_install', 'prefs.py' ]) +else : + userprefs=os.path.expanduser("~/.Eficas_install/prefs.py") + +if os.path.isfile(userprefs): + try: + execfile(userprefs) + except: + pass + + +#------------------------------------------------------------------- +# Partie pour TK +#------------------------------------------------------------------- + +labels= ('Fichier','Edition','Jeu de commandes', + 'Options', + 'Aide', + 'Traduction', + ) + +appli_composants=['readercata','bureau', + 'options', + ] + +menu_defs={ 'bureau': [ + ('Fichier',[ + ('Nouveau','newJDC','','Ctrl+N'), + ('Nouvel INCLUDE','newJDC_include'), + ('Ouvrir','openJDC','','Ctrl+O'), + ('Enregistrer','saveJDC','','Ctrl+S'), + ('Enregistrer sous','saveasJDC','','Ctrl+E'), + None, + ('Fermer','closeJDC','','Ctrl+W'), + ('Quitter','exitEFICAS','','Ctrl+Q'), + ] + ), + ('Edition',[ + ('Copier','copy','','Ctrl+C'), + ('Couper','cut','','Ctrl+X'), + ('Coller','paste','','Ctrl+V'), + ] + ), + ('Jeu de commandes',[ + ('Rapport de validation','visuCRJDC','','Ctrl+R'), + ('Fichier source','visu_txt_brut_JDC','','Ctrl+B'), + #('Paramètres Eficas','affichage_fichier_ini'), + ] + ), + ('Traduction',[ + ('Traduction v7 en v8','TraduitFichier7'), + ('Traduction v8 en v9','TraduitFichier8','','Ctrl+T'), + ] + ), + ('Aide',[ + ('Aide EFICAS','aideEFICAS','','Ctrl+A'), + ] + ), + ] + } diff --git a/Aster/qtEficas_aster.py b/Aster/qtEficas_aster.py index cf2dbf0e..a779bfcb 100755 --- a/Aster/qtEficas_aster.py +++ b/Aster/qtEficas_aster.py @@ -27,7 +27,10 @@ # Modules Eficas import prefs -#from InterfaceQT4 import eficas_go -from InterfaceQT import eficas_go +name='prefs_'+prefs.code +__import__(name) + +import sys +from InterfaceQT4 import eficas_go eficas_go.lance_eficas(code=prefs.code) diff --git a/Editeur/analyse_catalogue_initial.py b/Editeur/analyse_catalogue_initial.py new file mode 100644 index 00000000..8def014b --- /dev/null +++ b/Editeur/analyse_catalogue_initial.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +from string import split,strip,lowercase,uppercase +import re,string,os + + +# +__Id__="$Id: analyse_catalogue.py,v 1.7.4.1 2008-11-13 10:35:11 cchris Exp $" +__version__="$Name: BR_dev_V1_15 $" +# + + +class Catalogue_initial: + def __init__(self,fichier): + self.liste_commandes=[] + self.lignes=[] + self.fichier=fichier + self.ouvrir_fichier() + self.constr_list_txt_cmd() + + def ouvrir_fichier(self): + try : + f=open(self.fichier,'r') + self.lignes=f.readlines() + f.close() + except : + print "Impossible d'ouvrir le fichier :",self.fichier + + def constr_list_txt_cmd(self): + pattern = '^# Ordre Catalogue ' + for i in self.lignes : + if (re.search(pattern,i)): + i=i.replace('# Ordre Catalogue ','') + i=i.replace('\n','') + self.liste_commandes.append(i) + + +def analyse_catalogue(nom_cata): + cata = Catalogue_initial(nom_cata) + return cata.liste_commandes + + +if __name__ == "__main__" : + monCata="/home/noyret/Install_Eficas/EficasQT4/Openturns_StudyOpenTURNS_Cata_Study_V4.py" + analyse_catalogue(monCata) + + + + + + + + + + + + + diff --git a/Editeur/comploader.py b/Editeur/comploader.py index b20bfa9f..ba43dbfb 100644 --- a/Editeur/comploader.py +++ b/Editeur/comploader.py @@ -49,8 +49,10 @@ def charger_composants(Ihm="TK"): repertoire=reper+"/../InterfaceTK" package="InterfaceTK" else : - repertoire=reper+"/../InterfaceQT" - package="InterfaceQT" + repertoire=reper+"/../InterfaceQT4" + package="InterfaceQT4" + #repertoire=reper+"/../InterfaceQT" + #package="InterfaceQT" listfich=glob.glob(os.path.join(repertoire, "compo*.py")) for fichier in listfich: m= os.path.basename(fichier)[:-3] diff --git a/Editeur/import_code.py b/Editeur/import_code.py index 3d34eaa6..b4c24b70 100644 --- a/Editeur/import_code.py +++ b/Editeur/import_code.py @@ -26,26 +26,30 @@ import sys import os import prefs +name='prefs_'+prefs.code +prefs_Code=__import__(name) -INSTALLDIR=prefs.INSTALLDIR +INSTALLDIR=prefs_Code.INSTALLDIR sys.path.append(INSTALLDIR) -sys.path.append(INSTALLDIR+"/Ui") -sys.path.append(INSTALLDIR+"/InterfaceQT") +sys.path.append(INSTALLDIR+"/UiQT4") +sys.path.append(INSTALLDIR+"/InterfaceQT4") +#sys.path.append(INSTALLDIR+"/Ui") +#sys.path.append(INSTALLDIR+"/InterfaceQT") sys.path.append(INSTALLDIR+"/Editeur") # Ce chemin permet d'importer les modules Noyau et Validation # représentant le code utilisé (si fourni) # Ensuite on utilise les packages de l'intallation -if hasattr(prefs,'CODE_PATH'): - if prefs.CODE_PATH: - sys.path[:0]=[prefs.CODE_PATH] +if hasattr(prefs_Code,'CODE_PATH'): + if prefs_Code.CODE_PATH: + sys.path[:0]=[prefs_Code.CODE_PATH] import Noyau,Validation del sys.path[0] -sys.path[:0]=[prefs.INSTALLDIR] +sys.path[:0]=[prefs_Code.INSTALLDIR] # Ensuite on surcharge eventuellement -#if hasattr(prefs,'CODE_PATH_SURCHARGE'): -# if prefs.CODE_PATH_SURCHARGE: -# sys.path.insert(0,prefs.CODE_PATH_SURCHARGE) +#if hasattr(prefs_Code,'CODE_PATH_SURCHARGE'): +# if prefs_Code.CODE_PATH_SURCHARGE: +# sys.path.insert(0,prefs_Code.CODE_PATH_SURCHARGE) import Accas diff --git a/Editeur/listePatrons.py b/Editeur/listePatrons.py index 19f81ef5..62aa70fe 100644 --- a/Editeur/listePatrons.py +++ b/Editeur/listePatrons.py @@ -6,7 +6,8 @@ sous_menus={"ASTER" : {0:{"3D":"3D.comm"},1:{"poutre":"pou.comm"},2:{"salome":"s "OPENTURNS_WRAPPER" : {0:{"Anne":"wrapper_exemple.comm"}}, "HOMARD" : {}, "CUVE2DG" : {}, - 'SEP' : {} + 'SEP' : {}, + 'SIK' : {} } class listePatrons : diff --git a/Editeur/styles.py b/Editeur/styles.py index 2d5fc4a2..9d1265a3 100644 --- a/Editeur/styles.py +++ b/Editeur/styles.py @@ -1,10 +1,12 @@ # -*- coding: utf-8 -*- import os import prefs +name='prefs_'+prefs.code +prefsCode=__import__(name) import basestyle from basestyle import STYLE,style -inistylefile=os.path.join(prefs.REPINI,"style.py") +inistylefile=os.path.join(prefsCode.REPINI,"style.py") if os.path.isfile(inistylefile): execfile(inistylefile) diff --git a/Ihm/I_AVANT.py b/Ihm/I_AVANT.py new file mode 100644 index 00000000..f3a4678e --- /dev/null +++ b/Ihm/I_AVANT.py @@ -0,0 +1,78 @@ +#@ MODIF V_AU_MOINS_UN Validation DATE 14/09/2004 AUTEUR PNOYRET +# -*- coding: iso-8859-1 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== + +import types + + +class I_AVANT: + """ + La règle I_AVANT vérifie que l'on trouve l ordre des mots-clés + de la règle parmi les arguments d'un JDC. + + Ces arguments sont transmis à la règle pour validation sous la forme + d'une liste de noms de mots-clés ou d'un dictionnaire dont + les clés sont des noms de mots-clés. + """ + + def __init__(self,*args): + if len(args) > 2 : + print "Erreur à la création de la règle A_CLASSER(",args,")" + return + if type(args[0]) == types.TupleType: + self.listeAvant=args[0] + else : + self.listeAvant=(args[0],) + if type(args[1]) == types.TupleType: + self.listeApres=args[1] + else : + self.listeApres=(args[1],) + + def verif(self,args): + """ + args peut etre un dictionnaire ou une liste. Les éléments de args + sont soit les éléments de la liste soit les clés du dictionnaire. + """ + # on compte le nombre de mots cles presents + text ='' + boolListeAvant=0 + boolListeApres=0 + boolOK=1 + for nom in args: + if nom in self.listeAvant : + boolListeAvant=1 + if boolListeApres == 1 : + boolOK = 0 + if nom in self.listeApres : + boolListeApres=1 + if boolListeAvant == 0 and boolListeApres == 1 : boolOK = 0 + return text,boolOK + + + def gettext(self): + text = "Regle de classement "' :\n' + for mc in self.listeAvant : + text = text + mc + ', ' + text = text + " \nAvant : \n" + for mc in self.listeApres : + text = text + mc + ',' + return text + diff --git a/InterfaceQT4/componiveau.py b/InterfaceQT4/componiveau.py index 3b9539b0..78f9a8ff 100644 --- a/InterfaceQT4/componiveau.py +++ b/InterfaceQT4/componiveau.py @@ -25,11 +25,15 @@ class NIVEAUTreeItem(Objecttreeitem.ObjectTreeItem): def GetLabelText(self): """ Retourne 3 valeurs : - - le texte à afficher dans le noeud représentant l'item + - le texte a afficher dans le noeud représentant l'item - la fonte dans laquelle afficher ce texte - la couleur du texte """ - return self.labeltext,None,None + if self.isactif(): + fonte = Fonte_Niveau + else : + fonte = Fonte_Niveau_inactif + return self.labeltext,fonte,None def GetIconName(self): if self.isactif(): diff --git a/InterfaceQT4/monMCListAjoutPanel.py b/InterfaceQT4/monMCListAjoutPanel.py index 8be5fd7c..475a51f1 100644 --- a/InterfaceQT4/monMCListAjoutPanel.py +++ b/InterfaceQT4/monMCListAjoutPanel.py @@ -62,6 +62,7 @@ class MonMCListAjoutPanel(DMCListAjout,QTPanel): self.connecterSignaux() def connecterSignaux(self): + self.connect(self.BOk,SIGNAL("clicked()"),self.BAjoutClicked) self.connect(self.bAjout,SIGNAL("clicked()"),self.BAjoutClicked) diff --git a/InterfaceQT4/monUniqueBasePanel.py b/InterfaceQT4/monUniqueBasePanel.py index b57e5141..b18f23a7 100644 --- a/InterfaceQT4/monUniqueBasePanel.py +++ b/InterfaceQT4/monUniqueBasePanel.py @@ -103,7 +103,9 @@ class MonUniqueBasePanel(DUnBase,QTPanel,SaisieValeur): mc = self.node.item.get_definition() d_aides = { 'TXM' : "Une chaîne de caractères est attendue", 'R' : "Un réel est attendu", - 'I' : "Un entier est attendu"} + 'I' : "Un entier est attendu", + 'Matrice' : 'Une Matrice est attendue', + 'Fichier' : 'Un fichier est attendu'} type = mc.type[0] commentaire=d_aides.get(type,"Type de base inconnu") aideval=self.node.item.aide() diff --git a/Openturns_Study/configuration_OPENTURNS_STUDY.py b/Openturns_Study/configuration_OPENTURNS_STUDY.py new file mode 100644 index 00000000..b4022a16 --- /dev/null +++ b/Openturns_Study/configuration_OPENTURNS_STUDY.py @@ -0,0 +1,196 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== +""" + Ce module sert pour charger les paramètres de configuration d'EFICAS +""" +# Modules Python +print "passage dans la surcharge de configuration pour OTW" +import os, sys, string, types, re +import traceback +from PyQt4.QtGui import * + +# Modules Eficas +from Editeur import utils + +class CONFIG: + + #----------------------------------- + def __init__(self,appli,repIni): + #----------------------------------- + + # Classe de base permettant de lire, afficher + # et sauvegarder les fichiers utilisateurs + # On a deux directories : la directory generale (Repertoire d instal + Nom du code + # Par exemple : ~/Install_Eficas/EficasV1_14/Openturns_Wrapper + # et la directorie de l utilisateur + # HOME/.Eficas_Openturns + # Le fichier prefs.py va etre lu dans la directory generale puis surcharge eventuellement + # par celui de l utilisateur + # le fichier de catalogue va etre lu dans la directory de l utilisateur s il exite + # dans le fichier general sinon + self.appli = appli + self.code = appli.code + self.salome = appli.salome + self.repIni = repIni + + self.fic_prefs ="prefs.py" + + if self.appli: + self.parent=appli.top + self.appli.mode_nouv_commande='initial' + else: self.parent=None + + + self.labels=("OpenTURNS_path","rep_user","INSTALLDIR","path_doc","exec_acrobat","rep_cata","initialdir","savedir") + + # Valeurs par defaut + self.rep_user = os.path.join(os.environ['HOME'],'.Eficas_Openturns') + self.initialdir = self.rep_user + self.path_doc = self.rep_user + self.savedir = self.rep_user + self.exec_acrobat = self.rep_user + + #Lecture des fichiers utilisateurs + self.lecture_fichier_ini_standard() + self.lecture_fichier_ini_utilisateur() + self.lecture_catalogues() + + #-------------------------------------- + def lecture_fichier_ini_standard(self): + #-------------------------------------- + # Verifie l'existence du fichier "standard" + # appelle la lecture de ce fichier + self.fic_ini = os.path.join(self.repIni,self.fic_prefs) + if not os.path.isfile(self.fic_ini): + QMessageBox.critical( None, "Import du fichier de Configuration", + "Erreur à la lecture du fichier de configuration "+self.fic_ini+".py" ) + sys.exit(0) + import prefs + name='prefs_'+prefs.code + prefsCode=__import__(name) + for k in self.labels : + try : + valeur=getattr(prefsCode,k) + setattr(self,k,valeur) + except : + pass + + + #-------------------------------------- + def lecture_fichier_ini_utilisateur(self): + #-------------------------------------- + # Surcharge les paramètres standards par les paramètres utilisateur s'ils existent + self.fic_ini_utilisateur = os.path.join(self.rep_user,self.fic_prefs) + #if not os.path.isfile(self.fic_ini_utilisateur+".py"): + if not os.path.isfile(self.fic_ini_utilisateur): + return + from utils import read_file + txt = utils.read_file(self.fic_ini_utilisateur) + from styles import style + d=locals() + try: + exec txt in d + except : + l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) + QMessageBox.critical( None, "Import du fichier de Configuration", + "Erreur à la lecture du fichier de configuration " + self.fic_ini_utilisateur ) + sys.exit(0) + for k in self.labels : + try : + setattr(self,k,d[k]) + except : + pass + + + + #-------------------------------------- + def lecture_catalogues(self): + #-------------------------------------- + rep_mat=" " # Compatbilite Aster + fic_cata ="catalogues_openturns.ini" + fic_ini = os.path.join(self.repIni,fic_cata) + fic_user= os.path.join(self.rep_user,fic_cata) + if os.path.isfile(fic_user): + fichier = fic_user + else : + fichier = fic_ini + if not os.path.isfile(fic_ini) : + QMessageBox.critical( None, "Erreur a l'import du fichier des Catalogues", + "Le fichier de configuration des catalogues "+fic_ini+" n a pas été trouvé" ) + sys.exit(0) + + from utils import read_file + txt = utils.read_file(fichier) + d=locals() + try: + exec txt in d + self.catalogues=d["catalogues"] + except : + l=traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],sys.exc_info()[2]) + QMessageBox.critical( None, "Import du fichier de Configuration", + "Erreur à la lecture du fichier de configuration " + fichier ) + sys.exit(0) + + + + #-------------------------------------- + def save_params(self): + #-------------------------------------- + # sauvegarde + # les nouveaux paramètres dans le fichier de configuration utilisateur + # + print "a ecrire PNPNPN" +# l_param=('exec_acrobat', 'repIni','catalogues','rep_travail','rep_mat','path_doc') +# texte="" +# for clef in l_param : +# if hasattr(self,clef): +# valeur=getattr(self,clef) +# texte= texte + clef+" = " + repr(valeur) +"\n" +# +# +# # recuperation des repertoires materiaux +# try : +# for item in self.catalogues : +# try : +# (code,version,cata,format,defaut)=item +# except : +# (code,version,cata,format)=item +# codeSansPoint=re.sub("\.","",version) +# chaine="rep_mat_"+codeSansPoint +# if hasattr(self,chaine): +# valeur=getattr(self,chaine) +# texte= texte + chaine+" = '" + str(valeur) +"'\n" +# except : +# pass +# +# f=open(self.fic_ini_utilisateur,'w+') +# f.write(texte) +# f.close() +# + + +def make_config(appli,rep): + return CONFIG(appli,rep) + +def make_config_style(appli,rep): + return None + + diff --git a/Openturns_Study/opsOT.py b/Openturns_Study/opsOT.py new file mode 100644 index 00000000..28db9a95 --- /dev/null +++ b/Openturns_Study/opsOT.py @@ -0,0 +1,21 @@ +# -*- coding: iso-8859-1 -*- + +def INCLUDE(self,FileName,**args): + """ + Fonction sd_prod pour la macro INCLUDE + """ + if hasattr(self,'change_fichier'): + delattr(self,'change_fichier') + delattr(self,'fichier_ini') + + self.make_include2(fichier=FileName) + +def INCLUDE_context(self,d): + """ + Fonction op_init pour macro INCLUDE + """ + for k,v in self.g_context.items(): + print "IDM: ops.py k=%s v=%s" % (k,v) + d[k]=v + + diff --git a/Openturns_Study/prefs_OPENTURNS_STUDY.py b/Openturns_Study/prefs_OPENTURNS_STUDY.py new file mode 100644 index 00000000..752aee0d --- /dev/null +++ b/Openturns_Study/prefs_OPENTURNS_STUDY.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# CONFIGURATION MANAGEMENT OF EDF VERSION +# ====================================================================== +# COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG +# THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY +# IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY +# THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR +# (AT YOUR OPTION) ANY LATER VERSION. +# +# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT +# WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU +# GENERAL PUBLIC LICENSE FOR MORE DETAILS. +# +# YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE +# ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER, +# 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE. +# +# +# ====================================================================== + +import os, sys +# Les variables pouvant positionnees sont : +print "import des prefs de OPENTURNS_STUDY" + +# REPINI sert à localiser le fichier +# initialdir sert comme directory initial des QFileDialog +# positionnee a repin au debut mise a jour dans configuration +REPINI=os.path.dirname(os.path.abspath(__file__)) +initialdir=REPINI + +# INSTALLDIR sert à localiser l'installation d'Eficas +INSTALLDIR=os.path.join(REPINI,'..') + + +# Codage des strings qui accepte les accents (en remplacement de 'ascii') +# lang indique la langue utilisée pour les chaines d'aide : fr ou ang +lang='fr' +encoding='iso-8859-1' + +# Acces a la documentation +rep_cata = INSTALLDIR +path_doc = os.path.join(rep_cata,'Doc') +exec_acrobat = "/usr/bin/xpdf" + + +# OpenTURNS Python module +OpenTURNS_path="/opt/OpenTURNS/install/lib/python2.4/site-packages" +# Choix des catalogues +sys.path[:0]=[INSTALLDIR] +sys.path.append( OpenTURNS_path ) + diff --git a/UiQT4/OptionsEditeur.py b/UiQT4/OptionsEditeur.py index f674b1ed..8406bfb0 100644 --- a/UiQT4/OptionsEditeur.py +++ b/UiQT4/OptionsEditeur.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'OptionsEditeur.ui' # -# Created: Fri Apr 24 13:21:13 2009 +# Created: Fri Jun 19 11:40:14 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/OptionsPdf.py b/UiQT4/OptionsPdf.py index d23873c2..9a787aab 100644 --- a/UiQT4/OptionsPdf.py +++ b/UiQT4/OptionsPdf.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'OptionsPdf.ui' # -# Created: Tue Jan 27 12:25:38 2009 +# Created: Fri Jun 19 11:40:14 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/aideQT.py b/UiQT4/aideQT.py index 916f3b9f..617e3ea8 100644 --- a/UiQT4/aideQT.py +++ b/UiQT4/aideQT.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'aideQT.ui' # -# Created: Tue Jan 27 12:25:38 2009 +# Created: Fri Jun 19 11:40:14 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desChoixCata.py b/UiQT4/desChoixCata.py index 4e7eecd6..836caceb 100644 --- a/UiQT4/desChoixCata.py +++ b/UiQT4/desChoixCata.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desChoixCata.ui' # -# Created: Tue Jun 9 14:49:19 2009 +# Created: Fri Jun 19 11:40:11 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desCommande.py b/UiQT4/desCommande.py index 62a7a3db..8787cad4 100644 --- a/UiQT4/desCommande.py +++ b/UiQT4/desCommande.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desCommande.ui' # -# Created: Fri Apr 24 13:21:13 2009 +# Created: Fri Jun 19 11:40:11 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desCommentaire.py b/UiQT4/desCommentaire.py index 4217847c..37791894 100644 --- a/UiQT4/desCommentaire.py +++ b/UiQT4/desCommentaire.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desCommentaire.ui' # -# Created: Fri Apr 24 12:05:46 2009 +# Created: Fri Jun 19 11:40:11 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desError.py b/UiQT4/desError.py index 2fddae4b..d9184275 100644 --- a/UiQT4/desError.py +++ b/UiQT4/desError.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desError.ui' # -# Created: Tue Jan 27 12:25:36 2009 +# Created: Fri Jun 19 11:40:11 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desFormule.py b/UiQT4/desFormule.py index 8eb796ae..13fbad0a 100644 --- a/UiQT4/desFormule.py +++ b/UiQT4/desFormule.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desFormule.ui' # -# Created: Fri Apr 24 14:18:26 2009 +# Created: Fri Jun 19 11:40:11 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desInactif.py b/UiQT4/desInactif.py index a76d9ff7..73b1f04f 100644 --- a/UiQT4/desInactif.py +++ b/UiQT4/desInactif.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desInactif.ui' # -# Created: Thu Mar 12 12:15:36 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desInclude.py b/UiQT4/desInclude.py index d177ab1b..c5564846 100644 --- a/UiQT4/desInclude.py +++ b/UiQT4/desInclude.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desInclude.ui' # -# Created: Thu Mar 12 10:42:30 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desListeParam.py b/UiQT4/desListeParam.py index 2546d4ef..f888d117 100644 --- a/UiQT4/desListeParam.py +++ b/UiQT4/desListeParam.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desListeParam.ui' # -# Created: Tue Jan 27 12:25:36 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desMCFact.py b/UiQT4/desMCFact.py index 32cedf01..d2251c25 100644 --- a/UiQT4/desMCFact.py +++ b/UiQT4/desMCFact.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desMCFact.ui' # -# Created: Thu Mar 12 10:42:30 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desMCListAjout.py b/UiQT4/desMCListAjout.py index afad760f..702a712b 100644 --- a/UiQT4/desMCListAjout.py +++ b/UiQT4/desMCListAjout.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desMCListAjout.ui' # -# Created: Thu Mar 12 10:42:30 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desParam.py b/UiQT4/desParam.py index 6c9bb635..cf666555 100644 --- a/UiQT4/desParam.py +++ b/UiQT4/desParam.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desParam.ui' # -# Created: Fri Apr 24 10:10:36 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desPlusieursBase.py b/UiQT4/desPlusieursBase.py index 3c1d55d7..ab90eb30 100644 --- a/UiQT4/desPlusieursBase.py +++ b/UiQT4/desPlusieursBase.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desPlusieursBase.ui' # -# Created: Fri Apr 24 15:50:34 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desPlusieursInto.py b/UiQT4/desPlusieursInto.py index e26579cd..de7ec9bf 100644 --- a/UiQT4/desPlusieursInto.py +++ b/UiQT4/desPlusieursInto.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desPlusieursInto.ui' # -# Created: Fri Apr 24 15:53:20 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desPoursuite.py b/UiQT4/desPoursuite.py index 590b3058..d5cc8938 100644 --- a/UiQT4/desPoursuite.py +++ b/UiQT4/desPoursuite.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desPoursuite.ui' # -# Created: Thu Mar 12 10:42:31 2009 +# Created: Fri Jun 19 11:40:12 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desRacine.py b/UiQT4/desRacine.py index d0c26ca3..265c067c 100644 --- a/UiQT4/desRacine.py +++ b/UiQT4/desRacine.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desRacine.ui' # -# Created: Thu Apr 23 16:04:23 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desSelectVal.py b/UiQT4/desSelectVal.py index 29a89853..bb1b7923 100644 --- a/UiQT4/desSelectVal.py +++ b/UiQT4/desSelectVal.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desSelectVal.ui' # -# Created: Tue Jan 27 12:25:37 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desUniqueASSD.py b/UiQT4/desUniqueASSD.py index e7da3d8b..097589fe 100644 --- a/UiQT4/desUniqueASSD.py +++ b/UiQT4/desUniqueASSD.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desUniqueASSD.ui' # -# Created: Fri Apr 24 14:45:17 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desUniqueBase.py b/UiQT4/desUniqueBase.py index d88cadb8..beba5d9f 100644 --- a/UiQT4/desUniqueBase.py +++ b/UiQT4/desUniqueBase.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desUniqueBase.ui' # -# Created: Fri Apr 24 14:36:52 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desUniqueComp.py b/UiQT4/desUniqueComp.py index e3810b31..77999673 100644 --- a/UiQT4/desUniqueComp.py +++ b/UiQT4/desUniqueComp.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desUniqueComp.ui' # -# Created: Fri Apr 24 16:01:08 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desUniqueInto.py b/UiQT4/desUniqueInto.py index d3d887dc..40f6bdb3 100644 --- a/UiQT4/desUniqueInto.py +++ b/UiQT4/desUniqueInto.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desUniqueInto.ui' # -# Created: Fri Apr 24 14:21:54 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desUniqueSDCO.py b/UiQT4/desUniqueSDCO.py index 5bbfa88e..0d4e4475 100644 --- a/UiQT4/desUniqueSDCO.py +++ b/UiQT4/desUniqueSDCO.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desUniqueSDCO.ui' # -# Created: Thu Mar 12 10:42:32 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desUniqueSDCOInto.py b/UiQT4/desUniqueSDCOInto.py index 50d64c1f..38c28c9f 100644 --- a/UiQT4/desUniqueSDCOInto.py +++ b/UiQT4/desUniqueSDCOInto.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desUniqueSDCOInto.ui' # -# Created: Thu Mar 12 10:42:31 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desViewTexte.py b/UiQT4/desViewTexte.py index a83037c3..08f75b4c 100644 --- a/UiQT4/desViewTexte.py +++ b/UiQT4/desViewTexte.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desViewTexte.ui' # -# Created: Tue Jan 27 12:25:39 2009 +# Created: Fri Jun 19 11:40:14 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/desVisu.py b/UiQT4/desVisu.py index ca7866cb..4049c7dc 100644 --- a/UiQT4/desVisu.py +++ b/UiQT4/desVisu.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'desVisu.ui' # -# Created: Tue Jan 27 12:25:38 2009 +# Created: Fri Jun 19 11:40:13 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/UiQT4/myMain.py b/UiQT4/myMain.py index 1f4c506e..73c24c5b 100644 --- a/UiQT4/myMain.py +++ b/UiQT4/myMain.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'myMain.ui' # -# Created: Thu Apr 23 16:20:17 2009 +# Created: Fri Jun 19 11:40:14 2009 # by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! diff --git a/generator/OpenturnsBase.py b/generator/OpenturnsBase.py index 2b9d900c..e027ed1e 100644 --- a/generator/OpenturnsBase.py +++ b/generator/OpenturnsBase.py @@ -34,11 +34,13 @@ class Generateur : #---------------------------------------------------------# self.ListeVariables = ListeVariables self.ListeVariablesIn = [] + self.ListeVariablesOut = [] self.DictLois = DictLois self.DictVariables = DictVariables self.DictMCVal = DictMCVal self.DictTypeVar = {} self.nbVarIn = 0 + self.nbVarOut = 0 self.creeInfoVar() self.appli = appli # @@ -60,10 +62,10 @@ class Generateur : #--------------------------# try : gener = self.module.__dict__["MonSTDGenerateur"] - monSTDGenerateur=gener( self.DictMCVal, self.ListeVariablesIn, self.DictLois ) + monSTDGenerateur=gener( self.DictMCVal, self.ListeVariablesIn, self.ListeVariablesOut, self.DictLois ) except : from OpenturnsSTD import STDGenerateur - monSTDGenerateur = STDGenerateur( self.appli, self.DictMCVal, self.ListeVariablesIn, self.DictLois ) + monSTDGenerateur = STDGenerateur( self.appli, self.DictMCVal, self.ListeVariablesIn, self.ListeVariablesOut, self.DictLois ) return monSTDGenerateur def getXMLGenerateur(self) : @@ -89,6 +91,11 @@ class Generateur : if DictVariable["Type"] == "in" : self.nbVarIn = self.nbVarIn + 1 self.ListeVariablesIn.append( DictVariable ) + print "OpenturnsBase.py: new input variable = ", DictVariable + else: + self.nbVarOut = self.nbVarOut + 1 + self.ListeVariablesOut.append( DictVariable ) + print "OpenturnsBase.py: new output variable = ", DictVariable liste.append( DictVariable ) num = num + 1 self.ListeVariables = liste diff --git a/generator/OpenturnsSTD.py b/generator/OpenturnsSTD.py index 5bd61e8c..7631a1a4 100644 --- a/generator/OpenturnsSTD.py +++ b/generator/OpenturnsSTD.py @@ -56,12 +56,14 @@ class STDGenerateur : ''' Generation du fichier python ''' - def __init__ (self, appli, DictMCVal, ListeVariables, DictLois ) : + def __init__ (self, appli, DictMCVal, ListeVariablesIn, ListeVariablesOut, DictLois ) : self.DictMCVal = DictMCVal - self.ListeVariables = ListeVariables + self.ListeVariablesIn = ListeVariablesIn + self.ListeVariablesOut = ListeVariablesOut self.DictLois = DictLois #print "DictMCVal=", DictMCVal - #print "ListeVariables=", ListeVariables + print "ListeVariablesIn=", ListeVariablesIn + print "ListeVariablesOut=", ListeVariablesOut #print "DictLois=", DictLois self.texteSTD = defaultSTD self.OpenTURNS_path = appli.CONFIGURATION.OpenTURNS_path @@ -83,7 +85,7 @@ class STDGenerateur : "Threshold Exceedence" : ( "ThresholdExceedence", { "Simulation" : "Simulation", - "Analytical" : "Analytical", + "FORM_SORM" : "Analytical", "MonteCarlo" : "MonteCarlo", "LHS" : "LHS", "ImportanceSampling" : "ImportanceSampling", @@ -125,6 +127,7 @@ class STDGenerateur : "marginal" : "marginal", "collection" : "collection", "copula" : "copula", + "description" : "description", "inputRandomVector" : "inputRandomVector", "outputRandomVector" : "outputRandomVector", "myQuadraticCumul" : "myQuadraticCumul", @@ -145,7 +148,10 @@ class STDGenerateur : "SRRCcoefficient" : 'results["SRRCcoefficient"]', "kernel" : "kernel", "kernelSmoothedDist" : "kernelSmoothedDist", - "kernelSmoothedPDF" : "kernelSmoothedPDF", + "kernelSmoothedPDFDrawing" : "kernelSmoothedPDFDrawing", + "kernelSmoothedGraph" : "kernelSmoothedGraph", + "meanVector" : "meanVector", + "importanceDensity" : "importanceDensity", "myEvent" : "myEvent", "myAlgo" : "myAlgo", "myResult" : "myResult", @@ -155,7 +161,8 @@ class STDGenerateur : "length" : "length", "coefficientOfVariation" : 'results["coefficientOfVariation"]', "convergenceGraph" : "convergenceGraph", - "iterations" : 'results["iterations"]', + "convergenceDrawing" : "convergenceDrawing", + "simulationNumbers" : 'results["simulationNumbers"]', "myOptimizer" : "myOptimizer", "specificParameters" : "specificParameters", "startingPoint" : "startingPoint", @@ -165,7 +172,9 @@ class STDGenerateur : "eventProbabilitySensitivity" : 'results["eventProbabilitySensitivity"]', "hasoferReliabilityIndexSensitivity" : 'results["hasoferReliabilityIndexSensitivity"]', "eventProbabilitySensitivityGraph" : "eventProbabilitySensitivityGraph", + "eventProbabilitySensitivityDrawing" : "eventProbabilitySensitivityDrawing", "hasoferReliabilityIndexSensitivityGraph" : "hasoferReliabilityIndexSensitivityGraph", + "hasoferReliabilityIndexSensitivityDrawing" : "hasoferReliabilityIndexSensitivityDrawing", "modelEvaluationCalls" : 'results["modelEvaluationCalls"]', "modelGradientCalls" : 'results["modelGradientCalls"]', "modelHessianCalls" : 'results["modelHessianCalls"]', @@ -231,8 +240,6 @@ class STDGenerateur : Produit le fichier study correspondant a une analyse Min/Max ''' txt = self.Header() - txt += "# Etude 'Min/Max'\n" - txt += self.Model() Methode = None @@ -246,7 +253,6 @@ class STDGenerateur : if ( Traitement is not None ): txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) - txt += self.MinMaxComputation() txt += self.MinMaxResult() txt += self.Footer() @@ -264,6 +270,7 @@ class STDGenerateur : txt = "# Charge le modele physique\n" txt = "%s = WrapperFile( '%s' )\n" % (self.variable["wrapper"], name) + txt += "# Ces lignes sont utiles pour le fonctionnement du script sous Salome\n" txt += "if globals().has_key('%s'):\n" % self.variable["framework"] txt += " %s = %s.getWrapperData()\n" % (self.variable["wrapperdata"], self.variable["wrapper"]) txt += " %s = %s.getFrameworkData()\n" % (self.variable["frameworkdata"], self.variable["wrapperdata"]) @@ -272,6 +279,7 @@ class STDGenerateur : txt += " %s.componentname_ = %s['%s']\n" % (self.variable["frameworkdata"], self.variable["framework"], self.variable["componentname"]) txt += " %s.setFrameworkData( %s )\n" % (self.variable["wrapperdata"], self.variable["frameworkdata"]) txt += " %s.setWrapperData( %s )\n" % (self.variable["wrapper"], self.variable["wrapperdata"]) + txt += "# Fin des lignes pour Salome\n" txt += "%s = NumericalMathFunction( %s )\n" % (self.variable["model"], self.variable["wrapper"],) txt += "%s = %s.getInputNumericalPointDimension()\n" % (self.variable["n"], self.variable["model"]) @@ -289,6 +297,10 @@ class STDGenerateur : txt += self.TranslationVector() txt += "%s = %s\n" % (self.variable["inputSample"], self.variable["myExperimentPlane"]) txt += "\n" + txt += "# Etude 'Min/Max'\n" + txt += "# Calcul\n" + txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"]) + txt += "\n" return txt def MinMaxRandomSampling (self): @@ -296,15 +308,18 @@ class STDGenerateur : Etude par echantillonage aleatoire ''' size = 0 - if ( self.DictMCVal.has_key( 'PointsNumber' ) ): - size = self.DictMCVal[ 'PointsNumber' ] + if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): + size = self.DictMCVal[ 'SimulationsNumber' ] txt = "# Etude par echantillonage aleatoire\n" txt += self.InputDistribution() txt += self.InputRandomVector() - txt += "%s = %d\n" % (self.variable["inSize"], size) - txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["inputSample"], self.variable["inputRandomVector"], self.variable["inSize"]) txt += "\n" + txt += "# Etude 'Min/Max'\n" + txt += "# Calcul\n" + txt += "%s = %d\n" % (self.variable["inSize"], size) + txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"]) + txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["outputSample"], self.variable["outputRandomVector"], self.variable["inSize"]) return txt def InputDistribution (self): @@ -312,11 +327,12 @@ class STDGenerateur : Cree la loi jointe des variables d entree ''' txt = "# Definit la loi jointe des variables d'entree\n" - txt += "%s = DistributionCollection( %d )\n" % (self.variable["collection"], len( self.ListeVariables )) + txt += "%s = DistributionCollection( %s )\n" % (self.variable["collection"], self.variable["n"]) + txt += "%s = Description( %s )\n" % (self.variable["description"], self.variable["n"]) txt += "\n" dictVariables = {} - for variable in self.ListeVariables: + for variable in self.ListeVariablesIn: nomVar = variable['ModelVariable'].get_name() dictVariables[ nomVar ] = variable['Distribution'] @@ -330,23 +346,26 @@ class STDGenerateur : 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.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) txt += "\n" i += 1 - txt += self.Copula( len( self.ListeVariables ) ) + txt += self.Copula() txt += "# Definit la loi jointe\n" txt += "%s = ComposedDistribution( %s, Copula( %s ) )\n" % (self.variable["distribution"], self.variable["collection"], self.variable["copula"]) + txt += "%s.setDescription( %s )\n" % (self.variable["distribution"], self.variable["description"]) txt += "\n" return txt - def Copula (self, dimension): + def Copula (self): ''' Cree la copule de la loi jointe ''' txt = "# Definit la copule de la loi jointe\n" - txt += "%s = IndependentCopula( %d )\n" % (self.variable["copula"], dimension) + txt += "%s = IndependentCopula( %s )\n" % (self.variable["copula"], self.variable["n"]) txt += "\n" return txt @@ -363,8 +382,13 @@ class STDGenerateur : ''' Cree le vector aleatoire de sortie ''' + nomVar = "output" + for variable in self.ListeVariablesOut: + nomVar = variable['ModelVariable'].get_name() + txt = "# Definit le vecteur aleatoire de sortie\n" txt += "%s = RandomVector( %s, %s )\n" % (self.variable["outputRandomVector"], self.variable["model"], self.variable["inputRandomVector"]) + txt += "%s.setName( '%s' )\n" % (self.variable["outputRandomVector"], nomVar) txt += "\n" return txt @@ -432,25 +456,16 @@ class STDGenerateur : txt += "\n" return txt - def MinMaxComputation (self): - ''' - Realise le calcul deterministe - ''' - txt = "# Calcul\n" - txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"]) - txt += "\n" - return txt - def MinMaxResult (self): ''' Produit les resultats de l etude ''' txt = "# Resultats\n" txt += "%s = %s.getMin()\n" % (self.variable["minValue"], self.variable["outputSample"]) - txt += "print '%s = ', %s\n" % (self.variable["minValue"], self.variable["minValue"]) + txt += "print '%s = ', %s\n" % ("minValue", self.variable["minValue"]) txt += "\n" txt += "%s = %s.getMax()\n" % (self.variable["maxValue"], self.variable["outputSample"]) - txt += "print '%s = ', %s\n" % (self.variable["maxValue"], self.variable["maxValue"]) + txt += "print '%s = ', %s\n" % ("maxValue", self.variable["maxValue"]) txt += "\n" return txt @@ -459,8 +474,6 @@ class STDGenerateur : Produit le fichier study correspondant a une analyse d incertitude en valeur centrale ''' txt = self.Header() - txt += "# Etude 'Central Uncertainty'\n" - txt += self.Model() txt += self.InputDistribution() txt += self.InputRandomVector() @@ -475,6 +488,7 @@ class STDGenerateur : Traitement = subDict[ Methode ] if ( Traitement is not None ): + txt += "# Etude 'Central Uncertainty'\n" txt += apply( STDGenerateur.__dict__[ Traitement ], (self,) ) txt += self.Footer() @@ -493,13 +507,13 @@ class STDGenerateur : if ( self.DictMCVal.has_key( 'MeanFirstOrder' ) ): if ( self.DictMCVal[ 'MeanFirstOrder' ] == "yes" ): txt += "%s = %s.getMeanFirstOrder()\n" % (self.variable["meanFirstOrder"], self.variable["myQuadraticCumul"]) - txt += "print '%s = ', %s\n" % (self.variable["meanFirstOrder"], self.variable["meanFirstOrder"]) + txt += "print '%s = ', %s\n" % ("meanFirstOrder", self.variable["meanFirstOrder"]) txt += "\n" if ( self.DictMCVal.has_key( 'MeanSecondOrder' ) ): if ( self.DictMCVal[ 'MeanSecondOrder' ] == "yes" ): txt += "%s = %s.getMeanSecondOrder()\n" % (self.variable["meanSecondOrder"], self.variable["myQuadraticCumul"]) - txt += "print '%s = ', %s\n" % (self.variable["meanSecondOrder"], self.variable["meanSecondOrder"]) + txt += "print '%s = ', %s\n" % ("meanSecondOrder", self.variable["meanSecondOrder"]) txt += "\n" if ( self.DictMCVal.has_key( 'StandardDeviationFirstOrder' ) ): @@ -508,21 +522,19 @@ class STDGenerateur : txt += "dim = %s.getDimension()\n" % self.variable["standardDeviationFirstOrder"] txt += "for i in range( dim ):\n" txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"]) - txt += "print '%s = ', %s\n" % (self.variable["standardDeviationFirstOrder"], self.variable["standardDeviationFirstOrder"]) + txt += "print '%s = ', %s\n" % ("standardDeviationFirstOrder", self.variable["standardDeviationFirstOrder"]) txt += "\n" - if ( self.DictMCVal.has_key( 'NumericalResults' ) ): - if ( self.DictMCVal[ 'NumericalResults' ] == "yes" ): - txt += "if ( %s.getDimension() == 1):\n" % self.variable["outputRandomVector"] - txt += " %s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myQuadraticCumul"]) - txt += " print '%s = ', %s\n" % (self.variable["importanceFactors"], self.variable["importanceFactors"]) + if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ): + if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ): + txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myQuadraticCumul"]) + txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"] + txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"]) txt += "\n" - - if ( self.DictMCVal.has_key( 'GraphicalResults' ) ): - if ( self.DictMCVal[ 'GraphicalResults' ] == "yes" ): txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myQuadraticCumul"]) - txt += "Show( %s )\n" % self.variable["importanceFactorsGraph"] - txt += "%s.draw( '%s' )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"]) + txt += "#Show( %s )\n" % self.variable["importanceFactorsGraph"] + txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"]) txt += "ViewImage( %s.getBitmap() )\n" % self.variable["importanceFactorsGraph"] txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"] txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"] @@ -536,18 +548,19 @@ class STDGenerateur : Etude par echantillonage aleatoire ''' size = 0 - if ( self.DictMCVal.has_key( 'PointsNumber' ) ): - size = self.DictMCVal[ 'PointsNumber' ] + if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): + size = self.DictMCVal[ 'SimulationsNumber' ] txt = "# Echantillonnage aleatoire de la variable de sortie\n" txt += "%s = %d\n" % (self.variable["inSize"], size) - txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["outputSample"], self.variable["outputRandomVector"], self.variable["inSize"]) + txt += "%s = %s.getNumericalSample( %s )\n" % (self.variable["inputSample"], self.variable["inputRandomVector"], self.variable["inSize"]) + txt += "%s = %s( %s )\n" % (self.variable["outputSample"], self.variable["model"], self.variable["inputSample"]) txt += "\n" if ( self.DictMCVal.has_key( 'EmpiricalMean' ) ): if ( self.DictMCVal[ 'EmpiricalMean' ] == "yes" ): txt += "%s = %s.computeMean()\n" % (self.variable["empiricalMean"], self.variable["outputSample"]) - txt += "print '%s =', %s\n" % (self.variable["empiricalMean"], self.variable["empiricalMean"]) + txt += "print '%s =', %s\n" % ("empiricalMean", self.variable["empiricalMean"]) txt += "\n" if ( self.DictMCVal.has_key( 'EmpiricalStandardDeviation' ) ): @@ -556,27 +569,37 @@ class STDGenerateur : txt += "dim = %s.getDimension()\n" % self.variable["empiricalStandardDeviation"] txt += "for i in range( dim ):\n" txt += " %s[ i, i ] = math.sqrt( %s[ i, i ] )\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"]) - txt += "print '%s = ', %s\n" % (self.variable["empiricalStandardDeviation"], self.variable["empiricalStandardDeviation"]) + txt += "print '%s = ', %s\n" % ("empiricalStandardDeviation", self.variable["empiricalStandardDeviation"]) txt += "\n" if ( self.DictMCVal.has_key( 'EmpiricalQuantile_Order' ) ): ordre = self.DictMCVal[ 'EmpiricalQuantile_Order' ] txt += "%s = %s.computeQuantile( %s )\n" % (self.variable["empiricalQuantile"], self.variable["outputSample"], ordre) - txt += "print '%s =', %s\n" % (self.variable["empiricalQuantile"], self.variable["empiricalQuantile"]) + txt += "print '%s ( %s ) =', %s\n" % ("empiricalQuantile", ordre, self.variable["empiricalQuantile"]) txt += "\n" - if ( self.DictMCVal.has_key( 'AnalysedCorrelations' ) ): - if ( self.DictMCVal[ 'AnalysedCorrelations' ] == "yes" ): - txt += "# Ou est le %s ?\n" % self.variable["inputSample"] - txt += "#if ( ( %s.getDimension() == 1 ) and ( %s.getDimension() == 1 ) ):\n" % (self.variable["inputSample"], self.variable["outputSample"]) - txt += "# %s = CorrelationAnalysis.PCC( %s, %s )\n" % (self.variable["PCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) - txt += "# print '%s = ', %s\n" % (self.variable["PCCcoefficient"], self.variable["PCCcoefficient"]) - txt += "# %s = CorrelationAnalysis.PRCC( %s, %s )\n" % (self.variable["PRCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) - txt += "# print '%s = ', %s\n" % (self.variable["PRCCcoefficient"], self.variable["PRCCcoefficient"]) - txt += "# %s = CorrelationAnalysis.SRC( %s, %s )\n" % (self.variable["SRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) - txt += "# print '%s = ', %s\n" % (self.variable["SRCcoefficient"], self.variable["SRCcoefficient"]) - txt += "# %s = CorrelationAnalysis.SRRC( %s, %s )\n" % (self.variable["SRRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) - txt += "# print '%s = ', %s\n" % (self.variable["SRRCcoefficient"], self.variable["SRRCcoefficient"]) + if ( self.DictMCVal.has_key( 'CorrelationAnalysis' ) ): + if ( self.DictMCVal[ 'CorrelationAnalysis' ] == "yes" ): + txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"] + txt += " %s = CorrelationAnalysis.PCC( %s, %s )\n" % (self.variable["PCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += " print 'PCC Coefficients:'\n" + txt += " for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PCCcoefficient"]) + txt += "\n" + txt += " %s = CorrelationAnalysis.PRCC( %s, %s )\n" % (self.variable["PRCCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += " print 'PRCC Coefficients:'\n" + txt += " for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["PRCCcoefficient"]) + txt += "\n" + txt += " %s = CorrelationAnalysis.SRC( %s, %s )\n" % (self.variable["SRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += " print 'SRC Coefficients:'\n" + txt += " for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRCcoefficient"]) + txt += "\n" + txt += " %s = CorrelationAnalysis.SRRC( %s, %s )\n" % (self.variable["SRRCcoefficient"], self.variable["inputSample"], self.variable["outputSample"]) + txt += " print 'SRRC Coefficients:'\n" + txt += " for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':', %s[i]\n" % (self.variable["distribution"], self.variable["SRRCcoefficient"]) txt += "\n" if ( self.DictMCVal.has_key( 'KernelSmoothing' ) ): @@ -584,9 +607,15 @@ class STDGenerateur : txt += "# Kernel Smoohing\n" txt += "%s = KernelSmoothing()\n" % self.variable["kernel"] txt += "if ( %s.getDimension() == 1 ):\n" % self.variable["outputSample"] + txt += " %s.setName( 'Output' )\n" % self.variable["outputSample"] txt += " %s = %s.buildImplementation( %s, 'TRUE')\n" % (self.variable["kernelSmoothedDist"], self.variable["kernel"], self.variable["outputSample"]) - txt += " %s = %s.drawPDF()\n" % (self.variable["kernelSmoothedPDF"], self.variable["kernelSmoothedDist"]) - txt += " Show( %s )\n" % self.variable["kernelSmoothedPDF"] + txt += " %s = %s.drawPDF()\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedDist"]) + txt += " #Show( %s )\n" % self.variable["kernelSmoothedGraph"] + txt += " %s = '%s'\n" % (self.variable["kernelSmoothedPDFDrawing"], self.DictMCVal[ 'KernelSmoothingDrawingFilename' ]) + txt += " %s.draw( %s )\n" % (self.variable["kernelSmoothedGraph"], self.variable["kernelSmoothedPDFDrawing"]) + txt += " ViewImage( %s.getBitmap() )\n" % self.variable["kernelSmoothedGraph"] + txt += " print 'bitmap =', %s.getBitmap()\n" % self.variable["kernelSmoothedGraph"] + txt += " print 'postscript =', %s.getPostscript()\n" % self.variable["kernelSmoothedGraph"] txt += "\n" return txt @@ -641,7 +670,7 @@ class STDGenerateur : blockSize = None if ( self.DictMCVal.has_key( 'BlockSize' ) ): - maxOuterSampling = self.DictMCVal[ 'BlockSize' ] + blockSize = self.DictMCVal[ 'BlockSize' ] txt += "%s.setBlockSize( %s )\n" % (self.variable["myAlgo"], blockSize) maxCoefficientOfVariation = None @@ -658,13 +687,13 @@ class STDGenerateur : if ( self.DictMCVal.has_key( 'Probability' ) ): if ( self.DictMCVal[ 'Probability' ] == "yes" ): txt += "%s = %s.getProbabilityEstimate()\n" % (self.variable["probability"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["probability"], self.variable["probability"]) + txt += "print '%s =', %s\n" % ("probability", self.variable["probability"]) txt += "\n" if ( self.DictMCVal.has_key( 'StandardDeviation' ) ): if ( self.DictMCVal[ 'StandardDeviation' ] == "yes" ): txt += "%s = math.sqrt( %s.getProbabilityEstimate() )\n" % (self.variable["standardDeviation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["standardDeviation"], self.variable["standardDeviation"]) + txt += "print '%s =', %s\n" % ("standardDeviation", self.variable["standardDeviation"]) txt += "\n" if ( self.DictMCVal.has_key( 'ConfidenceInterval' ) and self.DictMCVal.has_key( 'Probability' ) ): @@ -677,19 +706,23 @@ class STDGenerateur : if ( self.DictMCVal.has_key( 'VariationCoefficient' ) ): if ( self.DictMCVal[ 'VariationCoefficient' ] == "yes" ): txt += "%s = %s.getCoefficientOfVariation()\n" % (self.variable["coefficientOfVariation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["coefficientOfVariation"], self.variable["coefficientOfVariation"]) + txt += "print '%s =', %s\n" % ("coefficientOfVariation", self.variable["coefficientOfVariation"]) txt += "\n" - if ( self.DictMCVal.has_key( 'IterationNumber' ) ): - if ( self.DictMCVal[ 'IterationNumber' ] == "yes" ): - txt += "%s = %s.getOuterSampling()\n" % (self.variable["iterations"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["iterations"], self.variable["iterations"]) + if ( self.DictMCVal.has_key( 'SimulationsNumber' ) ): + if ( self.DictMCVal[ 'SimulationsNumber' ] == "yes" ): + txt += "%s = %s.getOuterSampling()\n" % (self.variable["simulationNumbers"], self.variable["myResult"]) + txt += "print '%s =', %s\n" % ("simulationNumbers", self.variable["simulationNumbers"]) txt += "\n" - if ( self.DictMCVal.has_key( 'ConvergenceGraph' ) ): - if ( self.DictMCVal[ 'ConvergenceGraph' ] == "yes" ): - txt += "%s = %s.drawProbabilityConvergence()\n" % (self.variable["convergenceGraph"], self.variable["myAlgo"]) - txt += "Show( %s )\n" % self.variable["convergenceGraph"] + if ( self.DictMCVal.has_key( 'ConvergenceGraph' ) and self.DictMCVal.has_key( 'ConfidenceInterval' ) ): + if ( ( self.DictMCVal[ 'ConvergenceGraph' ] == "yes" ) and ( self.DictMCVal[ 'ConfidenceInterval' ] == "yes" ) ): + txt += "%s = %s\n" % (self.variable["alpha"], self.DictMCVal[ 'Level' ]) + txt += "%s = %s.drawProbabilityConvergence( %s )\n" % (self.variable["convergenceGraph"], self.variable["myAlgo"], self.variable["alpha"]) + txt += "#Show( %s )\n" % self.variable["convergenceGraph"] + txt += "%s = '%s'\n" % (self.variable["convergenceDrawing"], self.DictMCVal[ 'ConvergenceDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["convergenceGraph"], self.variable["convergenceDrawing"]) + txt += "ViewImage( %s.getBitmap() )\n" % self.variable["convergenceGraph"] txt += "\n" return txt @@ -736,10 +769,10 @@ class STDGenerateur : ''' txt = "" - iterations = None + simulationNumbers = None if ( self.DictMCVal.has_key( 'MaximumIterationsNumber' ) ): - iterations = self.DictMCVal[ 'MaximumIterationsNumber' ] - txt += "%s.setMaximumIterationsNumber( %s )\n" % (self.variable["myOptimizer"], iterations) + simulationNumbers = self.DictMCVal[ 'MaximumIterationsNumber' ] + txt += "%s.setMaximumIterationsNumber( %s )\n" % (self.variable["myOptimizer"], simulationNumbers) absoluteError = None if ( self.DictMCVal.has_key( 'MaximumAbsoluteError' ) ): @@ -800,69 +833,84 @@ class STDGenerateur : if ( self.DictMCVal.has_key( 'HasoferReliabilityIndex' ) ): if ( self.DictMCVal[ 'HasoferReliabilityIndex' ] == "yes" ): txt += "%s = %s.getHasoferReliabilityIndex()\n" % (self.variable["hasoferReliabilityIndex"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["hasoferReliabilityIndex"], self.variable["hasoferReliabilityIndex"]) + txt += "print '%s =', %s\n" % ("hasoferReliabilityIndex", self.variable["hasoferReliabilityIndex"]) txt += "\n" if ( self.DictMCVal.has_key( 'DesignPoint' ) ): if ( self.DictMCVal[ 'DesignPoint' ] == "yes" ): txt += "%s = %s.getStandardSpaceDesignPoint()\n" % (self.variable["standardSpaceDesignPoint"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["standardSpaceDesignPoint"], self.variable["standardSpaceDesignPoint"]) + txt += "print '%s =', %s\n" % ("standardSpaceDesignPoint", self.variable["standardSpaceDesignPoint"]) txt += "%s = %s.getPhysicalSpaceDesignPoint()\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["physicalSpaceDesignPoint"], self.variable["physicalSpaceDesignPoint"]) + txt += "print '%s =', %s\n" % ("physicalSpaceDesignPoint", self.variable["physicalSpaceDesignPoint"]) txt += "\n" - if ( self.DictMCVal.has_key( 'ImportanceFactorNumericalResults' ) ): - if ( self.DictMCVal[ 'ImportanceFactorNumericalResults' ] == "yes" ): + if ( self.DictMCVal.has_key( 'ImportanceFactor' ) ): + if ( self.DictMCVal[ 'ImportanceFactor' ] == "yes" ): txt += "%s = %s.getImportanceFactors()\n" % (self.variable["importanceFactors"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["importanceFactors"], self.variable["importanceFactors"]) + txt += "for i in range(%s.getDimension()):\n" % self.variable["importanceFactors"] + txt += " print %s.getDescription()[i], ':', %s[i]*100., '%%'\n" % (self.variable["distribution"], self.variable["importanceFactors"]) txt += "\n" - - if ( self.DictMCVal.has_key( 'ImportanceFactorGraphicalResults' ) ): - if ( self.DictMCVal[ 'ImportanceFactorGraphicalResults' ] == "yes" ): txt += "%s = %s.drawImportanceFactors()\n" % (self.variable["importanceFactorsGraph"], self.variable["myResult"]) - txt += "Show( %s )\n" % self.variable["importanceFactorsGraph"] + txt += "#Show( %s )\n" % self.variable["importanceFactorsGraph"] + txt += "%s = '%s'\n" % (self.variable["importanceFactorsDrawing"], self.DictMCVal[ 'ImportanceFactorDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["importanceFactorsGraph"], self.variable["importanceFactorsDrawing"]) + txt += "ViewImage( %s.getBitmap() )\n" % self.variable["importanceFactorsGraph"] + txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["importanceFactorsGraph"] + txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["importanceFactorsGraph"] txt += "\n" - if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivityNumericalResults' ) ): - if ( self.DictMCVal[ 'FORMEventProbabilitySensitivityNumericalResults' ] == "yes" ): + if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivity' ) ): + if ( self.DictMCVal[ 'FORMEventProbabilitySensitivity' ] == "yes" ): txt += "%s = %s.getEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivity"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["eventProbabilitySensitivity"], self.variable["eventProbabilitySensitivity"]) + txt += "print 'FORM Event Probability Sensitivity:'\n" + txt += "for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"] + txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["eventProbabilitySensitivity"] + txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["eventProbabilitySensitivity"], self.variable["eventProbabilitySensitivity"]) txt += "\n" - - if ( self.DictMCVal.has_key( 'FORMEventProbabilitySensitivityGraphicalResults' ) ): - if ( self.DictMCVal[ 'FORMEventProbabilitySensitivityGraphicalResults' ] == "yes" ): - txt += "%s = %s.drawEventProbabilitySensitivity()\n" % (self.variable["eventProbabilitySensitivityGraph"], self.variable["myResult"]) - txt += "Show( %s[0] )\n" % self.variable["eventProbabilitySensitivityGraph"] + 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 += "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"] txt += "\n" - if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivityNumericalResults' ) ): - if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivityNumericalResults' ] == "yes" ): + if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivity' ) ): + if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivity' ] == "yes" ): txt += "%s = %s.getHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["hasoferReliabilityIndexSensitivity"]) + txt += "print 'Hasofer Reliability Index Sensitivity:'\n" + txt += "for i in range( %s ):\n" % self.variable["n"] + txt += " print %s.getDescription()[i], ':'\n" % self.variable["distribution"] + txt += " for j in range( %s[i].getDimension() ):\n" % self.variable["hasoferReliabilityIndexSensitivity"] + txt += " print ' ', %s[i].getDescription()[j], ':', %s[i][j]\n" % (self.variable["hasoferReliabilityIndexSensitivity"], self.variable["hasoferReliabilityIndexSensitivity"]) txt += "\n" - - if ( self.DictMCVal.has_key( 'HasoferReliabilityIndexSensitivityGraphicalResults' ) ): - if ( self.DictMCVal[ 'HasoferReliabilityIndexSensitivityGraphicalResults' ] == "yes" ): - txt += "%s = %s.drawHasoferReliabilityIndexSensitivity()\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["myResult"]) - txt += "Show( %s[0] )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "%s = %s.drawHasoferReliabilityIndexSensitivity()[0]\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["myResult"]) + txt += "#Show( %s )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "%s = '%s'\n" % (self.variable["hasoferReliabilityIndexSensitivityDrawing"], self.DictMCVal[ 'HasoferReliabilityIndexSensitivityDrawingFilename' ]) + txt += "%s.draw( %s )\n" % (self.variable["hasoferReliabilityIndexSensitivityGraph"], self.variable["hasoferReliabilityIndexSensitivityDrawing"]) + txt += "ViewImage( %s.getBitmap() )\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "print 'bitmap =', %s.getBitmap()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] + txt += "print 'postscript =', %s.getPostscript()\n" % self.variable["hasoferReliabilityIndexSensitivityGraph"] txt += "\n" if ( self.DictMCVal.has_key( 'TvedtApproximation' ) ): if ( self.DictMCVal[ 'TvedtApproximation' ] == "yes" ): txt += "%s = %s.getEventProbabilityTvedt()\n" % (self.variable["tvedtApproximation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["tvedtApproximation"], self.variable["tvedtApproximation"]) + txt += "print '%s =', %s\n" % ("tvedtApproximation", self.variable["tvedtApproximation"]) txt += "\n" if ( self.DictMCVal.has_key( 'HohenBichlerApproximation' ) ): if ( self.DictMCVal[ 'HohenBichlerApproximation' ] == "yes" ): txt += "%s = %s.getEventProbabilityHohenBichler()\n" % (self.variable["hohenBichlerApproximation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["hohenBichlerApproximation"], self.variable["tvedtApproximation"]) + txt += "print '%s =', %s\n" % ("hohenBichlerApproximation", self.variable["tvedtApproximation"]) txt += "\n" if ( self.DictMCVal.has_key( 'BreitungApproximation' ) ): if ( self.DictMCVal[ 'BreitungApproximation' ] == "yes" ): txt += "%s = %s.getEventProbabilityBreitung()\n" % (self.variable["breitungApproximation"], self.variable["myResult"]) - txt += "print '%s =', %s\n" % (self.variable["breitungApproximation"], self.variable["breitungApproximation"]) + txt += "print '%s =', %s\n" % ("breitungApproximation", self.variable["breitungApproximation"]) txt += "\n" @@ -897,6 +945,7 @@ class STDGenerateur : txt = "# Evenement de defaillance\n" txt += "%s = Event( %s, ComparisonOperator( %s() ), %s )\n" % (self.variable["myEvent"], self.variable["outputRandomVector"], operator, threshold) + txt += "%s.setName( '%s' )\n" % (self.variable["myEvent"], "myEvent") txt += "\n" return txt @@ -924,8 +973,23 @@ class STDGenerateur : ''' Methode de tirage d importance ''' + dimension = 0 + if ( self.DictMCVal.has_key( 'MeanVector' ) ): + meanVector = self.DictMCVal[ 'MeanVector' ] + dimension = len( meanVector ) + txt = "# Simulation par Tirage d'importance\n" - txt += "%s = ImportanceSampling( %s )\n" % (self.variable["myAlgo"], self.variable["myEvent"]) + txt += "# Densite d'importance\n" + txt += "%s = NumericalPoint( %s )\n" % (self.variable["meanVector"], self.variable["n"]) + for i in range(dimension): + txt += "%s[%d] = %g\n" % (self.variable["meanVector"], i, meanVector[i]) + + if ( self.DictMCVal.has_key( 'Correlation' ) ): + if ( self.DictMCVal[ 'Correlation' ] in ( 'Independent', ) ): + txt += "%s = Normal( %s, CovarianceMatrix( IdentityMatrix( %s ) ) )\n" % (self.variable["importanceDensity"], self.variable["meanVector"], self.variable["n"]) + elif ( self.DictMCVal[ 'Correlation' ] in ( 'Linear', ) ): + txt += "# Linear correlation not yet implemented\n" + txt += "%s = ImportanceSampling( %s, Distribution( %s ) )\n" % (self.variable["myAlgo"], self.variable["myEvent"], self.variable["importanceDensity"]) txt += "\n" return txt @@ -954,9 +1018,10 @@ class STDGenerateur : ''' Do the computation ''' + txt = "" if ( self.DictMCVal.has_key( 'FunctionCallsNumber' ) ): if ( self.DictMCVal[ 'FunctionCallsNumber' ] == "yes" ): - txt = "%s = %s.getEvaluationCallsNumber()\n" % (self.variable["modelEvaluationCalls"], self.variable["model"]) + txt += "%s = %s.getEvaluationCallsNumber()\n" % (self.variable["modelEvaluationCalls"], self.variable["model"]) txt += "%s = %s.getGradientCallsNumber()\n" % (self.variable["modelGradientCalls"], self.variable["model"]) txt += "%s = %s.getHessianCallsNumber()\n" % (self.variable["modelHessianCalls"], self.variable["model"]) txt += "\n" @@ -972,9 +1037,9 @@ class STDGenerateur : txt += "%s = %s.getGradientCallsNumber() - %s\n" % (self.variable["modelGradientCalls"], self.variable["model"], self.variable["modelGradientCalls"]) txt += "%s = %s.getHessianCallsNumber() - %s\n" % (self.variable["modelHessianCalls"], self.variable["model"], self.variable["modelHessianCalls"]) txt += "\n" - txt += "print '%s =', %s\n" % (self.variable["modelEvaluationCalls"], self.variable["modelEvaluationCalls"]) - txt += "print '%s =', %s\n" % (self.variable["modelGradientCalls"], self.variable["modelGradientCalls"]) - txt += "print '%s =', %s\n" % (self.variable["modelHessianCalls"], self.variable["modelHessianCalls"]) + txt += "print '%s =', %s\n" % ("modelEvaluationCalls", self.variable["modelEvaluationCalls"]) + txt += "print '%s =', %s\n" % ("modelGradientCalls", self.variable["modelGradientCalls"]) + txt += "print '%s =', %s\n" % ("modelHessianCalls", self.variable["modelHessianCalls"]) txt += "\n" return txt @@ -1062,8 +1127,8 @@ class STDGenerateur : Definition de la loi Gumbel ''' settings = { - "AlphaBeta" : "Gamma.ALPHABETA", - "MuSigma" : "Gamma.MUSIGMA", + "AlphaBeta" : "Gumbel.ALPHABETA", + "MuSigma" : "Gumbel.MUSIGMA", } if loi[ 'Settings' ] == 'AlphaBeta' : arg1 = loi[ 'Alpha' ] @@ -1072,7 +1137,7 @@ class STDGenerateur : arg1 = loi[ 'Mu' ] arg2 = loi[ 'Sigma' ] - txt = "Gamma( %g, %g, %s )" % (arg1, arg2, settings[ loi[ 'Settings' ] ]) + txt = "Gumbel( %g, %g, %s )" % (arg1, arg2, settings[ loi[ 'Settings' ] ]) return txt def Histogram (self, loi, i, collection): @@ -1084,6 +1149,15 @@ class STDGenerateur : txt = "Histogram( %g, %s )" % (arg1, arg2) return txt + def Laplace (self, loi, i, collection): + ''' + Definition de la loi Laplace + ''' + arg1 = loi[ 'Lambda' ] + arg2 = loi[ 'Mu' ] + txt = "Laplace( %g, %g )" % (arg1, arg2) + return txt + def Logistic (self, loi, i, collection): ''' Definition de la loi Logistic @@ -1125,6 +1199,16 @@ class STDGenerateur : txt = "MultiNomial( NumericalPoint( %s ) , %d)" % (arg1, arg2) return txt + def NonCentralStudent (self, loi, i, collection): + ''' + Definition de la loi NonCentralStudent + ''' + arg1 = loi[ 'Nu' ] + arg2 = loi[ 'Delta' ] + arg3 = loi[ 'Gamma' ] + txt = "NonCentralStudent( %g, %g )" % (arg1, arg2, arg3) + return txt + def Normal (self, loi, i, collection): ''' Definition de la loi Normal @@ -1147,18 +1231,28 @@ class STDGenerateur : def Poisson (self, loi, i, collection): ''' - Definition de la loi + Definition de la loi Poisson ''' txt = "Poisson( %g )" % loi[ 'Lambda' ] return txt + def Rayleigh (self, loi, i, collection): + ''' + Definition de la loi Rayleigh + ''' + arg1 = loi[ 'Sigma' ] + arg2 = loi[ 'Gamma' ] + txt = "Rayleigh( %g, %g )" % (arg1, arg2) + return txt + def Student (self, loi, i, collection): ''' Definition de la loi Student ''' arg1 = loi[ 'Mu' ] arg2 = loi[ 'Nu' ] - txt = "Student( %g, %g )" % (arg1, arg2) + arg3 = loi[ 'Sigma' ] + txt = "Student( %g, %g, %g )" % (arg1, arg2, arg3) return txt def Triangular (self, loi, i, collection): @@ -1203,6 +1297,6 @@ class STDGenerateur : arg2 = loi[ 'Sigma' ] arg3 = loi[ 'Gamma' ] - txt = "Weibull( %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) + txt = "Weibull( %g, %g, %g, %s )" % (arg1, arg2, arg3, settings[ loi[ 'Settings' ] ]) return txt diff --git a/generator/OpenturnsXML.py b/generator/OpenturnsXML.py index 275e94cc..0a7aed85 100644 --- a/generator/OpenturnsXML.py +++ b/generator/OpenturnsXML.py @@ -186,8 +186,11 @@ class XMLGenerateur : Ecrit les donnees liees a l utilisation d un framework englobant ''' framework = openturns.WrapperFrameworkData() - #framework.studycase_ = "12:23:34" - framework.componentname_ = self.GetMCVal('SolverComponentName') +# framework.studycase_ = "12:23:34" +# framework.componentname_ = self.GetMCVal('SolverComponentName', 'UNDEFINED') + CN = self.GetMCVal('SolverComponentName', 'UNDEFINED') + print 'CN = ', CN + framework.componentname_ = CN return framework diff --git a/generator/generator_python.py b/generator/generator_python.py index 20b4ec3b..745ff656 100644 --- a/generator/generator_python.py +++ b/generator/generator_python.py @@ -518,12 +518,21 @@ class PythonGenerator: Convertit un objet MCSIMP en une liste de chaines de caractères à la syntaxe python """ + waitTuple=0 if type(obj.valeur) in (types.TupleType,types.ListType) : s = '' - for val in obj.valeur : - s =s +self.format_item(val,obj.etape) + ',' - if len(obj.valeur) > 1: - s = '(' + s + '),' + for ss_type in obj.definition.type: + if repr(ss_type).find('Tuple') != -1 : + waitTuple=1 + break + + if waitTuple : + s = str(obj.valeur) +',' + else : + for val in obj.valeur : + s =s +self.format_item(val,obj.etape) + ',' + if len(obj.valeur) > 1: + s = '(' + s + '),' if obj.nbrColonnes() : s=self.formatColonnes(obj.nbrColonnes(),s) else : @@ -547,5 +556,3 @@ class PythonGenerator: #else : textformat=text return textformat - - -- 2.39.2