If you want to remove the null values, you could use
z = [(u, v) for (u, v) in zip(a,n) if v != 0.0]
# or
z = [(u, v) for (u, v) in zip(a,n) if abs(v) < 1.0e-9]
however, I don't think you can plot your graph with matplotlib.pyplot.hist() then. You could use examples from the matplotlib's gallery instead, like this one http://matplotlib.sourceforge.net/examples/pylab_examples/custom_ticker1.html
I have tried both of the bits of code you suggested but i dont seem to be havign any luck with it. I've done a bit more on my code and now I have:-
import numpy as np, scipy, matplotlib.pylab as plt, itertools
mjd1, flux1, error1 = np.loadtxt("log_207_band1.dat", usecols=(1,2,3), unpack=True)
a = mjd1
b = flux1
c = error1
d = (1/c)**2
e = b/(c**2)
mim = min (a)
mam = max (a)
arm = [a]
are = [d]
bim = []
# Binned Mjd.
while mim <= mam:
bim.append(mim),
mim += 10
#Binned Error.
w = np.array(arm)
x = np.array(are)
m, bins = np.histogram(w, bins=np.array(bim), weights=x,)
bie = m**(-0.5)
#Binned Flux.
#Top.
arft = [e]
y = np.array(arft)
nt, bins = np.histogram(w, bins=np.array(bim), weights=y,)
#Bottem.
arfb = [d]
z = np.array(arfb)
nb, bins = np.histogram(w, bins=np.array(bim), weights=z,)
bif = (nt/nb)
f = zip(bim,bif,bie)
print f
As you can see I have now included the error in my data. A snippet of the data printed for Z is:-
[(52629.634891900001, 5.8216447829999991, 2.345571756),
(52639.634891900001, nan, inf),
(52649.634891900001, nan, inf),
(52659.634891900001, nan, inf),
(52669.634891900001, nan, inf),
(52679.634891900001, nan, inf),
(52689.634891900001, nan, inf),
(52699.634891900001, nan, inf),
(52709.634891900001, nan, inf),
(52719.634891900001, 5.1222770987666246, 0.55903046280511504),
(52729.634891900001, nan, inf),
(52739.634891900001, 4.2638768171735446, 0.42006474243340763),
(52749.634891900001, nan, inf),
(52759.634891900001, 3.4933218917231756, 0.098269515245267794),
(52769.634891900001, 1.6646994479708315, 0.52235125349315226),
(52779.634891900001, 2.0437369327933292, 0.47024580342005712),
(52789.634891900001, 2.1838623317766106, 0.92503409390429436),
(52799.634891900001, 3.5205974719355666, 0.19194470381687062),
(52809.634891900001, nan, inf),
(52819.634891900001, 7.553690679610451, 1.464913512979636),
(52829.634891900001, 2.1452428411935212, 0.48029633284501766),
(52839.634891900001, nan, inf),
(52849.634891900001, nan, inf),
(52859.634891900001, nan, inf)
As you can see the values with nan and inf are the ones I need to remove. Is there a way of removing them within the histogram function? This would also rectify the issue I'm having with the
bif = (nt/nb)
part of the code. The error message is:-
bif = (nt/nb)
RuntimeWarning: invalid value encountered in divide
Which I guess is due to the situation where it divides zero by zero.
Many thanks again Gribs you have been a massive help.