Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rmatsum836/58a619d2851732798f2840ee4b64084f to your computer and use it in GitHub Desktop.
Save rmatsum836/58a619d2851732798f2840ee4b64084f to your computer and use it in GitHub Desktop.
project = signac.get_project()
for job in project.find_jobs():
fig, ax = plt.subplots()
if os.path.isfile(os.path.join(job.workspace(), 'all-reducs.pkl')):
with open(os.path.join(job.workspace(), 'all-reducs.pkl'), 'rb') as f:
reduc = pickle.load(f)
c = deepcopy(reduc)
cluster_sizes = []
for proc in c:
for matrix in proc:
cluster_count = []
for i in range(len(matrix[0])):
cluster_count.append(np.sum(matrix[:,i]))
cluster_sizes.append(cluster_count)
flat_list = [item for sublist in cluster_sizes for item in sublist]
bins = np.array(range(np.max(flat_list)))
wtpct = job.statepoint()['wtpct']
x = np.histogram(flat_list, bins=bins)
ax.set_xlabel(r'Cluster size, $N_{ions}$', fontsize=15)
ax.set_ylabel(r'Number of clusters of size $N_{ions}$', fontsize=15)
ax.set_title('{}: {} IL mass fraction'.format(sys.argv[1], sys.argv[2]), fontsize=15)
ax.hlines(0, min(x[1][:-1]), max(x[1][:-1]))
ax.bar(x[1][:-1], x[0]/len(cluster_sizes)*x[1][:-1])
ax.set_xlim((1,max(x[1][:-1])))
ax.set_ylim((0,job.statepoint()['n_IL']/4))
len_ticks = 6
ticklabels = ['' for i in range(len_ticks-1)]
ticklabels.append(job.sp['n_IL']*2)
ticklabels[0] = '1'
ax.set_xticklabels(ticklabels, fontsize=18)
ax.set_xticks(np.linspace(0,max(x[1][:-1]),num=6))
plt.tight_layout()
print('saving')
np.savetxt('test-cluster-plots/{}-{}.txt'.format(sys.argv[1],sys.argv[2]),
np.transpose(np.vstack([x[1][:-1], x[0]/len(cluster_sizes)*x[1][:-1]])))
plt.savefig('test-cluster-plots/{}-{}.pdf'.format(sys.argv[1], sys.argv[2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment