CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Attributes

matplotRender::matplotRender Class Reference

List of all members.

Public Member Functions

def __init__
def drawHTTPstring
def drawInteractive
def drawPNG
def plotInst_RunLS
def plotPeakPerday_Time
def plotPerdayX_Time
def plotSumX_Fill
def plotSumX_Run
def plotSumX_Time

Public Attributes

 colormap

Private Attributes

 __canvas
 __fig

Detailed Description

Definition at line 45 of file matplotRender.py.


Constructor & Destructor Documentation

def matplotRender::matplotRender::__init__ (   self,
  fig 
)

Definition at line 46 of file matplotRender.py.

00047                           :
00048         self.__fig=fig
00049         self.__canvas=''
00050         self.colormap={}
00051         self.colormap['Delivered']='r'
00052         self.colormap['Recorded']='b'
00053         self.colormap['Effective']='g'
00054         self.colormap['Max Inst']='r'


Member Function Documentation

def matplotRender::matplotRender::drawHTTPstring (   self)

Definition at line 542 of file matplotRender.py.

00543                             :
00544         self.__canvas=CanvasBackend(self.__fig)    
00545         cherrypy.response.headers['Content-Type']='image/png'
00546         buf=StringIO()
00547         self.__canvas.print_png(buf)
00548         return buf.getvalue()
    
def matplotRender::matplotRender::drawInteractive (   self)

Definition at line 553 of file matplotRender.py.

00554                              :
00555         if batchonly:
00556             print 'interactive mode is not available for your setup, exit'
00557             sys.exit()    
00558         self.__canvas=CanvasBackend(self.__fig,master=root)
00559         self.__canvas.show()
00560         self.__canvas.get_tk_widget().pack(side=Tk.TOP,fill=Tk.BOTH,expand=1)
00561         toolbar=NavigationToolbar2TkAgg(self.__canvas,root)
00562         toolbar.update()
00563         self.__canvas._tkcanvas.pack(side=Tk.TOP,fill=Tk.BOTH,expand=1)
00564         button = Tk.Button(master=root,text='Quit',command=sys.exit)
00565         button.pack(side=Tk.BOTTOM)
        Tk.mainloop()
def matplotRender::matplotRender::drawPNG (   self,
  filename 
)

Definition at line 549 of file matplotRender.py.

00550                               :
00551         self.__canvas=CanvasBackend(self.__fig)    
00552         self.__canvas.print_figure(filename)
    
def matplotRender::matplotRender::plotInst_RunLS (   self,
  rawxdata,
  rawydata,
  nticks = 6 
)
Input: rawxdata [run,fill,norbit,starttime,stoptime,totalls,ncmsls]
       rawydata {label:[instlumi]}

Definition at line 451 of file matplotRender.py.

