X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=tabchdalc.py;h=4f79e4b89cf373442d4d1e5c9310c46d682258e1;hp=39fd37728734c40d31c6c01267712b749f4a5e7d;hb=161583780bee75faed286c562eea67b7f22ed7aa;hpb=22cd27b2bbe9ab1ffa7ef06fa764b5147ae17dad diff --git a/tabchdalc.py b/tabchdalc.py index 39fd377..4f79e4b 100644 --- a/tabchdalc.py +++ b/tabchdalc.py @@ -4,15 +4,15 @@ #Copyright (c) 2008-2009 Pierre Ratinaud #Lisense: GNU/GPL -from chemins import ConstructPathOut, ChdTxtPathOut, ConstructAfcUciPath, ffr +from chemins import ConstructPathOut, ChdTxtPathOut, ConstructAfcUciPath, ffr, PathOut from functions import sortedby, CreateIraFile, print_liste, exec_rcode, check_Rresult from PrintRScript import RchdQuest from layout import OpenCHDS, PrintRapport from dialog import PrefQuestAlc +from analysematrix import AnalyseMatrix import os import sys import wx -from numpy import * import tempfile import time @@ -22,52 +22,63 @@ class AnalyseQuest(): dlg = PrefQuestAlc(parent) dlg.CenterOnParent() self.val = dlg.ShowModal() + parametres = parent.tableau.parametre if self.val == wx.ID_OK : + parametres['nbcl_p1'] = dlg.spin_nbcl.GetValue() + parametres['mincl'] = dlg.spin_mincl.GetValue() if dlg.m_radioBox1.GetSelection() == 1 : - ListAct = dlg.nactives - ListSup = dlg.varsup - nbcl_p1 = dlg.spin_nbcl.GetValue() - mincl = dlg.spin_mincl.GetValue() - DoQuestAlceste(parent, ListAct, ListSup, nbcl = nbcl_p1, mincl = mincl) - else: - nbcl_p1 = dlg.spin_nbcl.GetValue() - mincl = dlg.spin_mincl.GetValue() - DoQuestAlceste(parent, nbcl = nbcl_p1, mincl = mincl) + parametres['listact'] = dlg.nactives + parametres['listsup'] = dlg.varsup + else : + parametres['formatted'] = 1 + DoQuestAlceste(parent, parametres) -class DoQuestAlceste: - def __init__(self, parent, ListAct=False, ListSup=False, nbcl = 10, mincl = 10): - self.t1 = time.time() -#------------------------------------------------------------------- - dlg = wx.ProgressDialog("Traitements", - "Veuillez patienter...", - maximum=5, - parent=parent, - style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME - ) - dlg.Center() - count = 1 - keepGoing = dlg.Update(count) -#------------------------------------------------------------------- - self.pathout = ConstructPathOut(parent.tableau.parametre['filename'], 'AlcesteQuest') +class DoQuestAlceste(AnalyseMatrix): + def __init__(self, parent, parametres): + parametres['pathout'] = ConstructPathOut(parent.tableau.parametre['filename'], 'gnepaMatrix') + self.parametres = parametres + self.parametres['type'] = 'gnepamatrix' self.DictForme = {} self.DictFormeSup = {} self.Min = 10 self.Linecontent = [] self.parent = parent self.RPath = self.parent.PathPath.get('PATHS', 'rpath') - self.dictpathout = ChdTxtPathOut(self.pathout) - self.parent.tableau.dictpathout = self.dictpathout + #self.dictpathout = PathOut(dirout = self.pathout) + #self.dictpathout = self.pathout + #self.dictpathout.basefiles(ChdTxtPathOut) + #self.pathout = self.dictpathout self.clnb = '' - self.ListAct = ListAct + self.ListAct = parametres.get('listact', False) self.ucecla = '' - self.parent = parent + dlg = wx.ProgressDialog("Traitements", + "Veuillez patienter...", + maximum=5, + parent=self.parent, + style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME + ) + + AnalyseMatrix.__init__(self, parent, parent.tableau, self.parametres, dlg = dlg) + + + #----------------------------------------------------------- + def doanalyse(self) : +#------------------------------------------------------------------- + self.dictpathout = self.pathout + self.dictpathout.basefiles(ChdTxtPathOut) + self.parent.tableau.dictpathout = self.dictpathout + + self.dlg.Center() + count = 1 + keepGoing = self.dlg.Update(count) +#------------------------------------------------------------------- count += 1 - dlg.Update(count, u"passage en O/1") - if not ListAct: - self.parent.tableau.make_01_alc_format(self.dictpathout['Act01']) + self.dlg.Update(count, u"passage en O/1") + if 'formatted' in self.parametres: + self.parent.tableau.make_01_alc_format(self.dictpathout['mat01']) else: - self.parent.tableau.make_01_from_selection(ListAct, ListSup) + self.parent.tableau.make_01_from_selection(self.parametres['listact'], self.parametres['listsup']) file = open(self.dictpathout['listeuce1'], 'w') file.write('num uce;num uc\n') for i in range(0, len(self.parent.tableau.linecontent)): @@ -75,44 +86,42 @@ class DoQuestAlceste: file.close() self.nbind = len(self.parent.tableau.linecontent) #------------------------------------------------------------ - RchdQuest(self.dictpathout, parent.RscriptsPath, nbcl, mincl) + RchdQuest(self.dictpathout, self.parent.RscriptsPath, self.parametres['nbcl_p1'], self.parametres['mincl']) #------------------------------------------------------------ count += 1 - dlg.Update(count, u"Analyse (patientez...)") + self.dlg.Update(count, u"Analyse (patientez...)") pid = exec_rcode(self.RPath, self.dictpathout['Rchdquest'], wait = False) while pid.poll() == None : - dlg.Pulse(u"Analyse (patientez...)") + self.dlg.Pulse(u"Analyse (patientez...)") time.sleep(0.2) check_Rresult(self.parent, pid) #------------------------------------------------------------ count += 1 - dlg.Update(count, u"Ecriture des résultats") + self.dlg.Update(count, u"Ecriture des résultats") self.parent.tableau.buildprofil() self.clnb = self.parent.tableau.clnb + self.parametres['clnb'] = self.clnb self.ucecla = self.parent.tableau.ucecla self.BuildProfile() temps = time.time() - self.t1 - PrintRapport(self, 'quest') + PrintRapport(self, self, {}, istxt = False) self.parent.tableau.save_tableau(self.dictpathout['db']) - CreateIraFile(self.dictpathout, self.clnb, corpname = os.path.basename(parent.filename), section = 'questionnaire') + #CreateIraFile(self.dictpathout, self.clnb, corpname = os.path.basename(self.parent.filename), section = 'questionnaire') afc_graph_list = [[os.path.basename(self.dictpathout['AFC2DL_OUT']), u'Variables actives - coordonnées - facteurs 1 / 2'], [os.path.basename(self.dictpathout['AFC2DSL_OUT']), u'variables illustratives - coordonnées - facteurs 1 / 2'], - [os.path.basename(self.dictpathout['AFC2DCL_OUT']), u'Classes - Coordonnées - facteur 1 / 2'], - [os.path.basename(self.dictpathout['AFC2DCoul']), u'Variables actives - Corrélation - facteur 1/2'], - [os.path.basename(self.dictpathout['AFC2DCoulSup']), u'Variables illustratives - Corrélation - facteur 1 / 2'], - [os.path.basename(self.dictpathout['AFC2DCoulCl']), u'Classes - Corrélations - facteurs 1 / 2'], ] + [os.path.basename(self.dictpathout['AFC2DCL_OUT']), u'Classes - Coordonnées - facteur 1 / 2'],] chd_graph_list = [[os.path.basename(self.dictpathout['dendro1']), u'dendrogramme à partir de chd1']] chd_graph_list.append([os.path.basename(self.dictpathout['arbre1']), u'chd1']) print_liste(self.dictpathout['liste_graph_afc'], afc_graph_list) print_liste(self.dictpathout['liste_graph_chd'], chd_graph_list) self.tableau = self.parent.tableau - OpenCHDS(self.parent, self, self.dictpathout['ira'], False) + #OpenCHDS(self.parent, self, self.dictpathout['ira'], False) #------------------------------------------------------------ print 'fini', time.time() - self.t1 count += 1 - dlg.Update(count, "Fini") + self.dlg.Update(count, "Fini") def BuildProfile(self): print 'build profile' @@ -186,23 +195,14 @@ class DoQuestAlceste: PARCEX<-%s """ % "0.9" txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debet-1), xlab = xlab, ylab = ylab) + xyminmax <- PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=1, fin=(debet-1), xlab = xlab, ylab = ylab) """ % (self.dictpathout['AFC2DL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='coord', deb=debet, fin=fin, xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) """ % (self.dictpathout['AFC2DSL_OUT']) txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col = TRUE, what='coord', xlab = xlab, ylab = ylab) + PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col = TRUE, what='coord', xlab = xlab, ylab = ylab, xmin = xyminmax$xminmax[1], xmax = xyminmax$xminmax[2], ymin = xyminmax$yminmax[1], ymax = xyminmax$yminmax[2]) """ % (self.dictpathout['AFC2DCL_OUT']) - txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='crl', deb=1, fin=(debet-1), xlab = xlab, ylab = ylab) - """ % (self.dictpathout['AFC2DCoul']) - txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", what='crl', deb=debet, fin=fin, xlab = xlab, ylab = ylab) - """ % (self.dictpathout['AFC2DCoulSup']) - txt += """ - PlotAfc2dCoul(afc, as.data.frame(chistabletot), "%s", col = TRUE, what='crl', xlab = xlab, ylab = ylab) - """ % (self.dictpathout['AFC2DCoulCl']) txt += """ save.image(file="%s") """ % self.dictpathout['RData']