本文整理汇总了Python中RecoLuminosity.LumiDB.CommonUtil.splitlistToRangeString方法的典型用法代码示例。如果您正苦于以下问题:Python CommonUtil.splitlistToRangeString方法的具体用法?Python CommonUtil.splitlistToRangeString怎么用?Python CommonUtil.splitlistToRangeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecoLuminosity.LumiDB.CommonUtil
的用法示例。
在下文中一共展示了CommonUtil.splitlistToRangeString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: toCSVOverview
# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import splitlistToRangeString [as 别名]
def toCSVOverview(lumidata,filename,resultlines,scalefactor,isverbose):
'''
input:
lumidata {run:[lumilsnum,cmslsnum,timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,(bxidx,bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}
resultlines [[resultrow1],[resultrow2],...,] existing result row
'''
result=[]
fieldnames = ['Run', 'DeliveredLS', 'Delivered(/ub)','SelectedLS','Recorded(/ub)']
r=csvReporter.csvReporter(filename)
for rline in resultlines:
result.append(rline)
for run in lumidata.keys():
lsdata=lumidata[run]
if lsdata is None:
result.append([run,'n/a','n/a','n/a','n/a'])
continue
nls=len(lsdata)
deliveredData=[x[5] for x in lsdata]
recordedData=[x[6] for x in lsdata if x[6] is not None]
totdeliveredlumi=0.0
totrecordedlumi=0.0
if len(deliveredData)!=0:
totdeliveredlumi=sum(deliveredData)
if len(recordedData)!=0:
totrecordedlumi=sum(recordedData)
selectedcmsls=[x[1] for x in lsdata if x[1]!=0]
if len(selectedcmsls)==0:
selectedlsStr='n/a'
else:
selectedlsStr = CommonUtil.splitlistToRangeString(selectedcmsls)
result.append([run,nls,totdeliveredlumi*scalefactor,selectedlsStr,totrecordedlumi*scalefactor])
sortedresult=sorted(result,key=lambda x : int(x[0]))
r=None
assert(filename)
if filename.upper()=='STDOUT':
r=sys.stdout
r.write(','.join(fieldnames)+'\n')
for l in sortedresult:
r.write(str(l)+'\n')
else:
r=csvReporter.csvReporter(filename)
r.writeRow(fieldnames)
r.writeRows(sortedresult)
示例2: toCSVTotEffective
# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import splitlistToRangeString [as 别名]
def toCSVTotEffective(lumidata,filename,resultlines,scalefactor,isverbose):
'''
input: {run:[lumilsnum(0),triggeredls(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),{hltpath:[l1name,l1prescale,hltprescale,efflumi]},bxdata,beamdata](8)}
screen Run,SelectedLS,Recorded,HLTPath,L1Bit,Effective
'''
result=[]#[run,selectedlsStr,recorded,hltpath,l1bitname,efflumi]
selectedcmsls=[]
for rline in resultlines:
result.append(rline)
for run in sorted(lumidata):#loop over runs
hprescdict={}
lprescdict={}
rundata=lumidata[run]
if rundata is None:
result.append([str(run),'n/a','n/a','n/a','n/a','n/a'])
continue
selectedcmsls=[x[1] for x in rundata if x[1]!=0]
totefflumiDict={}
totrecorded=0.0
pathmap={}#{hltpathname:1lname}
for lsdata in rundata:
cmslsnum=lsdata[1]
efflumiDict=lsdata[8]# this ls has no such path?
if not efflumiDict:
if cmslsnum in selectedcmsls:
selectedcmsls.remove(cmslsnum)
continue
for hltpathname,pathdata in efflumiDict.items():
if not totefflumiDict.has_key(hltpathname):
totefflumiDict[hltpathname]=0.0
pathmap[hltpathname]='n/a'
l1name=pathdata[0]
l1presc=pathdata[1]
hltpresc=pathdata[2]
lumival=pathdata[3]
if l1presc is None or hltpresc is None:#if found all null prescales and if it is in the selectedcmsls, remove it because incomplete
if cmslsnum in selectedcmsls:
selectedcmsls.remove(cmslsnum)
else:
recordedlumi=lsdata[6]
totrecorded+=recordedlumi
if not hprescdict.has_key(hltpathname):
hprescdict[hltpathname]=[]
hprescdict[hltpathname].append(hltpresc)
if not lprescdict.has_key(l1name):
lprescdict[l1name]=[]
lprescdict[l1name].append(l1presc)
if lumival:
totefflumiDict[hltpathname]+=lumival
pathmap[hltpathname]=l1name.replace('\"','')
if len(selectedcmsls)==0:
selectedlsStr='n/a'
else:
selectedlsStr= CommonUtil.splitlistToRangeString(selectedcmsls)
for name in sorted(totefflumiDict):
lname=pathmap[name]
if lname=='n/a':
continue
hprescs=list(set(hprescdict[hltpathname]))
lprescs=list(set(lprescdict['"'+lname+'"']))
hprescStr='('+','.join(['%d'%(x) for x in hprescs])+')'
lprescStr='('+','.join(['%d'%(x) for x in lprescs])+')'
result.append([run,selectedlsStr,totrecorded*scalefactor,name+hprescStr,lname+lprescStr,totefflumiDict[name]*scalefactor])
fieldnames=['Run','SelectedLS','Recorded','HLTpath','L1bit','Effective(/ub)']
assert(filename)
if filename.upper()=='STDOUT':
r=sys.stdout
r.write(','.join(fieldnames)+'\n')
for l in result:
r.write(str(l)+'\n')
else:
r=csvReporter.csvReporter(filename)
r.writeRow(fieldnames)
r.writeRows(result)
示例3: toScreenTotEffective
# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import splitlistToRangeString [as 别名]
def toScreenTotEffective(lumidata,resultlines,scalefactor,isverbose):
'''
input: {run:[lumilsnum(0),triggeredls(1),timestamp(2),beamstatus(3),beamenergy(4),deliveredlumi(5),recordedlumi(6),calibratedlumierror(7),{hltpath:[l1name,l1prescale,hltprescale,efflumi]},bxdata,beamdata](8)}
screen Run,SelectedLS,Recorded,HLTPath,L1Bit,Effective
'''
result=[]#[run,selectedlsStr,recorded,hltpath,l1bit,efflumi]
totdict={}#{hltpath:[nls,toteff]}
selectedcmsls=[]
alltotrecorded=0.0
alleffective=0.0
totOldSelectedLS=0
totOldRecorded=0.0
#totOldEffective=0.0
for rline in resultlines:
myls=rline[1]
mypath=rline[3]
if mypath!='n/a':
mypath=mypath.split('(')[0]
if not totdict.has_key(mypath):
totdict[mypath]=[0,0.0]
if myls!='n/a':
listcomp=myls.split(', ')
for lstr in listcomp:
enddigs=lstr[1:-1].split('-')
lsmin=int(enddigs[0])
lsmax=int(enddigs[1])
rls=lsmax-lsmin+1
totOldSelectedLS+=rls
totdict[mypath][0]+=rls
myrecorded=rline[2]
if myrecorded!='n/a':
totOldRecorded+=float(myrecorded)
(rr,lumiu)=CommonUtil.guessUnit(float(myrecorded))
rline[2]='%.3f'%(rr)+' ('+lumiu+')'
myeff=rline[5]
if myeff!='n/a':
reff=float(myeff)
(rr,lumiu)=CommonUtil.guessUnit(float(reff))
rline[5]='%.3f'%(rr)+' ('+lumiu+')'
totdict[mypath][1]+=reff
result.append(rline)
for run in sorted(lumidata):#loop over runs
hprescdict={}
lprescdict={}
rundata=lumidata[run]
if rundata is None:
result.append([str(run),'n/a','n/a','n/a','n/a','n/a'])
continue
selectedcmsls=[x[1] for x in rundata if x[1]!=0]
totefflumiDict={}
totrecorded=0.0
toteffective=0.0
pathmap={}#{hltpathname:1lname}
for lsdata in rundata:
cmslsnum=lsdata[1]
efflumiDict=lsdata[8]# this ls has no such path?
if not efflumiDict:
if cmslsnum in selectedcmsls:
selectedcmsls.remove(cmslsnum)
continue
for hltpathname,pathdata in efflumiDict.items():
if not totefflumiDict.has_key(hltpathname):
totefflumiDict[hltpathname]=0.0
pathmap[hltpathname]='n/a'
l1name=pathdata[0]
l1presc=pathdata[1]
hltpresc=pathdata[2]
lumival=pathdata[3]
if not totdict.has_key(hltpathname):
totdict[hltpathname]=[0,0.0]
if l1presc is None or hltpresc is None:#if found all null prescales and if it is in the selectedcmsls, remove it because incomplete
if cmslsnum in selectedcmsls:
selectedcmsls.remove(cmslsnum)
else:
recordedlumi=lsdata[6]
totrecorded+=recordedlumi
alltotrecorded+=recordedlumi
if not hprescdict.has_key(hltpathname):
hprescdict[hltpathname]=[]
hprescdict[hltpathname].append(hltpresc)
if not lprescdict.has_key(l1name):
lprescdict[l1name]=[]
lprescdict[l1name].append(l1presc)
totdict[hltpathname][0]+=1
if lumival:
totdict[hltpathname][1]+=lumival
totefflumiDict[hltpathname]+=lumival
pathmap[hltpathname]=l1name
if len(selectedcmsls)==0:
selectedlsStr='n/a'
else:
selectedlsStr = CommonUtil.splitlistToRangeString(selectedcmsls)
for name in sorted(totefflumiDict):
lname=pathmap[name]
if lname=='n/a':
continue
#.........这里部分代码省略.........
示例4: toScreenOverview
# 需要导入模块: from RecoLuminosity.LumiDB import CommonUtil [as 别名]
# 或者: from RecoLuminosity.LumiDB.CommonUtil import splitlistToRangeString [as 别名]
def toScreenOverview(lumidata,resultlines,scalefactor,isverbose):
'''
input:
lumidata {run:[lumilsnum,cmslsnum,timestamp,beamstatus,beamenergy,deliveredlumi,recordedlumi,calibratedlumierror,(bxidx,bxvalues,bxerrs),(bxidx,b1intensities,b2intensities)]}
resultlines [[resultrow1],[resultrow2],...,] existing result row
'''
result=[]
labels = [('Run', 'Delivered LS', 'Delivered','Selected LS','Recorded')]
totOldDeliveredLS=0
totOldSelectedLS=0
totOldDelivered=0.0
totOldRecorded=0.0
totaltable=[]
totalDeliveredLS = 0
totalSelectedLS = 0
totalDelivered = 0.0
totalRecorded = 0.0
for r in resultlines:
dl=0.0
if(r[2]!='n/a'):
dl=float(r[2])#delivered in /ub because it comes from file!
(rr,lumiu)=CommonUtil.guessUnit(dl)
r[2]='%.3f'%(rr)+' ('+lumiu+')'
dls=0
if(r[1]!='n/a'):
dls=int(r[1])
totOldDeliveredLS+=dls
totOldDelivered+=dl
rls=0
if(r[3]!='n/a'):
rlsstr=r[3]
listcomp=rlsstr.split(', ')
for lstr in listcomp:
enddigs=lstr[1:-1].split('-')
lsmin=int(enddigs[0])
lsmax=int(enddigs[1])
rls=lsmax-lsmin+1
totOldSelectedLS+=rls
if(r[4]!='n/a'):
rcd=float(r[4])#recorded in /ub because it comes from file!
(rrcd,rlumiu)=CommonUtil.guessUnit(rcd)
r[4]='%.3f'%(rrcd)+' ('+rlumiu+')'
totOldRecorded+=rcd
result.append(r)
for run in lumidata.keys():
lsdata=lumidata[run]
if lsdata is None:
result.append([str(run),'n/a','n/a','n/a','n/a'])
continue
nls=len(lsdata)
deliveredData=[x[5] for x in lsdata]
totdelivered=sum(deliveredData)
totalDelivered+=totdelivered
totalDeliveredLS+=len(deliveredData)
(totdeliveredlumi,deliveredlumiunit)=CommonUtil.guessUnit(totdelivered)
recordedData=[x[6] for x in lsdata if x[6] is not None]
totrecorded=sum(recordedData)
totalRecorded+=totrecorded
(totrecordedlumi,recordedlumiunit)=CommonUtil.guessUnit(totrecorded)
#print 'x[1] ',[x[1] for x in lsdata]
selectedcmsls=[x[1] for x in lsdata if x[1]!=0]
#print 'selectedcmsls ',selectedcmsls
totalSelectedLS+=len(selectedcmsls)
if len(selectedcmsls)==0:
selectedlsStr='n/a'
else:
selectedlsStr = CommonUtil.splitlistToRangeString(selectedcmsls)
result.append([str(run),str(nls),'%.3f'%(totdeliveredlumi*scalefactor)+' ('+deliveredlumiunit+')',selectedlsStr,'%.3f'%(totrecordedlumi*scalefactor)+' ('+recordedlumiunit+')'])
sortedresult=sorted(result,key=lambda x : int(x[0]))
print ' == = '
print tablePrinter.indent (labels+sortedresult, hasHeader = True, separateRows = False,
prefix = '| ', postfix = ' |', justify = 'right',
delim = ' | ', wrapfunc = lambda x: wrap_onspace (x,20) )
print ' == = Total : '
(totalDeliveredVal,totalDeliveredUni)=CommonUtil.guessUnit(totalDelivered+totOldDelivered)
(totalRecordedVal,totalRecordedUni)=CommonUtil.guessUnit(totalRecorded+totOldRecorded)
totrowlabels = [('Delivered LS','Delivered('+totalDeliveredUni+')','Selected LS','Recorded('+totalRecordedUni+')')]
totaltable.append([str(totalDeliveredLS+totOldDeliveredLS),'%.3f'%(totalDeliveredVal*scalefactor),str(totalSelectedLS+totOldSelectedLS),'%.3f'%(totalRecordedVal*scalefactor)])
print tablePrinter.indent (totrowlabels+totaltable, hasHeader = True, separateRows = False, prefix = '| ',
postfix = ' |', justify = 'right', delim = ' | ',
wrapfunc = lambda x: wrap_onspace (x, 20))