Refactor code
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
from lib.lib import read_load
|
||||
|
||||
alpha = read_load("../data/alpha")
|
||||
meaned_by_N = alpha.groupby('N').agg({'fd': ['mean', 'std']}) \
|
||||
.reset_index() \
|
||||
.replace([np.inf, -np.inf], np.nan)
|
||||
|
||||
without_prefix = meaned_by_N[50:]
|
||||
fig, ax = plt.subplots(figsize=(6, 6))
|
||||
|
||||
plt.fill_between(
|
||||
without_prefix.N,
|
||||
# TODO Check error math here
|
||||
(without_prefix['fd']['mean'] - without_prefix['fd']['std'] / np.sqrt(20)),
|
||||
(without_prefix['fd']['mean'] + without_prefix['fd']['std'] / np.sqrt(20)),
|
||||
alpha=0.2, label=f"Standard error band"
|
||||
)
|
||||
|
||||
plt.plot(
|
||||
without_prefix.N,
|
||||
without_prefix['fd']['mean'],
|
||||
color='tab:blue', label='fd mean, seeds = 20'
|
||||
)
|
||||
|
||||
plt.plot([50, 10000], [1.71, 1.71], color='red', label='Theory')
|
||||
plt.fill_between(without_prefix.N, 1.71 - 0.01, 1.71 + 0.01, alpha=0.2, label='Theory error band')
|
||||
|
||||
plt.xlabel("$N_C$")
|
||||
plt.ylabel("$fd$ (instantaneous)")
|
||||
plt.legend()
|
||||
|
||||
plt.savefig('../figures/nc-fd-convergence.svg')
|
||||
plt.savefig('../figures/nc-fd-convergence.png')
|
||||
plt.show()
|
||||
@@ -0,0 +1,15 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from lib.graphs import cr_n
|
||||
from lib.lib import read_load
|
||||
|
||||
alpha = read_load("../data/alpha")
|
||||
|
||||
cr_n(
|
||||
alpha,
|
||||
ignore_prefix=50
|
||||
)
|
||||
|
||||
plt.savefig('../figures/rmax-n.svg')
|
||||
plt.savefig('../figures/rmax-n.png')
|
||||
plt.show()
|
||||
@@ -0,0 +1,18 @@
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from lib.lib import read_sp, read_xyz_alt, aggregate_sp_fd
|
||||
|
||||
data_3d_sp = read_sp("../data/rust-3d-offaxis-sp", read_xyz_alt)
|
||||
sp_fd_data = aggregate_sp_fd(data_3d_sp)
|
||||
|
||||
# %%
|
||||
plt.fill_between(sp_fd_data.index, sp_fd_data.fd - sp_fd_data.fd_std, sp_fd_data.fd + sp_fd_data.fd_std, alpha=0.2, label=f"Standard error band")
|
||||
plt.plot(sp_fd_data.index, sp_fd_data.fd, color='tab:blue', label='fd mean, seeds = 100')
|
||||
|
||||
plt.xlabel("$p_{stick}$")
|
||||
plt.ylabel("$fd$")
|
||||
plt.legend()
|
||||
|
||||
plt.savefig('../figures/sp-fd-3d.svg')
|
||||
plt.savefig('../figures/sp-fd-3d.png')
|
||||
plt.show()
|
||||
@@ -0,0 +1,52 @@
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from lib.lib import read_sp, aggregate_sp_fd
|
||||
|
||||
c_sp = read_sp("../data/stick-probability")
|
||||
rust_sp = read_sp("../data/rust-sticking-probability")
|
||||
|
||||
# %%
|
||||
c_data = aggregate_sp_fd(c_sp)
|
||||
rust_data = aggregate_sp_fd(rust_sp)
|
||||
|
||||
# %%
|
||||
|
||||
# plt.fill_between(
|
||||
# c_data.index,
|
||||
# c_data.fd - c_data.fd_std,
|
||||
# c_data.fd + c_data.fd_std,
|
||||
# alpha=0.2,
|
||||
# color='tab:blue',
|
||||
# label=f"IPC + PS, Standard error band"
|
||||
# )
|
||||
|
||||
plt.plot(
|
||||
c_data.index,
|
||||
c_data.fd,
|
||||
color='tab:blue',
|
||||
label='IPC + PS, fd mean, seeds = 100'
|
||||
)
|
||||
|
||||
# plt.fill_between(
|
||||
# rust_data.index,
|
||||
# rust_data.fd - rust_data.fd_std,
|
||||
# rust_data.fd + rust_data.fd_std,
|
||||
# alpha=0.2,
|
||||
# color='tab:orange',
|
||||
# label=f"NF, Standard error band"
|
||||
# )
|
||||
|
||||
plt.plot(
|
||||
rust_data.index,
|
||||
rust_data.fd,
|
||||
color='tab:orange',
|
||||
label='NF, fd mean, seeds = 100'
|
||||
)
|
||||
|
||||
plt.xlabel("$p_{stick}$")
|
||||
plt.ylabel("$fd$")
|
||||
plt.legend()
|
||||
|
||||
plt.savefig('../figures/sp-fd-rust-vs-c.svg')
|
||||
plt.savefig('../figures/sp-fd-rust-vs-c.png')
|
||||
plt.show()
|
||||
@@ -0,0 +1,18 @@
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from lib.lib import read_sp, aggregate_sp_fd
|
||||
|
||||
data_2d_sp = read_sp("../data/stick-probability")
|
||||
sp_fd_data = aggregate_sp_fd(data_2d_sp)
|
||||
|
||||
# %%
|
||||
plt.fill_between(sp_fd_data.index, sp_fd_data.fd - sp_fd_data.fd_std, sp_fd_data.fd + sp_fd_data.fd_std, alpha=0.2, label=f"Standard error band")
|
||||
plt.plot(sp_fd_data.index, sp_fd_data.fd, color='tab:blue', label='fd mean, seeds = 100')
|
||||
|
||||
plt.xlabel("$p_{stick}$")
|
||||
plt.ylabel("$fd$")
|
||||
plt.legend()
|
||||
|
||||
plt.savefig('../figures/sp-fd.svg')
|
||||
plt.savefig('../figures/sp-fd.png')
|
||||
plt.show()
|
||||
Reference in New Issue
Block a user