コード例 #1
0
ファイル: compare.py プロジェクト: zhixing1996/dhad
def files(args):

    if args[0].startswith('/'):
        dira = args[0]
    else:
        dira = os.path.join(attr.base, args[0])

    if  args[1].startswith('/'):
        dirb = args[1]
    else:
        dirb = os.path.join(attr.base, args[1])

    d = filecmp.dircmp(dira, dirb)

    sys.stdout.write('There are %s different files. \n' % len(d.diff_files))

    tab = DHadTable()
    tab.row_append(['FileName', 'A', 'B'])

    for f in d.diff_files:
        filea = os.path.join(dira, f)
        fileb = os.path.join(dirb, f)

        tab.row_append_from_files(f, [filea, fileb])

    tab.output_org()
コード例 #2
0
ファイル: kkmass.py プロジェクト: xshi/dhad
def create_fig_mode(opts, tag, datatype, mode, lowmass, highmass, label):
    modekey = tools.get_modekey(mode)
    comname = '%s_%s' %(datatype.replace('/', '_'), mode)
    
    prefix = 'dir_%s/kkmass/%s_%s' % (label, lowmass, highmass)
    epsfile = tools.set_file('eps', datatype, modekey, tag,
                            prefix=prefix, extbase=attr.figpath)
    
    txtfile = tools.set_file('txt', datatype, modekey, tag,
                            prefix=prefix, extbase=attr.fitpath)

    head, figname = os.path.split(epsfile)
    figname = figname.replace('.eps', '')

    subdir = 'kkmass/%s_%s' % (lowmass, highmass)
    pdflink = './%s/%s.pdf' %(subdir, figname)
    pnglink = './%s/%s.png' %(subdir, figname)
    
    loglink = '[[../../log/%s/%s/%s.txt][log]]' %(label, subdir, comname)
    figlink = '[[%s][%s]]' %(pdflink, pnglink)
    
    modename = tools.get_orgname_from_fname(mode)
    secname = 'KK mass: %s - %s' % (lowmass, highmass)
    tablink = ''
    if os.access(txtfile, os.F_OK):
        orgtabfile = txtfile.replace('.txt', '.org')
        tab = DHadTable(txtfile)
        tab.output_org(orgtabfile)
        tablink = '#+INCLUDE: "%s"\n' % orgtabfile

    msg = '\n* %s \n  %s \n\n%s\n %s\n' % (
        secname, figlink, tablink, loglink)
        
    return msg
コード例 #3
0
ファイル: __init__.py プロジェクト: zhixing1996/dhad
def create_fig_mode(tag, dt_type, mode, label):
    if tag == 'single':
        modename = attr.modes[mode]['orgname']
    else:
        if mode == 'double_all_d0s':
            modename = 'Double all D0s'
        elif mode == 'double_all_dps':
            modename = 'Double all Dps'
        else:
            mode1 = mode[0]
            mode2 = mode[1]
            modename = '%s, %s' % (attr.modes[mode1]['orgname'],
                                   attr.modes[mode2]['orgnamebar'])

    prefix = 'dir_' + label
    epsfile = tools.set_file('eps',
                             dt_type,
                             mode,
                             tag,
                             prefix=prefix,
                             extbase=attr.figpath)

    head, tail = os.path.split(epsfile)
    comname = tail.replace('.eps', '')
    figlabel = label.split('/')[0]
    relpath = label.replace(figlabel, '')

    pdflink = '.%s/%s.pdf' % (relpath, comname)
    pnglink = '.%s/%s.png' % (relpath, comname)
    loglink = '[[../../log/%s/%s.txt][log]]' % (label, comname)
    figlink = '[[%s][%s]]' % (pdflink, pnglink)
    fitpath = attr.fitpath
    tabfile = tools.set_file('txt',
                             dt_type,
                             mode,
                             tag,
                             prefix=prefix,
                             extbase=fitpath)

    if os.access(tabfile, os.F_OK):
        orgtabfile = tools.set_file('org',
                                    dt_type,
                                    mode,
                                    tag,
                                    prefix=prefix,
                                    extbase=fitpath)
        tab = DHadTable(tabfile)
        tab.output_org(orgtabfile)
        abspath = os.path.join(attr.base)  #, attr.analysis)
        orgtabfile = orgtabfile.replace(abspath, '../..')
        tablink = '#+INCLUDE: "%s"\n' % orgtabfile
        msg = '\n* %s \n  %s \n\n%s\n %s\n' % (modename, figlink, tablink,
                                               loglink)
    else:
        sys.stdout.write('File does not exist: %s \n' % tabfile)
        sys.stdout.write('Skipping mode %s ... \n' % str(mode))
        msg = '\n* %s \n Skipped.\n' % modename

    return msg
