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 | |
import numpy as np | |
# create an example dataset | |
da = xr.DataArray(np.random.rand(10,30,40), dims=['time', 'lat', 'lon']) | |
# define a function to compute a linear trend of a timeseries | |
def linear_trend(x): | |
pf = np.polyfit(x.time, x, 1) | |
# we need to return a dataarray or else xarray's groupby won't be happy |