Пример #1
0
def read_data(filename, dpath_pion, dpath_kaon, plot='off'):
    pion = c51.open_data(filename, dpath_pion)
    kaon = c51.open_data(filename, dpath_kaon)

    #Fold meson data
    pion = c51.fold(pion)
    kaon = c51.fold(kaon)

    pion_ss = c51.make_gvars(pion[:, :, 0, 0])
    pion_ps = c51.make_gvars(pion[:, :, 1, 0])
    kaon_ss = c51.make_gvars(kaon[:, :, 0, 0])
    kaon_ps = c51.make_gvars(kaon[:, :, 1, 0])

    if plot == 'on':
        dat = pion_ps
        E0 = 0.237
        meff = c51.effective_mass(dat, 1, 'cosh')
        x = np.arange(len(meff))
        xlim = [4, 15]
        ylim = c51.find_yrange(meff, xlim[0], xlim[1])
        c51.scatter_plot(x, meff, 'meff', xlim=xlim, ylim=ylim)
        scaled2pt = c51.scaled_correlator(dat, E0)
        ylim = c51.find_yrange(scaled2pt, xlim[0], xlim[1])
        c51.scatter_plot(x, scaled2pt, 'scaled 2pt', xlim=xlim, ylim=ylim)
        ylim = c51.find_yrange(dat, xlim[0], xlim[1])
        c51.scatter_plot(x, dat, 'data', xlim=xlim, ylim=ylim)
    else:
        pass

    pion_ss_ps = np.concatenate((pion[:, :, 0, 0], pion[:, :, 1, 0]), axis=1)
    kaon_ss_ps = np.concatenate((kaon[:, :, 0, 0], kaon[:, :, 1, 0]), axis=1)
    pion_ss_ps_gv = c51.make_gvars(pion_ss_ps)
    kaon_ss_ps_gv = c51.make_gvars(kaon_ss_ps)

    return pion_ss_ps_gv, kaon_ss_ps_gv
Пример #2
0
def read_data(filename, dpath_pion, dpath_kaon, plot='off'):
    pion = c51.open_data(filename, dpath_pion)
    kaon = c51.open_data(filename, dpath_kaon)
    
    #Fold meson data
    pion = c51.fold(pion)
    kaon = c51.fold(kaon)

    pion_ss = c51.make_gvars(pion[:,:,0,0])
    pion_ps = c51.make_gvars(pion[:,:,1,0])
    kaon_ss = c51.make_gvars(kaon[:,:,0,0])
    kaon_ps = c51.make_gvars(kaon[:,:,1,0])
   
    if plot=='on':
        dat = pion_ps
        E0 = 0.237
        meff = c51.effective_mass(dat,1,'cosh')
        x = np.arange(len(meff))
        xlim = [4,15]
        ylim = c51.find_yrange(meff, xlim[0], xlim[1])
        c51.scatter_plot(x, meff, 'meff', xlim = xlim, ylim = ylim)
        scaled2pt = c51.scaled_correlator(dat, E0)
        ylim = c51.find_yrange(scaled2pt, xlim[0], xlim[1])
        c51.scatter_plot(x, scaled2pt, 'scaled 2pt', xlim=xlim, ylim=ylim)
        ylim = c51.find_yrange(dat, xlim[0], xlim[1])
        c51.scatter_plot(x, dat, 'data', xlim=xlim, ylim=ylim)
    else: pass

    pion_ss_ps = np.concatenate((pion[:,:,0,0],pion[:,:,1,0]), axis=1)
    kaon_ss_ps = np.concatenate((kaon[:,:,0,0],kaon[:,:,1,0]), axis=1)
    pion_ss_ps_gv = c51.make_gvars(pion_ss_ps)
    kaon_ss_ps_gv = c51.make_gvars(kaon_ss_ps)
    
    return pion_ss_ps_gv, kaon_ss_ps_gv
