Package: plate-model-manager
plate-model-managerOriginally the plate-model-manager was designed forGPlately. Later, it was found also useful in other scenarios and contexts. The plate-model-manager downloads and manages the plate reconstruction model files. It is a dataset manager for plate tectonic reconstruction models, similar to NPM or Conda for software packages.Have you ever wondered where to get the plate tectonic reconstruction models for your research? Are you tired of downloading files from Internet manually and specify file paths when calling PyGPlates functions? If the answer is yes, you probably want to check out this plate-model-manager Python module.How to installpip install plate-model-managerHow to useUse PMM with pyGPlates 🌰pm_manager=PlateModelManager()model=pm_manager.get_model("Muller2019")# create a point feature at (0,0)point_feature=pygplates.Feature()point_feature.set_geometry(pygplates.PointOnSphere(0,0))# assign plate IDpoint_feature_with_PID=pygplates.partition_into_plates(model.get_static_polygons(),# 👈👀 LOOK HEREmodel.get_rotation_model(),# 👈👀 LOOK HERE[point_feature])# Reconstruct the point features.reconstructed_feature_geometries=[]time=140pygplates.reconstruct(point_feature_with_PID,model.get_rotation_model(),# 👈👀 LOOK HEREreconstructed_feature_geometries,time)print(reconstructed_feature_geometries[0].get_reconstructed_geometry().to_lat_lon())See the full example athttps://github.com/GPlates/pygplates-tutorials/blob/master/notebooks/working-with-plate-model-manager.ipynbUse PMM with GPlately 🌰pm_manager=PlateModelManager()model=pm_manager.get_model("Muller2019")model.set_data_dir("plate-model-repo")age=55test_model=PlateReconstruction(model.get_rotation_model(),# 👈👀 LOOK HEREtopology_features=model.get_layer("Topologies"),# 👈👀 LOOK HEREstatic_polygons=model.get_layer("StaticPolygons"),# 👈👀 LOOK HERE)gplot=PlotTopologies(test_model,coastlines=model.get_layer("Coastlines"),# 👈👀 LOOK HERECOBs=model.get_layer("COBs"),# 👈👀 LOOK HEREtime=age,)See the full example athttps://github.com/GPlates/gplately/blob/master/Notebooks/Examples/working-with-plate-model-manager.pyUse the command linepmm lsThis command will list all available plate tectonic reconstruction models.pmm ls Muller2019This command will show the details of model 'Muller2019'.pmm download Muller2019 plate-models-data-dirThis command will download model "Muller2019" into a folder 'plate-models-data-dir'.pmm download allThis command will download all available models into the current working directory.Use in Python script👉 The Python code below prints all available model names.# print all available model namesfromplate_model_managerimportPlateModelManagerpm_manager=PlateModelManager()fornameinpm_manager.get_available_model_names():print(name)👉 The Python code below downloads the "Muller2019" model into folder "plate-models-data-dir".
The model.get_rotation_model() function returns the rotation file location.fromplate_model_managerimportPlateModelManagerpm_manager=PlateModelManager()model=pm_manager.get_model("Muller2019",data_dir="plate-models-data-dir")print(model.get_rotation_model())ExamplesThis Python module is mostly used inGPlately,GPlates Web Service,PyGPlates TutorialsandGPlates Python Proxy.A good example of using PlateModelManager with PyGPlates can be found athttps://github.com/GPlates/pygplates-tutorials/blob/master/notebooks/working-with-plate-model-manager.ipynb.The examples of using PlateModelManager with GPlately:https://github.com/GPlates/gplately/blob/master/Notebooks/Examples/introducing-plate-model-manager.pyhttps://github.com/GPlates/gplately/blob/master/Notebooks/Examples/working-with-plate-model-manager.pyThe PlateModelManager can also be used with the GPlates desktop. Use the command line to download the plate model files and open the files with GPlates desktop. This will save the trouble of downloading files from Internet manually.Dependenciesaiohttprequestsnest_asyncioEvent loop RuntimeErrorFor Jupyter Notebook, Web Server or GUI application users, you need the following two lines to workaround the event loop RuntimeError.
If you do not add these two lines, the PlateModelManager still works. But you will see a warning message. You can ignore the warning message safely.
If the warning message bothers you, add the two lines before calling PlateModelManager.https://anaconda.org/conda-forge/nest-asyncio/importnest_asyncionest_asyncio.apply()