I have a 3D matrix Temp[time,x,y] representing temperatures over a region at different times.
I want to count the number of times the temperature is in a given range [t0, t1, t2, ..., tn]
. That is, I want to compute the histogram of Temp[time,x,y] as a matrix HISTO such that:
Histo[0,x,y] = the number of times Temp[:,x,y] is in a range t0-t1
Histo[1,x,y] = the number of times Temp[:,x,y] is in a range t1-t2
What I have tried:
- looping through each (x,y) and use
np.histogram
on Temp[:,x,y] - looping through each range and compute
np.count_nonzero((Temp>tn) & (Temp<tm), axis=0)
Is there any other way of doing this? can I use hitogram over a given axe? ranges could be equally spaced if necesary.