00452                                                        :
00453         '''
00454         Input: rawxdata [run,fill,norbit,starttime,stoptime,totalls,ncmsls]
00455                rawydata {label:[instlumi]}
00456         '''
00457         runnum=rawxdata[0]
00458         fill=rawxdata[1]
00459         norbit=rawxdata[2]
00460         starttime=rawxdata[3]
00461         stoptime=rawxdata[4]
00462         totalls=rawxdata[-2]
00463         ncmsls=rawxdata[-1]
00464         peakinst=max(rawydata['Delivered'])
00465         lslength=float(norbit)*3564*25.0e-9
00466         totaldelivered=sum(rawydata['Delivered'])*lslength
00467         totalrecorded=sum(rawydata['Recorded'])*lslength
00468         xpoints=range(1,totalls+1)        
00469         #print len(xpoints)
00470         ypoints={}
00471         ymax={}
00472         for ylabel,yvalue in rawydata.items():
00473             ypoints[ylabel]=yvalue
00474             ymax[ylabel]=max(yvalue)
00475         left=0.15
00476         width=0.7
00477         bottom=0.1
00478         height=0.65
00479         bottom_h=bottom+height
00480         rect_scatter=[left,bottom,width,height]
00481         rect_table=[left,bottom_h,width,0.25]
00482         
00483         nullfmt=matplotlib.ticker.NullFormatter()
00484         nullloc=matplotlib.ticker.NullLocator()
00485         axtab=self.__fig.add_axes(rect_table,frameon=False)
00486         axtab.set_axis_off()
00487         axtab.xaxis.set_major_formatter(nullfmt)
00488         axtab.yaxis.set_major_formatter(nullfmt)
00489         axtab.xaxis.set_major_locator(nullloc)
00490         axtab.yaxis.set_major_locator(nullloc)
00491 
00492         ax=self.__fig.add_axes(rect_scatter)
00493         
00494         majorLoc=matplotlib.ticker.LinearLocator(numticks=nticks)
00495         minorLoc=matplotlib.ticker.LinearLocator(numticks=nticks*4)
00496         ax.set_xlabel(r'LS',position=(0.96,0))
00497         ax.set_ylabel(r'L $\mu$b$^{-1}$s$^{-1}$',position=(0,0.9))
00498         ax.xaxis.set_major_locator(majorLoc)
00499         ax.xaxis.set_minor_locator(minorLoc)
00500         ax.set_xbound(lower=xpoints[0],upper=xpoints[-1])
00501         xticklabels=ax.get_xticklabels()
00502         for tx in xticklabels:
00503             tx.set_horizontalalignment('right')
00504         ax.grid(True)
00505         keylist=ypoints.keys()
00506         keylist.sort()
00507         legendlist=[]
00508 
00509         for ylabel in keylist:
00510             cl='k'
00511             if self.colormap.has_key(ylabel):
00512                 cl=self.colormap[ylabel]
00513             ax.plot(xpoints,ypoints[ylabel],'.',label=ylabel,color=cl)
00514             legendlist.append(ylabel)      
00515         #ax.axhline(0,color='green',linewidth=0.2)
00516         ax.axvline(xpoints[ncmsls-1],color='green',linewidth=0.2)
00517 
00518         denomitor=1.0
00519         unitstring='/$\mu$b'
00520         if totaldelivered>=1.0e3 and totaldelivered<1.0e06:
00521             denomitor=1.0e3
00522             unitstring='/nb'
00523         elif totaldelivered>=1.0e6 and totaldelivered<1.0e9:
00524             denomitor=1.0e6
00525             unitstring='/pb'
00526         elif totaldelivered>=1.0e9 and totaldelivered<1.0e12:
00527             denomitor=1.0e9
00528             unitstring='/fb'
00529         elif totaldelivered>=1.0e12 and totaldelivered<1.0e15:
00530             denomitor=1.0e12
00531             unitstring='/ab'
00532         colLabels=('run','fill','max inst(/$\mu$b/s)','delivered('+unitstring+')','recorded('+unitstring+')')
00533         cellText=[[str(runnum),str(fill),'%.3f'%(peakinst),'%.3f'%(totaldelivered/denomitor),'%.3f'%(totalrecorded/denomitor)]]
00534        
00535         sumtable=axtab.table(cellText=cellText,colLabels=colLabels,colWidths=[0.12,0.1,0.27,0.27,0.27],cellLoc='center',loc='center')
00536         trans=matplotlib.transforms.BlendedGenericTransform(ax.transData,ax.transAxes)        
00537         axtab.add_table(sumtable)
00538         
00539         ax.text(xpoints[0],1.02,starttime[0:17],transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))   
00540         ax.text(xpoints[ncmsls-1],1.02,stoptime[0:17],transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))        
00541         ax.legend(tuple(legendlist),loc='upper right',numpoints=1)

def matplotRender::matplotRender::plotPeakPerday_Time (   self,
  daydict,
  minTime,
  maxTime,
  nticks = 6,
  annotateBoundaryRunnum = False,
  yscale = 'linear' 
)
Input: daydict={}#{day:[run,lsnum,instlumi]}

Definition at line 361 of file matplotRender.py.