コード例 #4
0
ファイル: __init__.py プロジェクト: xshi/dhad
def create_fig_mode(tag, dt_type, mode, label):
    if tag == 'single':
        modename = attr.modes[mode]['orgname']
    else:
        if mode == 'double_all_d0s':
            modename = 'Double all D0s'
        elif mode == 'double_all_dps':
            modename = 'Double all Dps'
        else:
            mode1 = mode[0]
            mode2 = mode[1]
            modename = '%s, %s' % (attr.modes[mode1]['orgname'],
                                   attr.modes[mode2]['orgnamebar'])

    prefix = 'dir_' + label
    epsfile = tools.set_file('eps', dt_type, mode, tag,
                             prefix=prefix, extbase=attr.figpath)

    head, tail = os.path.split(epsfile)
    comname = tail.replace('.eps', '')
    figlabel = label.split('/')[0]
    relpath = label.replace(figlabel, '')
    
    pdflink = '.%s/%s.pdf' %(relpath, comname)
    pnglink = '.%s/%s.png' %(relpath, comname)
    loglink = '[[../../log/%s/%s.txt][log]]' %(label, comname)
    figlink = '[[%s][%s]]' %(pdflink, pnglink)
    fitpath = attr.fitpath
    tabfile = tools.set_file('txt', dt_type, mode, tag,
                             prefix=prefix, extbase=fitpath)

    if os.access(tabfile, os.F_OK):
        orgtabfile =  tools.set_file('org', dt_type, mode, tag,
                                     prefix=prefix, extbase=fitpath)
        tab = DHadTable(tabfile)
        tab.output_org(orgtabfile)
        abspath = os.path.join(attr.base)#, attr.analysis)
        orgtabfile = orgtabfile.replace(abspath, '../..')
        tablink = '#+INCLUDE: "%s"\n' % orgtabfile
        msg = '\n* %s \n  %s \n\n%s\n %s\n' % (
            modename, figlink, tablink, loglink)
    else:
        sys.stdout.write('File does not exist: %s \n' %tabfile)
        sys.stdout.write('Skipping mode %s ... \n' % str(mode))
        msg = '\n* %s \n Skipped.\n'  % modename
        
    return msg
コード例 #5
0
def create_fig_mode(opts, tag, datatype, mode, lowmass, highmass, label):
    modekey = tools.get_modekey(mode)
    comname = '%s_%s' % (datatype.replace('/', '_'), mode)

    prefix = 'dir_%s/kpimass/%s_%s' % (label, lowmass, highmass)
    epsfile = tools.set_file('eps',
                             datatype,
                             modekey,
                             tag,
                             prefix=prefix,
                             extbase=attr.figpath)

    txtfile = tools.set_file('txt',
                             datatype,
                             modekey,
                             tag,
                             prefix=prefix,
                             extbase=attr.fitpath)

    head, figname = os.path.split(epsfile)
    figname = figname.replace('.eps', '')

    subdir = 'kpimass/%s_%s' % (lowmass, highmass)
    pdflink = './%s/%s.pdf' % (subdir, figname)
    pnglink = './%s/%s.png' % (subdir, figname)

    loglink = '[[../../log/%s/%s/%s.txt][log]]' % (label, subdir, comname)
    figlink = '[[%s][%s]]' % (pdflink, pnglink)

    modename = tools.get_orgname_from_fname(mode)
    secname = 'Kpi mass: %s - %s' % (lowmass, highmass)
    tablink = ''
    if os.access(txtfile, os.F_OK):
        orgtabfile = txtfile.replace('.txt', '.org')
        tab = DHadTable(txtfile)
        tab.output_org(orgtabfile)
        tablink = '#+INCLUDE: "%s"\n' % orgtabfile

    msg = '\n* %s \n  %s \n\n%s\n %s\n' % (secname, figlink, tablink, loglink)

    return msg
