This is my first posted question, so please forgive me if I've entered my attempt incorrectly.
My goal: I am trying to count the number of rows that satisfies a conditional range. The individual array elements represent the time (in seconds) at which a peak occurred. Each row in the input data represent an active/firing cell. I want to calculate the number of active cells (rows) per minute (iterations of 60 seconds).
My data: My input data (T) was imported from txt as an array of integers and had several 0s that I do not want counted in other operations. I have copied a subset of this data below.
My issue: My specific issue is that I don't see anything wrong with my attempt (below), but since the array is fairly small, I'm able to manually check the truthyness of the output. For whatever reason, the True arguments begin on the 'correct' iteration, but then remain True (when they should return false) until another True occurs in the loop. Then the output remains 'correctly' false. This is driving me crazy and I would greatly appreciate any help. The following attempt does not even attempt to sum the rows, but only to return the correct arrangement of True/False arguments.
import numpy as np
T = T.astype(float)
T[T==0] = np.nan
for x in xrange(0, 1321, 60):
RowSum = np.any(T>x, axis = 1) & np.any(T<x+60, axis = 1)
print RowSum
Input data:
array([[ 111., 184., 221., 344., 366., 0., 0., 0.,
0., 0., 0.],
[ 408., 518., 972., 1165., 1186., 0., 0., 0.,
0., 0., 0.],
[ 208., 432., 1290., 1321., 0., 0., 0., 0.,
0., 0., 0.],
[ 553., 684., 713., 888., 1012., 1108., 1134., 0.,
0., 0., 0.],
[ 285., 552., 1159., 1183., 0., 0., 0., 0.,
0., 0., 0.],
[ 304., 812., 852., 0., 0., 0., 0., 0.,
0., 0., 0.]])