Skip to content
gertmath edited this page Dec 9, 2016 · 55 revisions

It's not hard to run the OpenGrid code on your computer and start writing your own data analysis and visualization scripts. Just follow these steps below.

Installation as user

Linux

sudo apt-get update
sudo apt-get install python-numpy python-pandas ipython python-pip
sudo pip install -U pip
sudo pip install opengrid

Windows

For Windows users it is highly recommended to install python via a fully featured python installer. We've had good results with Anaconda, python(x,y) or WinPython. Normally, these python suites come with pip, but anaconda (also) has it's own package manager conda (which doubles as virtual environment manager). So you can now install OpenGrid with

pip install opengrid

or for anaconda:

conda install opengrid

MacOs

If you are using Mac OS X El Capitan, you might run in to some errors when running sudo pip install opengrid. This has to do with the default Python distribution on Mac using an older version of six, and it doesn't allow updates. The solution is to use a virtual environment: sudo pip install virtualenv, virtualenv venv. You can than activate this environment by running source venv/bin/activate. More info: here. Are you a user and not a developer? => Install opengrid in your new virtual environment: pip install opengrid.

Installation as developer

As developer, we don't need the opengrid package, but the source code. Then we need to install all dependencies.

Getting the source code

  1. Install git. For windows and mac, we recommend SourceTree.
  2. Fork the opengrid repo (https://github.com/opengridcc/opengrid) to your personal github account, then clone to your hard drive. Do the same thing with the tmpo-py repo.
  3. Add the paths to these repos to your PYTHONPATH environment variable. Don't put the PYTHONPATH just in your IDE, that won't work. For MacOS: you need to paste the path in your ~/.bash_profile file.

Installing dependencies

MacOs: we recommend to always work with a virtual environment (venv), click here for how to install. When in your new venv, first update pip: pip install --upgrade pip and then follow the same steps below.

A requirements.txt containing all dependencies is available in the root of opengrid. You can install all dependencies with the following command: pip install -r requirements.txt. You may have to ensure an up-to-date python installation first based on the instructions above.

Note: the instructions above may not give you the last versions of numpy, ipython, scipy etc. If you want the most recent versions, you can use the commands below:

apt-get build-dep python-numpy
pip install -U pip
pip install -r requirements.txt

Note: if you want to get rid of the "sudo pip" and you prefer not to use venv, the recommended way is to use:

pip install --user packagename

Forget installation, use docker

Docker is a container virtualization platform for linux. You can skip all of the installation steps by using docker. Should work also on mac and windows where docker is run in lightweight linux virtual machines.

Instructions:

  • Install docker
  • ./docker-build-dev.sh
  • ./docker-run-dev.sh

Notebook kernel should be running at http://IP-OF-DOCKER-MACHINE:8888/ (IP-OF-DOCKER-MACHINE should be localhost on a linux with a local docker install)

Obtaining the data

Meta information

We have a google spreadsheet with the meta-information of each participating household. This data is entered in a google form by the participants and can be accessed via a json passfile.

  • Your precious data needs a place to stay, so make a new folder named "data" in your opengrid folder.
  • Obtain the keyfile (.json) from the the opengrid website. You'll have to login on the website (through github) and only if you are a (public) contributor to the opengridcc organisation, you will be able to access this file here.
  • Save this file to the opengrid/config folder
  • Open the opengrid.cfg file and change the folder paths to your situation (depending on where you have put the opengrid and tmpo-py folder). To give an example:
[data]
folder: /Users/Gert/opengrid/data/

[houseprint]
json: /Users/Gert/opengrid/opengrid/config/houseprint-d74f58100c93.json

[tmpo]
folder: /Users/Gert/tmpo-py
data: /Users/Gert/opengrid/data/

When you have started the Jupyter notebook server (directly or through docker), you'll get a browser tab with a list of possible ipython notebooks. Start the notebook *demo_houseprint.ipynb`` to sync the data and get an idea of the houseprint functionality.

Measurement data

On the opengrid server, we currently have a few jobs running that collect the monitoring data of all participants. This data is zipped and stored on a private webserver. You can obtain this data as follows.

  • Fill in the required passwords in the opengrid.cfg file, as mentioned above
  • Start an ipython notebook in the /scripts subfolder of the opengrid codebase. You can start a notebook by opening a command window or terminal in this folder and typing "ipython notebook" or "jupyter notebook". A new window should open in your browser with a list of the notebooks available in the /notebooks folder. (In Windows, you can create (or copy a shortcut to Ipython notebook, with "starting directory" -under shortcut options- set to your /scripts folder)
  • click on the Synchronize data notebook
  • in the second cell, enter the path in which the data is to be saved (or fill it in in the config file)
  • run the notebook (in the menu: cell-->run all or type shift-enter in both cells to execute them)

Running your first script

Now you're all set to run your first script. To be sure everything is working, try running one of the existing scripts, and then start hacking the code. Do not forget that most scripts have a Settings section in one of the first cells where you can specify runtime options.