コード例 #6
0
ファイル: backgrounds.py プロジェクト: xshi/dhad
def create_fig_mode(tag, datatype, mode, label):
    if tag != 'single':
        raise NameError(tag)
        
    comname = '%s_%s' %(datatype.replace('/', '_'), mode)

    epspath = os.path.join(attr.figpath, label)    
    epsname = '%s.eps' % comname
    epsfile = os.path.join(epspath, epsname)

    txtpath = os.path.join(attr.fitpath(), label)    
    txtname = '%s.txt' % comname
    txtfile = os.path.join(txtpath, txtname)

    pdflink = './%s/%s.pdf' %(label, comname)
    pnglink = './%s/%s.png' %(label, comname)
    loglink = '[[../log/%s/backgrounds/%s.txt][log]]' %(label, comname)

    figlink = '[[%s][%s]]' %(pdflink, pnglink)

    modename = tools.get_orgname_from_fname(mode)

    tablink = ''
    if os.access(txtfile, os.F_OK):
        orgtabfile = txtfile.replace('.txt', '.org')
        tab = DHadTable(txtfile)
        tab.output_org(orgtabfile)

        abspath = os.path.join(attr.base, attr.analysis)
        orgtabfile = orgtabfile.replace(abspath, '..')

        tablink = '#+INCLUDE: "%s"\n' % orgtabfile

    msg = '\n* %s \n  %s \n\n%s\n %s\n' % (
        modename, figlink, tablink, loglink)

    return msg
コード例 #7
0
ファイル: backgrounds.py プロジェクト: zhixing1996/dhad
def create_fig_mode(tag, datatype, mode, label):
    if tag != 'single':
        raise NameError(tag)

    comname = '%s_%s' % (datatype.replace('/', '_'), mode)

    epspath = os.path.join(attr.figpath, label)
    epsname = '%s.eps' % comname
    epsfile = os.path.join(epspath, epsname)

    txtpath = os.path.join(attr.fitpath(), label)
    txtname = '%s.txt' % comname
    txtfile = os.path.join(txtpath, txtname)

    pdflink = './%s/%s.pdf' % (label, comname)
    pnglink = './%s/%s.png' % (label, comname)
    loglink = '[[../log/%s/backgrounds/%s.txt][log]]' % (label, comname)

    figlink = '[[%s][%s]]' % (pdflink, pnglink)

    modename = tools.get_orgname_from_fname(mode)

    tablink = ''
    if os.access(txtfile, os.F_OK):
        orgtabfile = txtfile.replace('.txt', '.org')
        tab = DHadTable(txtfile)
        tab.output_org(orgtabfile)

        abspath = os.path.join(attr.base, attr.analysis)
        orgtabfile = orgtabfile.replace(abspath, '..')

        tablink = '#+INCLUDE: "%s"\n' % orgtabfile

    msg = '\n* %s \n  %s \n\n%s\n %s\n' % (modename, figlink, tablink, loglink)

    return msg
コード例 #8
0
ファイル: crossfeeds.py プロジェクト: xshi/dhad
def create_fig_diag_mode(dt_type, stage, label, mode, sign):

    prefix='dir_'+label

    if sign == 1:
        uname = modes[mode]['uname']
        fname = modes[mode]['fname']
        title = modes[mode]['orgname']
    else:
        uname = modes[mode]['unamebar']
        fname = modes[mode]['fnamebar']
        title = modes[mode]['orgnamebar']

    comname = '%s_Single_%s_fakes_Single_%s' % (dt_type, fname, fname)

    epsfile  = tools.set_file(extbase=attr.figpath,
                              prefix=prefix, comname=comname+'.eps')

    pdffile  = epsfile.replace('.eps', '.pdf')

    figlabel = label.split('/')[0]
    relpath = label.replace(figlabel, '')

    pdflink = '.%s/%s.pdf' %(relpath, comname)
    pnglink = '.%s/%s.png' %(relpath, comname)

    if not os.access(pdffile, os.F_OK):
        if not os.access(epsfile, os.F_OK):
            sys.stdout.write('epsfile is not ready for (%s %s) \n' % (mode, sign))
        else:
            tools.eps2png(epsfile)
            tools.eps2pdf(epsfile)


    figlink = '[[%s][%s]]' %(pdflink, pnglink)
    
    txtfile  = tools.set_file(extbase=attr.fitpath,
                              prefix=prefix, comname=comname+'.txt')


    logname = 'stage_%s_%s_%s.txt' %(stage, mode, sign)
    logfile = tools.set_file(extbase=attr.logpath,
                              prefix=prefix, comname=logname)
    loglink = ''
    if os.access(logfile, os.F_OK):
        loglink = '[[../../log/%s/%s][log]]' %(label, logname)

    tablink = ''
    if os.access(txtfile, os.F_OK):
        orgtabfile = txtfile.replace('.txt', '.org')
        tab = DHadTable(txtfile)
        tab.output_org(orgtabfile)

        abspath = os.path.join(attr.base)#, attr.analysis)
        orgtabfile = orgtabfile.replace(abspath, '../..')

        tablink = '#+INCLUDE: "%s"\n' % orgtabfile

    msg = '\n* %s \n  %s \n\n%s\n %s\n' % (
        title, figlink, tablink, loglink)

    return msg
