seagrid.utils.gridtools#

Grid-spacing helpers (2.x interface), computed by seagrid.grids.metrics.

Functions

dx_approx(*[, lats, lons, grid])

Return the zonal cell width in metres from 2-D cell centres.

dy_approx(*[, lats, lons, grid])

Return the meridional cell height in metres from 2-D cell centres.

haversine_area(ds)

Return cell areas in km² from the distances between neighbouring centres.

seagrid.utils.gridtools.dx_approx(*, lats=None, lons=None, grid=None)[source]#

Return the zonal cell width in metres from 2-D cell centres.

Parameters:
  • lats (numpy.ndarray, optional) – 2-D cell-centre coordinates. Required without grid.

  • lons (numpy.ndarray, optional) – 2-D cell-centre coordinates. Required without grid.

  • grid (Grid or pyresample geometry, optional) – Grid; its coordinates are used instead.

Returns:

numpy.ndarray

Raises:

TypeError – If neither grid nor both lats and lons are given.

Return type:

ndarray[tuple[Any, …], dtype[Any]]

seagrid.utils.gridtools.dy_approx(*, lats=None, lons=None, grid=None)[source]#

Return the meridional cell height in metres from 2-D cell centres.

As dx_approx().

Parameters:
Return type:

ndarray[tuple[Any, …], dtype[Any]]

seagrid.utils.gridtools.haversine_area(ds)[source]#

Return cell areas in km² from the distances between neighbouring centres.

Parameters:

ds (xarray.Dataset) – With 1-D lat/lon coordinates or 2-D lats/lons variables.

Returns:

numpy.ndarray – Edge cells are linearly extrapolated.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

See also

seagrid.geospatial.cell_area

exact spherical areas of any grid.