Home » Blog
date 21.Jul.2024

■ Python web scraping for average wind speed


Aeolus is the most petulant of all minor gods (due to traumatic upbringing no doubt), tormenting us kite surfers with unpredictable and ever variable winds. If the wind speed is below 15 kts then we stay home and write blogs; above 15 we're happy. However we also need to know the magnitude of the wind to decide on the correct kite size to take to the beach (smaller for windier days).

I am living close to a "big" kite surfing beach near Softades (Cypriots are scared of kites and they confine us to specific areas by law). There are 2 websites with live weather data for said beach, kitemed that doesn't work at all, and kahuna. The problem with the latter is that it reports instantaneous wind speed, whereas one needs averages to mask out gusts and random variations. I tried in vain to explain to kite shack proprietors the importance of statistics, so I decided to web-scrape and calculate averages myself.

web scraping wind information

Using a Python library called Beautiful Soup you can break down the HTML tree that is the source of any webpage and read parts of interest. Examining Cahuna's weather page with my browser's Developer tools reveals that the wind data are in this element:

<span class="block text-red p--xl">4.7 knots</span>

The idea is to write a small Python program that reads the (instantaneous) wind speed once a minute, and then average and present the result over 5 minutes. Here is the code (jupyter notebook)

Click to download Python wind scraper (3 KB)

You need something like Anaconda to run this jupyter notebook

The user interface isn't much to look at, it merely prints out wind speeds as it reads them once a minute, and eventually reports the important average speed like this:

17.5 19.4
17.3 19.4
17.1 19.4
16.9 18.5
17.3 19.4
17.9 19.4
1-minute samples: 5 max gust: 19.4
average knots: 17.333 (std deviation: 0.344)

Based on this scientific evidence, for today I'll need my 12 meter kite. See you later!

Post a comment on this topic »


©2002-2024 ZABKAT LTD, all rights reserved | Privacy policy | Sitemap