コード例 #9
0
ファイル: crossfeeds.py プロジェクト: xshi/dhad
def create_fig_nondiag_mode(dt_type, stage, label, x, y):
    prefix='dir_'+label
    if x[1] == 1:
        uname = modes[x[0]]['uname']
        fname = modes[x[0]]['fname']
        title1 = modes[x[0]]['orgname']
    else:
        uname = modes[x[0]]['unamebar']
        fname = modes[x[0]]['fnamebar']
        title1 = modes[x[0]]['orgnamebar']

    if y[1] == 1:
        unameb = modes[y[0]]['uname']
        fnameb = modes[y[0]]['fname']
        title2 = modes[y[0]]['orgname']
    else:
        unameb = modes[y[0]]['unamebar']
        fnameb = modes[y[0]]['fnamebar']
        title2 = modes[y[0]]['orgnamebar']

    title = '%s fakes %s' % (title1, title2)

    comname = '%s_Single_%s_fakes_Single_%s' % (dt_type, fname, fnameb)

    epsfile  = tools.set_file(extbase=attr.figpath,
                              prefix=prefix, comname=comname+'.eps')

    pdffile  = epsfile.replace('.eps', '.pdf')
    
    figlabel = label.split('/')[0]
    relpath = label.replace(figlabel, '')
    pdflink = '.%s/%s.pdf' %(relpath, comname)
    pnglink = '.%s/%s.png' %(relpath, comname)

    if not os.access(pdffile, os.F_OK):
        if not os.access(epsfile, os.F_OK):
            sys.stdout.write('epsfile is not ready for %s, %s \n' % (x, y))
        else:
            sys.stdout.write('Converting %s ...' % epsfile)
            tools.eps2png(epsfile)
            tools.eps2pdf(epsfile)
            sys.stdout.write(' OK.\n')
        
    figlink = '[[%s][%s]]' %(pdflink, pnglink)
    
    txtfile  = tools.set_file(extbase=attr.fitpath,
                              prefix=prefix, comname=comname+'.txt')
    xstr = pair_to_str(x)
    ystr = pair_to_str(y)
    
    logname = 'stage_%s_%s_%s.txt' %(stage, xstr,ystr)
    logfile = tools.set_file(extbase=attr.logpath,
                              prefix=prefix, comname=logname)
    if not os.access(epsfile, os.F_OK):
        sys.stdout.write('Please check log: %s\n' % logfile)

    loglink = ''
    if os.access(logfile, os.F_OK):
        loglink = '[[../../log/%s/%s][log]]' %(label, logname)
    tablink = ''

    if os.access(txtfile, os.F_OK):
        orgtabfile = txtfile.replace('.txt', '.org')
        tab = DHadTable(txtfile)
        tab.output_org(orgtabfile)

        abspath = os.path.join(attr.base)#, attr.analysis)
        orgtabfile = orgtabfile.replace(abspath, '../..')

        tablink = '#+INCLUDE: "%s"\n' % orgtabfile

    msg = '\n* %s \n  %s \n\n%s\n %s\n' % (
        title, figlink, tablink, loglink)

    return msg
