The Python programming language is increasingly popular. It is a versatile language for general purpose programming and accessible for novice programmers. However, it is also increasingly used for applications in the domain of scientific computing. This training introduces modules that are useful in that context.
Learning outcomes
When you complete this training you will
- be able to use numpy to represent and compute with multidimensional arrays;
- have an overview of the scope of scipy;
- be able to create data visualizations with matplotlib and bokeh;
- be able to use sympy to do symbolic computations;
- be able to represent and manipulate data in HDF5 format;
- know how to start on an image or video manipulation project.
Schedule
Total duration: 4 hours.
| Subject | Duration |
|---|---|
| introduction and motivation | 5 min. |
| numpy | 80 min. |
| scipy | 25 min. |
| coffee break | 10 min. |
| matplotlib & bokeh | 30 min. |
| sympy | 25 min. |
| HDF5 | 40 min. |
| scikit-image & OpenCV | 20 min. |
| wrap up | 10 min. |
Training materials
Slides are available in the GitHub repository, as well as example code and hands-on material.
Target audience
This training is for you if you need to use Python for scientific computing.
Prerequisites
You will need experience programming in Python. This is not a training that starts from scratch.
If you plan to do Python programming in a Linux or HPC environment you should be familiar with these as well.
More concretely, participants should already be comfortable with the following:
- running Python code in Jupyter or from the command line;
- variables, numbers, strings, booleans, and basic containers such as lists and dictionaries;
if/elsestatements andforloops;- writing and calling simple functions with arguments and a return value;
- indexing and slicing sequences;
- importing modules and calling functions from them;
- reading short Python scripts without needing every line explained.
You do not need prior experience with NumPy, SciPy, SymPy, HDF5, or image processing. Those are part of the training itself.
Quick self-assessment
If you can do most of the tasks below without looking up basic Python syntax, you are likely ready for this training.
- write a function that returns
sin(x)for a given inputx; - loop over a list of numbers and compute their average;
- use
if/elseto classify a value as negative, zero, or positive; - extract every second element from a list or array using slicing;
- read a short function with nested loops and understand what it computes;
- import a module such as
mathand callmath.cos; - store a few values in a dictionary and retrieve one by key;
- make a small change to an example script and run it again.
If several of these items still feel difficult, the training will probably move too fast. In that case, it is better to first take a short introductory Python course or refresh the basics.
Software and access requirements
For following along hands-on, you need
- laptop or desktop with internet access.
- a system set up so you can connect to an HPC system, an account on an HPC system (e.g., VSC, CECI, …), compute credits if that is required to run jobs on the HPC system if you want to use an HPC system;
- a Python environment that can run Jupyter Lab if you want to use your own system;
- access to Google Colaboratory if you prefer not to install software.
Level of the Material
For participants who already have basic Python programming experience, the material in this training is approximately
- Introductory: 30 %
- Intermediate: 40 %
- Advanced: 30 %
These percentages describe the level of the scientific Python topics covered in the training, not the required entry level in Python itself.
Trainer(s)
- Geert Jan Bex (geertjan.bex@uhasselt.be)