lasif.rotations

A collection of functions to rotate vectors, seismograms and moment tensors on a spherical body, e.g. the Earth.

Note

On the used coordinate system

Latitude and longitude are natural geographical coordinates used on Earth.

The coordinate system is right handed with the origin at the center of the Earth. The z-axis points directly at the North Pole and the x-axis points at (latitude 0.0/longitude 0.0), e.g. the Greenwich meridian at the equator. The y-axis therefore points at (latitude 0.0/longitue 90.0), e.g. somewhere close to Sumatra.

\(\theta\) (theta) is the colatitude, e.g. 90.0 - latitude and is the angle from the z-axis. \(\phi\) (phi) is the longitude and the angle from the x-axis towards the y-axis, a.k.a the azimuth angle. These are also the generally used spherical coordinates.

All rotation axes have to be given as [x, y, z] in the just described coordinate system and all rotation angles have to given as degree. A positive rotation will rotate clockwise when looking in the direction of the rotation axis.

For convenience reasons, most function in this module work with coordinates given in latitude and longitude.

copyright

Lion Krischer (krischer@geophysik.uni-muenchen.de), 2012-2013

license

GNU General Public License, Version 3 (http://www.gnu.org/copyleft/gpl.html)

lasif.rotations.colat2lat(colat: Union[numpy.ndarray, float])[source]

Helper function to convert colatitude to latitude. This, surprisingly, is quite an error source.

>>> colat2lat(180)
-90.0
>>> colat2lat(135)
-45.0
>>> abs(colat2lat(90))
0.0
>>> colat2lat(45)
45.0
>>> colat2lat(0.0)
90.0
Parameters

colat (Union[numpy.ndarray, float]) – The colatitude.

lasif.rotations.get_center_angle(a, b)[source]

Returns the angle of both angles on a sphere.

Parameters
  • a – Angle A in degrees.

  • b – Angle B in degrees.

The examples use round() to guard against floating point inaccuracies.

>>> round(get_center_angle(350, 10), 9)
0.0
>>> round(get_center_angle(90, 270), 9)
0.0
>>> round(get_center_angle(-90, 90), 9)
0.0
>>> round(get_center_angle(350, 5), 9)
357.5
>>> round(get_center_angle(359, 10), 9)
4.5
>>> round(get_center_angle(10, 20), 9)
15.0
>>> round(get_center_angle(90, 180), 9)
135.0
>>> round(get_center_angle(0, 180), 9)
90.0
lasif.rotations.lat2colat(lat: Union[numpy.ndarray, float])[source]

Helper function to convert latitude to colatitude. This, surprisingly, is quite an error source.

>>> lat2colat(-90)
180.0
>>> lat2colat(-45)
135.0
>>> lat2colat(0)
90.0
>>> lat2colat(45)
45.0
>>> lat2colat(90)
0.0
Parameters

lat (Union[numpy.ndarray, float]) – The latitude.

lasif.rotations.lat_lon_radius_to_xyz(lat: Union[numpy.ndarray, float], lon: Union[numpy.ndarray, float], r: Union[numpy.ndarray, float])[source]

Converts latitude, longitude and radius to x, y, and z.

Parameters
lasif.rotations.xyz_to_lat_lon_radius(*args)[source]

Converts x, y, and z to latitude, longitude and radius.

>>> xyz_to_lat_lon_radius(1.0, 0.0, 0.0)
(-0.0, 0.0, 1.0)
>>> xyz_to_lat_lon_radius([1.0, 0.0, 0.0])
(-0.0, 0.0, 1.0)
>>> xyz_to_lat_lon_radius(0.0, 0.0, -2.0)
(-90.0, 0.0, 2.0)
>>> xyz_to_lat_lon_radius(0.0, 0.0, 2.0)
(90.0, 0.0, 2.0)