This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xarray as xr | |
def detrend_dim(da, dim, deg=1): | |
# detrend along a single dimension | |
p = da.polyfit(dim=dim, deg=deg) | |
fit = xr.polyval(dim, p.polyfit_coefficients) | |
return da - fit | |
def detrend(da, dims, deg=1): | |
# detrend along multiple dimensions |