On Apr 9, 1:33 am, Neil Crighton <neilcrigh...@gmail.com> wrote: > heidi taynton <heidihannah <at> mac.com> writes: > > > > > Hi, > > > I'm fairly new to programming and am having a probably cutting my arrays. I > > have two different 1d arrays, one> of time, and the second energy. I want > to cut both arrays of time > > min<=time<=max . I've created a 2d array> with [time,energy] and I believe > numpy.where is what I am looking for, but > > haven't been able to get the > > > conditions in right for it to work. > > I'm not sure exactly what you're trying to do, but maybe you want a boolean > array to select the right elements? So if time and energy are 1-d numpy arrays > of the same length: > > >>> condition = (min_time <= time) & (time <= max_time) > >>> new_time = time[condition] > >>> new_energy = energy[condition]
Won't work: condition is an array of ones and zeros, but you need to index the arrays with indices. So, add a call to nonzero to get the indices of the elements. elements = nonzero(logical_and(min_time<=time,max_time>=time)) new_time = time[elements] new_energy = energy[elements] Carl Banks -- http://mail.python.org/mailman/listinfo/python-list