PyAGNPS is a series of scripts and notebooks that helps in the creation of input files for TopAGNPS and AnnAGNPS.
This code was developed by Luc Rébillout during his tenure as Postdoctoral Research Associate and Research Scientist at the National Center for Computational Hydroscience and Engineering (NCCHE). Portions of this code have been used and internally modified in the development of the Agricultural Integrated Management System (AIMS), a decision support system for watershed modeling across the United States.
This work has been presented at AGU204:
Rébillout, L., Ozeren, Y., Al-Hamdan, O., & Bingner, R. (2023). PyAGNPS: A Python Toolbox for Watershed Modeling with AnnAGNPS [Poster IN41C-2235]
This README outlines the steps to install the pyagnps package along with its GDAL dependencies.
If you don't intend to use the topagnps and subannagnps submodules, then GDAL is not necessary and you can ignore the rest of this installation tutorial. Just run:
pip install git+https://github.com/LucRSquared/pyagnps.gitAnd you're good to go! Otherwise, see below
if you can execute without errors the following line of code within your environment then go to step 4
python -c "from osgeo import gdal"If you're using Linux/macOS, you need to install the system GDAL libraries before installing the GDAL Python bindings
The installation method for GDAL varies depending on your operating system and package manager. Here are some examples:
Ubuntu/Debian:
sudo apt update # Update package lists
sudo apt install -y libgdal-dev python3-gdal # Install GDAL librariesFedora/CentOS:
sudo dnf update # Update package lists
sudo dnf install -y gdal python3-gdalHomebrew (macOS):
brew update
brew install gdalThe install_gdal.py will attempt to find a suitable wheel to install in your python environment. You can skip executing this script if you already have a prefered way to install gdal in your python environment.
-
For Linux/macOS this will install the python bindings for GDAL
-
For Windows this will download and install a GDAL wheel from Christoph Gohlke's website. If it doesn't work then God be with you, you're on your own, use your favorite search engine to figure out how to install GDAL refer to the TL;DR, that's what you want to achieve.
-
Run the following command to download and execute the
install_gdal.pyscript:
curl -fsSL https://raw.githubusercontent.com/LucRSquared/pyagnps/master/install_gdal.py| python3 -This command downloads the script from the pyagnps GitHub repository and pipes it to the Python interpreter for execution.
Now you're ready to install pyagnps ! Just run:
pip install git+https://github.com/LucRSquared/pyagnps.gitIf the following command does not return any error then the installation is a success!
python -c "import pyagnps"Ensure you have activated your virtual environment (if you're using one) before running these commands.