Example #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
Example #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
Example #3
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
Example #4
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
Example #5
0
def read_proton(pr):
    # read data
    p_up = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['proton_spin_up'])
    p_dn = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['proton_spin_dn'])
    pnp_up = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['proton_np_spin_up'])
    pnp_dn = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['proton_np_spin_dn'])
    p_savg = c51.ispin_avg(p_up, p_dn)
    pnp_savg = c51.ispin_avg(pnp_up, pnp_dn)
    p_avg = c51.parity_avg(p_savg, pnp_savg, phase=-1.0)
    T = len(p_avg[0])
    p_avg = p_avg[:, :T/2] # keep only first half of data ('folded' length)
    if pr.plot_data_flag == 'on':
        # folded correlator data
        p_ss = p_avg[:,:,0,0]
        p_ps = p_avg[:,:,3,0]
        c51.scatter_plot(np.arange(len(p_ss[0])), c51.make_gvars(p_ss), 'proton ss folded')
        c51.scatter_plot(np.arange(len(p_ps[0])), c51.make_gvars(p_ps), 'proton ps folded')
        # effective mass
        eff = c51.effective_plots(T)
        meff_ss = eff.effective_mass(c51.make_gvars(p_ss)[1:], 1, 'cosh')
        meff_ps = eff.effective_mass(c51.make_gvars(p_ps)[1:], 1, 'cosh')
        xlim = [1, len(meff_ss)] #*2/5]
        #ylim = [0.7, 1.1]
        ylim = [0.3, 0.9]
        #ylim = c51.find_yrange(meff_ss, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff_ss))+1, meff_ss, 'proton 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))+1, meff_ps, 'proton ps effective mass', xlim = xlim, ylim = ylim)
        # scaled correlator
        E0 = pr.priors['proton']['E0'][0]
        scaled_ss = eff.scaled_correlator(c51.make_gvars(p_ss), E0, phase=1.0)
        scaled_ps = eff.scaled_correlator(c51.make_gvars(p_ps), E0, phase=1.0)
        ylim = c51.find_yrange(scaled_ss, xlim[0], xlim[1]/2)
        c51.scatter_plot(np.arange(len(scaled_ss)), scaled_ss, 'proton ss scaled correlator (take sqrt to get Z0_s)', xlim = xlim, ylim = ylim)
        ylim = c51.find_yrange(scaled_ps, xlim[0], xlim[1]/2)
        c51.scatter_plot(np.arange(len(scaled_ps)), scaled_ps, 'proton ps scaled correlator (divide by Z0_s to get Z0_p)', xlim = xlim, ylim = ylim)
        plt.show()
    return p_avg, T
