Earth

Class to to model Earth’s globe.

class pymeeus.Earth.Earth(ellipsoid=<pymeeus.Earth.Ellipsoid object>)[source]

Class Earth models the figure of the Earth surface and, with the help of a configurable reference ellipsoid, provides a set of handy method to compute different parameters, like the distance between two points on the surface.

Please note that here we depart a little bit from Meeus’ book because the Earth class uses the World Geodetic System 1984 (WGS84) as the default reference ellipsoid, instead of the International Astronomical Union 1974, which Meeus uses. This change is done because WGS84 is regarded as more modern.

__init__(ellipsoid=<pymeeus.Earth.Ellipsoid object>)[source]

Earth constructor.

It takes a reference ellipsoid as input. If not provided, the ellipsoid used is the WGS84 by default.

Parameters:ellipsoid – Reference ellipsoid to be used. WGS84 by default.
Returns:Earth object.
Return type:Earth
Raises:TypeError if input value is of wrong type.

#>>> a = Angle(-13, 30, 0.0) #>>> print(a) #-13.5 #>>> b = Angle(a) #>>> print(b) #-13.5

__str__()[source]

Method used when trying to print the Earth object. It essentially returns the corresponting ‘__str__()’ method from the reference ellipsoid being used.

Returns:Semi-major equatorial radius, flattening and angular velocity of the current reference ellipsoid, as a string.
Return type:string
>>> e = Earth()
>>> s = str(e)
>>> v = s.split(':')
>>> print(v[0] + '|' + str(round(float(v[1]), 14)) + '|' + v[2] )
6378137.0|0.00335281066475|7.292115e-05
__weakref__

list of weak references to the object (if defined)

distance(lon1, lat1, lon2, lat2)[source]

“This method computes the distance between two points on the Earth’s surface using the method from H. Andoyer.

Parameters:
  • lon1 (int, float, Angle) – Longitude of the first point, in degrees
  • lat1 (int, float, Angle) – Geodetical or geographical latitude of the first point, in degrees
  • lon2 (int, float, Angle) – Longitude of the second point, in degrees
  • lat2 (int, float, Angle) – Geodetical or geographical latitude of the second point, in degrees
Returns:

Tuple with distance between the two points along Earth’s surface, and approximate error, in meters

Return type:

tuple

Raises:

TypeError if input values are of wrong type.

>>> e = Earth(ellipsoid=IAU76)
>>> lon1 = Angle(-2, 20, 14.0)
>>> lat1 = Angle(48, 50, 11.0)
>>> lon2 = Angle(77, 3, 56.0)
>>> lat2 = Angle(38, 55, 17.0)
>>> dist, error = e.distance(lon1, lat1, lon2, lat2)
>>> round(dist, 0)
6181628.0
>>> error
69.0
>>> lon1 = Angle(-2.09)
>>> lat1 = Angle(41.3)
>>> lon2 = Angle(73.99)
>>> lat2 = Angle(40.75)
>>> dist, error = e.distance(lon1, lat1, lon2, lat2)
>>> round(dist, 0)
6176760.0
>>> error
69.0
linear_velocity(latitude)[source]

“Method to compute the linear velocity of a point at latitude, due to the rotation of the Earth.

Parameters:latitude (int, float, Angle) – Geodetical or geographical latitude of the observer, in degrees
Returns:Linear velocity of a point at latitude, in meters per second
Return type:float
Raises:TypeError if input value is of wrong type.
>>> e = Earth(ellipsoid=IAU76)
>>> round(e.linear_velocity(42.0), 2)
346.16
rho(latitude)[source]

“Method to compute the rho term, which is the observer distance to the center of the Earth, when the observer is at sea level. In this case, the Earth’s equatorial radius is taken as unity.

Parameters:latitude (int, float, Angle) – Geodetical or geographical latitude of the observer, in degrees
Returns:Rho: Distance to the center of the Earth from sea level. It is a ratio with respect to Earth equatorial radius.
Return type:float
Raises:TypeError if input value is of wrong type.
>>> e = Earth(ellipsoid=IAU76)
>>> round(e.rho(0.0), 1)
1.0
rho_cosphi(latitude, height)[source]

