SPHY Tutorial
SPHY Tutorial
First of all, for the installation of SPHY model we need some tools and software to run the
model. For additional software and tool go through the SPHY website to download the
necessary files.
1. Go to start, then control panel, and type environment in the top-right search window.
2. Click on “Edit the system environmental variables”.
3. Click “Environmental Variables” in the bottom-right of this window.
Tutorial for SPHY installation
4. Under system variables, select the Path variable and click “Edit”.
5. In order let your system know the existence of your Python installation, it is required
to add your Python installation folder to the “Path” system variable, which was the c:\
Python27 installation folder.
6. Finally, click OK and complete the installation of Python.
Numpy 1.8.0 32-bit
SPHY requires a Numpy version that works with the 32-bit version of Python 2.7.6, which is
Numpy 1.8.0 32-bit. it can be installed by double-clicking on downloaded .exe file. If Python
2.7.6 has been installed correctly in the previous step, then the Python installation folder will
be found automatically during the installation of Numpy.
PCRaster
SPHY v2.0 is based on the 32-bit system architecture, and therefore requires the 32-bit
PCRaster 4.0 or 4.1 version.
PCRaster is installed manually in your system. To install PCRaster 4.0, it is mandatory to
have successfully installed Python 2.7.6 and Numpy 1.8.0 during the previous two steps. To
install PCRaster you need to perform the following steps:
1. Create a new folder on your hard disk where you prefer to install PCRaster. For
example: c:\Program Files (x86)\PCRaster
2. Unzip the contents from the pcraster.zip file
3. To let your system recognize the existence of PCRaster, the Environmental Variables
need to be updated again. The steps to get to your system Environmental Variables
are shown in previously in python installation.
4. It is now required to add the “bin” directory of the extracted PCRaster package to the
“Path” system variable. The folder is: c:\Program Files (x86)\PCRaster\bin\
5. Click OK.
6. The next step involves setting the PYTHONPATH environment variable. In the same
system variables window check the existence of a PYTHONPATH variable. If it
exists, then edit the variable by adding the path of the Python directory of the
extracted PCRaster package, which is in our example: i.e c:\Program Files (x86)\
PCRaster40\python\
7. Otherwise click “New” to create it, and add PYTHONPATH as Variable name, and
add the Python directory folder as the Variable value.
8. Click OK and OK to complete the installation of PCRaster.
9. The successful installation of PCRaster can be tested as follows:
a) Open a command prompt
b) Type pcrcalc
c) You should see the command prompt
SPHY v2.0 source code
The SPHY v2.0 source code can be downloaded from SPHY website. The source code is
available as a zip-file (SPHY2.0.zip) and needs to be extracted to a folder on your hard drive.
In our case we created the folder c:\SPHY and unzipped the contents of SPHY2.0.zip to this
Tutorial for SPHY installation
PRE-PROCESSING
1. Launch QGIS 2.8.2 Desktop, Open the ‘SPHY pre-processor’
3. Go to General Settings Tab. Here, select all the required directories first, and then
specify the ‘UTM zone’ and ‘Meteorological forcing period to process’.
4. Area selection’ Tab
5. Using ‘Click to select area’ feature, draw a Rectangular area to select your Region.
Here, you can take the help of your area’s shapefile, if you already have it.
Tutorial for SPHY installation
6. Set spatial resolution, Re-calculate area properties and Create model clone.
7. Modules Tab – Select all the relevant ‘Modules to process’ and then click on ‘Create
initial maps’
Use ‘Toggle Editing’ option to edit and created file and add point features
Now, just browse and select your outlets shapefile and then click on ‘Delineate basin’.
9. Create Station
Same as previous step create a new shapefile and named it as “stations” and save the
shape file according to your area of UTM zone.
Then, just browse and select your stations shapefile, and then click on ‘Create stations’.
For the meteorological forcing, you may use your self-compiled temperature and precipitation
data from any source (preferred) or you may even use the default data provided in the
‘Database’. Finally click on ‘Create forcing’ to start the generation of forcing data.
Tutorial for SPHY installation
2. Climate tab: Select prec, tavg, tmax and tmin map from forcing folder
4. Groundwater tab: Set as default or you can change according to your area
5. Land used tab: Select Lulc.map and kc.tbl (kc.tbl is give in datasets)
9. Reporting options: select output components which are interesting for you.
10. Run Model: Select PCRaster bin folder and python.exe file
Tutorial for SPHY installation
The Python versions and packages for the SPHYv2.1.1 install are as follows:
Python = 2.7 (Anaconda)
PCRaster = 4.1.0 (Manually)
SPHY = 2.1.1 (Anaconda)
Numpy >= 1.16.2 (Anaconda)
Pandas >= 0.20.1 (Anaconda)
It is recommended to use Anaconda Python distribution to install and manage all the
environments and packages inside your computer. All the packages in exception to PCRaster
can install using Anaconda.
First you have to install anaconda to create environment variable to perform sphy
Installation of python, Numpy, and Pandas, gdal with Conda.
1.- Open anaconda command prompt.
2.- Create a new environment called “sphy” and install python, Numpy Pandas and gdal The
Python version 2.7 is required.
Command: conda create --name sphy -c conda-forge python=2.7 numpy pandas gdal
The manually Installation of PCRaster was already discus in previous steps during the
installation of additional software.
Check the installation of sphy environment to Activate the sphy environment.
Command: conda activate sphy
Activate Python
Command: python
Import PCRaster
Command: from pcraster import *
If all the commands run without error, we can go for installation of SPHY model.
Finally install SPHYv2.1.1
Close the conda command prompt, open again and activate the environment.
Command: conda activate sphy
Installing the SPHY
Command: conda install -c WilcoTerink SPHY=2.1.1