00362                                                                                                                :
00363         '''
00364         Input: daydict={}#{day:[run,lsnum,instlumi]}
00365         '''
00366         xpoints=[]
00367         ypoints=[]
00368         legendlist=[]
00369         days=daydict.keys()
00370         days.sort()
00371         beginfo=str(daydict[days[0]][0])+':'+str(daydict[days[0]][1])
00372         endinfo=str(daydict[days[-1]][0])+':'+str(daydict[days[-1]][1])
00373         maxinfo=''
00374         ymax=0.0
00375         xmax=0
00376         minday=days[0]
00377         maxday=days[-1]
00378         minvar=0.1
00379         for day in range(minday,maxday+1):
00380             xpoints.append(day)
00381             if not daydict.has_key(day):
00382                 ypoints.append(0.0)
00383                 continue
00384             daymaxdata=daydict[day]
00385             ypoints.append(daymaxdata[2])
00386             if daydict[day][2]>ymax:
00387                 ymax=daydict[day][2]
00388                 xmax=day
00389                 runmax=daydict[day][0]
00390                 lsmax=daydict[day][1]
00391                 maxinfo=str(runmax)+':'+str(lsmax)
00392         denomitor=1.0
00393         unitstring='$\mu$b$^{-1}$s$^{-1}$'
00394         if ymax>=1.0e3 and ymax<1.0e06:
00395             denomitor=1.0e3
00396             unitstring='nb$^{-1}$s$^{-1}$'
00397         elif ymax>=1.0e6 and ymax<1.0e9:
00398             denomitor=1.0e6
00399             unitstring='pb$^{-1}$s$^{-1}$'
00400         elif ymax>=1.0e9 and ymax<1.0e12:
00401             denomitor=1.0e9
00402             unitstring='fb$^{-1}$s$^{-1}$'
00403         elif ymax>=1.0e12 and ymax<1.0e15:
00404             denomitor=1.0e12
00405             unitstring='ab$^{-1}$s$^{-1}$'
00406             
00407         ax=self.__fig.add_subplot(111)
00408         if yscale=='linear':
00409             ax.set_yscale('linear')
00410         elif yscale=='log':
00411             ax.set_yscale('log')
00412             for i,v in enumerate(ypoints):
00413                     if v<minvar:
00414                         ypoints[i]=minvar
00415         else:
00416             raise 'unsupported yscale ',yscale
00417         dateFmt=matplotlib.dates.DateFormatter('%d/%m')
00418         majorLoc=matplotlib.ticker.LinearLocator(numticks=nticks)
00419         minorLoc=matplotlib.ticker.LinearLocator(numticks=nticks*4)
00420         ax.xaxis.set_major_formatter(dateFmt)
00421         ax.set_xlabel(r'Date',position=(0.84,0))
00422         ax.set_ylabel(r'L '+unitstring,position=(0,0.9))
00423         ax.xaxis.set_major_locator(majorLoc)
00424         ax.xaxis.set_minor_locator(minorLoc)
00425         xticklabels=ax.get_xticklabels()
00426         for tx in xticklabels:
00427             tx.set_horizontalalignment('right')
00428         ax.grid(True)
00429         cl=self.colormap['Max Inst']
00430         #print 'xpoints ',xpoints
00431         #print 'ypoints ',ypoints
00432         #print 'maxinfo ',maxinfo
00433         #print 'beginfo ',beginfo
00434         #print 'endinfo ',endinfo
00435         ax.plot(xpoints,[y/denomitor for y in ypoints],label='Max Inst',color=cl,drawstyle='steps')
00436         legendlist.append('Max Inst %.2f'%(ymax/denomitor)+' '+unitstring)
00437         ax.legend(tuple(legendlist),loc='upper left')
00438         ax.set_xbound(lower=matplotlib.dates.date2num(minTime),upper=matplotlib.dates.date2num(maxTime))
00439         if annotateBoundaryRunnum:
00440            #annotations
00441            trans=matplotlib.transforms.BlendedGenericTransform(ax.transData,ax.transAxes)
00442            ax.text(xpoints[0],1.025,beginfo,transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))
00443            ax.text(xpoints[-1],1.025,endinfo,transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))
00444            ax.annotate(maxinfo,xy=(xmax,ymax),xycoords='data',xytext=(0,13),textcoords='offset points',arrowprops=dict(facecolor='green',shrink=0.05),size='x-small',horizontalalignment='center',color='green',bbox=dict(facecolor='white'))
00445         yearStr=minTime.strftime('%Y')
00446         firstimeStr=minTime.strftime('%b %d %H:%M')
00447         lasttimeStr=maxTime.strftime('%b %d %H:%M')
00448         ax.set_title('Peak Luminosity/Day '+yearStr+' ('+firstimeStr+' UTC - '+lasttimeStr+' UTC)',size='small',family='fantasy')
00449         self.__fig.autofmt_xdate(bottom=0.18,rotation=0)
00450         self.__fig.subplots_adjust(bottom=0.1,left=0.1)

def matplotRender::matplotRender::plotPerdayX_Time (   self,
  days,
  databyday,
  minTime,
  maxTime,
  boundaryInfo = [],
  nticks = 6,
  annotateBoundaryRunnum = False,
  yscale = 'linear' 
)
input
    databyday {'Delivered':[lumiperday]}
    boundaryInfo [[begintime,begininfo],[endtime,endinfo]]

