Project 5 of 12, for Yahya
Weather History Dashboard
A weather history dashboard for the Archive wall: a century of real Met Office readings resampled into years and drawn as four honest charts on one page.
Act 5 needs a free account, so your work is saved as you go. Act 1 is open to everyone.
The brief
- YahyaWe've got a hundred years of weather and the Archive wall has one chart on it, from 1974.
- YahyaOur own station book has gaps and Fahrenheit in it, and for the wall I want a record anyone can check.
- YahyaThe Met Office's station at Stornoway goes back to 1873, far north and wet, and I want four charts on one page.
- PaulAnd honest ones, I expect.
- YahyaObviously the bars start at zero and every axis says what it measures. Anyone who wants drama can read a novel.
stornoway.csv is real: the Met Office's monthly readings at Stornoway from 1925 to 2024, one row a month: month, tmax and tmin (the mean daily high and low, degrees C), frost (days), rain (mm), sun (hours) and estimated. A few months are missing a reading. load_station is written: it reads the file with the month as a date index and adds temp, the mean of tmax and tmin.
Write six functions in dashboard.py:
yearly(station): a DataFrame with one row a year, labelled by the year as a number, and three columns:temp, the mean of the year's twelve months;rainandsun, the year's totals. A year with a month missing for a reading getsNaNfor that reading.warming_chart(ax, temps): draws onax. Take the century's average off every year, then draw three lines with a key: the differences (each year), their ten-year rolling average (ten-year average), and a line right across at 0 (century average). Labels:yearanddifference from average (degrees C).rain_bars(ax, totals): one bar a year, on a scale that starts at zero. Labels:yearandrain (mm).rain_histogram(ax, rain): how many months had each amount of rain, in bins 20 mm wide from 0 to 300. Labels:rain in the month (mm)andmonths.july_scatter(ax, station): one dot for each July with a sunshine record, its sunshine across and its temperature up. Labels:sunshine (hours)andtemperature (degrees C).dashboard(station): a figure of four axes, two by two, with each chart on one of them, a title on every chart, and a title for the whole page that names the station and the source. It returns the figure.
The headlines at the bottom are written; they save the dashboard as dashboard.png.
Stornoway, 1925 to 2024: 1200 months Warmest year: 2014 (9.52 degrees C). Coldest: 1979 (7.19 degrees C) Wettest year: 1999 (1547 mm). Driest: 1968 (800 mm) Last thirty years against the first thirty: +0.56 degrees C Left out for a missing month: temperature 1927; sunshine 1925, 1926, 1927, 1928, 2004, 2007 Saved dashboard.png
What you learn
What's in it
- A line on a chart
- Two years on one chart
- Bars, counts and dots
- Six months, two charts
- Several charts on one page
- Two panels, two scales
- Months into years
- Two at a time
- A century on one line
- Charts that don't fib
- Where the scale starts
- How Paul would do it
- Fix Caitlin's version
- Make the dashboard
- Ship it