Пример #3
0
def read_data(filename, dpath_pion_mp, dpath_pion_pp, dpath_etas_mp, dpath_etas_pp, plot='off'):
    pion_mp = c51.fold(c51.open_data(filename, dpath_pion_mp))
    pion_pp = c51.fold(c51.open_data(filename, dpath_pion_pp))
    etas_mp = c51.fold(c51.open_data(filename, dpath_etas_mp))
    etas_pp = c51.fold(c51.open_data(filename, dpath_etas_pp))

    #pion_mp = c51.open_data(filename, dpath_pion_mp)
    #pion_pp = c51.open_data(filename, dpath_pion_pp)
    #etas_mp = c51.open_data(filename, dpath_etas_mp)
    #etas_pp = c51.open_data(filename, dpath_etas_pp)

    pion = pion_mp/pion_pp
    etas = etas_mp/etas_pp

    pion_gv = c51.make_gvars(pion)
    etas_gv = c51.make_gvars(etas)

    pion_gv = gv.gvar(np.array([pion_gv[i].mean for i in range(len(pion_gv))]), np.array([pion_gv[j].sdev for j in range(len(pion_gv))]))
    etas_gv = gv.gvar(np.array([etas_gv[i].mean for i in range(len(pion_gv))]), np.array([etas_gv[j].sdev for j in range(len(pion_gv))]))

    if plot=='on':
        x = np.arange(len(pion_gv))
        c51.scatter_plot(x, pion_gv, title='pion mres')
        c51.scatter_plot(x, etas_gv, title='etas mres')
    else: pass

    return pion_gv, etas_gv
Пример #4
0
def read_data(filename,
              dpath_pion_mp,
              dpath_pion_pp,
              dpath_etas_mp,
              dpath_etas_pp,
              plot='off'):
    pion_mp = c51.fold(c51.open_data(filename, dpath_pion_mp))
    pion_pp = c51.fold(c51.open_data(filename, dpath_pion_pp))
    etas_mp = c51.fold(c51.open_data(filename, dpath_etas_mp))
    etas_pp = c51.fold(c51.open_data(filename, dpath_etas_pp))

    #pion_mp = c51.open_data(filename, dpath_pion_mp)
    #pion_pp = c51.open_data(filename, dpath_pion_pp)
    #etas_mp = c51.open_data(filename, dpath_etas_mp)
    #etas_pp = c51.open_data(filename, dpath_etas_pp)

    pion = pion_mp / pion_pp
    etas = etas_mp / etas_pp

    pion_gv = c51.make_gvars(pion)
    etas_gv = c51.make_gvars(etas)

    pion_gv = gv.gvar(np.array([pion_gv[i].mean for i in range(len(pion_gv))]),
                      np.array([pion_gv[j].sdev for j in range(len(pion_gv))]))
    etas_gv = gv.gvar(np.array([etas_gv[i].mean for i in range(len(pion_gv))]),
                      np.array([etas_gv[j].sdev for j in range(len(pion_gv))]))

    if plot == 'on':
        x = np.arange(len(pion_gv))
        c51.scatter_plot(x, pion_gv, title='pion mres')
        c51.scatter_plot(x, etas_gv, title='etas mres')
    else:
        pass

    return pion_gv, etas_gv
Пример #5
0
def decay_axial(pr, meson, draws):
    if meson == 'pion':
        shortname = 'll'
    elif meson == 'kaon':
        shortname = 'ls'
    # read data
    twopt_dat = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['spec_'+meson])
    twopt_ss = np.squeeze(twopt_dat[:,:,0,:])
    twopt_ps = np.squeeze(twopt_dat[:,:,1,:])
    axial_dat = np.squeeze(c51.open_data(pr.data_loc['file_loc'], pr.data_loc['axial_'+shortname]))
    T = len(twopt_ss[0])
    if pr.plot_data_flag == 'on':
        # unfolded correlator data
        c51.scatter_plot(np.arange(len(twopt_ss[0])), c51.make_gvars(twopt_ss), 'two point no fold')
        c51.scatter_plot(np.arange(len(axial_dat[0])), c51.make_gvars(axial_dat), 'axial_'+shortname+' no fold')
    # fold data
    axial_dat = c51.fold(axial_dat, phase=-1.0)
    twopt_ss = c51.fold(twopt_ss, phase=1.0)
    twopt_ps = c51.fold(twopt_ps, phase=1.0)
    if pr.plot_data_flag == 'on':
        # folded correlator data
        c51.scatter_plot(np.arange(len(twopt_ss[0])), c51.make_gvars(twopt_ss), 'two point folded')
        c51.scatter_plot(np.arange(len(axial_dat[0])), c51.make_gvars(axial_dat), 'axial_'+shortname+' folded')
        # effective mass
        eff = c51.effective_plots(T)
        meff = eff.effective_mass(c51.make_gvars(twopt_ss), 1, 'cosh')
        meff_axial = eff.effective_mass(c51.make_gvars(axial_dat)[1:], 1, 'cosh')
        xlim = [3, len(meff)]
        ylim = c51.find_yrange(meff, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff)), meff, 'two pt effective mass', xlim = xlim, ylim = ylim)
        ylim = c51.find_yrange(meff, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff_axial))+1, meff_axial, 'axial_'+shortname+' effective mass', xlim = xlim, ylim = ylim)
        # scaled correlator
        E0 = pr.priors[meson]['E0'][0]
        scaled = eff.scaled_correlator(c51.make_gvars(twopt_ss), E0, phase=1.0)
        scaled_axial = eff.scaled_correlator(c51.make_gvars(axial_dat)[1:], E0, phase=-1.0)
        c51.scatter_plot(np.arange(len(scaled)), scaled, 'two pt scaled correlator (take sqrt to get Z0)')
        c51.scatter_plot(np.arange(len(scaled_axial))+1, scaled_axial, 'axial_'+shortname+' scaled correlator (divide by Z0 to get F0)')
    # concatenate
    decay_axial_ss = np.concatenate((axial_dat, twopt_ss), axis=1)
    # read priors
    priors = pr.priors[meson]
    # read trange
    trange  = pr.trange['decay_axial']
    # fit
    args = ((g, trange, T, decay_axial_ss, priors, draws) for g in range(len(draws)))
    pool = multi.Pool()
    p = pool.map_async(decay_axial_fit, args)
    # sort via bootstrap number
    output = np.sort(np.array(p.get()), axis=0)
    return output
