Created
July 18, 2018 00:10
-
-
Save astro313/de262d919b97782478b8e56b6a8fe6ac to your computer and use it in GitHub Desktop.
Cloud mass CDF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# --- Cloud mass distribution, of clouds ID across all snapshots ----- | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
allmasses = [] | |
for snap in ss.iterkeys(): | |
for snapleafs in ss[snap].iterkeys(): | |
allmasses.append(ss[snap][snapleafs].mass_Msun) | |
allmasses = np.array(allmasses) | |
# unbinned CDF | |
X2 = np.sort(allmasses) | |
F2 = np.array(range(len(allmasses)))/float(len(allmasses)) | |
ax.plot(X2, F2, label='unbinned CDF', lw=2, alpha=1, zorder=2) | |
# binned CDF | |
H, X1 = np.histogram(allmasses, bins=10, normed=True) | |
dx = X1[1] - X1[0] | |
F1 = np.cumsum(H) * dx | |
ax.plot(X1[1:], F1, label='binned CDF, bins=10', lw=2.0, alpha=0.9, zorder=3) | |
H, X1 = np.histogram(allmasses, bins=50, normed=True) | |
dx = X1[1] - X1[0] | |
F1 = np.cumsum(H) * dx | |
ax.plot(X1[1:], F1, label='binned CDF, bins=50', lw=2.0, alpha=0.9, zorder=3) | |
H, X1 = np.histogram(allmasses, bins=100, normed=True) | |
dx = X1[1] - X1[0] | |
F1 = np.cumsum(H) * dx | |
ax.plot(X1[1:], F1, label='binned CDF, bins=100', lw=2.0, alpha=0.9, zorder=3) | |
H, X1 = np.histogram(allmasses, bins=200, normed=True) | |
dx = X1[1] - X1[0] | |
F1 = np.cumsum(H) * dx | |
ax.plot(X1[1:], F1, label='binned CDF, bins=200', lw=2.0, alpha=0.9, zorder=3) | |
ax.set_xscale("log") | |
ax.set_yscale("log") | |
ax.set_xlabel(r"$M_{\rm cl}$ [M$_\odot$]") | |
ax.set_ylabel("CDF") | |
ax.set_xlim(allmasses.min(), allmasses.max()) | |
ax.legend(loc="best") | |
plt.tight_layout() | |
plt.show() | |
fig.savefig(leafdir_out + 'MassDistribution.png', bbox_inches="tight") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment