コード例 #1
0
def vary_argus_single(opts, tabname, label):
    tab = DHadTable()

    print tabname

    tabprefix0 = 'dir_818ipbv7/argus_low/fix_n1n2'
    tabprefix1 = 'dir_818ipbv7'
    tabprefix2 = 'dir_818ipbv7/argus_high/fix_n1n2'

    tab.column_append_from_dict('Mode', 'fname,fnamebar')
    titles = ['argus_low', 'std', 'argus_high']
    tab.column_append_from_files(titles[0], 'N1,N2', fitbase, tabprefix0, 'd',
                                 's', 'txt')
    tab.column_append_from_files(titles[1], 'N1,N2', fitbase, tabprefix1, 'd',
                                 's', 'txt')
    tab.column_append_from_files(titles[2], 'N1,N2', fitbase, tabprefix2, 'd',
                                 's', 'txt')

    std = titles[1]
    colA = titles[0]
    colB = titles[2]
    headA = 'diff(%s)' % colA
    headB = 'diff(%s)' % colB
    headC = 'max-diff(%)'
    tab.column_append_by_diff_pct(headA, colA, std)
    tab.column_append_by_diff_pct(headB, colB, std)
    tab.column_append_by_max(headC, headA, headB)
    #tab.columns_delete([headA, headB])
    tab.columns_trim(titles, rnd='1.')

    tab.output()  #tabname, texhead, outputtxt=True)
コード例 #2
0
ファイル: compare.py プロジェクト: zhixing1996/dhad
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)
コード例 #3
0
ファイル: compare.py プロジェクト: zhixing1996/dhad
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)
コード例 #4
0
ファイル: compare.py プロジェクト: zhixing1996/dhad
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)