コード例 #10
0
def create_fig_diag_mode(dt_type, stage, label, mode, sign):

    prefix = 'dir_' + label

    if sign == 1:
        uname = modes[mode]['uname']
        fname = modes[mode]['fname']
        title = modes[mode]['orgname']
    else:
        uname = modes[mode]['unamebar']
        fname = modes[mode]['fnamebar']
        title = modes[mode]['orgnamebar']

    comname = '%s_Single_%s_fakes_Single_%s' % (dt_type, fname, fname)

    epsfile = tools.set_file(extbase=attr.figpath,
                             prefix=prefix,
                             comname=comname + '.eps')

    pdffile = epsfile.replace('.eps', '.pdf')

    figlabel = label.split('/')[0]
    relpath = label.replace(figlabel, '')

    pdflink = '.%s/%s.pdf' % (relpath, comname)
    pnglink = '.%s/%s.png' % (relpath, comname)

    if not os.access(pdffile, os.F_OK):
        if not os.access(epsfile, os.F_OK):
            sys.stdout.write('epsfile is not ready for (%s %s) \n' %
                             (mode, sign))
        else:
            tools.eps2png(epsfile)
            tools.eps2pdf(epsfile)

    figlink = '[[%s][%s]]' % (pdflink, pnglink)

    txtfile = tools.set_file(extbase=attr.fitpath,
                             prefix=prefix,
                             comname=comname + '.txt')

    logname = 'stage_%s_%s_%s.txt' % (stage, mode, sign)
    logfile = tools.set_file(extbase=attr.logpath,
                             prefix=prefix,
                             comname=logname)
    loglink = ''
    if os.access(logfile, os.F_OK):
        loglink = '[[../../log/%s/%s][log]]' % (label, logname)

    tablink = ''
    if os.access(txtfile, os.F_OK):
        orgtabfile = txtfile.replace('.txt', '.org')
        tab = DHadTable(txtfile)
        tab.output_org(orgtabfile)

        abspath = os.path.join(attr.base)  #, attr.analysis)
        orgtabfile = orgtabfile.replace(abspath, '../..')

        tablink = '#+INCLUDE: "%s"\n' % orgtabfile

    msg = '\n* %s \n  %s \n\n%s\n %s\n' % (title, figlink, tablink, loglink)

    return msg
コード例 #11
0
def create_fig_nondiag_mode(dt_type, stage, label, x, y):
    prefix = 'dir_' + label
    if x[1] == 1:
        uname = modes[x[0]]['uname']
        fname = modes[x[0]]['fname']
        title1 = modes[x[0]]['orgname']
    else:
        uname = modes[x[0]]['unamebar']
        fname = modes[x[0]]['fnamebar']
        title1 = modes[x[0]]['orgnamebar']

    if y[1] == 1:
        unameb = modes[y[0]]['uname']
        fnameb = modes[y[0]]['fname']
        title2 = modes[y[0]]['orgname']
    else:
        unameb = modes[y[0]]['unamebar']
        fnameb = modes[y[0]]['fnamebar']
        title2 = modes[y[0]]['orgnamebar']

    title = '%s fakes %s' % (title1, title2)

    comname = '%s_Single_%s_fakes_Single_%s' % (dt_type, fname, fnameb)

    epsfile = tools.set_file(extbase=attr.figpath,
                             prefix=prefix,
                             comname=comname + '.eps')

    pdffile = epsfile.replace('.eps', '.pdf')

    figlabel = label.split('/')[0]
    relpath = label.replace(figlabel, '')
    pdflink = '.%s/%s.pdf' % (relpath, comname)
    pnglink = '.%s/%s.png' % (relpath, comname)

    if not os.access(pdffile, os.F_OK):
        if not os.access(epsfile, os.F_OK):
            sys.stdout.write('epsfile is not ready for %s, %s \n' % (x, y))
        else:
            sys.stdout.write('Converting %s ...' % epsfile)
            tools.eps2png(epsfile)
            tools.eps2pdf(epsfile)
            sys.stdout.write(' OK.\n')

    figlink = '[[%s][%s]]' % (pdflink, pnglink)

    txtfile = tools.set_file(extbase=attr.fitpath,
                             prefix=prefix,
                             comname=comname + '.txt')
    xstr = pair_to_str(x)
    ystr = pair_to_str(y)

    logname = 'stage_%s_%s_%s.txt' % (stage, xstr, ystr)
    logfile = tools.set_file(extbase=attr.logpath,
                             prefix=prefix,
                             comname=logname)
    if not os.access(epsfile, os.F_OK):
        sys.stdout.write('Please check log: %s\n' % logfile)

    loglink = ''
    if os.access(logfile, os.F_OK):
        loglink = '[[../../log/%s/%s][log]]' % (label, logname)
    tablink = ''

    if os.access(txtfile, os.F_OK):
        orgtabfile = txtfile.replace('.txt', '.org')
        tab = DHadTable(txtfile)
        tab.output_org(orgtabfile)

        abspath = os.path.join(attr.base)  #, attr.analysis)
        orgtabfile = orgtabfile.replace(abspath, '../..')

        tablink = '#+INCLUDE: "%s"\n' % orgtabfile

    msg = '\n* %s \n  %s \n\n%s\n %s\n' % (title, figlink, tablink, loglink)

    return msg