本文整理汇总了Python中tools.DHadTable.output方法的典型用法代码示例。如果您正苦于以下问题:Python DHadTable.output方法的具体用法?Python DHadTable.output怎么用?Python DHadTable.output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools.DHadTable
的用法示例。
在下文中一共展示了DHadTable.output方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: para_md
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def para_md(args):
para = 'md'
namestyle = 'fname'
rnd = '0.0000001'
tag = 's'
tab_A = args[0]
tab_B = args[1]
latel_A = tab_A
latel_B = tab_B
label = tools.parseopts_set(opts.set, 'label')
if label:
labels = label.split(',')
label_A = labels[0]
label_B = labels[1]
tab = DHadTable()
tab.column_append_from_dict('Mode', namestyle)
tab.column_append_from_fit_files(label_A, tab_A, para, tag, rnd)
tab.column_append_from_fit_files(label_B, tab_B, para, tag, rnd)
tab.column_append_by_diff('diff[MeV]', label_B,label_A, rnd=rnd, factor=1000)
tab.output(_tabname)
示例2: divide_yields
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def divide_yields(args):
if args[0] not in ['signal', 'data'] :
raise NameError(args)
variable = 'yields'
rnd='.01'
dt_type = args[0]
tag = args[1]
tab_A = args[2]
tab_B = args[3]
label_A, fitbase_A, prefix_A = tools.parse_tabname(_opts, tab_A)
label_B, fitbase_B, prefix_B = tools.parse_tabname(_opts, tab_B)
sys.stdout.write('dhad.tab : Divide %s of %s by %s:' %(
variable, tab_A, tab_B))
tab = DHadTable()
namestyle = 'fname,fnamebar'
tab.column_append_from_dict('Mode', namestyle)
tab.column_append_from_files(label_A, 'N1,N2', fitbase_A, prefix_A,
dt_type, tag ,'txt', rnd='1.')
tab.column_append_from_files(label_B, 'N1,N2', fitbase_B, prefix_B,
dt_type, tag ,'txt', rnd='1.')
tab.column_append_by_divide('%s/%s' %(label_A, label_B), label_A,
label_B, rnd=rnd, err_type='Indp')
tab.output(_tabname)
示例3: diff
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def diff(args):
label= None
if opts.set:
for li in opts.set.split(':'):
name = li.split('=')[0]
value = li.split('=')[1]
sys.stdout.write('Set %s = %s \n' % (name, value))
if name == 'label':
label = value
if label:
labels = label.split(',')
label_A = labels[0]
label_B = labels[1]
tab_A = 'compare_%s.txt' % args[0]
tab_B = 'compare_%s.txt' % args[1]
tabfile_A = os.path.join(attr.tabpath, tab_A)
tabfile_B = os.path.join(attr.tabpath, tab_B)
tab = DHadTable()
tab.column_append_from_tab_file('Mode', tabfile_A, 'Mode')
tab.column_append_from_tab_file(label_A, tabfile_A, 'diff(%)')
tab.column_append_from_tab_file(label_B, tabfile_B, 'diff(%)')
tab.column_append_by_diff('diff', label_B,label_A)
tab.output(_tabname)
示例4: entries
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def entries(args):
dt_type = args[0]
tag = args[1]
label_A = args[2]
label_B = args[3]
evtpath = attr.evtpath
rnd='.01'
err_type=None
label = None
diff = 'pct'
tab = DHadTable()
tab.row_append(['Mode', label_A, label_B])
tab.head = tab.data[0]
for mode in attr.modes:
for sign in [1, -1]:
evtfile_A = tools.set_file('evt', dt_type, mode, tag, sign=sign,
prefix='dir_'+label_A, extbase=evtpath)
evtfile_B = tools.set_file('evt', dt_type, mode, tag, sign=sign,
prefix='dir_'+label_B, extbase=evtpath)
entries_A = tools.count_lines(evtfile_A)
entries_B = tools.count_lines(evtfile_B)
if sign == 1:
modename = attr.modes[mode]['fname']
else:
modename = attr.modes[mode]['fnamebar']
row = [modename, entries_A, entries_B]
tab.row_append(map(str, row))
tab.column_append_by_diff_pct('diff(%)', label_B,label_A, rnd=rnd, err_type=err_type)
tab.output(_tabname)
示例5: ratios_signal
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def ratios_signal(args):
if args[0] == '537ipb/281ipb' and args[1] == '537ipbv2/281ipb':
tabfilename1 = 'compare_yields_signal_divide_537ipb_9.03_regular12.txt'
title1 = args[0]
headname1 = title1
tabfilename2 = 'compare_yields_signal_divide_537ipbv2_9.03_regular12.txt'
title2 = args[1]
headname2 = title2
else:
raise NameError(args)
tabfile1 = os.path.join(attr.tabpath, tabfilename1)
tabfile2 = os.path.join(attr.tabpath, tabfilename2)
if opts.set and opts.set == 'info':
print 'here'
tab = DHadTable()
tab.column_append_from_tab_file('Mode', tabfile1, 'Mode')
tab.column_append_from_tab_file(title1, tabfile1, headname1)
tab.column_append_from_tab_file(title2, tabfile2, headname2)
tab.column_append_by_diff_sigma_pct('diff(%)', title2, title1)
tab.output(_tabname)
示例6: events
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def events(args):
parsed = yld.parse_args(args)
datatype = parsed[0]
tag = parsed[1]
modes = parsed[2]
label_A = parsed[3]
label_B = args[3]
datpath = attr.datpath
tab = DHadTable()
tab.row_append(['Mode', label_A, label_B, 'Common',
'Unique(%s)' %label_A, 'Unique(%s)' %label_B ])
tab.head = tab.data[0]
for mode in modes:
modename = mode.replace('Single_', '')
evtname = datatype + '_' + mode + '.evt'
evtpath_A = os.path.join(datpath, 'evt', label_A, 'events')
evtfile_A = os.path.join(evtpath_A, evtname)
f_A = UserFile(evtfile_A)
events_A = Set(f_A.data)
evtpath_B = os.path.join(datpath, 'evt', label_B, 'events')
evtfile_B = os.path.join(evtpath_B, evtname)
f_B = UserFile(evtfile_B)
events_B = Set(f_B.data)
events_inter = events_A & events_B
entries_A = len(events_A)
entries_B = len(events_B)
common = len(events_inter)
unique_A = len(events_A - events_inter)
unique_B = len(events_B - events_inter)
row = [modename, entries_A, entries_B, common, unique_A, unique_B]
tab.row_append(map(str, row))
tab.output(_tabname)
示例7: events
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def events(args):
parsed = yld.parse_args(args)
datatype = parsed[0]
tag = parsed[1]
modes = parsed[2]
label = parsed[3]
unique_evt_label = label
if _set and 'events' in _set:
unique_evt_label = _set.split('=')[1]
tab = DHadTable()
row = ['Mode']
row.extend(attr.datasets_281)
tab.row_append(row)
for mode in modes:
modename = mode.replace('Single_', '')
evtfile = get_unique_evtfile(
datatype, mode, unique_evt_label, debug=_debug)
f = EventsFile(evtfile)
row = map(str, f.datasets_sorted)
row.insert(0, modename)
tab.row_append(row)
tab.output(_tabname)
示例8: para_argus
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def para_argus(para, args):
namestyle = 'fname'
rnd = '0.01'
tag = 's'
rowName = para
extbase = attr.fitbase
ext = 'txt'
dt_type = args[0]
tab_A = args[1]
tab_B = args[2]
label_A = tab_A
label_B = tab_B
label = tools.parseopts_set(opts.set, 'label')
if label:
labels = label.split(',')
label_A = labels[0]
label_B = labels[1]
tab = DHadTable()
tab.column_append_from_dict('Mode', namestyle)
tab.column_append_from_files(label_A, rowName, extbase, 'dir_'+tab_A,
dt_type, tag, ext, rnd=rnd)
tab.column_append_from_files(label_B, rowName, extbase, 'dir_'+tab_B,
dt_type, tag, ext, rnd=rnd)
tab.column_append_by_diff_pct('diff(%)', label_B, label_A, rnd=rnd)
tab.output(_tabname)
示例9: make_overview_table
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def make_overview_table(tabname, datatype, modes, label, test=False):
tab = DHadTable()
tab.row_append(['Mode', 'Backgrounds'])
for mode in modes:
modename = mode.replace('Single_', '')
bkgtable = get_bkg_tab_link(datatype, mode, label)
line = [modename, bkgtable]
tab.row_append(line)
tab.output(tabname, test=test)
示例10: bkg_generic_cont
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def bkg_generic_cont(tabname, datatype, tag, modes,
label, test, debug):
tab = DHadTable()
row = ['Mode', 'Continuum Backgrounds']
tab.row_append(row)
for mode in modes:
new_row = bkg_cont_single_mode(datatype, mode, label, debug)
tab.row_append(new_row)
tab.output(tabname, test=test)
示例11: yields
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def yields(opts, tabname, args):
if args[0] not in ['signal', 'data'] :
raise NameError(args)
rnd='.01'
err_type=None
diff = 'pct'
sign = 1
if opts.set:
for li in opts.set.split(':'):
name = li.split('=')[0]
value = li.split('=')[1]
sys.stdout.write('Set %s = %s \n' % (name, value))
if name == 'diff':
diff = value
if name == 'err_type':
err_type = value
if name == 'sign':
sign = value
variable = 'yields'
dt_type = args[0]
tag = args[1]
label_A = args[2]
label_B = args[3]
fitbase = attr.fitbase
sys.stdout.write('dhad.tab : Compare %s between %s and %s:\n' %(
variable, label_A, label_B ))
tab = DHadTable()
namestyle = 'fname,fnamebar'
tab.column_append_from_dict('Mode', namestyle)
tab.column_append_from_files(label_A, 'N1,N2', fitbase, 'dir_%s' %label_A,
dt_type, tag ,'txt', rnd='1.')
tab.column_append_from_files(label_B, 'N1,N2', fitbase, 'dir_%s' %label_B,
dt_type, tag ,'txt', rnd='1.')
if sign == '0':
tab.rows_join_by_average(rnd='1.')
if diff == 'pct':
tab.column_append_by_diff_pct(
'diff(%)', label_B,label_A, rnd=rnd, err_type=err_type)
elif diff == 'sigma_pct':
tab.column_append_by_diff_sigma_pct('diff(%)', label_B,label_A, rnd=rnd)
elif diff == 'sigma2_pct':
tab.column_append_by_diff_sigma2_pct('diff(%)', label_B,label_A, rnd=rnd)
elif diff == 'ratio':
tab.column_append_by_divide(
'ratio', label_B,label_A, rnd=rnd, err_type='Indp')
else:
raise NameError(diff)
tab.output(tabname, test=opts.test)
示例12: brf_data_results
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def brf_data_results(opts, tabname, args):
'''
-----------------------------
Results of the Data Fit
-----------------------------
'''
label_A = args[0]
label_B = args[1]
verbose = opts.verbose
bffilename = 'bf_stat_sys'
labels = []
labels.append(label_A)
labels.append(label_B)
tab = DHadTable()
paras = False
for label in labels:
if '281ipb' in label:
factor = 0.000001
elif '537ipb' in label:
factor = 0.000001*281/537
elif '818ipb' in label or 'v13' in label:
factor = 0.000001*281/818
else:
raise NameError(label)
if '818ipb' in label_A and '818ipb' in label_B:
factor = 0.000001
if '818ipb' in label_A and 'v13' in label_B:
factor = 0.000001
bffile = os.path.join(attr.brfpath, label, bffilename)
if not paras:
tab.column_append(tools.parse_result(bffile, 'paras'),
'Parameters')
paras = True
tab.column_append(tools.parse_result(bffile, 'value'), 'value', rnd='.00001' )
tab.column_append(tools.parse_result(bffile, 'stat'), 'stat')
tab.column_append(tools.parse_result(bffile, 'syst'), 'syst')
tab.columns_join3('Fitted Value', 'value', 'stat', 'syst')
tab.column_trim('Fitted Value', row=['ND0D0Bar', 'ND+D-'],
rnd='.0001', factor=factor, opt='(cell)x1E6')
tab.column_trim('Fitted Value', rnd='.00001',
except_row=['ND0D0Bar', 'ND+D-'])
tab.column_append(tools.parse_result(bffile, 'err_frac'),
'Frac. Err', rnd='.1', opt='(cell%)')
tab.columns_join(label, 'Fitted Value','Frac. Err', str=' ')
tab.column_append_by_diff_sigma('Difference', label_B,label_A)
tab.output(tabname, test=opts.test)
示例13: bkg_names
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [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_)
示例14: bkg_generic_ddbar
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def bkg_generic_ddbar(tabname, datatype, tag, modes, label, test, debug):
ranges = ['>0', '>50', '>100', '>200', '>500',
'>1000', '>2000', '>3000']
tab = DHadTable()
row = ['Mode', 'Backgrounds']
row.extend(ranges)
tab.row_append(row)
for mode in modes:
new_row = bkg_ddbar_single_mode(datatype, mode, label, ranges, debug)
tab.row_append(new_row)
tab.output(tabname, test=test)
示例15: compare_yields_data_signal_divide_537ipb
# 需要导入模块: from tools import DHadTable [as 别名]
# 或者: from tools.DHadTable import output [as 别名]
def compare_yields_data_signal_divide_537ipb(args):
sys.stdout.write('dhad.table: Creating %s ...\n' % _tabname)
tabpath1 = os.path.join(
attr.base, '7.06', 'tab')
tabfile1 = os.path.join(
tabpath1, 'compare_yields_data_divide_281ipb_537ipb.txt')
tabfile2 = os.path.join(
attr.tabpath, 'compare_yields_signal_divide_537ipb_9.03_regular12.txt')
tab = DHadTable()
tab.column_append_from_tab_file('Mode', tabfile1, 'Mode')
tab.column_append_from_tab_file('Data', tabfile1, '537ipb/281ipb')
tab.column_append_from_tab_file('Signal', tabfile2, '537ipb/281ipb')
tab.column_append_by_diff_sigma_pct('diff(%)', 'Signal', 'Data')
tab.output(_tabname)