# Installation of SPHY

### General <a href="#toc534724195" id="toc534724195"></a>

SPHY v3.0 can be either be installed as i) a stand-alone application, where the user can run the model throughout the command prompt, or as ii) a an integrated application (plugin) in QGIS, where the model can be run using a Graphical User-Interface (GUI). The GUI has been developed as a plugin in QGIS\[7], and has the advantage that changing the model input and output, as well as changing model parameters, is more clear and user-friendly. Furthermore, the use of the plugin allows you to store and visualize your model input and output in the user-friendly and world-wide used QGIS Geographical Information System (GIS), which is in the public domain.The name of this SPHY model plugin is “SphyPlugin” (v1.0), and is compatible with SPHY (v3.0). The installation of the SPHY model plugin is not part of this manual and is described in the SPHY GUIs manual (Terink et al., 2015b).

This manual (Section 4.2) describes the installation of SPHY v3.0 as a stand-alone application.

### Installing SPHY as a stand-alone application <a href="#toc534724196" id="toc534724196"></a>

In order to install SPHY as a stand-alone application it is required to have a PC with a windows operating system. The software packages that are required to run the SPHY model as stand-alone application are:

1. Python 3.6, 64-bit
2. NumPy 1.8.0, 32-bit
3. PCRaster 4.2.0, 64-bit
4. SPHY v3.0 source code

These packages need to be installed in the same order as shown above, and the installation of each package is described in the following sections. The Python, NumPy, and PCRaster software packages can also be downloaded from the SPHY model website as zip-files:

