Skip to content

Commit 208651b

Browse files
committed
update examples
1 parent b562c96 commit 208651b

File tree

5 files changed

+62
-31
lines changed

5 files changed

+62
-31
lines changed
-37.3 KB
Loading
-44.6 KB
Loading

examples/plot_subduction_zones.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def plot_teeth(ax, lons, lats, polarity):
4040

4141

4242
def main(show=True):
43-
time = 0
44-
model_name = "Merdith2021"
43+
time = 100
44+
model_name = "Alfonso2024"
4545

4646
fig, ax = get_basemap_with_coastlines(model=model_name, time=time)
4747

@@ -71,7 +71,7 @@ def main(show=True):
7171
ax.plot(lons, lats, transform=ccrs.PlateCarree(), color="blue")
7272
plot_teeth(ax, lons, lats, polarity)
7373

74-
plt.title(f"{time} Ma (Merdith2021)")
74+
plt.title(f"{time} Ma ({model_name})")
7575

7676
fig.text(
7777
0.5,
@@ -86,7 +86,7 @@ def main(show=True):
8686
save_fig(__file__)
8787

8888

89-
def get_basemap_with_coastlines(model="Muller2019", crs=ccrs.Robinson(), time=140):
89+
def get_basemap_with_coastlines(model, crs=ccrs.Robinson(), time=140):
9090
coastlines_shapely = coastlines.get_paleo_coastlines(
9191
time=time, model=model, format="shapely"
9292
)
@@ -110,9 +110,9 @@ def get_basemap_with_coastlines(model="Muller2019", crs=ccrs.Robinson(), time=14
110110
ax.add_geometries(
111111
coastlines_shapely,
112112
crs=ccrs.PlateCarree(),
113-
facecolor="grey",
113+
facecolor="lightgrey",
114114
edgecolor="none",
115-
alpha=0.5,
115+
alpha=1,
116116
)
117117
return fig, ax
118118

examples/plot_topological_plate_boundaries.py

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import numpy as np
88
from shapely.geometry import MultiLineString, MultiPolygon, Polygon, shape
99

10-
from gwspy import PlateModel
10+
from gwspy import PlateModel, coastlines
1111

1212
OUTPUT_DIR = "output"
1313
Path(OUTPUT_DIR).mkdir(parents=True, exist_ok=True)
@@ -16,41 +16,55 @@
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

2022
def 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

examples/plot_topological_plate_polygons.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,31 @@
1515
# export GWS_URL=http://localhost:18000/
1616
# micromamba run -n gplates-ws-example ./plot_topological_plate_polygons.py
1717

18+
model_name = "Alfonso2024"
19+
1820

1921
def main(show=True):
20-
model = PlateModel("Muller2019")
21-
time = 10
22-
topology_10 = model.get_topology(time)
22+
model = PlateModel(model_name)
23+
time = 100
24+
topology_100 = model.get_topology(time)
2325

2426
# LOOK HERE!!!!
2527
# plot polygon without edges first
2628
# and then get the polygon edges as lines and plot the edges
2729
# this is to get rid of the vertical line along the dateline
28-
_polygons = topology_10.get_plate_polygons()
29-
_lines = topology_10.get_plate_polygons(as_lines=True)
30+
_polygons = topology_100.get_plate_polygons()
31+
_lines = topology_100.get_plate_polygons(as_lines=True)
3032

3133
# print(_polygons)
3234

3335
polygons = []
3436
for feature in _polygons["features"]:
35-
# if feature["properties"]["type"] != "gpml:TopologicalClosedPlateBoundary":
37+
# if "Africa Basins temporary rigid block" in feature["properties"]["name"]:
38+
# print(feature["properties"]["name"])
3639
# continue
40+
# print(feature["properties"]["name"])
41+
if feature["properties"]["type"] == "gpml:OceanicCrust":
42+
continue
3743
s = shape(feature["geometry"])
3844
if isinstance(s, Polygon) or isinstance(s, MultiPolygon):
3945
polygons.append(s.buffer(0))
@@ -43,16 +49,18 @@ def main(show=True):
4349
feature_types = []
4450
for feature in _lines["features"]:
4551
s = shape(feature["geometry"])
46-
lines.append(s)
4752
f_type = feature["properties"]["type"]
53+
if f_type == "gpml:OceanicCrust":
54+
continue
55+
56+
lines.append(s)
57+
4858
if f_type == "gpml:TopologicalNetwork":
4959
colors.append("green")
5060
elif f_type == "gpml:TopologicalClosedPlateBoundary":
5161
colors.append("blue")
5262
elif f_type == "gpml:TopologicalSlabBoundary":
5363
colors.append("yellow")
54-
elif f_type == "gpml:OceanicCrust":
55-
colors.append("orange")
5664
else:
5765
colors.append("red")
5866

@@ -110,7 +118,7 @@ def main(show=True):
110118
bbox_to_anchor=(1.1, 0.9),
111119
)
112120
plt.setp(legend.get_title(), fontsize="xx-small")
113-
plt.title(f"{time} Ma (Muller2019)")
121+
plt.title(f"{time} Ma ({model_name})")
114122

115123
fig.text(
116124
0.5,

0 commit comments

Comments
 (0)