def mres(pion_gv, etas_gv): prior = dict() prior['mres'] = gv.gvar(0.0, 1.0) x = np.arange(len(pion_gv)) c51.scatter_plot(x, pion_gv) trange = dict() T = len(pion_gv) - 2 trange['tmin'] = [2, 2] trange['tmax'] = [T, T] pionfit = c51.fitscript(trange, pion_gv, prior, c51.mres_fitfcn, result_flag='off') print "Pion" c51.stability_plot(pionfit, 'mres', 'pion') c51.scatter_plot(x, etas_gv) etasfit = c51.fitscript(trange, etas_gv, prior, c51.mres_fitfcn, result_flag='off') print "Etas" c51.stability_plot(etasfit, 'mres', 'kaon') #print kaonfit['post'] return 0
def decay(pion_ss_ps_gv, kaon_ss_ps_gv): prior = dict() prior['Z0_s'] = gv.gvar(0.025, 0.01) prior['Z1_s'] = gv.gvar(0.025, 0.035) prior['Z2_s'] = gv.gvar(0.025, 0.035) prior['Z0_p'] = gv.gvar(0.27, 0.15) prior['Z1_p'] = gv.gvar(0.27, 0.35) prior['Z2_p'] = gv.gvar(0.27, 0.35) prior['E0'] = gv.gvar(0.23, 0.2) prior['E1'] = gv.gvar(0.0, 1.0) prior['E2'] = gv.gvar(0.0, 1.0) trange = dict() trange['tmin'] = [6, 6] trange['tmax'] = [20, 20] T = len(pion_ss_ps_gv) fitfcn = c51.fit_function(T=T, nstates=2) fit = c51.fitscript(trange, pion_ss_ps_gv, prior, fitfcn.twopt_fitfcn_ss_ps, sets=2, result_flag='off') print "pion" c51.stability_plot(fit, 'Z0_p') c51.stability_plot(fit, 'E0') ml = 0.0158 ms = 0.0902 mres_pi = gv.gvar(0.0009633, 0.0000065) Z0_p = fit['post'][0]['Z0_p'] E0 = fit['post'][0]['E0'] fpi = Z0_p * np.sqrt(2.) * (2. * ml + 2. * mres_pi) / E0**(3. / 2.) print 'fpi:', fpi print "kaon" prior['Z0_s'] = gv.gvar(0.02, 0.01) prior['Z1_s'] = gv.gvar(0.02, 0.03) prior['Z2_s'] = gv.gvar(0.02, 0.03) prior['Z0_p'] = gv.gvar(0.2, 0.1) prior['Z1_p'] = gv.gvar(0.2, 0.3) prior['Z2_p'] = gv.gvar(0.2, 0.3) prior['E0'] = gv.gvar(0.404, 0.2) prior['E1'] = gv.gvar(0.0, 1.0) prior['E2'] = gv.gvar(0.0, 1.0) fit = c51.fitscript(trange, kaon_ss_ps_gv, prior, fitfcn.twopt_fitfcn_ss_ps, sets=2, result_flag='off') c51.stability_plot(fit, 'Z0_p') c51.stability_plot(fit, 'E0') mres_kaon = gv.gvar(0.0006685, 0.0000044) Z0_p = fit['post'][0]['Z0_p'] E0 = fit['post'][0]['E0'] fk = Z0_p * np.sqrt(2.) * (ml + ms + mres_pi + mres_kaon) / E0**(3. / 2.) print 'fk:', fk fkfpi = fk / fpi print 'fk/fpi:', fkfpi
def mres(pion_gv, etas_gv): prior = dict() prior['mres'] = gv.gvar(0.0, 1.0) x = np.arange(len(pion_gv)) c51.scatter_plot(x,pion_gv) trange = dict() T = len(pion_gv)-2 trange['tmin'] = [2, 2] trange['tmax'] = [T, T] pionfit = c51.fitscript(trange, pion_gv, prior, c51.mres_fitfcn, result_flag='off') print "Pion" c51.stability_plot(pionfit,'mres','pion') c51.scatter_plot(x,etas_gv) etasfit = c51.fitscript(trange, etas_gv, prior, c51.mres_fitfcn, result_flag='off') print "Etas" c51.stability_plot(etasfit,'mres','kaon') #print kaonfit['post'] return 0
def decay(pion_ss_ps_gv, kaon_ss_ps_gv): prior = dict() prior['Z0_s'] = gv.gvar(0.025, 0.01) prior['Z1_s'] = gv.gvar(0.025, 0.035) prior['Z2_s'] = gv.gvar(0.025, 0.035) prior['Z0_p'] = gv.gvar(0.27, 0.15) prior['Z1_p'] = gv.gvar(0.27, 0.35) prior['Z2_p'] = gv.gvar(0.27, 0.35) prior['E0'] = gv.gvar(0.23, 0.2) prior['E1'] = gv.gvar(0.0, 1.0) prior['E2'] = gv.gvar(0.0, 1.0) trange = dict() trange['tmin'] = [6,6] trange['tmax'] = [20,20] T = len(pion_ss_ps_gv) fitfcn = c51.fit_function(T=T, nstates=2) fit = c51.fitscript(trange, pion_ss_ps_gv, prior, fitfcn.twopt_fitfcn_ss_ps, sets=2, result_flag='off') print "pion" c51.stability_plot(fit, 'Z0_p') c51.stability_plot(fit, 'E0') ml = 0.0158 ms = 0.0902 mres_pi = gv.gvar(0.0009633, 0.0000065) Z0_p = fit['post'][0]['Z0_p'] E0 = fit['post'][0]['E0'] fpi = Z0_p*np.sqrt(2.)*(2.*ml+2.*mres_pi)/E0**(3./2.) print 'fpi:', fpi print "kaon" prior['Z0_s'] = gv.gvar(0.02, 0.01) prior['Z1_s'] = gv.gvar(0.02, 0.03) prior['Z2_s'] = gv.gvar(0.02, 0.03) prior['Z0_p'] = gv.gvar(0.2, 0.1) prior['Z1_p'] = gv.gvar(0.2, 0.3) prior['Z2_p'] = gv.gvar(0.2, 0.3) prior['E0'] = gv.gvar(0.404, 0.2) prior['E1'] = gv.gvar(0.0, 1.0) prior['E2'] = gv.gvar(0.0, 1.0) fit = c51.fitscript(trange, kaon_ss_ps_gv, prior, fitfcn.twopt_fitfcn_ss_ps, sets=2, result_flag='off') c51.stability_plot(fit, 'Z0_p') c51.stability_plot(fit, 'E0') mres_kaon = gv.gvar(0.0006685, 0.0000044) Z0_p = fit['post'][0]['Z0_p'] E0 = fit['post'][0]['E0'] fk = Z0_p*np.sqrt(2.)*(ml+ms+mres_pi+mres_kaon)/E0**(3./2.) print 'fk:', fk fkfpi = fk/fpi print 'fk/fpi:', fkfpi
#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') c51.stability_plot(fit, 'Z0_p') plt.show()
# bootstrap axial_ls fk = decay_axial(pr, 'kaon', draws) # process output and plot distribution fpi_proc = c51.process_bootstrap(fpi) fk_proc = c51.process_bootstrap(fk) fpi_boot0, fpi_bs = fpi_proc() fk_boot0, fk_bs = fk_proc() print fpi_boot0 if pr.plot_hist_flag == 'on': c51.histogram_plot(fpi_bs, 'F0', 'pion F0') c51.histogram_plot(fpi_bs, 'E0', 'pion E0') c51.histogram_plot(fk_bs, 'F0', 'kaon F0') c51.histogram_plot(fk_bs, 'E0', 'kaon F0') # plot stability for boot0 fits if pr.plot_stab_flag == 'on': c51.stability_plot(fpi_boot0, 'F0', 'boot0 fpi') c51.stability_plot(fpi_boot0, 'E0', 'boot0 m_pi') c51.stability_plot(fk_boot0, 'F0', 'boot0 fk') c51.stability_plot(fk_boot0, 'E0', 'boot0 m_k') # boot0 result F0_pi = fpi_proc.read_boot0('F0') E0_pi = fpi_proc.read_boot0('E0') F0_k = fk_proc.read_boot0('F0') E0_k = fk_proc.read_boot0('E0') # calculate decay constant fpi = -1.0 * F0_pi * np.sqrt(2.0 / E0_pi) fk = -1.0 * F0_k * np.sqrt(2.0 / E0_k) table_print = collections.OrderedDict() table_print['tmin'] = fpi_boot0['tmin'] table_print['tmax'] = fpi_boot0['tmax'] table_print['fk'] = fk
# bootstrap axial_ls fk = decay_axial(pr, 'kaon', draws) # process output and plot distribution fpi_proc = c51.process_bootstrap(fpi) fk_proc = c51.process_bootstrap(fk) fpi_boot0, fpi_bs = fpi_proc() fk_boot0, fk_bs = fk_proc() print fpi_boot0 if pr.plot_hist_flag == 'on': c51.histogram_plot(fpi_bs, 'F0', 'pion F0') c51.histogram_plot(fpi_bs, 'E0', 'pion E0') c51.histogram_plot(fk_bs, 'F0', 'kaon F0') c51.histogram_plot(fk_bs, 'E0', 'kaon F0') # plot stability for boot0 fits if pr.plot_stab_flag == 'on': c51.stability_plot(fpi_boot0, 'F0', 'boot0 fpi') c51.stability_plot(fpi_boot0, 'E0', 'boot0 m_pi') c51.stability_plot(fk_boot0, 'F0', 'boot0 fk') c51.stability_plot(fk_boot0, 'E0', 'boot0 m_k') # boot0 result F0_pi = fpi_proc.read_boot0('F0') E0_pi = fpi_proc.read_boot0('E0') F0_k = fk_proc.read_boot0('F0') E0_k = fk_proc.read_boot0('E0') # calculate decay constant fpi = -1.0*F0_pi*np.sqrt(2.0/E0_pi) fk = -1.0*F0_k*np.sqrt(2.0/E0_k) table_print = collections.OrderedDict() table_print['tmin'] = fpi_boot0['tmin'] table_print['tmax'] = fpi_boot0['tmax'] table_print['fk'] = fk
return np.array([[0, grandfit]]) if __name__ == '__main__': # read params pr = c51.process_params() # read data corr_avg, T = read_baryon(pr) # fit fit = chain_fit(pr, corr_avg, T) raise SystemExit # process fit fit_proc = c51.process_bootstrap(fit) fit_boot0, fit_bs = fit_proc() if pr.plot_stab_flag == 'on': c51.stability_plot(fit_boot0, 'E0', 'proton E0 ') c51.stability_plot(fit_boot0, 'Z0_p', 'proton Z0_p ') c51.stability_plot(fit_boot0, 'Z0_s', 'proton Z0_s ') if pr.print_tbl_flag == 'on': tbl = c51.tabulate_result(fit_proc, ['Z0_s', 'Z0_p', 'E0']) print tbl #c51.heatmap(fit_proc.nstates, fit_proc.tmin, fit_proc.normbayesfactor, [0,1], 'Bayes Factor', 'nstates', 'tmin') #c51.heatmap(fit_proc.nstates, fit_proc.tmin, fit_proc.chi2dof, [0,3], 'chi2/dof', 'nstates', 'tmin') # nstate stability c51.nstate_stability_plot(fit_boot0, 'E0', 'proton E0 ') c51.nstate_stability_plot(fit_boot0, 'Z0_p', 'proton Z0_p ') c51.nstate_stability_plot(fit_boot0, 'Z0_s', 'proton Z0_s ') # model averaging #bma = c51.bayes_model_avg(fit_proc, ['Z0_p', 'Z0_s', 'E0']) #print bma # look at small t values
#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()
draws = params.bs_draws(draw_n) # bootstrap mres mres_pion_fit = mres_bs(params, 'pion', draws) mres_etas_fit = mres_bs(params, 'etas', draws) # process bootstrap mres_pion_proc = c51.process_bootstrap(mres_pion_fit) mres_etas_proc = c51.process_bootstrap(mres_etas_fit) if params.print_fit_flag == 'on': print mres_pion_proc()[0]['rawoutput'] print mres_etas_proc()[0]['rawoutput'] # plot mres stability if params.plot_stab_flag == 'on': try: mres_pion_0, mres_pion_n = mres_pion_proc() mres_etas_0, mres_etas_n = mres_etas_proc() c51.stability_plot(mres_pion_0, 'mres', 'pion mres') c51.stability_plot(mres_etas_0, 'mres', 'etas mres') except: print 'error encountered' #plt.show() # print results if params.print_mres_flag == 'on': tbl_print = collections.OrderedDict() tbl_print['tmin'] = mres_pion_proc.tmin tbl_print['tmax'] = mres_pion_proc.tmax tbl_print['mres_pion_boot0'] = mres_pion_proc.read_boot0('mres') tbl_print['mres_pion_sdev'] = mres_pion_proc.read_boot0_sdev('mres') tbl_print['pion_chi2/dof'] = mres_pion_proc.chi2dof tbl_print['mres_etas_boot0'] = mres_etas_proc.read_boot0('mres') tbl_print['mres_etas_sdev'] = mres_etas_proc.read_boot0_sdev('mres') tbl_print['etas_chi2/dof'] = mres_etas_proc.chi2dof
except: grandfit['nstates'] = n*np.ones(len(fit[k])) return np.array([[0, grandfit]]) if __name__=='__main__': # read params pr = c51.process_params() # read data p_avg, T = read_proton(pr) # fit fit = fit_proton(pr, p_avg, T) # process fit fit_proc = c51.process_bootstrap(fit) fit_boot0, fit_bs = fit_proc() if pr.plot_stab_flag == 'on': c51.stability_plot(fit_boot0, 'E0', 'proton E0 ') c51.stability_plot(fit_boot0, 'Z0_p', 'proton Z0_p ') c51.stability_plot(fit_boot0, 'Z0_s', 'proton Z0_s ') if pr.print_tbl_flag == 'on': tbl = c51.tabulate_result(fit_proc, ['Z0_s', 'Z0_p', 'E0']) print tbl #c51.heatmap(fit_proc.nstates, fit_proc.tmin, fit_proc.normbayesfactor, [0,1], 'Bayes Factor', 'nstates', 'tmin') #c51.heatmap(fit_proc.nstates, fit_proc.tmin, fit_proc.chi2dof, [0,3], 'chi2/dof', 'nstates', 'tmin') # nstate stability c51.nstate_stability_plot(fit_boot0, 'E0', 'proton E0 ') c51.nstate_stability_plot(fit_boot0, 'Z0_p', 'proton Z0_p ') c51.nstate_stability_plot(fit_boot0, 'Z0_s', 'proton Z0_s ') # model averaging #bma = c51.bayes_model_avg(fit_proc, ['Z0_p', 'Z0_s', 'E0']) #print bma # look at small t values
def fittwo_pt(params, twopt_dat, T): # make data twopt_gv = c51.make_gvars(twopt_dat) # priors priors = params.priors[params.hadron] priors_gv = c51.dict_of_tuple_to_gvar(priors) # read trange trange = params.trange['twopt'] # fit fitfcn = c51.fit_function(T, nstates=1) fit = c51.fitscript_v2(trange, T, twopt_gv, priors_gv, fitfcn.twopt_fitfcn_phiqq, params.print_fit_flag) return np.array([[0, fit]]) if __name__=='__main__': # read parameters params = c51.process_params() # read data twopt_dat, T = read_data(params) # fit two point fit = fittwo_pt(params, twopt_dat, T) # process fit fit_proc = c51.process_bootstrap(fit) fit_boot0, fit_bs = fit_proc() if params.plot_stab_flag == 'on': c51.stability_plot(fit_boot0, 'E0', params.hadron+' E0 ') c51.stability_plot(fit_boot0, 'A0', params.hadron+' A0 ') if params.print_tbl_flag == 'on': tbl = c51.tabulate_result(fit_proc, ['A0', 'E0']) print tbl plt.show()
fit = c51.fitscript_v2(trange, T, mres_dat_bs, bsp, fitfcn.mres_fitfcn, result_flag='off') result = [g, fit] return result if __name__=='__main__': # read parameters params = c51.process_params() # generate bootstrap list draw_n = 0 draws = params.bs_draws(draw_n) # bootstrap mres mres_pion_fit = mres_bs(params, 'pion', draws) #mres_etas_fit = mres_bs(params, 'etas', draws, mres_data_flag) # process bootstrap mres_pion_proc = c51.process_bootstrap(mres_pion_fit) #mres_etas_proc = c51.process_bootstrap(mres_etas_fit) # plot mres stability if params.plot_stab_flag == 'on': mres_pion_0, mres_pion_n = mres_pion_proc() #mres_etas_0, mres_etas_n = mres_etas_proc() c51.stability_plot(mres_pion_0, 'mres', 'pion mres') #c51.stability_plot(mres_etas_0, 'mres', 'etas mres') plt.show() # print results if params.print_tbl_flag == 'on': tblp = c51.tabulate_result(mres_pion_proc, ['mres']) #tble = c51.tabulate_result(mres_etas_proc, ['mres']) print params.ens print tblp #print tble
result = [g, fit] return result if __name__ == '__main__': # read parameters params = c51.process_params() # generate bootstrap list draw_n = 0 draws = params.bs_draws(draw_n) # bootstrap mres mres_pion_fit = mres_bs(params, 'pion', draws) #mres_etas_fit = mres_bs(params, 'etas', draws, mres_data_flag) # process bootstrap mres_pion_proc = c51.process_bootstrap(mres_pion_fit) #mres_etas_proc = c51.process_bootstrap(mres_etas_fit) # plot mres stability if params.plot_stab_flag == 'on': mres_pion_0, mres_pion_n = mres_pion_proc() #mres_etas_0, mres_etas_n = mres_etas_proc() c51.stability_plot(mres_pion_0, 'mres', 'pion mres') #c51.stability_plot(mres_etas_0, 'mres', 'etas mres') plt.show() # print results if params.print_tbl_flag == 'on': tblp = c51.tabulate_result(mres_pion_proc, ['mres']) #tble = c51.tabulate_result(mres_etas_proc, ['mres']) print params.ens print tblp #print tble