Increase a numpy array's elements by 1 at particular indices (for use with grouping an astropy table)
That wasn't perhaps the best description in the title, but I can hopefully describe my problem below. There's really two parts to it.
The ultimate thing I'm trying to do is group certain times together within an astropy table - as the values are not the same for each time that will go into a particular group, I don't believe I can just give the column name in the group_by() method.
So, what I'm trying to do is produce an array describing which group each time with be associated with so that I can pass that to group_by(). I can get the bin edges by performing, for example (the 10 is arbitrary),
>>> np.where(np.diff(table['Times']) > 10) array([ 2, 8, 9, 12])
Let's say the table has length 15. What I want to know is how it might be possible to use that array above to create the following array without having to use loops
array([0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, 4])
such that when I place that array in the group_by() method it groups the table according to those bin edges.
Alternatively, if there is a better way of grouping an astropy table according to time ranges.