“Method to compute the rho*cos(phi’) term, needed in the calculation of diurnal parallaxes, eclipses and occulatitions.

Parameters:
  • latitude (int, float, Angle) – Geodetical or geographical latitude of the observer, in degrees
  • height (int, float) – Height of the observer above the sea level, in meters
Returns:

rho*cos(phi’) term

Return type:

float

Raises:

TypeError if input value is of wrong type.

>>> lat = Angle(33, 21, 22.0)
>>> e = Earth(ellipsoid=IAU76)
>>> round(e.rho_cosphi(lat, 1706), 6)
0.836339
rho_sinphi(latitude, height)[source]

“Method to compute the rho*sin(phi’) term, needed in the calculation of diurnal parallaxes, eclipses and occulatitions.

Parameters:
  • latitude (int, float, Angle) – Geodetical or geographical latitude of the observer, in degrees
  • height (int, float) – Height of the observer above the sea level, in meters
Returns:

rho*sin(phi’) term

Return type:

float

Raises:

TypeError if input value is of wrong type.

>>> lat = Angle(33, 21, 22.0)
>>> e = Earth(ellipsoid=IAU76)
>>> round(e.rho_sinphi(lat, 1706), 6)
0.546861
rm(latitude)[source]

“Method to compute the radius of curvature of the Earth’s meridian at the given latitude.

Parameters:latitude (int, float, Angle) – Geodetical or geographical latitude of the observer, in degrees
Returns:Radius of curvature of the Earth’s meridian at the given latitude, in meters
Return type:float
Raises:TypeError if input value is of wrong type.
>>> e = Earth(ellipsoid=IAU76)
>>> round(e.rm(42.0), 1)
6364033.3
rp(latitude)[source]

“Method to compute the radius of the parallel circle at the given latitude.

Parameters:latitude (int, float, Angle) – Geodetical or geographical latitude of the observer, in degrees
Returns:Radius of the parallel circle at given latitude, in meters
Return type:float
Raises:TypeError if input value is of wrong type.
>>> e = Earth(ellipsoid=IAU76)
>>> round(e.rp(42.0), 1)
4747001.2
set(ellipsoid)[source]

Method used to define an Earth object.

It takes a reference ellipsoid as input. If not provided, the ellipsoid used is the WGS84 by default.

Parameters:ellipsoid – Reference ellipsoid to be used. WGS84 by default.
Returns:None
Return type:None
Raises:TypeError if input value is of wrong type.
class pymeeus.Earth.Ellipsoid(a, f, omega)[source]

Class Ellipsoid is useful to encapsulate the most important parameters of a given reference ellipsoid.

__init__(a, f, omega)[source]

Ellipsoid constructor.

Parameters:
  • a (float) – Semi-major or equatorial radius, in meters
  • f (float) – Flattening
  • omega (float) – Angular velocity of the Earth, in rad/s
__str__()[source]

Method used when trying to print the object.

Returns:Semi-major equatorial radius, flattening and angular velocity as a string.
Return type:string
>>> a = Ellipsoid(6378140.0, 0.0033528132, 7.292e-5)
>>> print(a)
6378140.0:0.0033528132:7.292e-05
__weakref__

list of weak references to the object (if defined)

b()[source]

Method to return the semi-minor radius.

Returns:Semi-minor radius, in meters
Return type:float
>>> a = Ellipsoid(6378140.0, 0.0033528132, 7.292e-5)
>>> round(a.b(), 3)
6356755.288
e()[source]

Method to return the eccentricity of the Earth’s meridian.

Returns:Eccentricity of the Earth’s meridian
Return type:float
>>> a = Ellipsoid(6378140.0, 0.0033528132, 7.292e-5)
>>> round(a.e(), 8)
0.08181922
pymeeus.Earth.IAU76 = <pymeeus.Earth.Ellipsoid object>

Reference ellipsoid defined by the International Astronomic Union in 1976

pymeeus.Earth.WGS84 = <pymeeus.Earth.Ellipsoid object>

Reference ellipsoid World Geodetic System 1984, a modern ellipsoid used by the GPS system, and the standard in many applications