-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add two examples of plate-model-manager * save unittest output
- Loading branch information
1 parent
33e08cc
commit 3e0d788
Showing
9 changed files
with
190 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ gplately.egg-info | |
build | ||
__pycache__ | ||
.ipynb_checkpoints | ||
|
||
output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from plate_model_manager import PlateModelManager | ||
|
||
|
||
def main(): | ||
pm_manager = PlateModelManager() | ||
|
||
print("available models: ") | ||
print("*****************") | ||
for name in pm_manager.get_available_model_names(): | ||
print(name) | ||
print() | ||
|
||
model = pm_manager.get_model("Muller2019") | ||
model.set_data_dir("plate-model-repo") | ||
|
||
print("available layers in model Muller2019:") | ||
print("*************************************") | ||
for layer in model.get_avail_layers(): | ||
print(layer) | ||
print() | ||
|
||
print("rotation file(s):") | ||
print("*****************") | ||
print(model.get_rotation_model()) | ||
print() | ||
|
||
print("StaticPolygons file(s):") | ||
print("***********************") | ||
print(model.get_layer("StaticPolygons")) | ||
print() | ||
|
||
# for layer in model.get_avail_layers(): | ||
# print(model.get_layer(layer)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
|
||
|
||
import cartopy.crs as ccrs | ||
import matplotlib.pyplot as plt | ||
from plate_model_manager import PlateModelManager | ||
|
||
from gplately import PlateReconstruction, PlotTopologies | ||
|
||
# This is a simple example of how to use the Plate Model Manager with GPlately | ||
|
||
|
||
def main(): | ||
# Here is how to use PlateModelManager to create PlateReconstruction and PlotTopologies objects | ||
pm_manager = PlateModelManager() | ||
model = pm_manager.get_model("Muller2019") | ||
model.set_data_dir("plate-model-repo") | ||
|
||
age = 55 | ||
test_model = PlateReconstruction( | ||
model.get_rotation_model(), | ||
topology_features=model.get_layer("Topologies"), | ||
static_polygons=model.get_layer("StaticPolygons"), | ||
) | ||
gplot = PlotTopologies( | ||
test_model, | ||
coastlines=model.get_layer("Coastlines"), | ||
COBs=model.get_layer("COBs"), | ||
time=age, | ||
) | ||
|
||
# Now do some plotting | ||
fig = plt.figure(figsize=(12, 6), dpi=72) | ||
ax = fig.add_subplot(111, projection=ccrs.Robinson(central_longitude=180)) | ||
|
||
gplot.plot_continent_ocean_boundaries(ax, color="cornflowerblue") | ||
gplot.plot_coastlines(ax, color="black") | ||
gplot.plot_ridges_and_transforms(ax, color="red") | ||
gplot.plot_trenches(ax, color="orange") | ||
gplot.plot_subduction_teeth(ax, color="orange") | ||
ax.set_global() | ||
|
||
ids = set([f.get_reconstruction_plate_id() for f in gplot.topologies]) | ||
for id in ids: | ||
gplot.plot_plate_id(ax, id, facecolor="None", edgecolor="lightgreen") | ||
plt.title(f"{age} Ma") | ||
plt.show() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../Notebooks/Examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
import cartopy.crs as ccrs | ||
import matplotlib.pyplot as plt | ||
|
||
sys.path.insert(0, "../..") | ||
|
||
|
||
OUTPUT_DIR = "output" | ||
|
||
Path(OUTPUT_DIR).mkdir(parents=True, exist_ok=True) | ||
|
||
|
||
def save_fig(filename): | ||
output_file = f"{OUTPUT_DIR}/{Path(filename).stem}.png" | ||
plt.gcf().savefig(output_file, dpi=120, bbox_inches="tight") # transparent=True) | ||
print(f"Done! The {output_file} has been saved.") | ||
plt.close(plt.gcf()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
./test_subduction_teeth.py save | ||
|
||
./test_plot.py save |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters