本文整理汇总了Python中chainconsumer.ChainConsumer.get_summary方法的典型用法代码示例。如果您正苦于以下问题:Python ChainConsumer.get_summary方法的具体用法?Python ChainConsumer.get_summary怎么用?Python ChainConsumer.get_summary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainconsumer.ChainConsumer
的用法示例。
在下文中一共展示了ChainConsumer.get_summary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_unconstrained
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import get_summary [as 别名]
def is_unconstrained(chain, param):
c = ChainConsumer()
c.add_chain(chain, parameters=param)
constraints = c.get_summary()[0]
for key in constraints:
val = constraints[key]
if val[0] is None or val[2] is None:
return True
return False
示例2: repr
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import get_summary [as 别名]
plt.plot(out_absc[20:], out_lines[20:], '-', color='k')
plt.axhline(1.01)
plt.savefig(dir_output + 'GRtrace_pam_' + repr(nd) + '.png', bbox_inches='tight')
plt.close()
print
print '*************************************************************'
print
if args.cc != 'False':
cc = ChainConsumer()
for nd in xrange(0, mc.ndim): # (0,ndim):
cc.add_chain(chain[:, :, nd].flatten(), walkers=mc.nwalkers)
#print(cc.get_latex_table())
print cc.get_summary()
print cc.diagnostic_gelman_rubin(threshold=0.05)
print cc.diagnostic_geweke()
print
print '*************************************************************'
print
x0 = 1. / 150
M_star1_rand = np.random.normal(M_star1, M_star1_err, n_kept)
if 'kepler' in mc.model_list:
if args.p != 'False' or args.v != 'False':
示例3: load_stan_from_folder
# 需要导入模块: from chainconsumer import ChainConsumer [as 别名]
# 或者: from chainconsumer.ChainConsumer import get_summary [as 别名]
def load_stan_from_folder(folder, replace=True, merge=True, cut=False, num=None):
vals = get_truths_labels_significance()
full_params = [[k[2]] if not isinstance(k[2], list) else k[2] for k in vals if k[2] is not None]
params = [[k[2]] if not isinstance(k[2], list) else k[2] for k in vals if
k[3] and k[2] is not None]
full_params = list(itertools.chain.from_iterable(full_params))
full_params.remove("$\\rho$")
params = list(itertools.chain.from_iterable(params))
name_map = {k[0]: k[2] for k in vals}
truths = {k[2]: k[1] for k in vals if not isinstance(k[2], list)}
is_array = [k[0] for k in vals if not isinstance(k[1], float) and not isinstance(k[1], int)]
cs = {}
fs = sorted([f for f in os.listdir(folder) if f.startswith("stan") and f.endswith(".pkl")])
if num is not None:
filter = "_%d_" % num
fs = [f for f in fs if filter in f]
for f in fs:
splits = f.split("_")
c = splits[1]
t = os.path.abspath(folder + os.sep + f)
if cs.get(c) is None:
cs[c] = []
cs[c].append(get_chain(t, name_map, replace=replace))
assert len(cs.keys()) > 0, "No results found"
result = []
good_ks = []
for k in sorted(list(cs.keys())):
chains = cs[k]
chain = chains[0]
for c in chains[1:]:
for key in chain.keys():
chain[key] = np.concatenate((chain[key], c[key]))
posterior = chain["Posterior"]
del chain["Posterior"]
if "weight" in chain.keys():
weights = chain["weight"]
del chain["weight"]
else:
weights = np.ones(posterior.shape)
if "old\\_weight" in chain.keys():
ow = chain["old\\_weight"]
# ow -= ow.min()
# ow = np.exp(ow)
del chain["old\\_weight"]
elif "old_weight" in chain.keys():
ow = chain["old_weight"]
del chain["old_weight"]
else:
ow = np.ones(posterior.shape)
print(chain.keys())
for param in is_array:
latex = name_map[param]
truth_val = truths[latex]
shape = truth_val.shape
if not replace:
del chain[param]
if len(shape) > 1 or latex not in chain: continue # Dont do 2D parameters
for i in range(shape[0]):
column = chain[latex][:, i]
chain[latex % i] = column
truths[latex % i] = truth_val[i]
del chain[latex]
c = ChainConsumer()
c.add_chain(chain, weights=weights)
summary = c.get_summary()
num_failed = sum([1 if summary[k][0] is None else 0 for k in summary.keys()])
num_param = len(list(summary.keys()))
if not cut or num_failed < 4:
print("Chain %s good" % k)
good_ks.append(k)
result.append((chain, posterior, truths, params, full_params, len(chains), weights, ow))
else:
print("Chain %s is bad" % k)
if merge:
rr = list(result[0])
for r in result[1:]:
for key in rr[0].keys():
rr[0][key] = np.concatenate((rr[0][key], r[0][key]))
rr[1] = np.concatenate((rr[1], r[1]))
rr[6] = np.concatenate((rr[6], r[6]))
rr[7] = np.concatenate((rr[7], r[7]))
rr[5] += r[5]
return tuple(rr)
else:
return result