Пример #6
0
def decay_bs(params, meson, draws):
    print 'decay ', meson
    ens = params.ens
    ml = params.ml
    ms = params.ms
    loc = params.data_loc
    # read data
    decay_dat = c51.fold(c51.open_data(loc['file_loc'], loc['spec_'+meson]))
    decay_ss = np.squeeze(decay_dat[:,:,0,:])
    decay_ps = np.squeeze(decay_dat[:,:,1,:])
    T = 2*len(decay_ss[0])
    if params.plot_data_flag == 'on':
        # unfolded correlator data
        c51.scatter_plot(np.arange(len(decay_ss[0])), c51.make_gvars(decay_ss), meson+' ss folded')
        c51.scatter_plot(np.arange(len(decay_ps[0])), c51.make_gvars(decay_ps), meson+' ps folded')
        # effective mass
        eff = c51.effective_plots(T)
        meff_ss = eff.effective_mass(c51.make_gvars(decay_ss), 1, 'cosh')
        meff_ps = eff.effective_mass(c51.make_gvars(decay_ps), 1, 'cosh')
        xlim = [3, len(meff_ss)-2]
        ylim = c51.find_yrange(meff_ss, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff_ss)), meff_ss, meson+' ss effective mass', xlim = xlim, ylim = ylim)
        ylim = c51.find_yrange(meff_ps, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff_ps)), meff_ps, meson+' ps effective mass', xlim = xlim, ylim = ylim)
        # scaled correlator
        E0 = params.priors[meson]['E0'][0]
        scaled_ss = eff.scaled_correlator(c51.make_gvars(decay_ss), E0, phase=1.0)
        scaled_ps = eff.scaled_correlator(c51.make_gvars(decay_ps), E0, phase=1.0)
        ylim = c51.find_yrange(scaled_ss, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(scaled_ss)), scaled_ss, meson+' ss scaled correlator (take sqrt to get Z0_s)', xlim = xlim, ylim = ylim)
        ylim = c51.find_yrange(scaled_ps, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(scaled_ps)), scaled_ps, meson+' ps scaled correlator (divide by Z0_s to get Z0_p)', xlim = xlim, ylim = ylim)
        plt.show()
    # concatenate data
    decay_ss_ps = np.concatenate((decay_ss, decay_ps), axis=1)
    # priors
    priors = params.priors[meson]
    # read trange
    trange = params.trange['twopt']
    #Fit
    #args = ((g, trange, T, decay_ss_ps, priors, draws) for g in range(len(draws)))
    #pool = multi.Pool()
    #p = pool.map_async(decay_fit, args)
    ## sort via bootstrap number
    #output = np.sort(np.array(p.get()), axis=0)
    result = []
    for g in range(len(draws)):
        # resample decay data
        decay_bs = decay_ss_ps[draws[g]]
        decay_bs = c51.make_gvars(decay_bs)
        # priors
        bsp = c51.dict_of_tuple_to_gvar(priors)
        #Fit
        fitfcn = c51.fit_function(T, nstates=2)
        fit = c51.fitscript_v2(trange, T, decay_bs, bsp, fitfcn.twopt_fitfcn_ss_ps, result_flag='off')
        fit = [g, fit]
        result.append(fit)
    output = np.sort(np.array(result), axis=0)
    return output
