#read in the dos object
dos = nlread('NiO_sgga.hdf5',DensityOfStates)[0]
#generate some energies
energies = numpy.linspace(-5,5,400)*eV
#calculate the spectrum
n0_up = dos.tetrahedronSpectrum(energies=energies,
                                spin=Spin.Up,
                                projection_list = ProjectionList([0]))

n0_down = dos.tetrahedronSpectrum(energies=energies,
                                  spin=Spin.Down,
                                  projection_list = ProjectionList([0]))
e = dos.energies()

#do the same for GGA+U
dos_u = nlread('NiO_sgga_u.hdf5',DensityOfStates)[0]
n0_up_u = dos_u.tetrahedronSpectrum(energies=energies,
                                    spin=Spin.Up,
                                    projection_list = ProjectionList([0]))

n0_down_u = dos_u.tetrahedronSpectrum(energies=energies,
                                      spin=Spin.Down,
                                    projection_list = ProjectionList([0]))

#plot the spectrum using pylab
import pylab
#first plot the up component with dots
pylab.plot(e.inUnitsOf(eV), n0_up.inUnitsOf(eV**-1), 'k:',label = 'SGGA')
#now plot the down component with negative values and dots
pylab.plot(e.inUnitsOf(eV), -1.*n0_down.inUnitsOf(eV**-1), 'k:')
#now plot the GGA+U up  components with solid
pylab.plot(e.inUnitsOf(eV), n0_up_u.inUnitsOf(eV**-1),'k',label = 'SGGA+U')
#now plot the  GGA+U down component with negative values and solid
pylab.plot(e.inUnitsOf(eV), -1.*n0_down_u.inUnitsOf(eV**-1),'k')
#show legends
pylab.legend()
pylab.xlabel("Energy (eV)")
pylab.ylabel("DOS (1/eV)")
pylab.show()
