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
DataArrayit is namedearth_radiusand its only attributes are its own,long_nameandunits(km), not the latitude’s.- Return type:
ArrayLike
Notes
Originally copied from https://towardsdatascience.com/the-correct-way-to-average-the-globe-92ceecd172b7
WGS84: https://earth-info.nga.mil/GandG/publications/tr8350.2/tr8350.2-a/Chapter%203.pdf
See also
gridcell_areaCell 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'}