By Christian Hill
Cambridge University Press
Science cannot be accomplished nowadays without the help of computers to produce, analyse, treat and visualise large experimental data sets. Scientists are called to code their programs using a programming language such as Python, which in recent times has become very popular among researchers in different scientific domains. It is a high-level language that is relatively easy to learn, rich in functionality and fairly compact. It includes many additional modules, in particular scientific and visualisation tools covering a vast area in numerical computation, which make it very handy for scientists and engineers.
In this book, the author covers basic programming concepts – such as numbers, variables, strings, lists, basic data structures, control flow, and functions. It also deals with advanced concepts and idioms of the Python language and of the tools that are presented, enabling readers to quickly gain proficiency. The most advanced topics and functionalities are clearly marked, so they can be skipped in the first reading.
While discussing Python structures, the author explains the differences with respect to other languages, in particular C, which can be useful for readers migrating from these languages to Python. The book focuses on version 3 of Python, but when needed exposes the differences with version 2, which is still widely in use among the scientific community.
Once the basic concepts of the language are in place, the book passes to the NumPy, SciPy and Matplotlib libraries for numerical programming and data visualisation. These modules are open source, commonly used by scientists and easy to obtain and install. The functionality of each is well introduced with lots of examples, which is clearly an advantage with respect to the terse reference documentation of the modules that are available from the web. NumPy is the de facto standard for general scientific programming that deals very efficiently with data structures such as unidimensional arrays, while the SciPy library complements NumPy with more specific functionalities for scientific computing, including the evaluation of special functions frequently used in science and engineering, minimisation, integration, interpolation and equation solving.
Essential for any scientific work is the plotting of the data. This is achieved with the Matplotlib module, which is probably the most popular one that exists for Python. Many kinds of graphics are nicely introduced in the book, starting from the most basic ones, such as 1D plots, to fairly complex 3D and contour plots. The book also discusses the use of IPython notebooks to build rich-media documents, interleaving text and formulas with code and images into shareable documents for scientific analysis.
The book has many relevant examples, with their development traced from both science and engineering points of view. Each chapter concludes with a series of well-selected exercises, the complete step-by-step solutions of which are reported at the end of the volume. In addition, a nice collection of problems without solutions are also added to each section.
The book is a very complete reference of the major features of the Python language and of the most common scientific libraries. It is written in a clear, precise and didactical style that would appeal to those who, even if they are already familiar with the Python programming language, would like to develop their proficiency in numerical and scientific programming with the standard tools of the Python system.