Wednesday, September 16, 2015

Links to cool pages on plotting with python

A very interesting blog on python there:

A package to plot interactively:

And don't forget the impressive Mayavi package:

The Seaborn library is useful to make some nice plots:

A kind of summary of some of these different solutions is made there:

Monday, December 1, 2014

Nice book on python, numpy, ipython etc...

A very up-to-date (august 2014) electronic book on python named "Introduction to Python for Econometrics, Statistics and Data Analysis" from Kevin Sheppard is available here:
It's mainly on econometric, but most of the tools described there are also useful for astronomers.

Tuesday, November 11, 2014

Sending requests to MySQL and receiving the result from python, using PyMySQL

 Modern astrophysics is using every day more big databases. One of the mostly used interface to databases is MySQl (or its recent free fork MariaDB). I present in this lecture a python library to deal with MySQL databases: PyMySQL. In the lecture the examples are using access to 3MdB (, which requires a password. You can ask for it to me, or adapt the example to connect to other databases.
The lecture is here:

An introduction to MySQL can be found here:

Wednesday, October 8, 2014

Optimization, calling Fortran

2014 Python Lecture. Part IX

In this latest lecture of this series, I'll present some tools to optimize your code by CPU and memory profiling. It also contains some tips on using the python debugger.
The notebook is there:

I also give some indications on how one can call Fortran routines from within python, to accelerate the execution of some part the the code.
Here are small examples:

Wednesday, October 1, 2014

Object Oriented Programing. Objects, classes, etc...

2014 Python Lecture. Part VIII

In this lecture I'll introduce the basic (and some not that basic) concepts of Object Oriented Programing. I'll use an example to show how to:
  • use functions to do simple jobs
  • but use objects when things start to be more complex
  • define classes, objects, attributes, methods, etc...
  • use *args and **kwargs in functions calls
  • use the class variables
  • add functionalities to classes and objects
  • use class inheritance
  • use attributes properties
The notebook is here:

Thursday, September 25, 2014

The astropy library

2014 Python Lecture. Part VII

The Astropy Project is a community effort to develop a single core package for Astronomy in Python and foster interoperability between Python astronomy packages. More informations here:

In this lecture we will see some of the facilities of the astorpy library, including:

  • Constants and Units
  • Data Table (a very useful one!)
  • Time and Dates
  • Etc...

The lecture is here:

Thursday, September 18, 2014

Useful libraries

2014 Python Lecture. Part VI

This lecture will give some insights to the most useful python libraries. It is NOT exhaustive, you have to read the corresponding manual pages to find the best use you can have of them. The list of all python-included libraries is here:

I mention in this lecture:

  • time and datetime
  • timeit
  • os
  • sys
  • subprocess
  • glob
  • re
  • urllib2
The lecture is here: