Installation#

AVNI version 0.1.0 requires Python version 3.7 or higher. For the best experience, please considering using Anaconda as a virtual environment and package manager for Python (see Installing Python). Follow the instructions below to install AVNI with Anaconda.

Dependencies#

AVNI is built on top of Fortran and standard Python libraries - as such, the following projects are required dependencies of AVNI:

  • gfortran Fortran compiler - Legacy Fortran code is interfaced with AVNI using the Fortran compiler.

  • NumPy - NumPy arrays provide a core foundation for AVNI’s data array access.

  • pandas - Data analysis and manipulation routines that are required for AVNI’s I/O routines.

  • scipy - Scientific routines that perform standard calculations.

  • configobj - Configuration files

  • xarray - Labelled multi-dimensional arrays and datasets in Python

  • matplotlib - Used for colormaps and 2D plotting.

  • fortranformat - Some I/O routines in AVNI write files in format specifiers that are easily specified in Fortran.

  • pint - Unit system for conversion of state variables from SI to other systems.

  • h5py - Pythonic interface to the HDF5 binary data format that is used by AVNI is writing files in reference seismic data format (RSDF) files.

Installing Fortran compiler#

A prerequisite for AVNI is the gfortran Fortran compiler. Once Fortran is installed, please set the environment variable F90 in your command line shell to gfortran.

Run in your terminal:

$ echo $SHELL
$ export F90=gfortran # if SHELL is bash
$ setenv F90 gfortran # if SHELL is csh or tcsh

Installing dependencies#

We suggest to install AVNI into its own conda environment.

The dependency stack is moderate but may take a long time (several tens of minutes) to resolve on some systems via the default conda solver. We therefore highly recommend using mamba instead, a conda replacement that is much faster.

Run in your terminal:

$ conda install --channel=conda-forge --name=base mamba
$ curl --remote-name https://raw.githubusercontent.com/globalseismology/avni/main/requirements_base.txt
$ mamba create --override-channels --channel=conda-forge --file requirements_base.txt --name avni
$ conda activate avni

This will create a new conda environment in Python version 3.7 called avni (you can adjust this by passing a different name via --name) and install all dependencies into it.

Run the following installation commands to install AVNI into this environment.

Optional Dependencies#

AVNI includes several optional dependencies for visualization and reading a variety of additional file formats, including:

  • PyGeodesy - Geodesy tools for various ellipsoidal and spherical earth models. Used for benchmarking.

  • Basemap - Basemap toolkit is a library for plotting 2D data on maps in Python. Install with the following options to add topography at all resolutions:

  • pytables - PyTables is a package for managing hierarchical datasets that AVNI uses to write HDF files.

  • pyshtools - Spherical harmonic transforms are used by AVNI for testing purposes.

$ curl --remote-name https://raw.githubusercontent.com/globalseismology/avni/main/requirements_extra_conda.txt
$ mamba install --yes --file requirements_extra_conda.txt

From PyPI#

https://img.shields.io/pypi/v/avni?logo=python&logoColor=white

AVNI can be installed from PyPI using pip:

$ pip install avni

To install all the additional packages that extend AVNI (recommended), install using pip with:

$ pip install "avni[all]"

You will still need to first install the conda dependencies for this to work.

Source / Developers#

Alternatively, you can install the latest version from GitHub by visiting AVNI GitHub, and downloading the source (cloning) by running:

$ git clone https://github.com/globalseismology/avni.git
$ cd avni
$ python -m pip install -e .

The latest documentation for the main branch of AVNI can be found at AVNI.

Installing AVNI for other scenarios#

The Advanced setup page has additional tips and tricks for special situations (servers, notebooks, CUDA, installing the development version, etc). The Contributing guide has additional installation instructions for (future) contributors to AVNI (e.g, extra dependencies for running our tests and building our documentation).

Python IDEs#

Most users find it convenient to write and run their code in an Integrated Development Environment (IDE). Some popular choices for scientific Python development are:

  • Visual Studio Code (often shortened to “VS Code” or “vscode”) is a development-focused text editor that supports many programming languages in addition to Python, includes an integrated terminal console, and has a rich ecosystem of packages to extend its capabilities. Installing Microsoft’s Python Extension is enough to get most Python users up and running. VS Code is free and open-source.

  • PyCharm is an IDE specifically for Python development that provides an all-in-one installation (no extension packages needed). PyCharm comes in a free “community” edition and a paid “professional” edition, and is closed-source.

Note

A more comprehensive testing suite is available after cloning the source repository. For details on how to clone and test the AVNI source, please see our contributing guide.