Skip to content

requirements

Will Usher edited this page Dec 2, 2019 · 1 revision

Software requirements and setup the stand-alone version of OnSSET

-- Afghanistan Demo --

OnSSET Software Requirements

ArcGIS

ONSSET is a spatial electrification tool and as such highly relies on the usage of Geographic Information Systems (GIS). A GIS environment is therefore necessary for two main reasons:

Extract trivial characteristics for the electrification analysis from GIS layers and combine them all together in a format easy to read by the python code (a .csv file with all the attributes per population point).

Visualize the final results in maps.

In the current stage, OnSSET relies on ArcGIS[^1], however any alternative open source GIS environment can be used (e.g. QGIS^2, SAGA and/or GRASS).

Python - Anaconda package

OnSSET is written in python, an open source programming language used widely in many applications. Python[^3] is a necessary requirement for the OnSSET tool to work.

Programming in python usually relies on the usage of pre-defined functions that can be found in the so called modules. In order to work with OnSSET, certain modules need to be installed/updated. The easiest way to do so is by installing Anaconda, a package that contains various useful modules. Anaconda includes all the modules required to run OnSSET successfully.

Python Interfaces - Integrated Development Environment (IDEs)

PyCharm

Integrated Development Environments are used in order to ease the programming process when multiple or long scripts are required. There are plenty IDEs developed for Python (you can find a few here [http://noeticforce.com/best-python-ide-for-programmers-windows-and-mac]{.underline}). KTH dESA has been using PyCharm as the standard IDE to run OnSSET.

a) Jupyter notebook (via Anaconda)

Jupyter notebook is a console-based, interactive computing approach providing a web-based application suitable for capturing the whole computation process: developing, documenting, and executing code, as well as communicating the results. Jupyter notebook is used for the online OnSSET interface, recommended for small analyses and exploring code and results.

GitHub

GitHub is a web-based Git repository hosting service. It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project. OnSSET is an open source tool therefore the code behind it is open and freely accessible to any user. The code behind OnSSET tool is called "PyOnsset" and is available in KTH dESA's Github space. A GitHub account will allow you to propose changes, modifications and upgrades to the existing code. Access KTH dESA'a Github repository here: https://github.com/KTH-dESA.

Software installation and setup

Download Anaconda [here]{.underline} and install.

Please make sure that you download the version that is compatible with your operating system (Windows/MacOS/Linux - In case you run Windows open the Windows Control Panel System and Security System Check e.g. Windows 32-bit or 64-bit).

Following the installation process make sure that you click on the option "Add Python X.X to PATH". Also by choosing to customize the installation, you can specify the directory of your preference (suggest something convenient e.g. C:/Python35/..).

After the installation you can use the Anaconda command line (search for "Anaconda Prompt") to run python. It should work by simply writing "python" and pressing enter, since the path has already been included in the system variables. In case this doesn't work, you can either navigate to the specified directory and write "python" there, or add the directory to the PATH by editing the "environment variables".

Download PyCharm [here]{.underline} and install.

Please make sure that you download the version that is compatible with your operating system. Select the "Community", open-source version.

Download the code from GitHub [here]{.underline}.

Select "Download ZIP" from the {width="1.0624814085739283in" height="0.15977252843394577in"} tab and save the zipped folder on your Desktop. Unzip it and open the "Afghanistan_PyOnSSET" folder. If not already there, create a folder and name it "run". This folder will contain the final output with the results.

Download the "Afghanistan.csv" dataset from [here]{.underline} (to be updated) and save it in "~/PyOnSSET-master/Afghanistan_PyOnSSET/db".

PyCharm configuration and running the code

{width="0.60625in" height="0.19930555555555557in"}Once you have successfully completed all the previous steps, open PyCharm.

Select and then select "~/Desktop/PyOnSSET-master/Afghanistan_PyOnSSET" as {width="2.5652777777777778in" height="1.863888888888889in"}your working directory as shown below (Fig. 1).

Go to File Default Settings Project Interpreter and from the drop-down list select the Anaconda directory which we installed in the previous steps. Once all the packages load, click Apply and OK {width="6.5in" height="0.9645833333333333in"}(Fig. 2).

Once you have set your working directory, select "pyonsset", and from the drop-down menu {width="1.4604166666666667in" height="1.8027777777777778in"}double-click on a) onsset.py and b) runner.py in that order, in order to open them (Fig. 3).

Now that you have opened "onsset.py", right-click on its tab and click on "Create/Select 'onsset'..." (Fig. 4).

In the configuration window, make sure that the Anaconda interpreter is selected in the "Python interpreter" option before you click OK (Fig. 5).

You are ready to run "onsset.py" by clicking the Run button at the upper-right corner of your window (Fig. 6)

Repeat the same steps explained above for "runner.py" only if you get a "Process finished with exit code 0" message in the built-in console. Otherwise, move to step 5 before you run {width="5.1375in" height="1.2375in"}{width="1.9701388888888889in" height="3.4791666666666665in"}"runner.py".

{width="2.8194444444444446in" height="0.3472222222222222in"}

5. After running a python script, the output is shown in the console built in PyCharm.

If you get a "Process finished with exit code 0" message, that means that everything worked OK.

Otherwise, the console shows messages with errors or warnings. In case you get a "Module Not Found Error" message, that means that a module or package is missing.

Installing/updating modules and packages

1) Using Anaconda

Search for "Anaconda Prompt" in your Windows Search. In the command line, type :

conda install <package name>

and the installation/update will go through automatically. (Note: In the Proceed ([y]/[n])? prompt, type "y").

{width="6.5in" height="2.470138888888889in"}e.g. installation of module "pyproj" (Fig. 7)

2) pip

pip is a package management system used to install and manage software packages written in Python. Search for "Command Prompt" in your Windows Search. Using the command line, navigate to your Python directory and then type "pip" and enter. This will show you all the possible choices you have within pip. In order to update pip itself you can just type (Fig. 8):

pip install --upgrade pip

Picture 2{width="6.5in" height="1.8652176290463691in"}

In order to install any additional module required you can type:

pip install <package name>

e.g. installation of module "matplotlib" (Fig. 9)

pip install matplotlib

Picture 3{width="6.251303587051619in" height="1.4434437882764655in"}

6. Once you have successfully finished with the debugging process (module installation etc), and while "runner.py" is running, you will be asked to type in the appropriate input so that you get your final results (Fig. 10).{width="6.25111220472441in" height="1.965980971128609in"}

NOTES:

Please make sure to:

  • Not edit or modify in any way your input/output .csv files unless required.

  • Close any open .csv files before running the programs.

Additional Info

Basic navigating commands for DOS (cmd) can be found [here]{.underline}.

[Modules]{.underline} and [packages]{.underline} installation documentation from [python.org]{.underline} .

[^1]: Find instructions for a free trial installation of ArcGIS in the following link:

[[http://www.esri.com/landing-pages/software/arcgis/arcgis-desktop-student-trial]{.underline}](http://www.esri.com/landing-pages/software/arcgis/arcgis-desktop-student-trial)

[^3]: Python itself can be downloaded and installed for free using the official website: [https://www.python.org/downloads/]{.underline}

Clone this wiki locally