code: def grid_deltas_from_dataarray(f):
      
      if f.metpy.crs['grid_mapping_name'] == 'latitude_longitude':
          dx, dy = lat_lon_grid_deltas(f.metpy.x, f.metpy.y,
                                       initstring=f.metpy.cartopy_crs.proj4_init)
          slc_x = slc_y = tuple([np.newaxis] * (f.ndim - 2) + [slice(None)] * 2)
      else:
          dx = np.diff(f.metpy.x.metpy.unit_array.to('m').magnitude) * units('m')
          dy = np.diff(f.metpy.y.metpy.unit_array.to('m').magnitude) * units('m')
          slc = [np.newaxis] * (f.ndim - 2)
          slc_x = tuple(slc + [np.newaxis, slice(None)])
          slc_y = tuple(slc + [slice(None), np.newaxis])
      return dx[slc_x], dy[slc_y]
docs: Calculate the horizontal deltas between grid points of a DataArray.
  
      Calculate the signed delta distance between grid points of a DataArray in the horizontal
      directions, whether the grid is lat/lon or x/y.
  
      Parameters
      ----------
      f : `xarray.DataArray`
          Parsed DataArray on a latitude/longitude grid, in (..., lat, lon) or (..., y, x)
          dimension order
  
      Returns
      -------
      dx, dy:
          arrays of signed deltas between grid points in the x and y directions with dimensions
          matching those of `f`.
  
      See Also
      --------
      lat_lon_grid_deltas