gridcellarea

Contents

gridcellarea#

Area of grid cells on Earth

This module was written by Matthias Cuntz while at Department of Computational Hydrosystems, Helmholtz Centre for Environmental Research - UFZ, Leipzig, Germany, and continued while at Institut National de Recherche pour l’Agriculture, l’Alimentation et l’Environnement (INRAE), Nancy, France.

copyright:

Copyright 2009-2022 Matthias Cuntz, see AUTHORS.rst for details.

license:

MIT License, see LICENSE for details.

The following functions are provided

gridcellarea(lat, lon[, globe, rearth])

Area of grid cells on a spherical Earth in square metre

History
  • Written Jul 2009 by Matthias Cuntz - mc (at) macu (dot) de

  • Ported to Python 3, Feb 2013, Matthias Cuntz

  • Assert correct input, Apr 2014, Matthias Cuntz

  • Clip lat because -90 and 90 give negative area, Oct 2018, Matthias Cuntz

  • Corrected bug in checking ascending or descending lats, Apr 2022, Matthias Cuntz

  • Removed assertion of nlat/nlon > 2, Apr 2022, Matthias Cuntz

  • Keyword radius of Earth and changed default from 6371000 to 6371009 as in the rest of pyjams, Apr 2022, Matthias Cuntz

  • Rename cellarea to gridcellarea, Apr 2022, Matthias Cuntz

gridcellarea(lat, lon, globe=False, rearth=6371009.0)[source]#

Area of grid cells on a spherical Earth in square metre

Parameters:
  • lat (array_like) – Latitudes of grid cell centres in degrees N

  • lon (array_like) – Longitudes of grid cell centres in degrees E

  • globe (bool, optional) – Assumes that latitudes span the globe if True, i.e. they are bounded by 90 and -90 degrees latitude

  • rearth (float, optional) – Radius of the spherical Earth (default: 6371009.)

Return type:

numpy array with area in m^2

Notes

This is a rather rough routine with lots of possible improvements, notably allowing irregular grids, grid boundaries, etc.

Examples

Gaussian latitudes

>>> lat = np.array([ 12.98898858, 9.27785325, 5.56671363])
>>> lon = np.array([ 0., 3.75, 7.5])
>>> print(gridcellarea(lat, lon)[0,:])
[1.67639557e+11 1.67639557e+11 1.67639557e+11]
>>> print(gridcellarea(lat, lon)[1,:])
[1.69790907e+11 1.69790907e+11 1.69790907e+11]
>>> print(gridcellarea(lat, lon)[2,:])
[1.71230373e+11 1.71230373e+11 1.71230373e+11]