Definition at line 283 of file matplotRender.py.

00284                                                                                                                                    :
00285         '''input
00286             databyday {'Delivered':[lumiperday]}
00287             boundaryInfo [[begintime,begininfo],[endtime,endinfo]]
00288         '''
00289         ax=self.__fig.add_subplot(111)
00290         t=max(databyday['Delivered'])
00291         minvar=min([x for x in databyday['Recorded'] if x>0]) #used only for log scale
00292         maxvalues={}
00293         keylist=databyday.keys()
00294         keylist.sort()
00295         for k in keylist:
00296             maxvalues[k]=max(databyday[k])
00297             
00298         if yscale=='linear':
00299             ax.set_yscale('linear')
00300         elif yscale=='log':
00301             ax.set_yscale('log')
00302             for k in keylist:
00303                 for i,v in enumerate(databyday[k]):
00304                     if v<minvar:
00305                         databyday[k][i]=minvar
00306         else:
00307             raise 'unsupported yscale ',yscale
00308         dateFmt=matplotlib.dates.DateFormatter('%d/%m')
00309         majorLoc=matplotlib.ticker.LinearLocator(numticks=nticks)
00310         minorLoc=matplotlib.ticker.LinearLocator(numticks=nticks*4)
00311         ax.xaxis.set_major_formatter(dateFmt)
00312         ax.set_xlabel(r'Date',position=(0.84,0))
00313         ax.xaxis.set_major_locator(majorLoc)
00314         ax.xaxis.set_minor_locator(minorLoc)
00315         xticklabels=ax.get_xticklabels()
00316         for tx in xticklabels:
00317             tx.set_horizontalalignment('right')
00318         ax.grid(True)
00319         legendlist=[]
00320      
00321         denomitor=1.0
00322         unitstring='$\mu$b$^{-1}$'
00323         if t>=1.0e3 and t<1.0e06:
00324             denomitor=1.0e3
00325             unitstring='nb$^{-1}$'
00326         elif t>=1.0e6 and t<1.0e9:
00327             denomitor=1.0e6
00328             unitstring='pb$^{-1}$'
00329         elif t>=1.0e9 and t<1.0e12:
00330             denomitor=1.0e9
00331             unitstring='fb$^{-1}$'
00332         elif  t>=1.0e12 and t<1.0e15:
00333             denomitor=1.0e12
00334             unitstring='ab$^{-1}$'
00335 
00336         ax.set_ylabel(r'L '+unitstring,position=(0,0.9))    
00337         for ylabel in keylist:
00338             cl='k'
00339             if self.colormap.has_key(ylabel):
00340                 cl=self.colormap[ylabel]
00341             ax.plot(days,[y/denomitor for y in databyday[ylabel]],label=ylabel,color=cl,drawstyle='steps')
00342             legendlist.append(ylabel+' Max '+'%.2f'%(maxvalues[ylabel]/denomitor)+' '+unitstring)
00343         ax.legend(tuple(legendlist),loc='upper left')
00344         ax.set_xbound(lower=matplotlib.dates.date2num(minTime),upper=matplotlib.dates.date2num(maxTime))
00345         if annotateBoundaryRunnum:
00346             if len(boundaryInfo)!=0:
00347                 begtime=boundaryInfo[0][0]
00348                 beginfo=boundaryInfo[0][1]
00349                 endtime=boundaryInfo[1][0]
00350                 endinfo=boundaryInfo[1][1]
00351                 #annotations
00352                 trans=matplotlib.transforms.BlendedGenericTransform(ax.transData,ax.transAxes)
00353                 ax.text(matplotlib.dates.date2num(begtime),1.025,beginfo,transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))        
00354                 ax.text(matplotlib.dates.date2num(endtime),1.025,endinfo,transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))
00355         yearStr=minTime.strftime('%Y')
00356         firstimeStr=minTime.strftime('%b %d %H:%M')
00357         lasttimeStr=maxTime.strftime('%b %d %H:%M')
00358         ax.set_title('Integrated Luminosity/Day '+yearStr+' ('+firstimeStr+' UTC - '+lasttimeStr+' UTC)',size='small',family='fantasy')
00359         self.__fig.autofmt_xdate(bottom=0.18,rotation=0)
00360         self.__fig.subplots_adjust(bottom=0.18,left=0.1)