[http://www.sphy.nl/software/](http://www.sphy.nl/software/)

The login credentials that are required for downloading software and data can be obtained from:

[http://www.sphy.nl/software/download-sphy/](http://www.sphy.nl/software/download-sphy/)

#### Python 3.6, 64-bit <a href="#toc534724197" id="toc534724197"></a>

SPHY requires the installation of the Python\[8] programming language. PCRaster has been developed using the Python\[9]. Since SPHY v3.0 has been developed using the 64-bit version of PCRaster 4.2.0, it is required to install the 64-bit version of Python 3.6, which can be downloaded from the internet using the link below:

[https://www.python.org/downloads/release/python-360/](https://www.python.org/downloads/release/python-360/)

After downloading Python it can be installed by double clicking the downloaded file. During installation it will be asked where to install Python. You can choose any location that you prefer. As an example to be used in this manual, we have installed Python in the folder:

c:\Python36\\

A final installation step includes setting the environmental variables. In order to do this, follow the steps below:

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 (Figure 13).
4. Under system variables, select the Path variable and click “Edit” (Figure 14).
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. This is shown in Figure 15 for our case, which was the c:\Python36 installation folder. It is important to have a semicolon between the system variables.
6. Finally, click OK and OK again in order to complete the installation of Python.

![Figure 15: System properties to set Environmental Variables.](https://1703319430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqMZcdbfMcflSgnLW9i26%2Fuploads%2FehHMnlniEWrOOQ4I2dFp%2F17?alt=media)

![Figure 16: Setting the Path variable.](https://1703319430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqMZcdbfMcflSgnLW9i26%2Fuploads%2FfXqOj39bstbUZNFavzYC%2F18?alt=media)

![Figure 17: Adding the Python36 installation folder to the Path system variables.](https://1703319430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqMZcdbfMcflSgnLW9i26%2Fuploads%2F9h7BkgXIX8O36wT4jv6p%2F19?alt=media)

#### Numpy 1.8.0 32-bit <a href="#toc534724198" id="toc534724198"></a>

Numpy stands for Numerical Python, and is a fundamental package for scientific computing with Python. It has especially been developed to work with raster data (arrays), which is also the basis of the PCRaster dynamic modelling framework in which SPHY has been developed.

SPHY requires a Numpy version that works with the 64-bit version of Python 3.6, which is Numpy 1.8.0 32-bit. This package can be downloaded using the link below:

[http://sourceforge.net/projects/numpy/files/NumPy/1.8.0/numpy-1.8.0-win32-superpack-python2.7.exe/download](http://sourceforge.net/projects/numpy/files/NumPy/1.8.0/numpy-1.8.0-win32-superpack-python2.7.exe/download)

After downloading the Numpy package, it can be installed by double-clicking on the downloaded file. If Python 3.6 has been installed correctly in the previous step, then the Python installation folder will be found automatically during the installation of Numpy. In our example case this folder was c:\Python36\ (see example Figure 16).

![Figure 18: Illustration of selecting the Python installation folder during installation of the Numpy package.](https://1703319430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqMZcdbfMcflSgnLW9i26%2Fuploads%2FP42Gqo2xBCbDGHOlRTjg%2F20?alt=media)

#### PCRaster 4.2.0 64-bit <a href="#toc534724199" id="toc534724199"></a>

SPHY is written in the Python programming language using the PCRaster (Karssenberg et al., 2001; Karssenberg, 2002; Karssenberg et al., 2010; Schmitz et al., 2009, 2013) dynamic modelling framework. PCRaster\[10] has been developed at Utrecht University. PCRaster is targeted to the development and deployment of spatio-temporal environmental models. It allows users to develop their own simulation models for applications in environmental sciences, such as e.g. hydrology, ecology, geography, etc.

SPHY v3.0 is based on the 64-bit system architecture, and therefore requires the 64-bit PCRaster v4.2. SPHY v3.0 has been built and thoroughly tested using PCRaster 4.2.0, and it is therefore recommended to download and install this stable version of PCRaster. More information about this version of PCRaster can be found at the link below:

[https://pcraster.geo.uu.nl/pcraster-4-2-0/](https://pcraster.geo.uu.nl/pcraster-4-2-0/)

In order to install PCRaster 4.2.0, it is mandatory to have successfully installed Python 3.6 and Numpy 1.8.0 during the previous two steps (Section 0 and 4.2.2). To install PCRaster 4.2.0 you need to perform the following steps:

1. Download the PCRaster version using this link:

[https://pcraster.geo.uu.nl/pcraster-4-2-0/](https://pcraster.geo.uu.nl/pcraster-4-2-0/)

1. Create a new folder on your hard disk where you prefer to install PCRaster. For example: c:\Program Files (x86)\PCRaster42\\
2. Unzip the contents of the file downloaded under 1) to this folder
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 Section 0, steps 1-4.
4. It is now required to add the “bin” directory of the extracted PCRaster package to the “Path” system variable (Figure 17). In our example it is the folder: c:\Program Files (x86)\PCRaster42\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 (Figure 18) of the Python directory of the extracted PCRaster package, which is in our example:

c:\Program Files (x86)\PCRaster40\python\\

Otherwise click “New” to create it, and add PYTHONPATH as Variable name, and add the Python directory folder as the Variable value.

1. Click OK and OK to complete the installation of PCRaster.
2. The successful installation of PCRaster can be tested as follows:
   1. Open a command prompt
   2. Type _pcrcalc_
   3. You should see the command prompt view as is shown in Figure 19
3. To test the combination of PCRaster and Python:
   1. Open a command prompt
   2. Type _python_
   3. This opens the Python interactive console
   4. Type _import pcraster_
   5. If no errors are shown, then installation has been completed successfully.

Figure 19: Adding the PCRaster bin folder to the Path system variables.

Figure 20: Editing or creating the PYTHONPATH variable for the PCRaster package.

Figure 21: Command prompt view of testing a successful installation of PCRaster after entering the _pcrcalc_ command.

#### SPHY v3.0 source code <a href="#toc534724200" id="toc534724200"></a>

The SPHY v3.0 source code can be obtained from the SPHY model website ([http://www.sphy.nl/software/](http://www.sphy.nl/software/)). The source code is available as a zip-file (SPHY3.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 SPHY3.0.zip to this folder. After unzipping the contents of SPHY3.0.zip to a folder of your preference, installation has been completed successfully. The SPHY model v3.0 source code can be downloaded directly using the link below:

[https://www.dropbox.com/sh/4o90lu7h5yhbadu/AADcc5yFzCJL\_pVGmJ3jZ2i8a?dl=0](https://www.dropbox.com/sh/4o90lu7h5yhbadu/AADcc5yFzCJL_pVGmJ3jZ2i8a?dl=0)
