import numpy as np
import matplotlib.pyplot as plt

f=open("haloes_noPopIII_lw_z.txt",'r')
lw = []
z = []
mass = []
for line in f:
  mass.append(float(line.split()[1]))
  lw.append(float(line.split()[6]))
  z.append(float(line.split()[7]))

mass=np.array(mass)
lw=np.array(lw)
z=np.array(z)

lw1 = lw[mass>5e6]
z1 = z[mass>5e6]

n, bins, patches = plt.hist(np.log10(lw1/1e-21), 50,range=(-2.5,0), normed=1, cumulative = True )
plt.xlabel(r"$\mathrm{log(J_{21})}$")
plt.ylabel("f")
plt.title(r'$\mathrm{Histogram\ of\ Halos\ LW:}$')
plt.savefig("lw1")
plt.clf()

n, bins, patches = plt.hist(np.log10(z), 50, range=(-20,0), normed=1, cumulative = True )
plt.xlabel("[Z/H]")
plt.ylabel("f")
plt.title(r'$\mathrm{Histogram\ of\ Halos\ Metallicity:}$')
plt.savefig("z1")
