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 GNU General Public License, Version 3 (http://www.gnu.org/copyleft/gpl.html)
lasif.rotations.colat2lat(colat)[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 – The colatitude.
lasif.rotations.get_border_latlng_list(min_lat, max_lat, min_lng, max_lng, number_of_points_per_side=25, rotation_axis=(0, 0, 1), rotation_angle_in_degree=0)[source]

Helper function taking a spherical section defined by latitudinal and longitudal extension, rotate it around the given axis and rotation angle and return a list of points outlining the region. Useful for plotting.

Parameters: min_lat – The minimum latitude. max_lat – The maximum latitude. min_lng – The minimum longitude. max_lng – The maximum longitude. number_of_points_per_side – The number of points per side desired. rotation_axis – The rotation axis. Optional. rotation_angle_in_degree – The rotation angle in degrees. Optional.
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.get_max_extention_of_domain(min_lat, max_lat, min_lng, max_lng, rotation_axis=(0, 0, 1), rotation_angle_in_degree=0)[source]

Helper function getting the maximum extends of a rotated domain.

Returns a dictionary with the following keys:
• minimum_latitude
• maximum_latitude
• minimum_longitude
• maximum_longitude
Parameters: min_lat – The minimum latitude. max_lat – The maximum latitude. min_lng – The minimum longitude. max_lng – The maximum longitude. rotation_axis – The rotation axis in degree. rotation_angle_in_degree – The rotation angle in degree.
lasif.rotations.get_spherical_unit_vectors(lat, lon)[source]

Returns the spherical unit vectors e_theta, e_phi and e_r for a point on the sphere determined by latitude and longitude which are defined as they are for earth.

Parameters: lat – Latitude in degree lon – Longitude in degree
lasif.rotations.lat2colat(lat)[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 – The latitude.

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

Parameters: lat – The latitude. lon – The longitude. r – The radius.
lasif.rotations.rotate_data(north_data, east_data, vertical_data, lat, lon, rotation_axis, angle)[source]

Rotates three component data recorded at lat/lon a certain amount of degrees around a given rotation axis.

Parameters: north_data – The north component of the data. east_data – The east component of the data. vertical_data – The vertical component of the data. Vertical is defined to be up, e.g. radially outwards. lat – Latitude of the recording point. lon – Longitude of the recording point. rotation_axis – Rotation axis given as [x, y, z]. angle – Rotation angle in degree.
lasif.rotations.rotate_lat_lon(lat, lon, rotation_axis, angle)[source]

Takes a point specified by latitude and longitude and return a new pair of latitude longitude assuming the earth has been rotated around rotation_axis by angle.

Parameters: lat – Latitude of original point lon – Longitude of original point rotation_axis – Rotation axis specified as [x, y, z]. angle – Rotation angle in degree.
lasif.rotations.rotate_moment_tensor(Mrr, Mtt, Mpp, Mrt, Mrp, Mtp, lat, lon, rotation_axis, angle)[source]

Rotates a moment tensor, given in spherical coordinates, located at lat/lon around the rotation axis and simultaneously performs a base change from the spherical unit vectors at lat/lon to the unit vectors at the new coordinates.

Parameters: Mrr – A moment tensor component. Mtt – A moment tensor component. Mpp – A moment tensor component. Mrt – A moment tensor component. Mrp – A moment tensor component. Mtp – A moment tensor component. lat – Latitude of the recording point. lon – Longitude of the recording point. rotation_axis – Rotation axis given as [x, y, z]. angle – Rotation angle in degree.
lasif.rotations.rotate_vector(vector, rotation_axis, angle)[source]

Takes a vector and rotates it around a rotation axis with a given angle.

Parameters: vector – The vector to be rotated given as [x, y, z]. rotation_axis – The axis to be rotating around given as [x, y, z]. angle – The rotation angle in degree.