Introduction
“What is the course about?”
This is a 1st year undergraduate course for geoscientists taught by Nicolas Barral and Gerard Gorman. It is designed to be a first introduction to computer programming. No previous knowledge of computer programming, or indeed computing, is assumed. We will be covering core concepts in programming which you will be able to reapply to any other programming language that you are likely to encounter in the future.
The lectures notes are written in Jupyter notebooks “ which is an open source project was born out of the IPython Project in 2014 as it evolved to support interactive data science and scientific computing across all programming languages.” It is a web-based interactive computational environment where you can combine code execution, text, mathematics, plots and rich media into a single document. In short, it’s what all the cool kids are using these days for computational and data science.
“I did not sign up for computer science - why on earth am I doing this?”
You might be asking as a geoscientist why on earth are you learning to program. You were expecting exciting field trips etc., not hours squinting at a computer screen. The fact is that computing and at least basic programming are crucial skills in nearly all fields of modern science and engineering. It has many uses in data analysis, simulation and prediction. Irrespective of what area you pursue in geoscience, you will need to do somewhere between a little and a lot of programming. Ultimately, with just the right set of basic skills, you can automate all the tedious work and get to focus on the actual geoscience/geophysics.
“Hey, the lecturer is not lecturing us!”
Let’s get this straight because it comes up every year - for a number of reasons I will not be standing in front, talking at you, for 3 hours each week. This worries some students because it does not align with the common notion of what a lecture entails. So let me explain…
For starters, in the best of circumstances the adult student can maintain focus for 15-20 minutes. Then you need refreshing or resetting. Sure you may sit passively for much longer and think you are learning/being taught but the scientific evidence says you are working sub-optimally and spend significant periods zoned out or updating facebook. Secondly, passive learning simply does not work for this course no more than it would work for learning to cycle. Computing programming is a practical skill and you mostly learn by doing it yourself. On the plus side the learning experience usually results in fewer injuries than when you learned to cycle.
For this reason we apply a form of blended learning. All the course material is online and you are expected to have read through the relevant material before a lecture. Let’s face it - you do not need me to read to you. The face-to-face lecture is based in the computer lab. There we will have a series of ~10 minute lectures to establish context/motivation, run through live examples and explore issues raised by you, the students. Most of the time you will be working through the exercises that make use of the concepts introduced in the lecture material. This should be a highly interactive experience with your peers (sometimes the best person to explain something is someone who just learned it themselves, as they are closer to your perspective), teaching assistants (we have a really good GTA/student ratio so make use of them!) and lecturer. While I have suggested a text book which you may choose to read sections of for greater understanding and entertainment - the critical aspect of the course is to complete these exercises. Just ask the students in the years ahead of you.
The exam
The exam for this course will also similarly involve a set of programming exercises. It is done in the lab just before we break for Christmas and is open book. If you do all the exercises then you can expect the exam to be trivial - last year 50% got above 70%. On the other hand if you do not to the exercises, chances are you will fail (there are things you just cannot sugar coat).
Why Python? Why not [insert whatever language] instead?
Python is a modern, general-purpose, high-level programming language. It is widely used in science and engineering and overall has a significant share of the programming market share - it has even topped 2017’s most popular programming list. It is also one of the most popular introductary teaching languages. If you need more convincing then take a look at job adverts and see what employers are looking for… Its advantages are:
- Simplicity: It is easy to read and easy to learn.
- Expressive: Fewer lines of code, fewer bugs and easy to maintain.
- Powerful: Python is not a language you grow out of. It can also be used for large projects, Big Data, High Performance Computing applications, etc.
Course material
All the course notes are online. Sample solutions to the exercises will be made available after each lecture. If you miss a lecture (short of an alien invasion this shouldn’t happen of course) then make an earnest attempt at the exercises before reading the solution or you will deprive yourself of the learning experience. Let me say this a second time as it is another one of those talking points that comes up every year; seeing Mark Cavendish cycle on TV doesn’t mean you magically learn to cycle…
Supplementary material
This course loosely follows the text book A Primer on Scientific Programming with Python, by Hans Petter Langtangen. There are many copies of the book in the library and a PDF online. As explained above, you do not have to read this book to excel in this course as the online course material is self contained. However, it is a good resource if you want to broaden your understanding of the subject.
One size does not fit all. Therefore, I encourage you to browse a few different resources suggested by students over the years (see below) which might appeal to your learning habits. Just remember to always go back and do the exercises to ensure we are all on the same page.
- Python. The official Python web site.
- Python tutorials. The official Python tutorials.
- Think Python. A free book on Python.
- Free online Python course from the Codecademy.
- Software Carpentry python course.
- Khan Academy python course.