本文整理汇总了Python中tools.DHadTable.sort_by_column方法的典型用法代码示例。如果您正苦于以下问题:Python DHadTable.sort_by_column方法的具体用法?Python DHadTable.sort_by_column怎么用?Python DHadTable.sort_by_column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools.DHadTable
的用法示例。
在下文中一共展示了DHadTable.sort_by_column方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bkg_names
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import sort_by_column [as 别名]
def bkg_names(opts, args):
debug_ = opts.debug
test_ = opts.test
set_ = opts.set
prefix = None
if args[0] == 'peak':
prefix = 'peak'
args = args[1:]
parsed = yld.parse_args(args)
datatype = parsed[0]
tag = parsed[1]
modes = parsed[2]
label = parsed[3]
limit = None
if set_ != None and 'min' in set_:
min_ = set_.split('=')[1]
limit = '>%s' %min_
bkgmodes = 20
if set_ != None and 'bkgmodes' in set_:
bkgmodes = int(set_.split('=')[1])
for mode in modes:
tabname = 'bkg_names_%s_%s_%s' %(
datatype, mode, label)
if prefix != None:
tabname = 'bkg_names_%s_%s_%s_%s' %(
prefix, datatype, mode, label)
tabname = tabname.replace('/', '_')
tab = DHadTable()
modename = get_orgname_from_fname(mode)
bkg_names, bkg_numbers = bkg_names_single_mode(
datatype, mode, label, limit, bkgmodes, debug_, prefix)
tab.column_append(bkg_names, title='Backgrounds for %s' %modename)
tab.column_append(bkg_numbers, title='Number of Events')
tab.sort_by_column('Number of Events', reverse=True)
orgfooter = ': '+sys.argv[0].split('/')[-1]+\
' tab backgrounds names %s %s %s ' %(
datatype, mode, label)
if prefix != None:
orgfooter = ': '+sys.argv[0].split('/')[-1]+\
' tab backgrounds names %s %s %s %s ' %(
prefix, datatype, mode, label)
tab.output(tabname, orgfooter=orgfooter, test=test_)
示例2: bkg_names_single_mode
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import sort_by_column [as 别名]
def bkg_names_single_mode(datatype, mode, label, limit, bkgmodes,
debug, prefix=None):
bkgname = '%s_%s.txt' %(datatype, mode)
if prefix !=None:
bkgname = '%s_%s_%s.txt' %(prefix, datatype, mode)
bkgname = bkgname.replace('/', '_')
bkgfile = tools.set_file(
extbase=attr.bkgpath(), prefix='dir_'+label, comname=bkgname)
if debug:
sys.stdout.write('\ndebug: bkgfile %s\n' %bkgfile)
tab = DHadTable(bkgfile, evalcell=True)
tab.sort_by_column('Number', reverse=True)
if limit != None:
mcddbars = tab.column_get('Mode', 'Number'+limit)[1:]
if bkgmodes != None:
mcddbars = tab.column_get('Mode')[1:bkgmodes+1]
numbers = tab.column_get('Number')[1:len(mcddbars)+1]
mcddbarmodenames = mcddbars_to_modenames(mcddbars)
return mcddbarmodenames, numbers