The scientific Python stack#

Unlike MATLAB, the set of Python tools used by scientists does not come from one single source. It is the result of a non-coordinated, chaotic and creative development process originating from a community of volunteers and professionals.

In this chapter we will briefly discuss some of the essential tools that every scientific Python programmer should know about. The list is not complete. There are many more useful packages out there and you will discover many as you go along programming.

Python’s scientific ecosystem#

The set of Python scientific packages is sometimes referred to as the “scientific Python ecosystem”. There is also a Scientific Python project, whose mission it is to “better coordinate the ecoystem and support the commuity of contributors and maintainers”.

Jake Vanderplas made a great graphic in a 2015 presentation (the video of the presentation is also available here if you are interested), reproduced with slight adaptations by Fabien:

img

The core packages#

NumPy provides the N-dimensional arrays necessary to do fast computations, and SciPy adds the fundamental scientific tools to it. SciPy is a very large package and covers many aspects of the scientific workflow. It is organized in submodules, all dedicated to a specific aspect of data processing. For example: scipy.integrate, scipy.optimize, or scipy.linalg. Matplotlib is the traditional package to make graphics in Python.

Essential NumPy “extensions”#

There are two packages which are essential when it comes to processing data in atmospheric sciences:

They both add a layer of abstraction to NumPy arrays, giving “names” and “labels” to their dimensions and the data they contain.

Domain specific packages#

There are so many of them! We cannot list them all, but here are a few that you will probably come across in your career:

Geosciences/Meteorology:

  • MetPy: the meteorology toolbox

  • Cartopy: maps and map projections

  • xESMF: Universal Regridder for Geospatial Data

  • xgcm: General Circulation Model Postprocessing with xarray

  • GeoPandas: Pandas for vector data

  • Rasterio: geospatial raster data I/O

  • wrf-python: working with output from the WRF model

  • earthkit: format-agnostic interface for geospatial data, plotting weather and climate data, meteorological calculations, and more

Statistics/Machine Learning:

Miscellaneous: