Python interface#
Before you can use the Python Interface, make sure your installation of the Worldbuilder includes SWIG and Python. See Installing the prerequisites for details.
The Python wrapper can be installed by running python3 setup.py install --user in the lib folder inside your build directory. It is helpful to install this into a virtual environment.
Afterwards, you should be able to from gwb import WorldBuilderWrapper inside a Python script.
See https://github.com/GeodynamicWorldBuilder/WorldBuilder/blob/main/examples/python/python_example.py for an example:
from gwb import WorldBuilderWrapper
filename = "../../tests/data/continental_plate.wb"
world_builder = WorldBuilderWrapper(filename);
print ("2d temperature:")
print ("temperature in Python = ", world_builder.temperature_2d(120.0e3,500.0e3,0));
print ("3d temperature:")
print ("temperature in Python = ", world_builder.temperature_3d(120.0e3,500.0e3,0,0));
print ("2d composition:")
print ("composition in Python = ", world_builder.composition_2d(120.0e3,500.0e3,0,3));
print ("3d composition:")
print ("composition in Python = ", world_builder.composition_3d(120.0e3,500.0e3,.0e3,0e3,3));