Пример #7
0
def read_data(params):
    # read data
    twopt_dat = c51.fold(c51.open_data(params.data_loc['file_loc'], params.data_loc['phiqq_'+params.hadron]))
    T = 2*len(twopt_dat[0])
    if params.plot_data_flag == 'on':
        # unfolded correlator data
        c51.scatter_plot(np.arange(len(twopt_dat[0])), c51.make_gvars(twopt_dat), params.hadron+' folded')
        # effective mass
        eff = c51.effective_plots(T)
        meff = eff.effective_mass(c51.make_gvars(twopt_dat), 1, 'cosh')
        xlim = [2, len(meff)]
        ylim = c51.find_yrange(meff, xlim[0], xlim[1])
        ylim = [0.0, 0.7]
        c51.scatter_plot(np.arange(len(meff)), meff, params.hadron+' effective mass', xlim = xlim, ylim = ylim)
        # scaled correlator
        E0 = params.priors[params.hadron]['E0'][0]
        scaled = eff.scaled_correlator(c51.make_gvars(twopt_dat), E0, phase=1.0)
        c51.scatter_plot(np.arange(len(scaled)), scaled, params.hadron+' scaled correlator (A0 = Z0_s*Z0_p)')
    return twopt_dat, T
Пример #8
0
def decay_axial(pr, meson, draws):
    if meson == 'pion':
        shortname = 'll'
    elif meson == 'kaon':
        shortname = 'ls'
    # read data
    twopt_dat = c51.open_data(pr.data_loc['file_loc'],
                              pr.data_loc['spec_' + meson])
    twopt_ss = np.squeeze(twopt_dat[:, :, 0, :])
    twopt_ps = np.squeeze(twopt_dat[:, :, 1, :])
    axial_dat = np.squeeze(
        c51.open_data(pr.data_loc['file_loc'],
                      pr.data_loc['axial_' + shortname]))
    T = len(twopt_ss[0])
    if pr.plot_data_flag == 'on':
        # unfolded correlator data
        c51.scatter_plot(np.arange(len(twopt_ss[0])), c51.make_gvars(twopt_ss),
                         'two point no fold')
        c51.scatter_plot(np.arange(len(axial_dat[0])),
                         c51.make_gvars(axial_dat),
                         'axial_' + shortname + ' no fold')
    # fold data
    axial_dat = c51.fold(axial_dat, phase=-1.0)
    twopt_ss = c51.fold(twopt_ss, phase=1.0)
    twopt_ps = c51.fold(twopt_ps, phase=1.0)
    if pr.plot_data_flag == 'on':
        # folded correlator data
        c51.scatter_plot(np.arange(len(twopt_ss[0])), c51.make_gvars(twopt_ss),
                         'two point folded')
        c51.scatter_plot(np.arange(len(axial_dat[0])),
                         c51.make_gvars(axial_dat),
                         'axial_' + shortname + ' folded')
        # effective mass
        eff = c51.effective_plots(T)
        meff = eff.effective_mass(c51.make_gvars(twopt_ss), 1, 'cosh')
        meff_axial = eff.effective_mass(
            c51.make_gvars(axial_dat)[1:], 1, 'cosh')
        xlim = [3, len(meff)]
        ylim = c51.find_yrange(meff, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff)),
                         meff,
                         'two pt effective mass',
                         xlim=xlim,
                         ylim=ylim)
        ylim = c51.find_yrange(meff, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff_axial)) + 1,
                         meff_axial,
                         'axial_' + shortname + ' effective mass',
                         xlim=xlim,
                         ylim=ylim)
        # scaled correlator
        E0 = pr.priors[meson]['E0'][0]
        scaled = eff.scaled_correlator(c51.make_gvars(twopt_ss), E0, phase=1.0)
        scaled_axial = eff.scaled_correlator(c51.make_gvars(axial_dat)[1:],
                                             E0,
                                             phase=-1.0)
        c51.scatter_plot(np.arange(len(scaled)), scaled,
                         'two pt scaled correlator (take sqrt to get Z0)')
        c51.scatter_plot(
            np.arange(len(scaled_axial)) + 1, scaled_axial, 'axial_' +
            shortname + ' scaled correlator (divide by Z0 to get F0)')
    # concatenate
    decay_axial_ss = np.concatenate((axial_dat, twopt_ss), axis=1)
    # read priors
    priors = pr.priors[meson]
    # read trange
    trange = pr.trange['decay_axial']
    # fit
    args = ((g, trange, T, decay_axial_ss, priors, draws)
            for g in range(len(draws)))
    pool = multi.Pool()
    p = pool.map_async(decay_axial_fit, args)
    # sort via bootstrap number
    output = np.sort(np.array(p.get()), axis=0)
    return output
