Blog

A blog of Python-related topics and code.

COVID deaths and vaccination rates

The Python script below generates the following visualization of COVID deaths per 100,000 people for two classes of European country: those with less than 75% of the population vaccinated and those with at least this percentage vaccinated. The ongoing (as of January 2022) third wave of infections is causing fewer deaths in the countries with a higher vaccination rate.

The Klein–Nishina formula

The Klein–Nishina formula gives the differential cross section for the scattering of photons off an electron. At low energies, light scatters elastically (Thomson scattering); at higher energies (for example, gamma radiation), inelastic Compton scattering occurs. In terms of the incoming and outgoing photon wavelengths, $\lambda$ and $\lambda'$:

Manufacturing Cobalt-60

Lecture 12 of the MIT course 22.01: Introduction to Nuclear Engineering and Ionizing Radiation covers the manufacture of $\mathrm{^{60}Co}$ by neutron irradiation of $\mathrm{^{59}Co}$ in a research reactor. The thermal neutron absorption cross section of $\mathrm{^{59}Co}$ is $\sigma_0 \approx 20 \; \mathrm{barn}$, so for a neutron flux $\Phi$, the rate of change of the number of $\mathrm{^{59}Co}$ nuclei, $N_0$, may be written $$ \frac{\mathrm{d}N_0}{\mathrm{d}t} = -\sigma_0 \Phi N_0 \quad\Rightarrow N_0(t) = N_0(0)\mathrm{e}^{-\sigma_0\Phi t} $$

Changing the palette of an image

A short script to reduce the palette of an image and replace it with random colours, using the image mona_lisa_400.jpg.

Floyd-Steinberg Dithering

Floyd-Steinberg dithering is a technique for reducing the colour palette of an image (for example, to reduce its file size) whilst keeping as much of the perceived detail as possible. For each pixel in the original image, the nearest colour to that pixel is chosen from a restricted palette and any "error" (difference in pixel colour value, original - new) is distributed across the neighbouring pixels as follows: