US precipitation forecast at a glance

2010-01-07 14:48

Sometimes, especially when traveling, I just want to know what will be falling from the sky in the next day or so. Weather.com provides regional maps of how much precipitation (and what US precipitation forecast thumbnail sort) to expect over the next 24 hours. I have stitched together nine of these maps to produce a US precipitation forecast graphic (about 1420 x 800 pixels; link opens in a new window). The images are pulled directly from weather.com's image server, where they are updated hourly at around the quarter-hour mark.

Weather.com may store regional images at different sizes; they almost certainly have forecasts for areas outside of the US. All this remains to be explored.

Making a poor man’s weather movie

My normal working environment is a MacBook Pro. Paul Hammond's webkit2png is exactly what’s needed to fetch a Web page and save it as a .PNG file on a Macintosh.

Since Mac OSX runs atop a foundation of BSD Unix, cron is available. My crontab contains the following line, which invokes the named script file every hour at one minute past the hour. (The final /dev/null machinery makes sure that cron does not email me the results of every run, which in my environment contains several diagnostic messages thrown by webkit2png.)

1 0-23 * * * ~/cron/cron-hour.cmd >/dev/null 2>&1

The file cron-hour.cmd consists of:

/usr/bin/python ~/bin/webkit2png.py \
   http://recoveringphysicist.com/us-precip-forecast.html \
   -D ~/wx -H 800 -W 1420 \
   -T -s 0.7 \
   -o `date +"%Y-%m-%d+%H-%M"`

The first line invokes python and feeds it the webkit2png script. Note that you must give the full path to python on your system in order that it can locate all the necessary libraries. The second line is the URL of the US precipitation map. The third line specifies where to put the output file (-D option) and how big to make it, in pixels. The fourth line says to save only a thumbnail of the .PNG and what scale factor to use for it — I use 0.7 and this results in a file of about 800KB on disk. The final line gives a name for the output file, which is based on the date and time, e.g. 2010-01-23+08-01-thumb.png (the -thumb.png is appended by webkit2png).

Weather maps build up in my ~/wx directory at a rate of one per hour. It's a simple matter to select ten or a dozen recent maps, open them in Preview (in a single window), and use the arrow navigation keys to get a simple animation of the developing weather pattern.

  

---
~~-