xarray.apply ufunc
Official documents
Wrapping custom computation
Automatic parallelization
Applying unvectorized functions with apply_ufunc — xarray documentation
xarray.apply_ufunc
input_core_dims
Core dimensions are automatically moved to the last axes of input variables before applying func
Tips
Rapidly Prototyping High-Performance Meteorological Data Systems Using Xarray and Numba: 99th American Meteorological Society Annual Meeting
https://ams.confex.com/ams/2019Annual/meetingapp.cgi/Paper/348989
Pangeo use case - when dask.array and xarray.apply_ufunc are not the answer
https://github.com/pangeo-data/pangeo/issues/143
Xarray with Dask Arrays — Custom workflows and automatic parallelization
https://examples.dask.org/xarray.html#Custom-workflows-and-automatic-parallelization
python xarray - dask performance apply along axis - Stack Overflow
https://stackoverflow.com/questions/47314800/dask-performance-apply-along-axis?rq=1
python - What's the difference between dask=parallelized and dask=allowed in xarray's apply_ufunc? - Stack Overflow
https://stackoverflow.com/questions/51736172/whats-the-difference-between-dask-parallelized-and-dask-allowed-in-xarrays-app?rq=1
Chunking and performance
http://xarray.pydata.org/en/stable/dask.html?highlight=apply_ufunc#chunking-and-performance
A good rule of thumb is to create arrays with a minimum chunksize of at least one million elements (e.g., a 1000x1000 matrix).
apply_ufunc(dask='parallelized'): mix of chunked and non-chunked *args results in shape mismatch · Issue '#2817 · pydata/xarray · GitHub
https://github.com/pydata/xarray/issues/2817
Examples
linregress in xarrayutils https://github.com/jbusecke/xarrayutils/
https://github.com/jbusecke/xarrayutils/blob/7b09a2bdc70f035e290e75419c2d025b7267adf4/xarrayutils/utils.py#L52
linear regression
海洋の等温線の深さを求める(python, xarray) - Qiita
code:python
sigma0 = xr.apply_ufunc(gsw.sigma0, ds.salt, ds.thetaoga,
dask='parallelized', output_dtypes=ds.salt.dtype)
How to use apply_ufunc with numpy.digitize for each image along time dimension of xarray.DataArray? - Stack Overflow
See also
dask array operations
xr-scipy