bradyrx / esmtools

:octopus: a toolbox for Earth System Model analysis :octopus:
https://esmtools.readthedocs.io/en/latest/
MIT License
27 stars 4 forks source link

stats.linear_slope slow #101

Closed aaronspring closed 3 years ago

aaronspring commented 3 years ago

stats.linear_slope is quite slow compared to

def slope(da, dim='time'):
    deg=1
    return da.polyfit(dim=dim, deg=deg).sel(degree=deg,drop=True)

I know you put lots of effort into the function and xarray had the development shortly later. I think we should get rid of our implementation.

bradyrx commented 3 years ago

Yeah it just so happened that it came out around the time I worked on all this. I think we can switch over to that or just remove it if there's a direct way through xarray. I'm in favor of keeping things like linregress that offer additional functionality -- i.e., the ability to get slope, intercept, p, corr, etc.

aaronspring commented 3 years ago

See https://github.com/pangeo-data/climpred/blob/68629d831d6f61848eb5d10f10399edbd72876f1/climpred/stats.py#L14 for faster