def matplotRender::matplotRender::plotSumX_Fill (   self,
  rawxdata,
  rawydata,
  rawfillDict,
  nticks = 6,
  yscale = 'linear' 
)

Definition at line 127 of file matplotRender.py.

00128                                                                                   :
00129         #print 'plotSumX_Fill rawxdata ',rawxdata
00130         ytotal={}
00131         ypoints={}
00132         xpoints=rawfillDict.keys()
00133         if len(xpoints)==0:
00134             print '[WARNING]: no data, do nothing'
00135             return
00136         xpoints.sort()
00137         beginfo=''
00138         endinfo=''
00139         t=sum(rawydata['Delivered'])
00140         denomitor=1.0
00141         unitstring='$\mu$b$^{-1}$'
00142         if t>=1.0e3 and t<1.0e06:
00143             denomitor=1.0e3
00144             unitstring='nb$^{-1}$'
00145         elif t>=1.0e6 and t<1.0e9:
00146             denomitor=1.0e6
00147             unitstring='pb$^{-1}$'
00148         elif t>=1.0e9 and t<1.0e12:
00149             denomitor=1.0e9
00150             unitstring='fb$^{-1}$'
00151         elif  t>=1.0e12 and t<1.0e15:
00152             denomitor=1.0e12
00153             unitstring='ab$^{-1}$'
00154             
00155         for ylabel,yvalue in rawydata.items():
00156             ypoints[ylabel]=[]
00157             ytotal[ylabel]=sum(rawydata[ylabel])/denomitor
00158             for idx,fill in enumerate(xpoints):
00159                 runlist=rawfillDict[fill]
00160                 if idx==0:
00161                     beginfo=str(fill)+':'+str(runlist[0])
00162                 if idx==len(xpoints)-1:
00163                     endinfo=str(fill)+':'+str(runlist[-1])
00164                 xidx=rawxdata.index(max(runlist))
00165                 ypoints[ylabel].append(sum(yvalue[0:xidx])/denomitor)
00166         ax=self.__fig.add_subplot(111)
00167         ax.set_xlabel(r'LHC Fill Number',position=(0.84,0))
00168         ax.set_ylabel(r'L '+unitstring,position=(0,0.9))
00169         ax.set_xbound(lower=xpoints[0],upper=xpoints[-1])
00170         if yscale=='linear':
00171             ax.set_yscale('linear')
00172         elif yscale=='log':
00173             ax.set_yscale('log')
00174         else:
00175             raise 'unsupported yscale ',yscale
00176         xticklabels=ax.get_xticklabels()
00177         majorLocator=matplotlib.ticker.LinearLocator( nticks )
00178         majorFormatter=matplotlib.ticker.FormatStrFormatter('%d')
00179         #minorLocator=matplotlib.ticker.MultipleLocator(sampleinterval)
00180         ax.xaxis.set_major_locator(majorLocator)
00181         ax.xaxis.set_major_formatter(majorFormatter)
00182         #ax.xaxis.set_minor_locator(minorLocator)
00183         ax.grid(True)
00184         keylist=ypoints.keys()
00185         keylist.sort()
00186         legendlist=[]
00187         for ylabel in keylist:
00188             cl='k'
00189             if self.colormap.has_key(ylabel):
00190                 cl=self.colormap[ylabel]
00191             ax.plot(xpoints,ypoints[ylabel],label=ylabel,color=cl,drawstyle='steps')
00192             legendlist.append(ylabel+' '+'%.2f'%(ytotal[ylabel])+' '+unitstring)
00193         #font=FontProperties(size='medium',weight='demibold')
00194         #annotations
00195         trans=matplotlib.transforms.BlendedGenericTransform(ax.transData,ax.transAxes)
00196         ax.text(xpoints[0],1.025,beginfo,transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))
00197         ax.text(xpoints[-1],1.025,endinfo,transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))
00198         ax.legend(tuple(legendlist),loc='upper left')
00199         self.__fig.subplots_adjust(bottom=0.1,left=0.1)
        
def matplotRender::matplotRender::plotSumX_Run (   self,
  rawxdata,
  rawydata,
  nticks = 6,
  yscale = 'linear' 
)

Definition at line 55 of file matplotRender.py.

