A blog of Python-related topics and code.

Computer generated contemporary art (update)

This is an update to the post from February 2016 with an improved algorithm (given below) for generating pleasing random images by sequentially shifting the colour of pixels across a canvas.

Update: the frequency of intense tornadoes

Five years ago, I wrote a blog post, "Is the frequency of intense tornadoes increasing?". Here is an updated plot, including tornadoes up to 2020 and accounting for the National Centers for Environmental Information (NCEI)'s use of the Enhanced Fujita scale – this includes the category "EFU" for tornadoes which inflict no identifiable damage.

The electric field of a capacitor

Just a quick update on this blog post on visualizing the electric field of a multipole arrangement of electric charges to visualize the electric field of a capacitor (two oppositely-charged plates, separated by a distance $d$). The code, which uses Matplotlib's streamplot function to visualize the electric field from the plates, modelled as rows of discrete point charges, is below.

Matching coloured LED combinations to a spectrum

A previous blog post provides a class, ColourSystem, which can be used to predict the colour (within some colour system) of a provided spectrum. This post uses the class to determine how to combine a number of light emitting diodes (LEDs), or other light sources with known spectra in order to produce light with a given spectrum. This task is not as simple as fitting a linear combination of the LED spectra to the given spectrum because the colour matching functions determining the tristimulus values (which, in turn model the colour perceived by the human eye) vary with wavelength and overlap. Also, LEDs emit light, so no negative coefficient in such a linear combination can be allowed.

Animated landscapes with Matplotib

Just a quick experiment in creating animated surfaces in Matplotlib. The distortions to the plane are sine waves applied in octaves with a random phase, $\phi_n$: