grid_spacing#

rojak.core.derivatives.grid_spacing(latitude, longitude, units, geod=None)[source]#

Compute the geodesic distance between adjacent points of a 2D latitude/longitude grid

Unlike nominal_grid_spacing(), the distance is computed at every grid point (rather than approximated from a single row/column), so this accounts for the grid spacing varying with latitude.

Parameters:
  • latitude (NDArray | DataArray) – 1D array of latitude coordinates

  • longitude (NDArray | DataArray) – 1D array of longitude coordinates

  • units (LatLonUnits) – Units latitude/longitude are expressed in

  • geod (Geod | None) – Geodesic to compute distances with. Defaults to a WGS84 ellipsoid.

Returns:

Grid spacing (in meters) between adjacent grid points along each Cartesian direction

Raises:
  • ValueError – If latitude and longitude do not have the same number of dimensions

  • NotImplementedError – If latitude/longitude are 2D (not yet supported)

  • ValueError – If latitude/longitude have more than 2 dimensions

Return type:

GridSpacing