def showfit(linhpd, linfile, names=None, set_plot=False, mode="test", model='Rmap'): if mode == "run": linfile = ".".join([linfile, "myrun"]) print linfile zydata = get_data(linfile, names=names) if model == 'Rmap' or model == 'Rmap2': rmap = Rmap_Model(zydata) elif model == 'Pmap': rmap = Pmap_Model(zydata) elif model == 'DPmap': rmap = DPmap_Model(zydata) if mode == "test": return (None) else: zypred = rmap.do_pred(linhpd[1, :]) zypred.names = names print names if set_plot: zypred.plot(set_pred=True, obs=zydata, figout="prediction_" + model, figext=figext)
def rm_single(rmid, nwalker, nchain, nburn, min_lag, max_lag, fig_out): # Input and output data position and name file_con = Location.project_loca + "result/light_curve/" + str(rmid) + \ "/cont.txt" file_hbeta = Location.project_loca + "result/light_curve/" + str(rmid) + \ "/Hbetab.txt" lc_plot = Location.project_loca + "result/light_curve/" + str(rmid) + \ "/lightcurve" data_out = Location.project_loca + "result/light_curve/" + str(rmid) + \ "/cont-hbeta.txt" last_mcmc = Location.project_loca + "result/light_curve/" + str(rmid) + \ "/last_mcmc" # Fit continuum c = get_data([file_con]) cmod = Cont_Model(c) cmod.do_mcmc(threads=100, nwalkers=nwalker, nchain=nchain, nburn=nburn) # Do mcmc cy = get_data([file_con, file_hbeta], names=["Continuum", "Hbeta"]) cy.plot(figout=lc_plot, figext="png") cymod = Rmap_Model(cy) cymod.do_mcmc(conthpd=cmod.hpd, threads=100, fchain=data_out, nwalkers=nwalker, nchain=2.0 * nchain, nburn=2.0 * nburn, laglimit=[[min_lag, max_lag]]) # Output mcmc result cymod.show_hist(figout=fig_out, figext="png") cypred = cymod.do_pred() cypred.plot(set_pred=True, obs=cy, figout=last_mcmc, figext="png") return [cymod.hpd[0][2], cymod.hpd[1][2], cymod.hpd[2][2]]
def showfit(linhpd, linfile, names=None, set_plot=False, mode="test") : if mode == "run" : linfile = ".".join([linfile, "myrun"]) print (linfile) zydata = get_data(linfile, names=names) rmap = Rmap_Model(zydata) if mode == "test" : return(None) else : zypred = rmap.do_pred(linhpd[1,:]) zypred.names = names if set_plot : zypred.plot(set_pred=True, obs=zydata, figout="prediction", figext=figext)
def showfit(linhpd, linfile, names=None, set_plot=False, mode="test") : if mode == "run" : linfile = ".".join([linfile, "myrun"]) print linfile zydata = get_data(linfile, names=names) rmap = Rmap_Model(zydata) if mode == "test" : return(None) else : zypred = rmap.do_pred(linhpd[1,:]) zypred.names = names if set_plot : zypred.plot(set_pred=True, obs=zydata, figout="prediction", figext=figext)
x = cont_best.jlist[:] y = cont_best.mlist[:] + cont_best.blist[:] ey = cont_best.elist[:] plt.plot(x[0], y[0] + javdata_con.cont_mean) plt.fill_between(x[0], y[0] - ey[0] + javdata_con.cont_mean, y[0] + ey[0] + javdata_con.cont_mean, where=None, color='grey') x = javdata_con.jlist[:] y = javdata_con.mlist[:] + javdata_con.blist[:] ey = javdata_con.elist[:] plt.errorbar(x[0], y[0] + javdata_con.cont_mean, yerr=ey[0], ls='none', marker='o') plt.show() rmap1 = Rmap_Model(javdata_rm) #rmap1.do_mcmc(conthpd=conthpd, fchain="mychain1.dat", laglimit=[[0, 10],], nwalkers=100, nburn=200, nchain=1000) rmap1.load_chain("mychain1.dat") rmap1.show_hist() rmap1.get_hpd() rmap1hpd = rmap1.hpd par_best = rmap1hpd[1, :] print(par_best) javdata_best = rmap1.do_pred(par_best) javdata_best.plot(set_pred=True, obs=javdata_rm)