Skip to content

Instantly share code, notes, and snippets.

View alexsalr's full-sized avatar

Alejandro Salazar-Romero alexsalr

  • Mexico
View GitHub Profile
@alexsalr
alexsalr / xr_apply_ufunc_parallel.py
Created July 5, 2018 14:31
Example of parellelization of xr.apply_ufunc as an alternative to groupby('y','x').apply(func)
def interpolate_(dataarray, intdates):
"""
Interpolate time series in a data array for the specified dates. Tries to
parallelize using dask.
Args:
dataarray (xarray.DataArray): data array (time,y,x) with time series
intdates (np.ndarray(np.datetime64)): array of dates to interpolate