title: Using Mann Kendall in python with a lot of data
body: <p>I have a set of 46 years worth of rainfall data. It's in the form of 46 numpy arrays each with a shape of <code>145, 192</code>, so each year is a different array of maximum rainfall data at each lat and lon coordinate in the given model. </p>
  
  <p>I need to create a global map of tau values by doing an M-K test (Mann-Kendall) for each coordinate over the 46 years. </p>
  
  <p>I'm still learning python, so I've been having trouble finding a way to go through all the data in a simple way that doesn't involve me making 27840 new arrays for each coordinate. </p>
  
  <p>So far I've looked into how to use <a href="https://docs.scipy.org/doc/scipy-0.19.1/reference/generated/scipy.stats.kendalltau.html" rel="nofollow noreferrer"><code>scipy.stats.kendalltau</code></a> and using the definition from here: <a href="https://github.com/mps9506/Mann-Kendall-Trend" rel="nofollow noreferrer">https://github.com/mps9506/Mann-Kendall-Trend</a></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>To clarify and add a little more detail, I need to perform a test on for each coordinate and not just each file individually. For example, for the first M-K test, I would want my x=46 and I would want y=data1[0,0],data2[0,0],data3[0,0]...data46[0,0]. Then to repeat this process for every single coordinate in each array. In total the M-K test would be done 27840 times and leave me with 27840 tau values that I can then plot on a global map. </p>
  
  <p><strong>EDIT 2:</strong></p>
  
  <p>I'm now running into a different problem. Going off of the suggested code, I have the following:
  <code>for i in range(145):
      for j in range(192):
          out[i,j] = mk_test(yrmax[:,i,j],alpha=0.05)
  print out</code></p>
  
  <p>I used <code>numpy.stack</code> to stack all 46 arrays into a single array (yrmax) with shape: <code>(46L, 145L, 192L)</code> I've tested it out and it calculates p and tau correctly if I change the code from out[i,j] to just out. However, doing this messes up the for loop so it only takes the results from the last coordinate in stead of all of them. And if I leave the code as it is above, I get the error: <code>TypeError: list indices must be integers, not tuple</code> </p>
  
  <p>My first guess was that it has to do with mk_test and how the information is supposed to be returned in the definition. So I've tried  altering the code from the link above to change how the data is returned, but I keep getting errors relating back to tuples. So now I'm not sure where it's going wrong and how to fix it. </p>
  
  <p><strong>EDIT 3:</strong></p>
  
  <p>One more clarification I thought I should add. I've already modified the definition in the link so it returns only the two number values I want for creating maps, p and z. </p>