Skip to main content

Plate Model Manager

Project description

plate-model-manager

unittest unittest-win build-doc PyPI version anaconda_badge platforms downloads

Originally the plate-model-manager was designed for GPlately. 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 install

pip install plate-model-manager

How to use

Basic Usage

👉 The Python code below downloads the "Muller2019" model into local folder "plate-models-data-dir" and returns the rotation file's location.

from plate_model_manager import PlateModelManager

print(PlateModelManager().get_model("Muller2019",data_dir="plate-models-data-dir").get_rotation_model())

python print rotation screenshot

👉 The Python code below lists all available reconstruction models.

from plate_model_manager import PlateModelManager

print(PlateModelManager().get_available_model_names())

python list all models screenshot

Use 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 ID
point_feature_with_PID = pygplates.partition_into_plates(
  model.get_static_polygons(), # 👈👀 LOOK HERE
  model.get_rotation_model(), # 👈👀 LOOK HERE
  [point_feature])

# Reconstruct the point features.
reconstructed_feature_geometries = []
time=140
pygplates.reconstruct(
  point_feature_with_PID,
  model.get_rotation_model(), # 👈👀 LOOK HERE
  reconstructed_feature_geometries,
  time)

print(reconstructed_feature_geometries[0].get_reconstructed_geometry().to_lat_lon())

See the full example at https://github.com/GPlates/pygplates-tutorials/blob/master/notebooks/working-with-plate-model-manager.ipynb

Use PMM with GPlately 🌰

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(), # 👈👀 LOOK HERE
    topology_features=model.get_layer("Topologies"), # 👈👀 LOOK HERE
    static_polygons=model.get_layer("StaticPolygons"), # 👈👀 LOOK HERE
)
gplot = PlotTopologies(
    test_model,
    coastlines=model.get_layer("Coastlines"), # 👈👀 LOOK HERE
    COBs=model.get_layer("COBs"), # 👈👀 LOOK HERE
    time=age,
)

See the full example at https://github.com/GPlates/gplately/blob/master/Notebooks/Examples/working-with-plate-model-manager.py

Use the command line

  • pmm ls

    This command will list all available plate tectonic reconstruction models.

    pmm ls command screenshot

  • pmm ls Muller2019

    This command will show the details of model 'Muller2019'.

    pmm ls model command screenshot

  • pmm download Muller2019 plate-models-data-dir

    This command will download model "Muller2019" into a folder 'plate-models-data-dir'.

    pmm download model screenshot

  • pmm download all

    This command will download all available models into the current working directory.

    pmm download all screenshot

Examples

This Python module is mostly used in

A good example of using PlateModelManager with PyGPlates can be found at

The examples of using PlateModelManager with GPlately:

The 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.

Dependencies

  • aiohttp
  • requests
  • nest_asyncio

Event loop RuntimeError

For 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/

import nest_asyncio
nest_asyncio.apply()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plate_model_manager-1.2.2.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

plate_model_manager-1.2.2-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

Details for the file plate_model_manager-1.2.2.tar.gz.

File metadata

  • Download URL: plate_model_manager-1.2.2.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.12

File hashes

Hashes for plate_model_manager-1.2.2.tar.gz
Algorithm Hash digest
SHA256 fd3c6fd2173e5b9711a66a9e5abd35c9bc72289b3e502f7c8b8ff436dbc5cfd7
MD5 8645822268e22a2f93207e36b51be557
BLAKE2b-256 d9f49c16b2115b4b4bc7b068d24d03dc366efeef1a5d57d2e9600205ae2a1ea7

See more details on using hashes here.

File details

Details for the file plate_model_manager-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for plate_model_manager-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ebf01d56f9071a6fec02e45f9886f5dff58a4b524fb5c16e34255ab9ad87f4ad
MD5 30d2c0496ef5abf64ff8f29c01c73ff2
BLAKE2b-256 1ed06b2dfb959acf8380215c739524da42828bd9984a8e1bfd99b5aa450a12d7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page