code: def preprocess_xarray(func):
      
      @functools.wraps(func)
      def wrapper(*args, **kwargs):
          args = tuple(a.metpy.unit_array if isinstance(a, xr.DataArray) else a for a in args)
          kwargs = {name: (v.metpy.unit_array if isinstance(v, xr.DataArray) else v)
                    for name, v in kwargs.items()}
          return func(*args, **kwargs)
      return wrapper
docs: Decorate a function to convert all DataArray arguments to pint.Quantities.
  
      This uses the metpy xarray accessors to do the actual conversion.