Some graph work
This commit is contained in:
parent
571bc09516
commit
788f7ed64d
File diff suppressed because one or more lines are too long
26
notebooks/graphs.py
Normal file
26
notebooks/graphs.py
Normal file
@ -0,0 +1,26 @@
|
||||
import numpy as np
|
||||
import scipy
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
from notebooks.lib import linear
|
||||
|
||||
|
||||
def cr_n(df, ignore_prefix=0, data_color="tab:blue", fit_color="tab:red"):
|
||||
p, pcov = scipy.optimize.curve_fit(linear, np.log(df.cr[df.N > ignore_prefix]), np.log(df.N[df.N > ignore_prefix]))
|
||||
linear_extent = np.linspace(0, np.max(np.log(df.cr)))
|
||||
|
||||
plt.scatter(
|
||||
np.log(df.cr),
|
||||
np.log(df.N),
|
||||
s=1, marker='.', color=data_color
|
||||
)
|
||||
|
||||
plt.plot(
|
||||
linear_extent,
|
||||
linear(linear_extent, *p),
|
||||
color=fit_color
|
||||
)
|
||||
|
||||
plt.xlabel("$\\log r_{max}$")
|
||||
plt.ylabel("$\\log N$")
|
||||
return p, pcov
|
||||
@ -1,29 +1,14 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import scipy
|
||||
|
||||
from notebooks.graphs import cr_n
|
||||
from notebooks.lib import read_load
|
||||
|
||||
|
||||
def linear(x, a, b):
|
||||
return x * a + b
|
||||
|
||||
|
||||
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 = alpha[alpha.N > 50]
|
||||
|
||||
p, pcov = scipy.optimize.curve_fit(linear, np.log(without_prefix.cr), np.log(without_prefix.N))
|
||||
linear_extent = np.linspace(0, np.max(np.log(alpha.cr)))
|
||||
|
||||
plt.scatter(np.log(alpha.cr), np.log(alpha.N), s=1, marker='.', color="tab:blue")
|
||||
plt.plot(linear_extent, linear(linear_extent, *p), color="tab:red")
|
||||
|
||||
plt.xlabel("$\\log r_{max}$")
|
||||
plt.ylabel("$\\log N$")
|
||||
cr_n(
|
||||
alpha,
|
||||
ignore_prefix=50
|
||||
)
|
||||
|
||||
plt.savefig('../figures/rmax-n.svg')
|
||||
plt.savefig('../figures/rmax-n.png')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user