Saturday, February 16, 2019

NOAA weather data

Resources discussed in this post:

This post is just about using public weather data to display a temperature in my windowing environment, but at some point I’d like to use it as a jumping off point for more deeply exploring the available data. It’s really cool how much of this stuff is available as simple text files and the like. Your tax dollars at work, but in a good way.

I use xmonad for window management, and along with it a simple status bar called xmobar.

xmobar offers some monitoring plugins that display various bits of system status and other things. One of them is a weather plugin that can grab temperature and other values from NOAA-supplied weather data. I’ve been using the temperature from a METAR site at Denver International Airport, code KDEN, but I wondered if there was something closer to home available.

I always have the vague sense that there’s a ton of public weather data like this out there, but I don’t have a very good mental map of where it lives and I usually wind up fumbling around until I hit a directory full of text files on some FTP site. The docs for xmobar also aren’t very clear on what the station codes actually reference.

Some notes follow for the next time I’m thinking about this.

xmobar’s weather plugin (source on GitHub) uses decoded METAR station data, available in text files from The path to the site is, at this writing, hardcoded in the plugin.

METAR itself (“Meteorological Aerodrome Reports”) is evidently a standard that’s been around since 1968 in some form. The data looks something like this:

$ curl --silent
2019/02/16 21:48
KDEN 162148Z 36016G27KT 1 1/2SM -SN BKN022 OVC026 M02/M05 A2952 RMK AO2 PK WND 36027/2142 WSHFT 2118 SNB2057 P0000

And NOAA also offers decoded versions, which is what xmobar is parsing:

$ curl --silent
DENVER INTERNATIONAL AIRPORT, CO, United States (KDEN) 39-52N 104-40W 1640M
Feb 16, 2019 - 04:48 PM EST / 2019.02.16 2148 UTC
Wind: from the N (360 degrees) at 18 MPH (16 KT) gusting to 31 MPH (27 KT):0
Visibility: 1 1/2 mile(s):0
Sky conditions: overcast
Weather: light snow
Precipitation last hour: A trace
Temperature: 28 F (-2 C)
Windchill: 15 F (-9 C):1
Dew Point: 23 F (-5 C)
Relative Humidity: 79%
Pressure (altimeter): 29.52 in. Hg (999 hPa)
ob: KDEN 162148Z 36016G27KT 1 1/2SM -SN BKN022 OVC026 M02/M05 A2952 RMK AO2 PK WND 36027/2142 WSHFT 2118 SNB2057 P0000
cycle: 22

In Debian, you can install a package called weather-util which makes for easy searching of the data. Here’s a station at the airport in Longmont:

$ weather KLMO
Searching via station...
[caching result Vance Brand Airport, US]
Current conditions at <UNKNOWN>
Last updated Feb 16, 2019 - 04:35 PM EST / 2019.02.16 2135 UTC
   Temperature: 36.0 F (2.2 C)
   Relative Humidity: 70%
   Wind: from the E (100 degrees) at 3 MPH (3 KT)
   Sky conditions: partly cloudy

Finally, I couldn’t figure out why I was just getting the string “Updating…” instead of a temperature after swapping in KLMO for KDEN, then I realized that you also need to change the station name in the template. Here are the changes I made to my .xmobarrc while writing this post. They also include a tweak to display sky conditions and a slightly different date format.

tags: topics/bpb-kit, topics/data, topics/noaa, topics/technical, topics/warelogging, topics/weather, topics/xmobar, topics/xmonad

p1k3 / 2019 / 2 / 16