PEATDB/Compare.py
def displayEkin(self, srecs, sfields, slabel='', html=False,
                        overlay=False, cols=None, groupby='field'):
        """Format and display ekin plots from given recs/fields/label,
           plots can be grouped according to field if required"""

        from Ekin.Base import EkinProject
        tmppath = os.getcwd()
        slabels = self.findNames(srecs, sfields, slabel)
        all_labels = self.findNames(srecs, sfields, '')
        if len(slabels) == 0:
            return

        def insert(En, r, f, grp='field'):
            """reused in both loops"""
            E = self.DB[r][f]
            for d in all_labels:
                edata = E.getDataset(d)
                if edata != None:
                    if grp=='field':
                        name = r+' '+d
                    elif grp=='record':
                        name = f+' '+d
                    else:
                        name = r+' '+f+' '+d
                    En.insertDataset(edata, name,
                                     fit=E.getFitData(d), replace=True)

        #create ekinprojects grouped by field or record, or just one big one
        ekprojects = {}
        
        if groupby == 'none':
            En = ekprojects['all'] = EkinProject()
        if groupby == 'field' or groupby == 'none':
            for f in sfields:
                if groupby == 'field':
                    En = ekprojects[f] = EkinProject()
                for r in srecs:
                    if not self.DB[r].has_key(f):
                        continue
                    insert(En, r, f, grp=groupby)
        elif groupby == 'record':
            for r in srecs:
                En = ekprojects[r] = EkinProject()
                for f in sfields:
                    if not self.DB[r].has_key(f):
                        continue
                    insert(En, r, f, grp=groupby)

        if html == True:
            from Ekin.Web import EkinWeb
            ew = EkinWeb()
            dirs=['plots', 'csv']
            for p in dirs:
                if not os.path.exists(os.path.join(tmppath, p)):
                    os.mkdir(os.path.join(tmppath, p))
                    ew.showEkinPlots(project=En,
                              outfile=os.path.join(tmppath, 'plots.html'),
                              imgpath=os.path.join(tmppath, 'plots'),
                              path='plots/',
                              title='PEAT plots',
                              columns=3)
            import webbrowser
            webbrowser.open('plots.html',autoraise=1)
        else:
            if groupby=='field': t=sfields
            else: t=srecs
            if self.orientvar.get() == 1: orient=VERTICAL
            else: orient = HORIZONTAL
            cwin = ComparatorWin('Comparing %s' %t, labels=all_labels,
                                 selected=slabels, orient=orient)
            cwin.Opt = self.Opt
            for e in ekprojects:
                En = ekprojects[e]
                En.name = e                
                plotframe = cwin.add(E=En, selected=slabels, overlay=overlay)
            cwin.configSize()

        return
Format and display ekin plots from given recs/fields/label,
           plots can be grouped according to field if required
Format and display ekin plots from given recs/fields/label,
plots can be grouped according to field if required
Format and display ekin plots from given recs / fields / label plots can be grouped according to field if required
def displayEkin(self, srecs, sfields, slabel='', html=False,
                        overlay=False, cols=None, groupby='field'):
        from Ekin.Base import EkinProject
        tmppath = os.getcwd()
        slabels = self.findNames(srecs, sfields, slabel)
        all_labels = self.findNames(srecs, sfields, '')
        if len(slabels) == 0:
            return
        def insert(En, r, f, grp='field'):
            E = self.DB[r][f]
            for d in all_labels:
                edata = E.getDataset(d)
                if edata != None:
                    if grp=='field':
                        name = r+' '+d
                    elif grp=='record':
                        name = f+' '+d
                    else:
                        name = r+' '+f+' '+d
                    En.insertDataset(edata, name,
                                     fit=E.getFitData(d), replace=True)
        ekprojects = {}
        if groupby == 'none':
            En = ekprojects['all'] = EkinProject()
        if groupby == 'field' or groupby == 'none':
            for f in sfields:
                if groupby == 'field':
                    En = ekprojects[f] = EkinProject()
                for r in srecs:
                    if not self.DB[r].has_key(f):
                        continue
                    insert(En, r, f, grp=groupby)
        elif groupby == 'record':
            for r in srecs:
                En = ekprojects[r] = EkinProject()
                for f in sfields:
                    if not self.DB[r].has_key(f):
                        continue
                    insert(En, r, f, grp=groupby)
        if html == True:
            from Ekin.Web import EkinWeb
            ew = EkinWeb()
            dirs=['plots', 'csv']
            for p in dirs:
                if not os.path.exists(os.path.join(tmppath, p)):
                    os.mkdir(os.path.join(tmppath, p))
                    ew.showEkinPlots(project=En,
                              outfile=os.path.join(tmppath, 'plots.html'),
                              imgpath=os.path.join(tmppath, 'plots'),
                              path='plots/',
                              title='PEAT plots',
                              columns=3)
            import webbrowser
            webbrowser.open('plots.html',autoraise=1)
        else:
            if groupby=='field': t=sfields
            else: t=srecs
            if self.orientvar.get() == 1: orient=VERTICAL
            else: orient = HORIZONTAL
            cwin = ComparatorWin('Comparing %s' %t, labels=all_labels,
                                 selected=slabels, orient=orient)
            cwin.Opt = self.Opt
            for e in ekprojects:
                En = ekprojects[e]
                En.name = e                
                plotframe = cwin.add(E=En, selected=slabels, overlay=overlay)
            cwin.configSize()
        return
