Recipes/InitialMassFunctionSeries

Code to plot IMFs at each time step and a graph of the evolution of the particles witrh time

from yt.mods import *
import pylab
import sys

i_mass = na.zeros((5001,56), dtype='float64')
for i in range(55,44,-5): # make matricies of index and mass by time and particle number
    pf = EnzoStaticOutput("%s/data%04i" % (sys.argv[-1], i))
    sp = pf.h.sphere([0.5,0.5,0.5], 1.0)
    if sp["ParticleMassMsun"].size == 0: continue
    for k in range(sp["ParticleMassMsun"].size):
        j = sp["particle_index"][k] -1
        i_mass[j,i]=sp["ParticleMassMsun"][k]
    pylab.hist(sp["ParticleMassMsun"],100, range=(-22,-18), histtype='step', label=("%01i dynamical times"  % (n/20)))

pylab.legend()   
pylab.xlabel('Mass (M$_{sun}$)')
pylab.ylabel('Number')
pylab.savefig("IMF_all.png")
pylab.clf()