PEATDB/Ekin/Web.py
def showEkinPlots(self, ekindata=None, project=None, filename=None,
                            datasets='ALL',
                            title='Ekin plots',
                            outfile=None, imgpath=None, path='',
                            normalise=False, showfitvars=False,
                            plotoption=1, columns=2, legend=False, size=(8,6),
                            logx=False, logy=False):
        """Plot ekin datasets from the provided ekin project data"""

        def downloadLink():
            #do csv download link for data displayed
            print '<table id="mytable" valign=top>'
            cfname = tempfile.mktemp('.csv', dir=csvpath)
            E.exportCSV(filename=cfname)
            p = os.path.split(path)[0]
            print '<td><a href=%s title="right-click to save as"> download data </a>' \
                      %os.path.join(p, 'csv', os.path.basename(cfname))
            print '</td></tr>'
            print '</table>'

        csvpath = os.path.join( os.path.split(imgpath)[0], 'csv')

	print project
        if ekindata != None: #convert from ekindata
            E = EkinProject(data=ekindata, mode='NMR titration')
        elif project != None: #just passed object
            E = project
        elif filename != None: #load project from file
            E = EkinProject()
            E.openProject(project)
        else:
            return
	E.checkDatasets()
        #if outfile is given, we override imgpath
        if outfile != None and imgpath==None:
            imgpath = os.path.dirname(outfile)
        if imgpath != None:
            tempfile.tempdir = imgpath

        size=(8,6)
        if datasets == 'ALL':
            #we plot all the datasets
            datasets = E.datasets
        if plotoption == 1:
            if columns>2:
                size=(4,3)
            imagenames={}
            for d in datasets:
                imgfile = self.maketempImage()
                name = os.path.basename(imgfile)                
                E.plotDatasets(d, filename=imgfile, size=size, linecolor='r',
                                    normalise=normalise,showfitvars=showfitvars,legend=legend,
                                    logx=logx, logy=logy)
                imagenames[d] = name

        elif plotoption == 3:
            name = self.maketempImage()
            E.plotDatasets(datasets, filename=name, plotoption=3, size=size,
                                normalise=normalise, legend=legend,
                                logx=logx, logy=logy)

        if outfile != None:
            saveout = sys.stdout
            fsock = open(outfile, 'w')
            sys.stdout = fsock

        self.doheader(title)
        downloadLink()

        print '<table id="mytable" align=center cellspacing="0" borderwidth=1>'
        row=1;c=1
        datasets.sort()
        if plotoption == 1:
            for d in datasets:
                if not imagenames.has_key(d):
                    continue
                if c==1:
                    print '<tr>'
                print '<td> <img src=%s/%s  align=center></td>' % (path, imagenames[d])
                print '<td class="alt">'
                #use ekinproject to supply formatted fit and model info here..
                self.showMetaData(ekinproj=E, dataset=d)
                print '</td>'
                c=c+1
                if c >= columns:
                    print '</tr>'
                    row=row+1
                    c=1
        elif plotoption == 3:
            print '<td> <img src=%s/%s  align=center></td>' % (path, os.path.basename(name))
            print '<td class="alt">'
            #use ekinproject to supply formatted fit and model info here..
	    x=1
            for d in datasets:
		if x>2:
		   n=True
		   x=0
	    	else:
		   n=False
		if n==False:
		   print '<td>'
            	self.showMetaData(ekinproj=E, dataset=d)
		x+=1
            print '</td>'
            c=c+1
            if c >= columns:
                print '</tr>'
                row=row+1
                c=1


        print '</table>'
        if outfile != None:
            sys.stdout.flush()
            sys.stdout = saveout
            fsock.close()
        return
Plot ekin datasets from the provided ekin project data
Plot ekin datasets from the provided ekin project data
Plot ekin datasets from the provided ekin project data
def showEkinPlots(self, ekindata=None, project=None, filename=None,
                            datasets='ALL',
                            title='Ekin plots',
                            outfile=None, imgpath=None, path='',
                            normalise=False, showfitvars=False,
                            plotoption=1, columns=2, legend=False, size=(8,6),
                            logx=False, logy=False):
        def downloadLink():
            print '<table id="mytable" valign=top>'
            cfname = tempfile.mktemp('.csv', dir=csvpath)
            E.exportCSV(filename=cfname)
            p = os.path.split(path)[0]
            print '<td><a href=%s title="right-click to save as"> download data </a>' \
                      %os.path.join(p, 'csv', os.path.basename(cfname))
            print '</td></tr>'
            print '</table>'
        csvpath = os.path.join( os.path.split(imgpath)[0], 'csv')
	print project
        if ekindata != None: 
            E = EkinProject(data=ekindata, mode='NMR titration')
        elif project != None: 
            E = project
        elif filename != None: 
            E = EkinProject()
            E.openProject(project)
        else:
            return
	E.checkDatasets()
        if outfile != None and imgpath==None:
            imgpath = os.path.dirname(outfile)
        if imgpath != None:
            tempfile.tempdir = imgpath
        size=(8,6)
        if datasets == 'ALL':
            datasets = E.datasets
        if plotoption == 1:
            if columns>2:
                size=(4,3)
            imagenames={}
            for d in datasets:
                imgfile = self.maketempImage()
                name = os.path.basename(imgfile)                
                E.plotDatasets(d, filename=imgfile, size=size, linecolor='r',
                                    normalise=normalise,showfitvars=showfitvars,legend=legend,
                                    logx=logx, logy=logy)
                imagenames[d] = name
        elif plotoption == 3:
            name = self.maketempImage()
            E.plotDatasets(datasets, filename=name, plotoption=3, size=size,
                                normalise=normalise, legend=legend,
                                logx=logx, logy=logy)
        if outfile != None:
            saveout = sys.stdout
            fsock = open(outfile, 'w')
            sys.stdout = fsock
        self.doheader(title)
        downloadLink()
        print '<table id="mytable" align=center cellspacing="0" borderwidth=1>'
        row=1;c=1
        datasets.sort()
        if plotoption == 1:
            for d in datasets:
                if not imagenames.has_key(d):
                    continue
                if c==1:
                    print '<tr>'
                print '<td> <img src=%s/%s  align=center></td>' % (path, imagenames[d])
                print '<td class="alt">'
                self.showMetaData(ekinproj=E, dataset=d)
                print '</td>'
                c=c+1
                if c >= columns:
                    print '</tr>'
                    row=row+1
                    c=1
        elif plotoption == 3:
            print '<td> <img src=%s/%s  align=center></td>' % (path, os.path.basename(name))
            print '<td class="alt">'
	    x=1
            for d in datasets:
		if x>2:
		   n=True
		   x=0
	    	else:
		   n=False
		if n==False:
		   print '<td>'
            	self.showMetaData(ekinproj=E, dataset=d)
		x+=1
            print '</td>'
            c=c+1
            if c >= columns:
                print '</tr>'
                row=row+1
                c=1
        print '</table>'
        if outfile != None:
            sys.stdout.flush()
            sys.stdout = saveout
            fsock.close()
        return
