Radio header images with Python

Real signals, synthesised from scratch

6 minutes

Radio header images with Python

When I moved this site to Grav, every page and every section of the knowledge base wanted a header image. For some of them a good public‐domain photo was easy to find: a Vibroplex key, the ISS, a boy at his home‐built station in 1922. For others, like the pages about FT8, SSTV or signal reports, the usual stock photos just didn’t work. They’re either generic (a microphone in front of a blurry rig) or simply wrong, and as a radio amateur you notice that straight away.

So I made them myself, with a handful of small Python scripts. The header above is one of them: the whole 20m band on a busy day.

Don’t draw a waterfall, make one

The easiest way to draw a waterfall would be to put coloured rectangles on a dark background. It would also look fake. Instead, the scripts do what your receiver software does:

  1. Synthesise the audio of the signals: the actual tones, at the actual frequencies, with the actual timing.
  2. Add white noise, so weak signals sink into it just as they do on the air.
  3. Cut the audio into short overlapping slices and calculate the spectrum of each slice (a short‐time Fourier transform).
  4. Put the slices on top of each other, newest at the top, and give each level a colour.

The nice thing about this approach is that getting the radio part right does most of the design work. If the signal is right, the picture looks right.

FT8 signals in a WSJT-X style waterfall

Take FT8. Each signal in the picture above is a real FT8 transmission: 79 symbols of 0.16 seconds, eight tones 6.25 Hz apart, with the Costas sync pattern at the start, in the middle and at the end. The message itself is random, which looks exactly the same as a real one. The tone steps are slightly smoothed, as in the real GFSK modulation, and the signals start about half a second into each 15‐second period, give or take. Their strengths range from −22 dB, barely visible, to +8 dB, so you get the familiar mix of faint and bright traces.

A picture inside a picture

An SSTV transmission in Martin M1 in a waterfall

The SSTV header goes one step further. The script first draws a small landscape (sky, sun, hills and a field) and then sends it in Martin M1, the mode you hear most on 14.230 MHz: the calibration header, the VIS code that tells the receiver which mode follows, and then line by line the green, blue and red scans with their sync pulses. In SSTV the brightness of a pixel sets the audio frequency, between 1500 and 2300 Hz, so the landscape itself is hidden in the wobbles of the signal. Look closely at the bottom of the waterfall and you can see the VIS code just before the picture starts.

One thing I’d still like to try: writing the synthesised audio to a WAV file and feeding it to an SSTV decoder, to see whether the landscape comes out again.

Noise, on purpose

Waterfall full of man-made noise

For the page about dealing with QRM in the city, the challenge was the other way round: making it look bad in the right way. The script builds the kinds of noise many of us know all too well: a raised noise floor that slowly swells and fades (LED lighting and inverters), a comb of harmonics from a switch‐mode power supply whose frequency wanders about, a carrier drifting upwards, and broadband clicks. Somewhere in the middle, one weak FT8 signal is trying to get through.

The 20m band in the header at the top is built differently. A band 350 kHz wide is far too much to synthesise as audio, so that script builds the spectrum directly. All the details are still there, though: keyed CW at the bottom of the band, the dense FT8 block with a gap every 15 seconds, FT4 with its shorter rhythm, the NCDXF beacon on 14.100 MHz stepping down from 100 W to 0.1 W, and SSB stations that start and stop their overs.

A small joke for lost visitors

Read it from the bottom up
Read it from the bottom up

If you ever end up on a page that doesn’t exist on this site, you’ll see this waterfall. It’s a very slow Morse signal, one dot every two seconds as in QRSS, sending “404”. To make it look like a real capture, the signal drifts a little and fades in and out, there’s a weak carrier and a faint unrelated station next to it, and a few static crashes cut right across. Because the newest line is at the top, you read it from the bottom up. Read it from the top down and it says “606”. That one is for the CW operators.

Drawn, not synthesised

Not everything is a waterfall. A few headers are drawn, but with the same rule: it should be correct.

S-meter scale with the needle at S7

The S‑meter has the classic amber backlit face, S1 to S9 in black and the part over S9 in red. The scale is a small piece of a very large circle whose centre lies far below the picture, which gives that gently curved arc of a real meter. Everything is drawn at three times the final size and then scaled down, so the lines come out smooth.

Smith chart with the impedance sweep of an antenna

The Smith chart is calculated rather than drawn: every circle on it is a line of constant resistance or reactance, and the antenna’s impedance sweep goes through the same formula. Because the banner is so wide, only the middle strip of the chart is visible, which I think makes it more interesting than the whole circle.

ADIF record of a QSO with PI4DX

The ADIF record is a real QSO from my log: PI4DX on 40m FT8, in May 2023. The length in each field tag is calculated from the value, so the record in the picture is valid ADIF. If you’d like to know what all those tags mean, have a look at ADIF in a nutshell.

Make your own

Every script has a seed: a number that decides how all the random parts turn out, from the noise to the position of each FT8 signal. Change the seed and you get a new picture, with the same character. The header at the top of this page is the same script as the one on the band plans page, with only a different seed.

Feel free to use the scripts for your own site, a presentation for your club, or just to play with. They’re written to be read: each one starts with an explanation of what it draws, and the code is commented along the way.

Script What it draws
ft8_waterfall.py WSJT‑X style waterfall full of FT8 signals
sstv_waterfall.py An SSTV picture coming in, in Martin M1
qrm_waterfall.py A waterfall full of man‐made noise
band_waterfall_20m.py The whole 20m band: CW, PSK31, FT8, FT4, beacon and SSB
qrss_404.py Slow Morse sending “404” (or any digits you like)
s_meter.py Analogue S‑meter scale, with the needle wherever you want it
swr_sweep.py SWR sweep of a 20m antenna
smith_chart.py Smith chart with the impedance sweep of an antenna
adif_record.py One QSO as an ADIF record

You need Python 3 with NumPy and Pillow (pip install numpy pillow), plus Matplotlib for the Smith chart. A README in the download explains the options; --help on any script does the same.

Download the scripts (zip, 24 kB). They’re released under the MIT licence: free to use, change and share. A link back to this site is appreciated, but not required. And if you make something nice with them, I’d love to see it via the contact page.

Previous