When I do running / rolling mean with weights in numpy, I e.g. do something like this:
data = np.random.random(100) # Example data...
weights = np.array([1, 2, 1])
data_m = np.convolve(data, weights/float(np.sum(weights)), "same")
And then replace data_m[0] and data_m[-1] with e.g. nans, depending on application.
Something alike can be done with xarray. What I do (in this case) is
xr.DataArray(data).rolling(dim_0=3, center=True).mean(dim="dim_0")
But this corresponds to the weights
weights = np.array([1, 1, 1])
in the numpy example. How would I apply other weights, when using xarray?