Branch | Status | Docs |
---|---|---|
master |
Shyft is an OpenSource hydrological toolbox developed by Statkraft. It is optimized for highly efficient modeling of hydrologic processes following the paradigm of distributed, lumped parameter models -- though recent developments have introduced more physically based / process-level methods.
The code is based on an early initiative for distributed hydrological simulation , called ENKI funded by Statkraft and developed at Sintef by Sjur Kolberg with contributions from Kolbjorn Engeland and Oddbjorn Bruland.
Shyft's primary end-user documentation is at Shyft readthedocs, where you will find instructions for installing Shyft and getting up and running with the tools it provides.
We also maintain this README file with basic instructions for building Shyft from a developer perspective.
IMPORTANT: While Shyft is being developed to support Linux and Windows platforms, it should be noted that the instructions contained in this README are geared toward linux systems. Users will generally want to readthedocs first.
Shyft is developed by Statkraft, and the two main initial authors to the C++ core were Sigbjørn Helset [email protected] and Ola Skavhaug [email protected].
Orchestration and the Python wrappers were originally developed by John F. Burkhart [email protected]
Contributors and current project participants include:
- Sigbjørn Helset [email protected]
- Ola Skavhaug [email protected]
- John Burkhart [email protected]
- Yisak Sultan Abdella [email protected]
- Felix Matt [email protected]
- Francesc Alted [email protected]
Shyft is released under LGPL V.3 See LICENCE
The documentation below is maintained for the purposes of Shyft development. First time users and those are interested in learning how to use Shyft for hydrologic simulation are strongly encouraged to see Shyft at readthedocs.
Shyft is distributed in three separate code repositories. This repository, shyft
provides the main code base. A second repository (required for tests) is located at shyft-data. A third repository shyft-doc is available containing example notebooks and tutorials. The three repositories assume they have been checked out in parallel into a shyft_workspace
directory:
mkdir shyft_workspace && cd shyft_workspace
export SHYFT_WORKSPACE=`pwd`
git clone https://github.com/statkraft/shyft.git
git clone https://github.com/statkraft/shyft-data.git
git clone https://github.com/statkraft/shyft-doc.git
For compiling and running Shyft, you will need:
- A C++1y compiler (gcc-5 or higher)
- The BLAS and LAPACK libraries (development packages)
- A Python3 (3.4 or higher) interpreter
- The NumPy package (>= 1.8.0)
- The netCDF4 package (>= 1.2.1)
- The CMake building tool (2.8.7 or higher)
In addition, a series of Python packages are needed mainly for running the tests. These can be easily installed via:
$ pip install -r requirements.txt
or, if you are using conda (see below):
$ cat requirements.txt | xargs conda install
Please refer to our Python Installation Guide
NOTE: the build/compile instructions below have been mainly tested on Linux platforms. Shyft can also be compiled (and it is actively maintained) for Windows, but the building instructions are not covered here (yet).
NOTE: the dependency regarding a modern compiler generally means gcc-7 is required to build Shyft.
You can compile Shyft by using the typical procedure for Python packages. We use environment variables to control the build. The SHYFT_DEPENDENCIES_DIR
defines where the dependencies will be built (or exist). When you call setup.py
the script will call cmake. If the dependencies exist in the aforementioned directory, they will be used. Otherwise, they will be downloaded and built into that directory as part of the build process. If not set, cmake will create a directory shyft-dependencies
in the shyft
repository directory. A suggestion is to set the shyft-dependencies
directory to your shyft-workspace
. If you have set these as part of your conda environment
per the instructions above, and assuming you are active in that environment, then simply:
pip install -r requirements.txt
python setup.py build_ext --inplace
NOTE: If you haven't set env_vars
as part of your conda environment, then you need to do the following:
# assumes you are still in the shyft_workspace directory containing
# the git repositories
export SHYFT_WORKSPACE=`pwd`
mkdir shyft-dependencies
export SHYFT_DEPENDENCIES_DIR=$SHYFT_WORKSPACE/shyft-dependencies
cd shyft #the shyft repository
python setup.py build_ext --inplace
It is recommended to at least run a few of the tests after building. This will ensure your paths and environment variables are set correctly.
The quickest and easiest test to run is:
python -c "from shyft import api"
If this raises:
ImportError: libboost_python3.so.1.61.0: cannot open shared object file: No such file or directory
Then you don't have your LD_LIBRARY_PATH
set correctly. This should point to:
export LD_LIBRARY_PATH=$SHYFT_DEPENDENCIES_DIR/local/lib
To run further tests, see the TESTING section below.
If the tests above run, then you can simply install Shyft using:
cd $SHYFT_WORKSPACE/shyft
python setup.py install
Just be aware of the dependency of the LD_LIBRARY_PATH so that the libboost libraries are found.
Now, you should be set to start working with the shyft documentation and ideally clone the shyft-doc repositories to work through the notebooks and learning Shyft!
Although (at least on Linux) the setup.py
method above uses the
CMake building tool behind the scenes, you can also compile it
manually (in fact, if you plan to develop Shyft, this may be recommended because you will be able to run
the integrated C++ tests). The steps are the usual ones:
$ export SHYFT_SOURCES=$SHYFT_WORKSPACE # absolute path required!
$ cd $SHYFT_SOURCES
$ mkdir build
$ cd build
$ export SHYFT_DEPENDENCIES_DIR=$SHYFT_SOURCES/.. # directory_to_keep_dependencies, absolute path
$ cmake .. # configuration step; or "ccmake .." for curses interface
$ make -j 4 # do the actual compilation of C++ sources (using 4 processes)
$ make install # copy Python extensions somewhere in $SHYFT_SOURCES
We have the beast compiled by now. For testing:
$ export LD_LIBRARY_PATH=$SHYFT_DEPENDENCIES_DIR/local/lib
$ make test # run the C++ tests
$ export PYTHONPATH=$SHYFT_SOURCES
$ nosetests .. # run the Python tests
If all the tests pass, then you have an instance of Shyft that is
fully functional. In case this directory is going to act as a
long-term installation it is recommended to persist your
$LD_LIBRARY_PATH
and $PYTHONPATH
environment variables (in ~/.bashrc
or using the conda env_vars
described above).
The way to test Shyft is by running:
$ nosetests
from the root shyft repository directory.
The test suite is comprehensive, and in addition to unit-tests covering c++ parts and python parts, it also covers integration tests with netcdf and geo-services.
Shyft tests are meant to be run from the sources directory. As a start, you can run the python api test suite by:
cd $SHYFT_WORKSPACE/shyft/shyft/tests/api
nosetests
To conduct further testing and to run direct C++ tests, you need to be sure you have the shyft-data
repository as a sibling of the shyft
repository directory.
To run some of the C++ core tests you can try the following:
cd $SHYFT_WORKSPACE/shyft/build/test
make test