Welcome
Contents
Welcome#
Lecture notes of the master lecture 707716 - Scientific Programming, taught to 1st semester students following a Master in Atmospheric Sciences curriculum from the Department of Atmospheric and Cryospheric Sciences (ACINN) at the University of Innsbruck.
Warning
This website is from an old course (WS 2021). Visit http://fabienmaussion.info/scientific_programming for the recent version.
This lecture is tailored for a 15 weeks-long class, but these notes might also be of interest to other (geo-)scientists wanting to learn the fundamentals of scientific programming. Welcome to you all!

Learning outcomes#
This class aims at teaching modern programming techniques for (geo-)scientists. After completing the class, attendees will be able to program in a structured, extendable and reproducible manner. They will become familiar with a modern and open-source programming language (Python) and will be able to read and write python programs of medium complexity. They will be able to search for, understand, install and take advantage of existing packages and libraries available in the rich scientific Python ecosystem. They should understand how numbers are handled by computers and be aware of numerical accuracy errors as well as simple performance considerations (vectorization). Furthermore, they will get acquainted with various programming tools (IDEs, debugger, unit testing, open development practices).
The course encompasses the following topics, developed by means of concrete examples and practicals:
Introduction to Linux
General programming concepts, differences between compiled and interpreted languages
Revisiting and formalizing basic programming structures (e.g. loops) and learn more advanced ones (e.g. context managers)
Semantics: precise vocabulary in order to ask questions “the right way” (see Getting help).
Numerics: floating point numbers, N-dimensional arrays
Software structure: packages, modules, functions, scripts
Object oriented programming: fundamentals, usage, and basic design patterns
Code testing with pytest
Short overview of major scientific python packages
Real world applications!
Important!
This course is very dense (especially if you don’t have much prior experience with python), but it won’t make of you a “fully accomplished programmer”. For one, there is no such thing, but more importantly: programming is best “learned-by-doing”.
My main objective for this course is to get you prepared to learn independently about the more advanced tools you’ll need for the rest of your studies and professional life.
Prerequisites#
The targeted audience for this lecture are students at the master level with previous experience in programming. No prior knowledge of python is required, but I’ll assume that you are familiar with a similar language (Matlab, IDL, R…) and basic programming structures (loops, functions, conditional blocks…). Ideally you will have the programming level of a student having completed Chapters 1 to 10 from the “Programming for Everybody” lecture by Dr. Charles R. Severance.
How to use these notes#
These notes are written as a companion to the lectures. During class I will go through the major concepts (using slides or the good old blackboard), and you can use these notes for independent learning.
They are actualized on the go, as this course advances. I am trying to write them in such a way that they are understandable without actually attending the course, but I strongly recommend to participate to both the lectures and the practicals.
The notes are a mix of examples and small exercises for you to try at home. They are written in Jupyter Notebooks. If you want to run the lecture’s code yourself, you can:
copy-paste the code of the lecture in a python interpreter and repeat the steps yourself (recommended for beginners)
run the notebooks online in an interactive window, by clicking on the “Launch Binder” button on the top-right of this page. For a primer on Jupyter Notebooks and MyBinder, visit OGGM-Edu.
download the jupyter notebooks from the course’s repository and run them on your computer (recommended after you have become more familiar with Jupyter Notebooks1).
Tip
When you will be going through the examples of these notes, some sentences are marked in bold: this underlines their importance for the course. When single words are bold this symbolizes new programming concepts or definitions: they need to be understood (and googled if needed).
Grading#
The lecture will be graded based on three assessments:
a mid-term group project (the
climvis
package): 40%an oral examination at the end of the semester: 60%
A positive evaluation of each of these elements is mandatory to pass the class!
The climvis
package itself will be graded as a group work (50%) and individual contribution (50%).
There will be bonus points for pointing me to typos / mistakes / broken links / incomprehensible or difficult passages in the lecture notes.
Each week there will be an assignment (unless specified otherwise, e.g. during the group projects). These assignments can be worked through alone or in groups. Each week, I will ask one volunteer group to present their results to the rest of the class on the following week.
The class grants you 5 ECTS if successfully passed: in theory, this represents 8 to 10 hours work per week (not including holidays). For this course, it means that you will spend at least twice as much time doing homework than sitting in class.
Getting help#
Seeking for information online is necessary and helpful for programmers of any level. I would even argue that the best programmers are the ones who know how to efficiently find information online.
When encountering an issue, the first question you should ask yourself is: “am I the only person likely to be affected by this problem?”. The answer will be no in 99% of the cases. For these, here is a list of recommendations:
Stack Overflow is THE place for programming questions. Thanks to community based moderation rules, the good questions are more visible than bad ones, and good answers are rewarded. Take a tour of the site’s principles, and look for similar questions before asking your own one.
Learn to ask the right question to your search engine. Naming this the correct way (semantics) is one of the objectives of this lecture, and I hope that in the end you will not only write better code, you will also speak the programming language a little better.
If every other thing fails (i.e the remaining 1% of the cases), then:
Ask a friend
Ask your professor
Ask a question on Stack Overflow. Before doing so, read what a Minimal, Complete, and Verifiable Example is and try to stick to these recommendations.
If you think you discovered a bug, than report it to the library directly. Almost all the scientific python packages are hosted on GitHub: the “issues” tab is where to report bugs. Read the excellent Craft Minimal Bug Reports article from Matt Rocklin before doing so.