I have an array [x,y] where the values of x is ascending and the y values are random. I would like to sum all of the y values together when the x values are within a certain range. I can't show you any code as i dont even know where to start with this but this is the desired effect:-
If the range of y is 10. So from y=1 to y=10 and from y=11 to y=20 the x values will be summed within these two bands, I will get a list:-
11.0, 9.0, ...... etc.
So far I have been advised to sum all the y values, this gives:-
import numpy, scipy, matplotlib.pylab as plt mjd1, flux1, error1 = numpy.loadtxt("log_207_band1.dat", usecols=(1,2,3), unpack=True) x=mjd1 y=flux1 z=zip(x,y) print sum(i for i in z)
I'm really at a loss of what to do next.