本文整理汇总了Python中chainconsumer.ChainConsumer.configure_bar方法的典型用法代码示例。如果您正苦于以下问题:Python ChainConsumer.configure_bar方法的具体用法?Python ChainConsumer.configure_bar怎么用?Python ChainConsumer.configure_bar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainconsumer.ChainConsumer
的用法示例。
在下文中一共展示了ChainConsumer.configure_bar方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ChainConsumer
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure_bar [as 别名]
t = os.path.abspath(dir_name + "/output/data_%d")
plot_file = os.path.abspath(dir_name + "/output/surfaces.png")
walk_file = os.path.abspath(dir_name + "/output/walk_%s.png")
c = ChainConsumer()
n = 2
colours = ["#4CAF50", "#D32F2F", "#1E88E5"] * n # , "#FFA000"] * n
for i in range(n):
mean, sigma, cut, observed, mask = get_data(seed=i)
model_good = EfficiencyModelUncorrected(observed, name="Good")
model_un = EfficiencyModelUncorrected(observed[mask])
model_cor = EfficiencyModelCorrected(observed[mask], cut)
sampler = EnsembleSampler(num_steps=25000, num_burn=1000, temp_dir=t % i)
model_good.fit(sampler, chain_consumer=c)
model_un.fit(sampler, chain_consumer=c)
biased_chain = c.chains[-1]
# model_cor.fit(sampler, chain_consumer=c)
mus = biased_chain[:, 0]
sigmas = biased_chain[:, 1]
weights = 1 / get_weights(cut, mus, sigmas, mask.sum())
c.add_chain(biased_chain, name="Importance Sampled", weights=weights)
c.configure_bar(shade=True)
c.configure_general(colours=colours, bins=0.5)
c.configure_contour(contourf=True, contourf_alpha=0.2)
c.plot(filename=plot_file, figsize=(5, 5), truth=[mean, sigma], legend=False)
示例2: ChainConsumer
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import configure_bar [as 别名]
if __name__ == "__main__":
dir_name = os.path.dirname(os.path.abspath(__file__))
output = dir_name + "/output/complete.png"
output2 = dir_name + "/output/complete2.png"
folders = ["simple", "approx"] # "stan_mc",
use_weight = [False, True]
c = ChainConsumer()
for f, u in zip(folders, use_weight):
loc = dir_name + os.sep + f + "/stan_output"
t = None
try:
chain, posterior, t, p, ff, l, w, ow = load_stan_from_folder(loc, merge=True)
if u:
c.add_chain(chain, posterior=posterior, walkers=l, name=f)
c.add_chain(chain, weights=w, posterior=posterior, walkers=l, name="full")
else:
c.add_chain(chain, posterior=posterior, walkers=l, name=f)
except Exception as e:
print(e)
print("No files found in %s" % loc)
print(p)
c.configure_general(linestyles=['-', '--', '-'], colours=["#1E88E5", "#555555", "#D32F2F"]) #4CAF50
c.configure_bar(shade=[True, True, True])
c.configure_contour(shade=[True, True, True])
pp = ['$\\Omega_m$', '$\\alpha$', '$\\beta$', '$\\langle M_B \\rangle$', '$\\langle x_1 \\rangle$',
'$\\langle c \\rangle$'] #, '$\\sigma_{\\rm m_B}$', '$\\sigma_{x_1}$', '$\\sigma_c$']
c.plot(filename=output, truth=t, parameters=pp)
c.plot(filename=output2, truth=t)