00056                                                                      :
00057         xpoints=[]
00058         ypoints={}
00059         ytotal={}
00060         xidx=[]
00061         #print 'max rawxdata ',max(rawxdata)
00062         #print 'min rawxdata ',min(rawxdata)
00063         for x in CommonUtil.inclusiveRange(min(rawxdata),max(rawxdata),1):
00064             #print 'x : ',x
00065             xpoints.append(x)
00066             xidx.append(rawxdata.index(x)) #get the index of the sample points
00067             #print 'xidx : ',rawxdata.index(x)
00068         if len(xpoints)==0:
00069             print '[WARNING]: no data, do nothing'
00070             return
00071         t=sum(rawydata['Delivered'])
00072         denomitor=1.0
00073         unitstring='$\mu$b$^{-1}$'
00074         if t>=1.0e3 and t<1.0e06:
00075             denomitor=1.0e3
00076             unitstring='nb$^{-1}$'
00077         elif t>=1.0e6 and t<1.0e9:
00078             denomitor=1.0e6
00079             unitstring='pb$^{-1}$'
00080         elif t>=1.0e9 and t<1.0e12:
00081             denomitor=1.0e9
00082             unitstring='fb$^{-1}$'
00083         elif  t>=1.0e12 and t<1.0e15:
00084             denomitor=1.0e12
00085             unitstring='ab$^{-1}$'
00086         for ylabel,yvalues in rawydata.items():
00087             ypoints[ylabel]=[]           
00088             for i in xidx:
00089                 ypoints[ylabel].append(sum(yvalues[0:i])/denomitor)
00090             ytotal[ylabel]=sum(yvalues)/denomitor  
00091         ax=self.__fig.add_subplot(111)
00092         if yscale=='linear':
00093             ax.set_yscale('linear')
00094         elif yscale=='log':
00095             ax.set_yscale('log')
00096         else:
00097             raise 'unsupported yscale ',yscale
00098         ax.set_xlabel(r'Run',position=(0.95,0))
00099         ax.set_ylabel(r'L '+unitstring,position=(0,0.9))
00100         xticklabels=ax.get_xticklabels()
00101         for tx in xticklabels:
00102             tx.set_rotation(30)
00103         majorLocator=matplotlib.ticker.LinearLocator( nticks )
00104         majorFormatter=matplotlib.ticker.FormatStrFormatter('%d')
00105         minorLocator=matplotlib.ticker.LinearLocator(numticks=4*nticks)
00106         ax.xaxis.set_major_locator(majorLocator)
00107         ax.xaxis.set_major_formatter(majorFormatter)
00108         ax.xaxis.set_minor_locator(minorLocator)
00109         ax.set_xbound(lower=xpoints[0],upper=xpoints[-1])
00110         ax.grid(True)
00111         keylist=ypoints.keys()
00112         keylist.sort()
00113         legendlist=[]
00114         for ylabel in keylist:
00115             cl='k'
00116             if self.colormap.has_key(ylabel):
00117                 cl=self.colormap[ylabel]
00118             ax.plot(xpoints,ypoints[ylabel],label=ylabel,color=cl,drawstyle='steps')
00119             legendlist.append(ylabel+' '+'%.2f'%(ytotal[ylabel])+' '+unitstring)
00120         #font=FontProperties(size='medium',weight='demibold')
00121         #annotations
00122         trans=matplotlib.transforms.BlendedGenericTransform(ax.transData,ax.transAxes)
00123         ax.text(xpoints[0],1.025,str(xpoints[0]),transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))
00124         ax.text(xpoints[-1],1.025,str(xpoints[-1]),transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))
00125         ax.legend(tuple(legendlist),loc='upper left')
00126         self.__fig.subplots_adjust(bottom=0.18,left=0.1)
        
def matplotRender::matplotRender::plotSumX_Time (   self,
  rawxdata,
  rawydata,
  minTime,
  maxTime,
  hltpath = '',
  nticks = 6,
  annotateBoundaryRunnum = False,
  yscale = 'linear' 
)
input:
   rawxdata runDict{runnumber:[delivered,recorded,recorded_hltpath]}
   rawydata {label:[rundata]}

Definition at line 200 of file matplotRender.py.

