Apply a vectorized function for unlabeled arrays on xarray objects. The function will be mapped over the data variable(s) of the input arguments using xarray's standard rules for labeled computation, including alignment, broadcasting, looping over GroupBy/Dataset variables, and merg
(
func: Callable,
*args: Any,
input_core_dims: Sequence[Sequence] | None = None,
output_core_dims: Sequence[Sequence] | None = ((),),
exclude_dims: AbstractSet = frozenset(),
vectorize: bool = False,
join: JoinOptions = "exact",
dataset_join: str = "exact",
dataset_fill_value: object = _NO_FILL_VALUE,
keep_attrs: bool | str | None = None,
kwargs: Mapping | None = None,
dask: Literal["forbidden", "allowed", "parallelized"] = "forbidden",
output_dtypes: Sequence | None = None,
output_sizes: Mapping[Any, int] | None = None,
meta: Any = None,
dask_gufunc_kwargs: dict[str, Any] | None = None,
on_missing_core_dim: MissingCoreDimOptions = "raise",
)
| 894 | |
| 895 | |
| 896 | def apply_ufunc( |
| 897 | func: Callable, |
| 898 | *args: Any, |
| 899 | input_core_dims: Sequence[Sequence] | None = None, |
| 900 | output_core_dims: Sequence[Sequence] | None = ((),), |
| 901 | exclude_dims: AbstractSet = frozenset(), |
| 902 | vectorize: bool = False, |
| 903 | join: JoinOptions = "exact", |
| 904 | dataset_join: str = "exact", |
| 905 | dataset_fill_value: object = _NO_FILL_VALUE, |
| 906 | keep_attrs: bool | str | None = None, |
| 907 | kwargs: Mapping | None = None, |
| 908 | dask: Literal["forbidden", "allowed", "parallelized"] = "forbidden", |
| 909 | output_dtypes: Sequence | None = None, |
| 910 | output_sizes: Mapping[Any, int] | None = None, |
| 911 | meta: Any = None, |
| 912 | dask_gufunc_kwargs: dict[str, Any] | None = None, |
| 913 | on_missing_core_dim: MissingCoreDimOptions = "raise", |
| 914 | ) -> Any: |
| 915 | """Apply a vectorized function for unlabeled arrays on xarray objects. |
| 916 | |
| 917 | The function will be mapped over the data variable(s) of the input |
| 918 | arguments using xarray's standard rules for labeled computation, including |
| 919 | alignment, broadcasting, looping over GroupBy/Dataset variables, and |
| 920 | merging of coordinates. |
| 921 | |
| 922 | Parameters |
| 923 | ---------- |
| 924 | func : callable |
| 925 | Function to call like ``func(*args, **kwargs)`` on unlabeled arrays |
| 926 | (``.data``) that returns an array or tuple of arrays. If multiple |
| 927 | arguments with non-matching dimensions are supplied, this function is |
| 928 | expected to vectorize (broadcast) over axes of positional arguments in |
| 929 | the style of NumPy universal functions [1]_ (if this is not the case, |
| 930 | set ``vectorize=True``). If this function returns multiple outputs, you |
| 931 | must set ``output_core_dims`` as well. |
| 932 | *args : Dataset, DataArray, DataArrayGroupBy, DatasetGroupBy, Variable, \ |
| 933 | numpy.ndarray, dask.array.Array or scalar |
| 934 | Mix of labeled and/or unlabeled arrays to which to apply the function. |
| 935 | input_core_dims : sequence of sequence, optional |
| 936 | List of the same length as ``args`` giving the list of core dimensions |
| 937 | on each input argument that should not be broadcast. By default, we |
| 938 | assume there are no core dimensions on any input arguments. |
| 939 | |
| 940 | For example, ``input_core_dims=[[], ['time']]`` indicates that all |
| 941 | dimensions on the first argument and all dimensions other than 'time' |
| 942 | on the second argument should be broadcast. |
| 943 | |
| 944 | Core dimensions are automatically moved to the last axes of input |
| 945 | variables before applying ``func``, which facilitates using NumPy style |
| 946 | generalized ufuncs [2]_. |
| 947 | output_core_dims : list of tuple, optional |
| 948 | List of the same length as the number of output arguments from |
| 949 | ``func``, giving the list of core dimensions on each output that were |
| 950 | not broadcast on the inputs. By default, we assume that ``func`` |
| 951 | outputs exactly one array, with axes corresponding to each broadcast |
| 952 | dimension. |
| 953 |
searching dependent graphs…