Commit 2e7004ee authored by Daniel Wysocki's avatar Daniel Wysocki

Updating auto-correlation plots

parent 97a650ae
Pipeline #153361 failed with stage
in 1 minute and 10 seconds
......@@ -124,14 +124,14 @@ def main(raw_args=None):
)
)
# delta_n_acorr = numpy.tile(n_acorr, (f.n_walkers, f.n_dim))
print(
"Auto-correlation time is {dn} for the worst parameter."
.format(dn=n_acorr)
)
print(
"Auto-correlation time for all parameters are",
", ".join([str(x) for x in acorr_times[n_acorr]]),
)
# print(
# "Auto-correlation time is {dn} for the worst parameter."
# .format(dn=n_acorr)
# )
# print(
# "Auto-correlation time for all parameters are",
# ", ".join([str(x) for x in acorr_times[n_acorr]]),
# )
# Take the most auto-correlated walker and parameter throughout.
n_thinning = numpy.max(n_acorr)
print("Thinning is", n_thinning)
......@@ -140,6 +140,8 @@ def main(raw_args=None):
integrated_acorr.plot_integrated_auto_correlation(
cli_args.acorr_plot,
acorr_times, None,
param_names=f.variable_names,
safety_factor=cli_args.acorr_safety_factor,
)
elif cli_args.fixed_thinning is not None:
n_thinning = cli_args.fixed_thinning
......
......@@ -222,7 +222,11 @@ def plot_auto_correlation(
fig.savefig(filename)
def plot_integrated_auto_correlation(filename, acorr_times, acorr_time_errs):
def plot_integrated_auto_correlation(
filename,
acorr_times, acorr_time_errs,
param_names=None, safety_factor=None,
):
import itertools
import numpy
......@@ -233,14 +237,31 @@ def plot_integrated_auto_correlation(filename, acorr_times, acorr_time_errs):
K_final = K_final_plus_one - 1
Ks = numpy.arange(K_final_plus_one)
fig, ax = plt.subplots(figsize=(8,4))
fig, ax = plt.subplots(figsize=(8,4), constrained_layout=True)
# Plot K = m*tau_K line
if safety_factor is not None:
ax.plot(
Ks, Ks/safety_factor,
color="black", linestyle="dashed",
label="$K = m \\, \\tau_K$",
)
# Plot autocorrelation curves.
for d, color in zip(range(n_dim), itertools.cycle(color_cycle)):
# Determine label.
if param_names is None:
label = "Param #{i}".format(i=d+1)
else:
label = param_names[d]
# Plot autocorrelation curve.
ac = acorr_times[...,d]
ax.plot(
Ks, ac,
color=color,
label="Param #{i}".format(i=d+1),
label=label,
)
if acorr_time_errs is not None:
......@@ -265,5 +286,4 @@ def plot_integrated_auto_correlation(filename, acorr_times, acorr_time_errs):
ax.legend(loc="best")
fig.tight_layout()
fig.savefig(filename)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment