I am trying to use linspace in a for loop. I would like intervals of 0.5 between 0 and 10. It appears the z_bin is executing properly.
My question: How can I use linspace correctly in the for loop in place of the range function that is shown next to it in the comment line? What do I need to change in the loop as I move from working with integers to working with decimals?
z_bin = numpy.linspace (0.0,10.0,num=21)
print 'z_bin: ', z_bin
num = len(z_bin)
grb_binned_data = []
for i in numpy.linspace(len(z_bin)-1): #range(len(z_bin)-1):
zmin = z_bin[i]
zmax = z_bin[i+1]
grb_z_bin_data = []
for grb_row in grb_data:
grb_name = grb_row[0]
ra = grb_row[1]
dec = grb_row[2]
z = float(grb_row[3])
if z > zmin and z <= zmax:
grb_z_bin_data.append(grb_row)
grb_binned_data.append(grb_z_bin_data)