lair.geo.earth_radius#

lair.geo.earth_radius(lat)[source]#

Calculate radius of Earth assuming oblate spheroid defined by WGS84

The radius is the distance from the Earth’s center to the ellipsoid at each latitude. It is not the radius of a sphere with the ellipsoid’s areas: gridcell_area() computes those on the ellipsoid itself.

Parameters:

lat (array-like) – latitudes in degrees

Returns:

array-like – vector of radius in kilometers. For a DataArray it is named earth_radius and its only attributes are its own, long_name and units (km), not the latitude’s.

Return type:

ArrayLike

Notes

See also

gridcell_area

Cell areas on the ellipsoid, not on a sphere of this radius.

Examples

>>> import xarray as xr
>>> from lair import geo
>>> lat = xr.DataArray([0.0, 90.0], dims="lat", attrs={"units": "degrees_north"})
>>> radius = geo.earth_radius(lat)
>>> radius.values.round(3)
array([6378.137, 6356.752])
>>> radius.attrs
{'long_name': 'Earth radius', 'units': 'km'}