Esempio n. 1
0
def main(nop, nod, out, fnu=1):
    '''
    Using parameters in nop and data in nod, print a plot to out
    '''
    nop = nuosc.read_param_file(nop)
    nod = nuosc.read_data(nod)

    h = make_og(nod, fnu)
    params = nop_params(nop, fnu)
    title_og(h, **params)
    shape_linlog_og(h)

    c = make_canvas_og()
    h.Draw("CONTZ")

    lovere = math.pi / (2 * 1.267 * abs(float(nop['atm'])))
    g1 = make_vac_osc(h, lovere)
    g2 = make_vac_osc(h, 3 * lovere)
    l = make_base_line(h)
    lt = make_text("1300 km", 1250, math.log10(3), 90)
    where = 1500
    g1t = make_text("1{}^{st} vac. osc. max", where, g1.Eval(1.10 * where), 15)
    g2t = make_text("2{}^{nd} vac. osc. max", where, g2.Eval(1.10 * where), 15)

    for o in [l, g1, g2, lt, g1t, g2t]:
        o.Draw("same")

    c.Print(out)
Esempio n. 2
0
def test_param_file():
    d = dict(osc_params)
    tfd, tname = tempfile.mkstemp()
    nuosc.write_param_file(tname, **d)
    d2 = nuosc.read_param_file(tname)
    assert d == d2, 'failure in %s' % tname
    os.remove(tname)
Esempio n. 3
0
def main(nop, nod, out, fnu=1):
    '''
    Using parameters in nop and data in nod, print a plot to out
    '''
    nop = nuosc.read_param_file(nop)
    nod = nuosc.read_data(nod)

    h = make_og(nod, fnu)
    params = nop_params(nop, fnu)
    title_og(h, **params)
    shape_linlog_og(h)

    c = make_canvas_og()
    h.Draw("CONTZ")

    lovere = math.pi / (2*1.267*abs(float(nop['atm'])))
    g1 = make_vac_osc(h, lovere)
    g2 = make_vac_osc(h, 3*lovere)
    l = make_base_line(h)
    lt = make_text("1300 km", 1250, math.log10(3), 90)
    where = 1500
    g1t = make_text("1{}^{st} vac. osc. max",where,g1.Eval(1.10*where),15)
    g2t = make_text("2{}^{nd} vac. osc. max",where,g2.Eval(1.10*where),15)

    for o in [l, g1, g2, lt, g1t, g2t]:
        o.Draw("same")
    
    c.Print(out)
Esempio n. 4
0
def main(fnu, out, *files):
    '''Main interface to making an energy spectrum plot

    <fnu> is final neutrino number to plot.

    <out> is the output file to print

    <files> is a list of .nop and .nod files.  There must be one of
    each and they must have identical  file names (ignoring extension)
    '''

    nops = []
    nods = []
    for f in sorted(files):
        if f.endswith('.nop'):
            p = nuosc.read_param_file(f)
            p['idname'] = os.path.splitext(os.path.basename(f))[0]
            nops.append(p)
        if f.endswith('.nod'):
            d = nuosc.read_data(f)
            nods.append(d)
    fnu = str(fnu)
    if nops[0]['atm'].startswith('-') and not fnu.startswith('-'):
        fnu = '-' + fnu
    return make_energy_plot(zip(nops,nods), out, fnu)
Esempio n. 5
0
File: movie.py Progetto: BNLIF/nuosc
def main(cmdline_file, outpat):
    outdir = os.path.dirname(outpat)
    data_file = os.path.join(outdir, 'magic.nod')
    params = nuosc.read_param_file(cmdline_file)
    params['data'] = data_file
    params['cmdline'] = os.path.join(outdir, 'magic.nop')
    params['info'] = '/dev/null'
    nuosc.call(**params)
    prob_data = nuosc.read_data(data_file)
    make_frames(prob_data, outpat, **params)
Esempio n. 6
0
def main(cmdline_file, outpat):
    outdir = os.path.dirname(outpat)
    data_file = os.path.join(outdir, "magic.nod")
    params = nuosc.read_param_file(cmdline_file)
    params["data"] = data_file
    params["cmdline"] = os.path.join(outdir, "magic.nop")
    params["info"] = "/dev/null"
    nuosc.call(**params)
    prob_data = nuosc.read_data(data_file)
    make_frames(prob_data, outpat, **params)
Esempio n. 7
0
def main(rootfile, params_file, data_file, *plots):
    params = nuosc.read_param_file(params_file)
    data = nuosc.read_data(data_file)

    fp = ROOT.TFile.Open(rootfile, 'recreate')
    allres = []
    for plotter in plots:
        meth = eval(plotter)
        res = meth(data, **params)
        for r in res:
            r.SetDirectory(fp)
            #r.Write()
        allres += res
    fp.Write()
    return fp,allres
Esempio n. 8
0
def test_call():
    tdir = tempfile.mkdtemp()
    print tdir

    info_file = os.path.join(tdir,"test.info")
    cmdl_file = os.path.join(tdir,"test.cmdline")

    d = dict(osc_params, info = info_file, cmdline = cmdl_file)
    res = [x for x in nuosc.call(**d)]
    assert res, "No results for: %s" % str(d)
    
    args = nuosc.read_param_file(cmdl_file)
    res2 = [x for x in nuosc.call(**args)]
    
    print 'res:', res
    print 'res2:', res2
    for x1,x2 in zip(res, res2):
        assert x1 == x2
        print x1