My start
Open data without a key - and only a few true monthly values
For Sweden I first thought the integration would be very straightforward. SMHI provides the observations openly, without registration or an API key. That is genuinely pleasant: through the MetObs catalogue I can move transparently from parameters to stations, periods and individual files.
Official monthly values exist only for mean temperature and precipitation. That helps, but it is only two values. For maximum, minimum, sunshine, temperature-day counts and thunderstorm days I still have to calculate from daily or hourly data myself - exactly what has already created a lot of extra logic for other countries.
Separate observing networks
One station, several identifiers
Not every weather station measures the same things. In the station list each station therefore has several identifiers, depending on whether temperature, precipitation or sunshine hours are measured there, for example. I first have to keep these identifiers apart and assign them to the matching data.
For the different measured quantities, data from different stations then have to be combined. That matters, because otherwise it is easy to get the impression that the data are equally well distributed everywhere. In fact the number of stations differs by measured quantity.
Sunshine hours in particular are measured at only a few places. Coverage therefore differs by metric and must not be read as one uniform station network.
Parameters and quality
Official monthly values, complete days and no silent zeros
The mapper implementation deliberately separates these data by their technical origin. Parameter 22 supplies mean temperature and parameter 23 precipitation directly as official monthly values. From the daily extremes of parameters 20 and 19, temperature maximum, temperature minimum and summer, tropical, frost and ice days are calculated only when every day of a month is present.
The hourly sunshine values from parameter 10 are first summed into complete days and then into months. For thunderstorm days I use parameter 13; I describe the exact rule in the next section.
I like SMHI's quality information. Green values are checked, but yellow values must not be discarded across the board: for monthly values and daily extremes they can mean official aggregated values. The mapper therefore accepts G and Y, but does not treat missing or discarded values as null.
I do not integrate new snow. SMHI provides snow depth, but snow depth is not new snow. A difference between two snow depths would be misleading because of melting or drifting. I prefer an open metric here to an apparently complete but wrong number.
This distinction matters because a zero can be a real measurement and a missing value is simply no statement.
SMHI parameters 1 to 40
The IDs come from the official MetObs parameter catalogue. Highlighted are the values I use for Climate Chronicle.
| ID | Meaning |
|---|---|
| 1 | Air temperature, hourly value |
| 2 | Air temperature, daily mean |
| 3 | Wind direction |
| 4 | Wind speed |
| 5 | Precipitation, daily sum at 06 UTC |
| 6 | Relative humidity |
| 7 | Precipitation, hourly sum |
| 8 | Snow depth, daily value |
| 9 | Air pressure reduced to mean sea level |
| 10 | Sunshine duration, hourly sum |
| 11 | Global radiation |
| 12 | Visibility |
| 13 | Present weather / weather phenomenon |
| 14 | Precipitation, 15-minute sum |
| 15 | maximum precipitation intensity within 15 minutes |
| 16 | Total cloud cover |
| 17 | Precipitation / precipitation type, 12-hour value |
| 18 | Precipitation / precipitation type, 24-hour value |
| 19 | Daily minimum temperature |
| 20 | Daily maximum temperature |
| 21 | maximum wind gust |
| 22 | Monthly mean temperature |
| 23 | Monthly precipitation sum |
| 24 | longwave radiation |
| 25 | maximum 10-minute wind mean within 3 hours |
| 26 | Minimum temperature, 12 hours |
| 27 | Maximum temperature, 12 hours |
| 28 | Height of the lowest cloud layer |
| 29 | Cloud amount of the lowest cloud layer |
| 30 | Height of the second cloud layer |
| 31 | Cloud amount of the second cloud layer |
| 32 | Height of the third cloud layer |
| 33 | Cloud amount of the third cloud layer |
| 34 | Height of the fourth cloud layer |
| 35 | Cloud amount of the fourth cloud layer |
| 36 | lowest cloud base |
| 37 | minimum lowest cloud base within 15 minutes |
| 38 | maximum mean precipitation intensity within 15 minutes |
| 39 | Dew-point temperature |
| 40 | State of the ground surface |
Note on thunderstorm days
Special case: thunderstorm days
At first I derived thunderstorm days from parameter 13 in the normal way: only clearly documented thunderstorm codes count as a thunderstorm day. If a valid weather observation is missing, the value stays open. If a month's daily series was complete and no thunderstorm code appeared, I stored 0 - meaning "observed, but no thunderstorm".
Later I noticed in the chart that from about 1995/96 almost only zeros remained at almost all stations. According to the numbers that would mean that for years there was no single thunderstorm left across almost all of Sweden, which would of course be completely illogical. In time, though, this illogic matched the switch to the automatic station network OBS 2000.
In the SMHI blog on the automatic station network OBS 2000, SMHI describes that official distribution of the new automatic stations began on 1 August 1995 and that the network was upgraded accordingly in 1995/96. Weather observation from parameter 13 continued to be recorded after that, but thunderstorm codes are often no longer reliably detectable in it. Many stations still deliver valid weather codes without any thunderstorm evidence - and that is exactly how masses of apparent 0 values arose = apparently no thunderstorm.
That is why Sweden now has its own rule:
If a station has no single positive thunderstorm day in a year, I leave all thunderstorm monthly values of that station-year open (null), instead of treating them as thunderstorm-free (0). Only if at least one thunderstorm day occurs in the same station-year do real zero months also remain.
The rule therefore continues relatively consistently with the years before: as long as thunderstorms were still captured reasonably reliably, stations with real thunderstorm evidence - and with them their zero months - stay unchanged. Only from 1995 onwards did suddenly fewer and fewer stations report any thunderstorm day at all, even though the weather observation itself continued. That is exactly the break the rule is meant to catch, instead of pulling the country curve wrongly downwards after the network change.
Language and file formats
Swedish terms and CSV files that do not look the same
The language was again an extra research step for me. SMHI field names, parameter descriptions and quality notes are in Swedish. Terms such as present weather, representative month or quality first had to be placed securely before I could assign them correctly.
Downloading also brought technical pitfalls. The CSV files start with different header blocks depending on the measured quantity: first come details about the station and the period, and only then the actual values. The time columns are not uniform either. Monthly and daily data use time intervals, while sunshine hours and weather observations use separate date and time columns.
In addition, SMHI reports some CSV files technically as text/plain instead of CSV. The downloader still has to recognise these variants as data files, otherwise existing measurements would wrongly be skipped. That is not a fault at SMHI, but it makes a general import more work.
Download and mapper
Quick to fetch - but too large for one pass
The two periods corrected-archive and latest-months bring another compromise. The archive holds the quality-controlled history, but ends before the newest months. latest-months closes that gap, but is only provisional. I merge both and always let corrected-archive win on overlaps. New data stay visible without provisional values overwriting final archive values.
The historical bulk download should also only run sequentially. Especially the many hourly sunshine values make the first import slow. That is understandable and fair to the source, but less convenient for processing. In practice I still find Sweden pleasantly fast despite the large volume. For this retrieval SMHI does not impose tight request limits or API-key hurdles. I can therefore load the files without artificial waiting times.
In the climate-data mapper, however, I hit a hard memory limit.
The SE holding comprises several thousand SMHI CSV files; taken together that is on the order of about 50 to 80 million data rows. The hourly and weather archives weigh especially heavily, with individual files already holding hundreds of thousands of rows. As long as the mapper first reads all raw rows completely and only then aggregates them, tens of millions of observations are held in memory at once - and even with 128 GB of RAM that repeatedly caused crashes, so I never finished the full series in one pass.
The solution was a special case for Sweden: a streaming import. Each file is aggregated immediately and then discarded, instead of holding the entire holding at once. The principle may help me later with other countries as well, because hourly values in particular can be huge, and it was first needed for Sweden.
My conclusion is mixed: the open, well documented SMHI source and the official monthly values are a very good foundation. At the same time the separate observing networks, the different formats, partly different headers per metric and the limited thunderstorm observation require careful handling of coverage. Sweden was basically integrable, but smaller hurdles kept appearing that I found unnecessary, so despite those smaller hurdles I still had to adapt my mapper and downloader quite strongly to Sweden.
Sources and working material