gwspy package
Submodules
gwspy.coastlines module
- gwspy.coastlines.get_paleo_coastlines(time: float, model='MULLER2022', format='geojson', facecolor='lime', edgecolor='none', alpha: float = 0.5, extent=(-180, 180, -90, 90), wrap: bool = True, central_meridian: float = 0.0, anchor_plate_id: int = 0, min_area: float = None)[source]
Get paleo-coastlines
By default, the polygons are wrapped along (180/-180). If you would like to wrap them at other locations, be careful that some plotting packages might not work well with them.
- Parameters:
time – the input paleo age
model – the name of rotation model
format – the return data format, such as geojson, shapely, png
facecolor – face color – only for png format
edgecolor – edge color – only for png format
alpha – alpha – only for png format
extent – (left, right, bottom, top) – only for png format
anchor_plate_id – anchor plate id
central_meridian – central meridian
wrap – flag to indicate if wrap the polygons along dateline
min_area – only returns polygons with a larger area
- Returns:
paleo-coastlines
- Return type:
geojson
gwspy.geometry_utils module
- gwspy.geometry_utils.find_two_great_circles_intersections(point_a, point_b, point_c, point_d)[source]
return the two intersection points
- gwspy.geometry_utils.test_line_segment_cross_dateline(point_a_lon, point_b_lon, central_meridian)[source]
Return True if the line segment cross dateline, otherwise False. All parameters are in radians.
gwspy.gplates module
gwspy.paleoearth module
gwspy.plate_model module
- class gwspy.plate_model.PlateModel(name='MULLER2019')[source]
Bases:
object
- get_coastlines(time: float, format='geojson', facecolor='lime', edgecolor='none', alpha: float = 0.5, extent=(-180, 180, -90, 90), wrap: bool = True, central_meridian: float = 0.0, anchor_plate_id: int = 0, min_area: float | None = None)[source]
- gwspy.plate_model.reconstruct_shapely_points(model: PlateModel, points: list[Point], time: float, pids: list[int] = []) list[Point] [source]
reconstruct a list of shapely points to {time}Ma
gwspy.quaternions module
gwspy.reconstruction module
gwspy.resample_line module
- gwspy.resample_line.resample_line(line, distance, strict=False)[source]
resample a line. :param line: a list of (lat, lon) in radians :param distance: the distance of the adjacent points :param strict: in strict mode, we guarantee the distance. sacrifice the end point if necessary
in unstrict mode, we always keep the end point
- Returns:
the new line a list of (lat, lon) in radians. If the input line is shorter than distance, in strict mode, return []
- gwspy.resample_line.sample_next_point(line, distance, strict=False, accum_length=0)[source]
recursive function to sample point one by one :param line: a list of (lat, lon) in radians :param distance: the distance to the next point :param strict: in strict mode, we guarantee the distance. sacrifice the end point if necessary :accum_length: parameter to pass down the accumulated length for this recursive function :returns: (next point, new line)
next point (lat,lon) in radians. None, if no more point new line – the line after taking out this point
gwspy.rotation module
- gwspy.rotation.cross(a, b)[source]
cross product of two vectors defined only in three-dimensional space https://www.mathsisfun.com/algebra/vectors-cross-product.html https://en.wikipedia.org/wiki/Cross_product#Computing
- Parameters:
a – 3D vector, such as [1,2,3]
b – 3D vector, such as [234]
- Returns:
cross product 3D vector
- gwspy.rotation.distance(point_a, point_b, earth_radius=6378.14)[source]
calculate the distance between to points (lat, lon) in radians return the distance in km
- Parameters:
point_a – point a (lat, lon) in radians
point_b – point b (lat, lon) in radians
earth_radius – earth radius
- Returns:
distance in km
- gwspy.rotation.dot(a, b)[source]
dot product of two vectors https://www.mathsisfun.com/algebra/vectors-dot-product.html
- Parameters:
a – a vector, such as [1,2,3,4,5] (must be the same length with b)
b – a vector, such as [6,7,8,9,10] (must be the same length with a)
- Returns:
dot product (a number)
- gwspy.rotation.find_axis_and_angle(point_a, point_b)[source]
given two points point_a and point_b in (lat, lon) format in radians, return axis(lat, lon) and angle in radians
- Parameters:
point_a – point a (lat, lon) in radians
point_b – point b (lat, lon) in radians
- Returns:
axis(lat, lon) in radians; angle in radians
- gwspy.rotation.interp_two_points(point_a, point_b, num=10)[source]
interpolate between two points(in radians) along the great circle return a list of interpolated points (lat, lon) in radians
- Parameters:
point_a – point a (lat, lon) in radians
point_b – point b (lat, lon) in radians
num – the number of segments
- Returns:
a list of interpolated points (lat, lon) in radians the return list has num+1 points(num segments)
- gwspy.rotation.radian_distance(point_a, point_b)[source]
calculate the distance between to points (lat, lon) in radians return the distance in radians
- Parameters:
point_a – point a (lat, lon) in radians
point_b – point b (lat, lon) in radians
- Returns:
distance in radians
- gwspy.rotation.rotate(point, axis, angle)[source]
rotate a point by axis and angle
- Parameters:
point – (lat, lon) in radians
axis – (lat, lon) in radians
angle – in radians
- Returns:
new point(lat, lon) in radians
- gwspy.rotation.sample_between_two_points(point_a, point_b, distances_to_point_a)[source]
sample points between two points along the great circle according to a list of distances to point a
- Parameters:
point_a – point a (lat, lon) in radians
point_b – point b (lat, lon) in radians
distances_to_point_a – a list of distances(in radians) to point a. the distance must less than the distance between point a and point b. invalid distances will produce Nones in the return list
- Returns:
a list of sampled points (lat, lon) in radians. The return list has the same length with the list of distances_to_point_a. point_a and point_b will not be included.
gwspy.spherical_triangle module
gwspy.subduction_teeth module
- class gwspy.subduction_teeth.Polarity(value)[source]
Bases:
Enum
An enumeration.
- LEFT = 2
- RIGHT = 1
- UNKNOWN = 0
- gwspy.subduction_teeth.get_subduction_teeth(lons: list[float], lats: list[float], base_length: float = 0.03, spacing: float = 0.01, height: float = 0.03, polarity: Polarity = Polarity.UNKNOWN, geojson: bool = False, return_degrees: bool = True, central_meridian: float | None = None)[source]
return a list of triangle polygons for given polyline
- Params lons:
a list of lons (in radian)
- Params lats:
a list of lats (in radian)
- Params base_length:
base length of triangle (in radian)
- Params spacing:
space between triangles (in radian)
- Params height:
triangle height (in radian)
- Params polarity:
the polarity of this subduction zone (left or right)
- Params geojson:
if set True, return data in geojson format
- Params return_degrees:
if set True, return coordinates in degrees
- Params central_meridian:
if set, omit triangles cross dateline (in radian)
- Returns:
[[{‘lon’:lon, ‘lat’:lat}, {‘lon’:lon, ‘lat’:lat}, {‘lon’:lon, ‘lat’:lat}],…] or {
”type”: “GeometryCollection”, “geometries”: [
- {
“type”: “Polygon”, “coordinates”: [
- [
[100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
]
]
}, {
”type”: “Polygon”, “coordinates”: [
- [
[110.0, 10.0], [10.0, 10.0], [101.0, 10.0],
]
]
]
}
- gwspy.subduction_teeth.get_subduction_teeth_in_degrees(lons: list[float], lats: list[float], base_length: float = 1, spacing: float = 0.5, height: float = 1, polarity: Polarity = Polarity.UNKNOWN, geojson: bool = False, central_meridian: float | None = None)[source]
same as get_subduction_teeth, just everything is in degrees