cb = [numpy.take(e,numpy.where(e<=0))[0][-1] for e in energies]
(You may want to change the variable name :) )
It's a lot simpler of course. You don't need the k-point mapping and griddata conversion, just do (from line 14)
kx = bs.kpoints()[:,0]
ky = bs.kpoints()[:,1]
Then skip to
P.contour(kx,ky,cb,20,colors=['w'])
P.contourf(kx,ky,cb,60,cmap=P.cm.hot)
And, in the other script (to generate the band structure) you can probably reduce the range of k-points to
x = numpy.linspace(-1.0,1.0,Nk)
Of course, we are now assuming the kz doesn't matter, i.e. you are working with a 2D material.