Preparatory Assignment#

This assignment is available at https://courses.gistools.geog.uni-heidelberg.de/advancedgeoscripting/preparatory-assignment

Submission by Sunday, August 4th via GitLab.

The purpose of this preparatory assignment is to make sure that you (and your computer) are well prepared for the course to avoid technical issues. In this assignment you will

  • read about best practices in scientific computing

  • install and configure all required software

  • use git to track your work progress

Important notes:

  • If you encounter problems which you cannot solve on your own, create an issue on GitLab.

  • Do NOT use whitespaces in file names! To avoid errors make sure to name the output files exactly as described.

  • Watch the videos which explain and help you with some of the exercises. The links are in the section titles marked as → [Video].

1. Best Practices in Scientific Computing#

Read the paper by Wilson et al. (2014) on Best Practices for Scientific Computing and answer the following questions. Write your answer in a Markdown file called scientific_programming.md.

Note: Read this Guide on markdown to format your file nicely.

  1. The paper describes several problems scientists face when performing scientific data analyses. From your experience in performing GIS and general data analyses, which of these problems seem familiar to you? Have you faced other problems not mentioned in the paper? (~100 words)

  2. Which methods described in the paper or which other skills, tools etc. would you like to learn to help you avoid these problems in the future? (~100 words)

  3. One of the recommendations by Wilson et al. (2014) for scientists is to use a Version Control System (VCS). Briefly explain in your own words, what the benefits of VCS are in the context of scientific analyses. (~100 words) The video What is Git? Explained in 2 Minutes! may help you understand the concept of it as well.

2. Software Setup#

Follow the instructions in Software Setup to install and configure all software that is required for the course on your computer.

3. Download the materials using git#

Note: You need the program git for this part of the assignment. See how to install it here.

git is very useful to track your work progress. To practice using it, all materials of this course will be distributed via GitLab - a platform to store and share git repositories online.

1. Introduction to git#

Watch this short video on What is Git? Explained in 2 Minutes!.

2. Fork this repository → [Video]#

Go to https://courses.gistools.geog.uni-heidelberg.de/advancedgeoscripting/preparatory-assignment. After loging in using your university credentials (i.e. Uni ID), click on the “Fork” button on the upper right corner.

Note: If there is no “Fork” Button even though you are logged in, write me an email with your Uni ID.

Afterwards, you will be redirected to your new forked repository. Its URL should be something like this (Replace test123 with your own Uni ID): https://courses.gistools.geog.uni-heidelberg.de/test123/preparatory-assignment

3. Clone your forked repository → [Video]#

Note: The video is from a previous course, so the links and files are a bit different and it is using GitHub instead of GitLab, but the principle is the same.

Execute the following command to clone your repository to your computer. Make sure to replace “test123” with your own Uni ID!

$ git clone https://courses.gistools.geog.uni-heidelberg.de/test123/preparatory-assignment.git

4. Check software#

1. Check Python environment#

Afterwards, execute check_environment.py from within your new Python environment to verify that all required packages have been installed successfully (i.e. no ModuleImportError). Using the following command the output of the program will be written to a new text file called check_environment_result.txt.

$ python check_environment.py > check_environment_result.txt

2. Check PyCharm#

Check whether the new environment is also available within PyCharm by executing the file check_environment.py from within the Python Console in PyCharm by importing and executing the check_packages function from check_environment.py.

3. Check Jupyter Notebook#

If you are not familiar with Jupyter notebooks yet, watch this tutorial video.

  1. Activate the advgeo environment, move into the main folder of your repository and start a Jupyter Notebook server.

    $ cd preparatory-assignment
    $ conda activate advgeo
    $ jupyter notebook
    
  2. Create a new Jupyter notebook using the Python 3 kernel and name it preparatory_assignment.ipynb.

  3. Import the function check_packages() from check_environment.py and execute it in order to check whether the notebook is using the right anaconda environment advgeo. If you get a ModuleImportError, check whether the right kernel is selected (Jupyter Menu: Kernel → Change kernel).

  4. Within the notebook, write a new function called list_sum(), which calculates the sum of all numbers in a list. e.g.

    >>> numbers = [1,2,3,4]
    >>> numbers_sum = list_sum(numbers)
    >>> print(numbers_sum)
    10
    

5. Track your work progress using git → [Video]#

Note: The video is from a previous course, so the links and files are a bit different and it is using GitHub instead of GitLab, but the principle is the same.

Now you will use git to upload your changes to GitLab.

1. Copy files#

In the previous exercises you have created three files:

  • scientific_programming.md

  • check_environment_result.txt

  • preparatory_assignment.ipynb

Copy these files into the main folder of your local repository, if they aren’t there yet.

2. Create commits#

Create a commit for each one of them in order to track them in your local git repository, e.g.

$ git add scientific_programming.md
$ git commit -m "added scientific_programming.md"

Do the same for the files check_environment_result.txt and the Jupyter notebook preparatory_assignment.ipynb. Don’t forget to adapt the commit messages accordingly.

3. Push to GitLab#

To push all your commits to GitLab execute

$ git push origin main

Afterwards go to your repository on GitLab and check whether your changes are visible there.

One last note: If you make further edits to your files (e.g. editing your answers to the questions) remember that you can always create new commits containing these changes and push them to your GitLab repository.

Well done, you’re ready for the course! :)#