day-1-2

Day 1-2

Python

Organized by Luisa Bernardinelli and Alessandra Retico
The course is aimed at teaching how to write readable and efficient scientific software using the Python language and the great tool-set it comes with. It will start from the very basics of the language before venturing into some of its more advanced features. Then, it will cover a selection of the most renowned Python libraries for manipulating, analyzing and plotting data, as well as the Scikit-learn and Keras libraries for machine learning. The contents will be addressed from a practical point of view, with the aid of many examples and guided exercises.

Day 1: Introduction and Python Primer

Introduction

  • Writing good scientific software, what to aim for
  • The Python language
  • Installing Python
  • Run your first script in Python

Python primer

  • Python basics: variables, expressions, statements, indentation and comments
  • Control flow and logical operators
  • Data structures
  • Strings and string formatting
  • File handling and context managers
  • Functions
  • Modules


The Python Standard Library


Day 2: Advanced Python, Software Development and Scientific Libraries

Advanced Python

  • Errors and exceptions
  • Variadic and keyword arguments
  • Command line argument parsing
  • Generators and iterators
  • A taste of classes and OOP


Software development in Python

  • Coding convention
  • Documentation
  • Unit testing

The scientific Python ecosystem:

  • NumPy
  • SciPy
  • Matplotlib
  • Pandas
  • Scikit-learn
  • Keras


Speaker:

Alberto Manfreda is a PostDoc researcher at INFN (Istituto Nazionale di Fisica Nucleare), Pisa. Alberto obtained a PhD in Physics in 2018 at the University of Pisa. He has worked in the field of cosmic-ray science and high-energy astrophysics as member of the Fermi – Large Area Telescope collaboration. He is currently one of the main developers of the software for the NASA Imaging X-Ray Polarimetry Explorer mission. Passionate programmer, he has been guest lecturer of advanced Python in a course of Computing Methods for Experimental Physics and Data Analysis at the University of Pisa.
Affiliation: Istituto Nazionale di Fisica Nucleare, sez. Pisa
e-mail: alberto.manfreda@pi.infn.it
Alberto Manfreda

Online resources:

Tutorials:
Free online books:
  • “Python Cookbook, 3rd Edition” by Brian K. Jones, David Beazley

Further readings:
  • “Fluent Python” by Luciano Ramalho
  • “Python for Data Analysis” by WesMcKinney