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.lat_lon_to_xyz(lat, lon)[source]

all in radians

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.geometry_utils.test_line_segment_cross_dateline_in_degrees(point_a_lon, point_b_lon, central_meridian)[source]

same as test_line_segment_cross_dateline except all arguments are in degrees

gwspy.geometry_utils.xyz_to_lat_lon(x, y, z)[source]

in radians

gwspy.gplates module

gwspy.paleoearth module

gwspy.paleoearth.get_paleo_cities(time: float, model: str = 'MULLER2022')[source]

get a list of paleo-cities

Returns:

a dict object, {“names”: names, “lons”: lons, “lats”: lats}

gwspy.paleoearth.get_paleo_labels(time: float, model: str = 'MULLER2022')[source]

get a list of paleo-labels

Returns:

a dict object, {“names”: names, “lons”: lons, “lats”: lats}

gwspy.plate_model module

class gwspy.plate_model.PlateModel(name='MULLER2019')[source]

Bases: object

get_cfg()[source]

Given a rotation model name, return the details about the model

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]
get_paleo_labels()[source]

get a list of paleo-labels

Returns:

a dict object, {“names”: names, “lons”: lons, “lats”: lats}

get_subduction_zones(time)[source]
get_topology(time)[source]
list_models()[source]

return a list which contains all the available rotation models

reconstruct(lats: list[float], lons: list[float], age: float, pids: list[int] = []) dict[str, list][source]

reconstruct a list of lats and lons to age

Returns:

for example, {‘lats’:[1.1,2.2], ‘lons’:[2.1,2.3]}

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.quaternions.axis_angle_to_quat(v, theta)[source]
gwspy.quaternions.cart_to_lat_lon(x, y, z)[source]
gwspy.quaternions.lat_lon_to_cart(lat, lon)[source]
gwspy.quaternions.normalize(v, tolerance=1e-05)[source]
gwspy.quaternions.quat_conjugate(q)[source]
gwspy.quaternions.quat_mult(q1, q2)[source]
gwspy.quaternions.quat_to_axis_angle(quat)[source]
gwspy.quaternions.quat_vec_mult(q1, v1)[source]
gwspy.quaternions.test_rotate(point, axis, angle)[source]

test rotate point

Parameters:
  • point – point to be rotated (in lat,lon)

  • axis – rotation axis (in lat,lon)

  • angle – roation angle (in degrees)

Returns:

new coordinates of the point (in lat,lon)

gwspy.reconstruction module

gwspy.reconstruction.get_paleo_coordinates(lats, lons, age, model='SETON2012', pids=[])[source]

convenient function to get paleo-coordinates at {age}

gwspy.reconstruction.reconstruct_points(points: list[Point], age, model='SETON2012', pids=[])[source]

get paleo-coordinates for a list of shapely points, return new shapely points

gwspy.resample_line module

gwspy.resample_line.degree_to_radian(point)[source]
gwspy.resample_line.radian_to_degree(point)[source]
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.km_to_radian(km, earth_radius=6378.14)[source]
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.radian_to_km(radian, earth_radius=6378.14)[source]
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.spherical_triangle.get_third_vertex(point_a, point_b, height=0.05)[source]

Given two points, get third point of triangle.

Params point_a:

{“lon”: lon, “lat”: lat} in radian

Params point_b:

{“lon”: lon, “lat”: lat} in radian

Params height:

in radian

Returns:

{“lon”: lon, “lat”: lat} in radian

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

gwspy.subduction_teeth.get_triangle(point_a, point_b, base_length, height, polarity)[source]

return a triangle

Params point_a:

{“lon”: lon, “lat”: lat} in radian

Params point_b:

{“lon”: lon, “lat”: lat} in radian

Params base_length:

triangle base length

Params polarity:

subduction polarity

gwspy.topology module

class gwspy.topology.Topology(model_name, time)[source]

Bases: object

get_features(name, return_format='geojson')[source]
get_plate_boundaries(return_format='geojson')[source]
get_plate_boundary_types()[source]
get_plate_polygon_names()[source]
get_plate_polygons(return_format='geojson', as_lines=False)[source]
gwspy.topology.get_subduction_zones(model, time)[source]

return subduction zones as geojson object

gwspy.topology.get_topological_plate_boundaries(model, time)[source]

return topological plate boundaries

Params model:

model name

Params time:

reconstruction time

Returns:

geojson

gwspy.topology.get_topological_plate_polygons(model, time, as_lines=False)[source]

return topological plate polygons

Params model:

model name

Params time:

reconstruction time

Returns:

geojson

gwspy.utils module

gwspy.utils.geojson_to_shapely(json_data)[source]
gwspy.utils.get_cfg()[source]

Module contents