1. Introduction
Assuming there is a 3-d array in the shape of (365,100,100): Prec.
- It represent the daily precipitation condition of an area for whole year.
- Apparently, the first dimension represent the time series.
- The last 2 dimensions represent the spatial distribution(for example, there are 10000 grids in size 1km x 1 km)
2. Attempt
Test each grid for whole area whether its precipitation above certain value Pd which separate dry and wet. I want to sum the dry day for the whole year.
3. My code
freq = np.zeros(100,100).reshape(100,100)
Pd = xxx
for i in range(0,prec.shape[0],1):
for j in range(0,prec.shape[1],1):
for k in range(0,prec.shape[2],1):
if prec[i,j,k] < Pd:
freq[j,k] +=1
I think too many loop must waste time. Are there some cleanest way to achieve similar work?
Any advices would be appreciate!