A blog of Python-related topics and code.

This is just a simple script that takes an image and renders it as a grid of ASCII characters in the console. The character chosen depends on the brightness of each pixel in the image: the following sequence (from densest (brightest) to least dense) is used:

As a companion script to this one on UK monthly temperatures the Met Office's data on rainfall can be compared in a similar way. The script below produces "raincloud" plots of the monthly rainfall since 1891 for two regions of the UK: East Anglia (relatively dry) and Wales (notoriously wet). The "cloud" for each month is a kernel density estimate of the distribution of the number of days on which at least 1mm of rain falls; the "rain" is a histogram of the same data.

The UK Meteorological Office offers historical data of mean monthly temperatures in different regions of the UK for download. For the purposes of this blog post, I downloaded the data corresponding to two regions: Scotland.txt and South_England.txt.

This earlier blog post presented a way of performing a non-linear least squares fit on two-dimensional data using a sum of (2D) Gaussian functions.

Many phenomena can be described in terms of a measured variable varying exponentially with a quantity. For example, a processes such as radioactive decay and first-order reaction rates are described by an ordinary differential equation of the form