Example #6
0
def read_proton(pr):
    # read data
    p_up = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['proton_spin_up'])
    p_dn = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['proton_spin_dn'])
    pnp_up = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['proton_np_spin_up'])
    pnp_dn = c51.open_data(pr.data_loc['file_loc'], pr.data_loc['proton_np_spin_dn'])
    p_savg = c51.ispin_avg(p_up, p_dn)
    pnp_savg = c51.ispin_avg(pnp_up, pnp_dn)
    p_avg = c51.parity_avg(p_savg, pnp_savg, phase=-1.0)
    T = len(p_avg[0])
    p_avg = p_avg[:, :T/2] # keep only first half of data ('folded' length)
    if pr.plot_data_flag == 'on':
        # folded correlator data
        p_ss = p_avg[:,:,0,0]
        p_ps = p_avg[:,:,3,0]
        c51.scatter_plot(np.arange(len(p_ss[0])), c51.make_gvars(p_ss), 'proton ss folded')
        c51.scatter_plot(np.arange(len(p_ps[0])), c51.make_gvars(p_ps), 'proton ps folded')
        # effective mass
        eff = c51.effective_plots(T)
        meff_ss = eff.effective_mass(c51.make_gvars(p_ss)[1:], 1, 'cosh')
        meff_ps = eff.effective_mass(c51.make_gvars(p_ps)[1:], 1, 'cosh')
        xlim = [1, len(meff_ss)] #*2/5]
        ylim = [0.6, 1.2]
        #ylim = c51.find_yrange(meff_ss, xlim[0], xlim[1])
        c51.scatter_plot(np.arange(len(meff_ss))+1, meff_ss, 'proton 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))+1, meff_ps, 'proton ps effective mass', xlim = xlim, ylim = ylim)
        # scaled correlator
        E0 = pr.priors['proton']['E0'][0]
        scaled_ss = eff.scaled_correlator(c51.make_gvars(p_ss), E0, phase=1.0)
        scaled_ps = eff.scaled_correlator(c51.make_gvars(p_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, 'proton 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, 'proton ps scaled correlator (divide by Z0_s to get Z0_p)', xlim = xlim, ylim = ylim)
    return p_avg, T
Example #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
Example #8
0
#Read meson data
filename = 'l2464f211b600m0102m0509m635a_avg.h5'
datapath = 'l2464f211b600m0102m0509m635/wf1p0_m51p2_l58_a51p5_smrw5p0_n75/spectrum/ml0p0126_ms0p0693/pion/corr'
data_ss = c51.read_data(filename, datapath, 0, 0)
data_ps = c51.read_data(filename, datapath, 1, 0)

data = np.concatenate((data_ss, data_ps), axis=1)
data = c51.make_gvars(data)
#data = data_ps

#Plot effective mass
T = len(data) * 0.5
meff = c51.effective_mass(data, 1)
x = np.arange(len(meff))
ylim = c51.find_yrange(meff, 1, 10)
#ylim = [0.47, 0.57]
xr = [1, 15]
c51.scatter_plot(x, meff, 'effective mass', xlim=[xr[0], xr[1]], ylim=ylim)
#ylim = c51.find_yrange(meff, 65, 79)
c51.scatter_plot(x,
                 meff,
                 'effective mass ps',
                 xlim=[T + xr[0], T + xr[1]],
                 ylim=ylim)

#Fit
inputs = c51.read_yaml('temp.yml')
prior = c51.dict_of_tuple_to_gvar(inputs['prior'])
trange = inputs['trange']
fitfcn = c51.fit_function(T, nstates=2)
Example #9
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
Example #10
0
def read_baryon(pr):
    # read data
    baryon = pr.baryon2pt
    if baryon in ['proton', 'sigma', 'xi', 'lambda']:
        corr_up = c51.open_data(pr.data_loc['file_loc'],
                                pr.data_loc[baryon + '_spin_up'])
        corr_dn = c51.open_data(pr.data_loc['file_loc'],
                                pr.data_loc[baryon + '_spin_dn'])
        corrnp_up = c51.open_data(pr.data_loc['file_loc'],
                                  pr.data_loc[baryon + '_np_spin_up'])
        corrnp_dn = c51.open_data(pr.data_loc['file_loc'],
                                  pr.data_loc[baryon + '_np_spin_dn'])
        # spin avg
        corr = 0.5 * (corr_up + corr_dn)
        corrnp = 0.5 * (corrnp_up + corrnp_dn)
    elif baryon in ['delta', 'sigma_st', 'xi_st', 'omega']:
        corr_upup = c51.open_data(pr.data_loc['file_loc'],
                                  pr.data_loc[baryon + '_spin_upup'])
        corr_up = c51.open_data(pr.data_loc['file_loc'],
                                pr.data_loc[baryon + '_spin_up'])
        corr_dn = c51.open_data(pr.data_loc['file_loc'],
                                pr.data_loc[baryon + '_spin_dn'])
        corr_dndn = c51.open_data(pr.data_loc['file_loc'],
                                  pr.data_loc[baryon + '_spin_dndn'])
        corrnp_upup = c51.open_data(pr.data_loc['file_loc'],
                                    pr.data_loc[baryon + '_np_spin_upup'])
        corrnp_up = c51.open_data(pr.data_loc['file_loc'],
                                  pr.data_loc[baryon + '_np_spin_up'])
        corrnp_dn = c51.open_data(pr.data_loc['file_loc'],
                                  pr.data_loc[baryon + '_np_spin_dn'])
        corrnp_dndn = c51.open_data(pr.data_loc['file_loc'],
                                    pr.data_loc[baryon + '_np_spin_dndn'])
        # spin avg
        corr = 0.25 * (corr_upup + corr_up + corr_dn + corr_dndn)
        corrnp = 0.25 * (corrnp_upup + corrnp_up + corrnp_dn + corrnp_dndn)
    # parity avg
    corr_avg = c51.parity_avg(corr, corrnp, phase=-1.0)
    T = len(corr_avg[0])
    corr_avg = corr_avg[:, :T /
                        2]  # keep only first half of data ('folded' length)
    if pr.plot_data_flag == 'on':
        for src in range(len(corr_avg[0, 0, 0])):
            for snk in range(len(corr_avg[0, 0])):
                # folded correlator data
                corr_i = corr_avg[:, :, snk, src]
                #c51.scatter_plot(np.arange(len(corr_i[0])), c51.make_gvars(corr_i), '%s snk_%s src_%s folded' %(baryon,str(snk),str(src)))
                # effective mass
                eff = c51.effective_plots(T)
                meff = eff.effective_mass(
                    c51.make_gvars(corr_i)[1:], 1, 'cosh')
                xlim = [1, len(meff)]
                ylim = c51.find_yrange(meff, xlim[0], xlim[1] * 2 / 5)
                c51.scatter_plot(np.arange(len(meff)) + 1,
                                 meff,
                                 '%s snk_%s src_%s effective mass' %
                                 (baryon, str(snk), str(src)),
                                 xlim=xlim,
                                 ylim=ylim)
                # scaled correlator
                E0 = pr.priors[baryon]['E0'][0]
                scaled = eff.scaled_correlator(c51.make_gvars(corr_i),
                                               E0,
                                               phase=1.0)
                ylim = c51.find_yrange(scaled, xlim[0], xlim[1] * 2 / 5)
                c51.scatter_plot(
                    np.arange(len(scaled)),
                    scaled,
                    '%s snk_%s src_%s scaled correlator (take sqrt to get Z0_s)'
                    % (baryon, str(snk), str(src)),
                    xlim=xlim,
                    ylim=ylim)
                plt.show()
    return corr_avg, T
Example #11
0
#datapath = 'prot_w6p1_n94'
#datapath = 'prot_w5p6_n94'
filename = 'l2464f211b600m0102m0509m635a_avg.h5'
datapath = 'l2464f211b600m0102m0509m635/wf1p0_m51p2_l58_a51p5_smrw5p0_n75/spectrum/ml0p0126_ms0p0693/pion/corr'
data_ss = c51.read_data(filename, datapath, 0, 0)
data_ps = c51.read_data(filename, datapath, 3, 0)

data = np.concatenate((data_ss, data_ps), axis=1)
data = c51.make_gvars(data)
#data = data_ps

#Plot effective mass
T = len(data)*0.5
meff = c51.effective_mass(data, 1)
x = np.arange(len(meff))
ylim = c51.find_yrange(meff, 1, 10)
#ylim = [0.47, 0.57]
xr = [1,15]
c51.scatter_plot(x, meff, 'effective mass', xlim=[xr[0],xr[1]], ylim=ylim)
#ylim = c51.find_yrange(meff, 65, 79)
c51.scatter_plot(x, meff, 'effective mass ps', xlim=[T+xr[0],T+xr[1]], ylim=ylim)

#Fit
inputs = c51.read_yaml('temp.yml')
prior = c51.dict_of_tuple_to_gvar(inputs['prior'])
trange = inputs['trange']
fitfcn = c51.fit_function(T, nstates=2)
fit = c51.fitscript(trange, data, prior, fitfcn.twopt_fitfcn_ss_ps, sets=2, result_flag='on')
c51.stability_plot(fit, 'E0')
c51.stability_plot(fit, 'Z0_s')
plt.show()
Example #12
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