mirror of
https://github.com/vale981/master-thesis
synced 2025-03-05 10:01:43 -05:00
plot complex can now show absolute values and add consistency plot
This commit is contained in:
parent
8c2f1ac377
commit
64b803d52f
1 changed files with 74 additions and 5 deletions
|
@ -110,10 +110,22 @@ def get_figsize(width="thesis", fraction=1, subplots=(1, 1)):
|
|||
|
||||
|
||||
@wrap_plot
|
||||
def plot_complex(x, y, *args, ax=None, label="", **kwargs):
|
||||
def plot_complex(x, y, *args, ax=None, label="", absolute=False, **kwargs):
|
||||
label = label + ", " if (len(label) > 0) else ""
|
||||
ax.plot(x, y.real, *args, label=f"{label}real part", **kwargs)
|
||||
ax.plot(x, y.imag, *args, label=f"{label}imag part", **kwargs)
|
||||
ax.plot(
|
||||
x,
|
||||
abs(y.real) if absolute else y.real,
|
||||
*args,
|
||||
label=f"{label}absolute real part",
|
||||
**kwargs,
|
||||
)
|
||||
ax.plot(
|
||||
x,
|
||||
abs(y.imag) if absolute else y.imag,
|
||||
*args,
|
||||
label=f"{label}absolute imag part",
|
||||
**kwargs,
|
||||
)
|
||||
ax.legend()
|
||||
|
||||
|
||||
|
@ -144,7 +156,7 @@ def plot_convergence(
|
|||
line = ax.plot(
|
||||
x,
|
||||
current_value.value,
|
||||
label=f"{label}$N={current_value.N}$ $({consistency:.0f}\%)$",
|
||||
label=f"{label}$N={current_value.N}$ $({consistency:.1f}\%)$",
|
||||
alpha=current_value.N / y.N,
|
||||
linestyle=linestyle if i == (len(y) - 1) else ":",
|
||||
)
|
||||
|
@ -411,6 +423,63 @@ def plot_interaction_consistency_development(
|
|||
return fig, [ax, ax2, ax3]
|
||||
|
||||
|
||||
def plot_consistency_development(value, reference):
|
||||
fig, (ax, ax2) = plt.subplots(nrows=2, sharex=True)
|
||||
|
||||
ax.set_xscale("log")
|
||||
ax2.set_xscale("log")
|
||||
ax2.set_yscale("log")
|
||||
|
||||
diff = abs(value - reference)
|
||||
|
||||
ns, values, σs, max_diff = [], [], [], []
|
||||
|
||||
for N, val, σ in diff.aggregate_iterator:
|
||||
ns.append(N)
|
||||
values.append(((val < σ).sum() / len(val[0])) * 100)
|
||||
σs.append(σ.mean())
|
||||
max_diff.append(val.mean())
|
||||
|
||||
values = np.array(values)
|
||||
ns = np.array(ns)
|
||||
where_consistent = values >= 68
|
||||
|
||||
values_consistent = values.copy()
|
||||
values_consistent[~where_consistent] = np.nan
|
||||
|
||||
values_inconsistent = values.copy()
|
||||
values_inconsistent[where_consistent] = np.nan
|
||||
|
||||
ax.plot(
|
||||
ns,
|
||||
values_consistent,
|
||||
linestyle="none",
|
||||
marker=".",
|
||||
markersize=5,
|
||||
)
|
||||
|
||||
ax.plot(
|
||||
ns,
|
||||
values_inconsistent,
|
||||
linestyle="none",
|
||||
marker=".",
|
||||
markersize=5,
|
||||
)
|
||||
|
||||
ax2.plot(ns, np.array(σs) / abs(reference).max(), label=r"$\langle σ\rangle$")
|
||||
ax2.plot(ns, np.array(max_diff) / abs(reference).max(), label=r"$\langle Δ\rangle$")
|
||||
|
||||
ax.axhline(68, linestyle="-.", color="grey", alpha=0.5)
|
||||
ax.set_xlabel("$N$")
|
||||
ax2.set_xlabel("$N$")
|
||||
ax.set_ylabel(r"Consistency [$\%$]")
|
||||
ax2.set_ylabel(r"$\mathrm{Deviation}/{J_\mathrm{max}}$")
|
||||
|
||||
ax2.legend()
|
||||
|
||||
return fig, [ax, ax2]
|
||||
|
||||
|
||||
def plot_flow_bcf(models, label_fn=lambda model: f"$ω_c={model.ω_c:.2f}$", **kwargs):
|
||||
fig, ax = plt.subplots()
|
||||
for model in models:
|
||||
|
@ -528,5 +597,5 @@ def plot_σ_development(ensemble_value, ax=None, **kwargs):
|
|||
**kwargs,
|
||||
)
|
||||
|
||||
ax.set_ylabel("$σ$")
|
||||
ax.set_ylabel("mean $σ$")
|
||||
ax.set_xlabel("$N$")
|
||||
|
|
Loading…
Add table
Reference in a new issue