Пример #9
0
def decay_bs(params, meson, draws):
    print 'decay ', meson
    ens = params.ens
    ml = params.ml
    ms = params.ms
    loc = params.data_loc
    # read data
    decay_dat = c51.fold(c51.open_data(loc['file_loc'], loc['spec_' + meson]))
    decay_ss = np.squeeze(decay_dat[:, :, 0, :])
    decay_ps = np.squeeze(decay_dat[:, :, 1, :])
    T = 2 * len(decay_ss[0])
    if params.plot_data_flag == 'on':
        # unfolded correlator data
        c51.scatter_plot(np.arange(len(decay_ss[0])), c51.make_gvars(decay_ss),
                         meson + ' ss folded')
        c51.scatter_plot(np.arange(len(decay_ps[0])), c51.make_gvars(decay_ps),
                         meson + ' ps folded')
        # effective mass
        eff = c51.effective_plots(T)
        meff_ss = eff.effective_mass(c51.make_gvars(decay_ss), 1, 'cosh')
        meff_ps = eff.effective_mass(c51.make_gvars(decay_ps), 1, 'cosh')
        xlim = [3, len(meff_ss) - 2]
        ylim = c51.find_yrange(meff_ss, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff_ss)),
                         meff_ss,
                         meson + ' ss effective mass',
                         xlim=xlim,
                         ylim=ylim)
        ylim = c51.find_yrange(meff_ps, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff_ps)),
                         meff_ps,
                         meson + ' ps effective mass',
                         xlim=xlim,
                         ylim=ylim)
        # scaled correlator
        E0 = params.priors[meson]['E0'][0]
        scaled_ss = eff.scaled_correlator(c51.make_gvars(decay_ss),
                                          E0,
                                          phase=1.0)
        scaled_ps = eff.scaled_correlator(c51.make_gvars(decay_ps),
                                          E0,
                                          phase=1.0)
        ylim = c51.find_yrange(scaled_ss, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(scaled_ss)),
                         scaled_ss,
                         meson +
                         ' ss scaled correlator (take sqrt to get Z0_s)',
                         xlim=xlim,
                         ylim=ylim)
        ylim = c51.find_yrange(scaled_ps, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(scaled_ps)),
                         scaled_ps,
                         meson +
                         ' ps scaled correlator (divide by Z0_s to get Z0_p)',
                         xlim=xlim,
                         ylim=ylim)
        plt.show()
    # concatenate data
    decay_ss_ps = np.concatenate((decay_ss, decay_ps), axis=1)
    # priors
    priors = params.priors[meson]
    # read trange
    trange = params.trange['twopt']
    #Fit
    #args = ((g, trange, T, decay_ss_ps, priors, draws) for g in range(len(draws)))
    #pool = multi.Pool()
    #p = pool.map_async(decay_fit, args)
    ## sort via bootstrap number
    #output = np.sort(np.array(p.get()), axis=0)
    result = []
    for g in range(len(draws)):
        # resample decay data
        decay_bs = decay_ss_ps[draws[g]]
        decay_bs = c51.make_gvars(decay_bs)
        # priors
        bsp = c51.dict_of_tuple_to_gvar(priors)
        #Fit
        fitfcn = c51.fit_function(T, nstates=2)
        fit = c51.fitscript_v2(trange,
                               T,
                               decay_bs,
                               bsp,
                               fitfcn.twopt_fitfcn_ss_ps,
                               result_flag='off')
        fit = [g, fit]
        result.append(fit)
    output = np.sort(np.array(result), axis=0)
    return output