[最佳答案] This blog post mentioned in the comments above contains an incredibly fast vectorized function for cross-correlation, covariance, and regression for multi-dimensional data in Python. It produces all of the regression outputs I need, and does so in milliseconds as it relies entirely on simple vectorised array operations in xarray. https://hrishichandanpurkar.blogspot.com/2017/09/vectorized-functions-for-correlation.html I have made one minor change (first line after #3) to ensure the function co