lundi 13 août 2012

Cours de Python

Le cours « Analyse scientifique en python » (L3/M1/M2) est disponible en ligne. Les suggestions et commentaires sont les bienvenus.

Taylor diagram

A Taylor diagram is a plot that shows the similarities of different models with respect to a given data set (correlation and RMS). It seems to be mostly used for climate models, but I've never seen it in action in astronomy fields.

I made a python/numpy/matplotlib implementation, which was then used by Michael Rawlins (from Univ. Massachusetts) to produce plots to be published in Rawlins et al., 2012. Assessment of regional climate model simulation estimates over the Northeast U.S., Journal of Geophysical Research (in review).

N.B.: do not trust this illustration for (geo)scientific purposes, but refer directly to the published version of the plot if needed.

Search for a unicode character.

If you're fed up with opening the so-called gucharmap (or any other equivalent) to look for a specific unicode character, you might be interested in this python script based on the standard unicodedata module.

$ searchUnicode.py letter lamda
Λ GREEK CAPITAL LETTER LAMDA &#923 0x39b
λ GREEK SMALL LETTER LAMDA &#955 0x3bb
ᴧ GREEK LETTER SMALL CAPITAL LAMDA &#7463 0x1d27

$ searchUnicode.py "letter lamda"
Λ GREEK CAPITAL LETTER LAMDA &#923 0x39b
λ GREEK SMALL LETTER LAMDA &#955 0x3bb

Encode intensity vector in an HSL image

I wanted to mimic emission and absorption spectra of gas lamps. One solution is to encode the spectrum intensity into a specific color component of a simple "rainbow" image, e.g.:
  • the luminance component of the HLS color system for an emission spectrum,
  • the value component of the HSV color system for a transmission spectrum.
Loading ....
The following Gist is an example in python/numpy/matplotlib, using standard module colorsys for color system conversion.