How do I calculate linear trend for a multi-dimensional array in Python
I would look into numpy.polyfit but I'm not sure what performance gain it has over scipy.stats.linregress.
It's pretty fast from my experience. You might have to do some math on your own to get r and p values from residuals and covariance matrix.
I've got a 3d array of shape (time,latitude,longitude). I'd like to calculate the linear trend at each lon/lat point. 
I know I can simply loop over all points and use spicy.stats.linregress at each point. However, that gets quite slow for large arrays. 
The scipy function "detrend" can calculate and remove linear trends for n-dimensional arrays, and is really fast. But I can't find any method to just calculate the trends. 
Does anyone know of a fast way to calculate slope, intercept, r value and p value for each point on a large grid?
Any help/suggestion is greatly appreciated!
Cheers
Joakim