def displayEkin ( self , srecs , sfields , slabel = '' , html = False , overlay = False , cols = None , groupby = 'field' ) : from Ekin . Base import EkinProject tmppath = os . getcwd ( ) slabels = self . findNames ( srecs , sfields , slabel ) all_labels = self . findNames ( srecs , sfields , '' ) if len ( slabels ) == 0 : return def insert ( En , r , f , grp = 'field' ) : """reused in both loops""" E = self . DB [ r ] [ f ] for d in all_labels : edata = E . getDataset ( d ) if edata != None : if grp == 'field' : name = r + ' ' + d elif grp == 'record' : name = f + ' ' + d else : name = r + ' ' + f + ' ' + d En . insertDataset ( edata , name , fit = E . getFitData ( d ) , replace = True ) ekprojects = { } if groupby == 'none' : En = ekprojects [ 'all' ] = EkinProject ( ) if groupby == 'field' or groupby == 'none' : for f in sfields : if groupby == 'field' : En = ekprojects [ f ] = EkinProject ( ) for r in srecs : if not self . DB [ r ] . has_key ( f ) : continue insert ( En , r , f , grp = groupby ) elif groupby == 'record' : for r in srecs : En = ekprojects [ r ] = EkinProject ( ) for f in sfields : if not self . DB [ r ] . has_key ( f ) : continue insert ( En , r , f , grp = groupby ) if html == True : from Ekin . Web import EkinWeb ew = EkinWeb ( ) dirs = [ 'plots' , 'csv' ] for p in dirs : if not os . path . exists ( os . path . join ( tmppath , p ) ) : os . mkdir ( os . path . join ( tmppath , p ) ) ew . showEkinPlots ( project = En , outfile = os . path . join ( tmppath , 'plots.html' ) , imgpath = os . path . join ( tmppath , 'plots' ) , path = 'plots/' , title = 'PEAT plots' , columns = 3 ) import webbrowser webbrowser . open ( 'plots.html' , autoraise = 1 ) else : if groupby == 'field' : t = sfields else : t = srecs if self . orientvar . get ( ) == 1 : orient = VERTICAL else : orient = HORIZONTAL cwin = ComparatorWin ( 'Comparing %s' % t , labels = all_labels , selected = slabels , orient = orient ) cwin . Opt = self . Opt for e in ekprojects : En = ekprojects [ e ] En . name = e plotframe = cwin . add ( E = En , selected = slabels , overlay = overlay ) cwin . configSize ( ) return
Format and display ekin plots from given recs/fields/label,
plots can be grouped according to field if required
Format and display ekin plots from given recs / fields / label plots can be grouped according to field if required
"""Format and display ekin plots from given recs/fields/label,
           plots can be grouped according to field if required""" """reused in both loops""" #create ekinprojects grouped by field or record, or just one big one
self
srecs
sfields
slabel
html
overlay
cols
groupby