diagnostic.wrappers.acceptable_variables#
- acceptable_variables(variables)[source]#
Decorator that checks if the dataset contains at least one of the acceptable variables before applying the diagnostic. The required variables are specified as a list of strings. If at least one of the acceptable variables is present the diagnostic is applied. If an acceptable variable is present all acceptable variables are passed to the diagnostic function - other variables will be dropped.
- Parameters:
variables (str or list of str) – The variable(s) that are acceptable to apply the diagnostic.
Examples
>>> # The diagnostic function accepts the variables 'tas', 'tas_max' and 'tas_min'. >>> @acceptable_variables(["tas", "tas_max", "tas_min"]) >>> def my_diagnostic(ds: xr.Dataset): >>> #Function which is valid for tas, tas_max and tas_min >>> return result