00201                                                                                                                               :
00202         '''
00203         input:
00204            rawxdata runDict{runnumber:[delivered,recorded,recorded_hltpath]}
00205            rawydata {label:[rundata]}
00206         '''
00207         xpoints=[]
00208         ypoints={}
00209         ytotal={}
00210         xidx=[]
00211         runs=rawxdata.keys()
00212         runs.sort()
00213         for idx,run in enumerate(runs):
00214             xpoints.append(matplotlib.dates.date2num(rawxdata[run][0]))
00215             xidx.append(idx)
00216         if len(xpoints)==0:
00217             print '[WARNING]: no data, do nothing'
00218             return
00219         t=sum(rawydata['Delivered'])
00220         denomitor=1.0
00221         unitstring='$\mu$b$^{-1}$'
00222         if t>=1.0e3 and t<1.0e06:
00223             denomitor=1.0e3
00224             unitstring='nb$^{-1}$'
00225         elif t>=1.0e6 and t<1.0e9:
00226             denomitor=1.0e6
00227             unitstring='pb$^{-1}$'
00228         elif t>=1.0e9 and t<1.0e12:
00229             denomitor=1.0e9
00230             unitstring='fb$^{-1}$'
00231         elif  t>=1.0e12 and t<1.0e15:
00232             denomitor=1.0e12
00233             unitstring='ab$^{-1}$'
00234             
00235         for ylabel,yvalue in rawydata.items():
00236             ypoints[ylabel]=[]
00237             for i in xidx:
00238                 ypoints[ylabel].append(sum(yvalue[0:i])/denomitor)
00239             ytotal[ylabel]=sum(yvalue)/denomitor
00240         ax=self.__fig.add_subplot(111)
00241         if yscale=='linear':
00242             ax.set_yscale('linear')
00243         elif yscale=='log':
00244             ax.set_yscale('log')
00245         else:
00246             raise 'unsupported yscale ',yscale
00247         dateFmt=matplotlib.dates.DateFormatter('%d/%m')
00248         majorLoc=matplotlib.ticker.LinearLocator(numticks=nticks)
00249         ax.xaxis.set_major_locator(majorLoc)
00250         minorLoc=matplotlib.ticker.LinearLocator(numticks=nticks*4)
00251         ax.xaxis.set_major_formatter(dateFmt)
00252         ax.set_xlabel(r'Date',position=(0.84,0))
00253         ax.set_ylabel(r'L '+unitstring,position=(0,0.9))
00254         ax.xaxis.set_minor_locator(minorLoc)
00255         ax.set_xbound(lower=xpoints[0],upper=xpoints[-1])
00256         xticklabels=ax.get_xticklabels()
00257         for tx in xticklabels:
00258             tx.set_horizontalalignment('left')
00259         ax.grid(True)
00260         keylist=ypoints.keys()
00261         keylist.sort()
00262         legendlist=[]
00263         for ylabel in keylist:
00264             cl='k'
00265             if self.colormap.has_key(ylabel):
00266                 cl=self.colormap[ylabel]
00267             ax.plot(xpoints,ypoints[ylabel],label=ylabel,color=cl,drawstyle='steps')
00268             legendlist.append(ylabel+' '+'%.2f'%(ytotal[ylabel])+' '+unitstring)
00269         #annotations
00270         trans=matplotlib.transforms.BlendedGenericTransform(ax.transData,ax.transAxes)
00271         #print 'run boundary ',runs[0],runs[-1]
00272         #print 'xpoints boundary ',xpoints[0],xpoints[-1]
00273         if annotateBoundaryRunnum:
00274             ax.text(xpoints[0],1.025,str(runs[0]),transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))        
00275             ax.text(xpoints[-1],1.025,str(runs[-1]),transform=trans,horizontalalignment='left',size='x-small',color='green',bbox=dict(facecolor='white'))
00276         yearStr=minTime.strftime('%Y')
00277         firstimeStr=minTime.strftime('%b %d %H:%M')
00278         lasttimeStr=maxTime.strftime('%b %d %H:%M')
00279         ax.set_title('Total Integrated Luminosity '+yearStr+' ('+firstimeStr+' UTC - '+lasttimeStr+' UTC)',size='small',family='fantasy')
00280         ax.legend(tuple(legendlist),loc='upper left')
00281         self.__fig.autofmt_xdate(bottom=0.18,rotation=0)
00282         self.__fig.subplots_adjust(bottom=0.1,left=0.1)
        

Member Data Documentation

Definition at line 46 of file matplotRender.py.

Definition at line 46 of file matplotRender.py.

Definition at line 46 of file matplotRender.py.