def showEkinPlots ( self , ekindata = None , project = None , filename = None , datasets = 'ALL' , title = 'Ekin plots' , outfile = None , imgpath = None , path = '' , normalise = False , showfitvars = False , plotoption = 1 , columns = 2 , legend = False , size = ( 8 , 6 ) , logx = False , logy = False ) : def downloadLink ( ) : print '<table id="mytable" valign=top>' cfname = tempfile . mktemp ( '.csv' , dir = csvpath ) E . exportCSV ( filename = cfname ) p = os . path . split ( path ) [ 0 ] print '<td><a href=%s title="right-click to save as"> download data </a>' % os . path . join ( p , 'csv' , os . path . basename ( cfname ) ) print '</td></tr>' print '</table>' csvpath = os . path . join ( os . path . split ( imgpath ) [ 0 ] , 'csv' ) print project if ekindata != None : E = EkinProject ( data = ekindata , mode = 'NMR titration' ) elif project != None : E = project elif filename != None : E = EkinProject ( ) E . openProject ( project ) else : return E . checkDatasets ( ) if outfile != None and imgpath == None : imgpath = os . path . dirname ( outfile ) if imgpath != None : tempfile . tempdir = imgpath size = ( 8 , 6 ) if datasets == 'ALL' : datasets = E . datasets if plotoption == 1 : if columns > 2 : size = ( 4 , 3 ) imagenames = { } for d in datasets : imgfile = self . maketempImage ( ) name = os . path . basename ( imgfile ) E . plotDatasets ( d , filename = imgfile , size = size , linecolor = 'r' , normalise = normalise , showfitvars = showfitvars , legend = legend , logx = logx , logy = logy ) imagenames [ d ] = name elif plotoption == 3 : name = self . maketempImage ( ) E . plotDatasets ( datasets , filename = name , plotoption = 3 , size = size , normalise = normalise , legend = legend , logx = logx , logy = logy ) if outfile != None : saveout = sys . stdout fsock = open ( outfile , 'w' ) sys . stdout = fsock self . doheader ( title ) downloadLink ( ) print '<table id="mytable" align=center cellspacing="0" borderwidth=1>' row = 1 ; c = 1 datasets . sort ( ) if plotoption == 1 : for d in datasets : if not imagenames . has_key ( d ) : continue if c == 1 : print '<tr>' print '<td> <img src=%s/%s  align=center></td>' % ( path , imagenames [ d ] ) print '<td class="alt">' self . showMetaData ( ekinproj = E , dataset = d ) print '</td>' c = c + 1 if c >= columns : print '</tr>' row = row + 1 c = 1 elif plotoption == 3 : print '<td> <img src=%s/%s  align=center></td>' % ( path , os . path . basename ( name ) ) print '<td class="alt">' x = 1 for d in datasets : if x > 2 : n = True x = 0 else : n = False if n == False : print '<td>' self . showMetaData ( ekinproj = E , dataset = d ) x += 1 print '</td>' c = c + 1 if c >= columns : print '</tr>' row = row + 1 c = 1 print '</table>' if outfile != None : sys . stdout . flush ( ) sys . stdout = saveout fsock . close ( ) return
Plot ekin datasets from the provided ekin project data
Plot ekin datasets from the provided ekin project data
"""Plot ekin datasets from the provided ekin project data""" #do csv download link for data displayed #convert from ekindata #just passed object #load project from file #if outfile is given, we override imgpath #we plot all the datasets #use ekinproject to supply formatted fit and model info here.. #use ekinproject to supply formatted fit and model info here..
self
ekindata
project
filename
datasets
title
outfile
imgpath
path
normalise
showfitvars
plotoption
columns
legend
size
logx
logy