77import numpy as np
88from shapely .geometry import MultiLineString , MultiPolygon , Polygon , shape
99
10- from gwspy import PlateModel
10+ from gwspy import PlateModel , coastlines
1111
1212OUTPUT_DIR = "output"
1313Path (OUTPUT_DIR ).mkdir (parents = True , exist_ok = True )
1616# export GWS_URL=http://localhost:18000/
1717# micromamba run -n gplates-ws-example ./plot_topological_plate_boundaries.py
1818
19+ model_name = "Alfonso2024"
20+
1921
2022def main (show = True ):
21- model = PlateModel ("Muller2019" )
22- time = 10
23- topology_10 = model .get_topology (time )
23+ model = PlateModel (model_name )
24+ time = 100
25+ topology_100 = model .get_topology (time )
2426
25- _lines = topology_10 .get_plate_boundaries ()
27+ _lines = topology_100 .get_plate_boundaries ()
2628 colors = []
2729 feature_types = []
2830 polylines = []
29- color_map = {}
31+ color_map = {
32+ "MidOceanRidge" : "red" ,
33+ "Transform" : "red" ,
34+ "SubductionZone" : "blue" ,
35+ "Fault" : "orange" ,
36+ }
3037 for feature in _lines ["features" ]:
3138 s = shape (feature ["geometry" ])
3239 polylines .append (s )
3340 f_type = feature ["properties" ]["type" ]
34- feature_types . append ( f_type )
41+
3542 if f_type not in color_map :
36- cc = list (np .random .choice (range (256 ), size = 3 ) / 256 )
37- color_map [f_type ] = cc
43+ cc = "grey"
44+ feature_types .append ("other" )
45+ # cc = list(np.random.choice(range(256), size=3) / 256)
46+ # color_map[f_type] = cc
3847 else :
48+ feature_types .append (f_type )
3949 cc = color_map [f_type ]
4050 colors .append (cc )
4151 # if f_type == "gpml:TopologicalNetwork":
4252 # colors.append("green")
4353
4454 print (set (feature_types ))
4555
56+ coastlines_shapely = coastlines .get_paleo_coastlines (
57+ time = time , model = model_name , format = "shapely"
58+ )
59+
4660 fig = plt .figure (figsize = (12 , 6 ), dpi = 120 )
4761 ax = plt .axes (projection = ccrs .Robinson ())
4862
4963 ax .set_global ()
5064 gl = ax .gridlines (
5165 crs = ccrs .PlateCarree (),
5266 draw_labels = True ,
53- color = "grey " ,
67+ color = "black " ,
5468 alpha = 0.5 ,
5569 linestyle = "--" ,
5670 )
@@ -59,17 +73,26 @@ def main(show=True):
5973 gl .xlabel_style = {"size" : 7 , "color" : "gray" }
6074 gl .ylabel_style = {"size" : 7 , "color" : "gray" }
6175
76+ ax .add_geometries (
77+ coastlines_shapely ,
78+ crs = ccrs .PlateCarree (),
79+ facecolor = "lightgrey" ,
80+ edgecolor = "none" ,
81+ alpha = 0.5 ,
82+ )
83+
6284 # plot the lines
6385 for line , c , t in zip (polylines , colors , feature_types ):
6486 if isinstance (line , MultiLineString ):
6587 for g in line .geoms :
6688 ax .plot (
67- * g .xy , transform = ccrs .PlateCarree (), color = c , label = t , linewidth = 0.7
89+ * g .xy , transform = ccrs .PlateCarree (), color = c , label = t , linewidth = 1
6890 )
6991 else :
7092 ax .plot (
71- * line .xy , transform = ccrs .PlateCarree (), color = c , label = t , linewidth = 0.7
93+ * line .xy , transform = ccrs .PlateCarree (), color = c , label = t , linewidth = 1
7294 )
95+
7396 # plot the legend
7497 handles , labels = ax .get_legend_handles_labels ()
7598 unique = [
@@ -80,16 +103,16 @@ def main(show=True):
80103 title = "Feature Types" ,
81104 prop = {"size" : 6 },
82105 loc = "lower right" ,
83- bbox_to_anchor = (1.14 , 0.6 ),
106+ bbox_to_anchor = (1.08 , 0.8 ),
84107 )
85108 plt .setp (legend .get_title (), fontsize = "xx-small" )
86109
87- plt .title (f"{ time } Ma (Muller2019 )" )
110+ plt .title (f"{ time } Ma ({ model_name } )" )
88111
89112 fig .text (
90113 0.5 ,
91114 0.03 ,
92- "topological plate boundaries with random colours for each feature type " ,
115+ "the topological plate boundaries are plotted as line segments " ,
93116 ha = "center" ,
94117 )
95118
0 commit comments