gospl recipes

Overview

_images/earthcolab.png
_images/USydney-logo.jpg

What is this?

This online documentation provides some examples of pre- and post- processing techniques used to run different gospl simulations and extract useful information from them.

gospl (short for Global Scalable Paleo Landscape Evolution) is an open source, GPL-licensed library providing a scalable parallelised Python-based numerical model to simulate landscapes and basins reconstruction at global scale.

gospl

For an overview of gospl functionalities readers are invited to go through the online documentation:

  1. the technical guide provides in-depth information on the underlying physics,

  2. the getting started pages shows how to install the code itself, but the following sections will provide additional information on that as well,

  3. the complete list of input file parameters is describe in the user guide section,

  4. the API reference describes how methods work and functions have been declared.

How to use these recipies

This documentation is written as an online companion to gospl simulation. The examples and pre- and post- processing methods are actualised on the go, as we develop them.

We are trying to write them in such a way that they are quickly understandable and modifiable to fit with your specific simulation. If you are starting to use gospl, we strongly recommend to go through several of these examples to familiarise yourself with the code capabilities and input/output formats.

The notes are written in Jupyter Notebooks. If you want to run the examples, you can:

_images/launch_binder.png
  • run the notebooks online in an interactive window, by clicking on the “Launch Binder” button on the top-right of this page.

  • download the jupyter notebooks from the recipies repository and run them on your computer.

  • download some of the dataset from figshare and visualise the model outputs directly.

_images/figshare.png

gospl recipes environment

Combining all of the previous sections, we can very easily spin-up a full-featured scientific Python environment with a set of packages curated for the course. Copy and paste the following environment.yml file somewhere on your local hard drive:

name: stellar
channels:
  - conda-forge
  - defaults
  - anaconda
dependencies:
  - python=3.8    # Python version 3.8
  - compilers
  - llvm-openmp
  - sphinx
  - importlib_resources
  - pip           # Python package
  - pandas        # Labeled array library
  - netCDF4       # Wrapper for netcdf4
  - xarray        # N-d labeled array library
  - matplotlib    # 2D plotting library
  - numpy         # N-d array and numerics
  - numpy-indexed # Numerics adds on
  - scipy         # Common math/stats/science functions
  - scikit-image  # Image processing routines
  - scikit-learn  # Machine learning library
  - scikit-fuzzy  # Fuzzy logic library
  - geopandas     # Labeled array library for geosciences
  - shapely       # Geometric library
  - cftime        # Time units decoder
  - cartopy       # Geographic plotting toolkit
  - myst-nb       # Notebook syntax
  - sympy         # Symbolic expression
  - cmocean       # Colormaps for oceanography
  - jupyterlab    # Jupyter Lab environment
  - jupyter-book  # Jupyter book environment
  - basemap       # Mapping package
  - h5py          # Wrapper for HDF5
  - pymannkendall # Mann-Kendall trend analysis
  - seaborn       # Statistical visualizations
  - pyresample    # Geographic resampling tools
  - petsc4py
  - meshio
  - vtk
  - pre-commit
  - ruamel.yaml
  - mpi4py
  - cython
  - pyvista
  - pooch
  - ipywidgets
  - itkwidgets
  - nodejs
  - pyvista
  - pyevtk
  - panel
  - gdown
  - jigsawpy
  - pysheds
  - rioxarray
  - rasterio
  - ipygany
  - fiona
  - pycrs
  - richdem
  - holoviews
  - geoviews
  - hvplot
  - panel
  - wget
  - pip:
    - pyproj      # Geographic projections
    - jupyter-book==0.10.1
    - meshplex
    - gospl
    - stripy
    - zmapio

(Note: Installing this environment will also install many dependencies, including compiled libraries. This is totally fine; even if you have these libraries already installed through your system package manager, conda will install and link for use in the environment a configuration which should be to play nicely and work with all of its components.)

Create this environment through conda

$ conda env create -f environment.yml

Activate this environment

$ source activate stellar

Tip

This environment should be sufficient for all of the presented examples in this documentation.

Installing more packages

Once you have a basic Python environment, you can easily add or remove packages using the conda command line utility. Conda was created to help manage the complex dependencies and pre-compiled binary libraries that are necessary in scientific python.

If you set up your python environment using the Anaconda Python Distribution or with Miniconda, you should already have the conda command available on the command line. With it, you can easily install packages from an official, curated set of packages which are built and tested for a number of different system configurations on Linux, Windows, and macOS

$ conda install <package-name>

Additionally, there is a community-maintained collection of packages/recipes called conda forge which is accessible through conda as a special “channel”

$ conda install -c conda-forge <package-name>

While conda allows you to install almost any science-related package, there may be other general-use python packages you wish to you that are not available in via conda. For these, you can use an alternative installation method.

Outside of the scientific python community, the most common way to install packages is to search for them on the official PyPI index. Once you’ve found the package you want to install (you may have also just found it on github or elsewhere), you use the pip command from a the command line:

$ pip install <package-name>

This will fetch the source code, build it, and install it to wherever your $PYTHONPATH is set. This works in the vast majority of cases, particularly when the code you’re installing doesn’t have any compiled dependencies.

If you can’t find a package on either PyPI or conda-forge, you can always install it directly from the source code. If the package is on github, pip already has an alias to do this for you:

$ pip install git+https://github.com/<user>/<package-name>.git

If all else fails, you can always download the source code and install it manually like

$ wget https:/path/to/my/pkg/source.tar.gz
$ tar -xvzf source.tar.gz
$ cd source/
$ python setup.py install

You can also use pip to install code you’ve downloaded:

$ cd source/
$ pip install -e .

This will automatically call setup.py for you. The “-e” flag will install the package in “editable” mode, which means that any change you make to the source code will automatically be recognised when you load the package in Python.