Occasionally, I hear people still talk about the radiation in Fukushima. It's been over 3 years since the accident, and you rarely hear anything mentioned on the news anymore.
However, safecast.org has done a great job of collecting on-going radiation measurements, and publishes a number of maps. I've done similar maps over the years and decided to tackle making one in an attempt to answer the question, "how have the values changed over time". (I'm also taking the opportunity to do this as my first python3 django project)
So, the first step is to get the data.
Go grab the CSV at http://blog.safecast.org/data/
I'm then averaging the data monthly on load into geographic bins. For the timelapse, I'm using 1500m bins. For each month-area, the data is using simple average of all values in uSv/hour that fall in that area. I'm not sure if this is the best way to handle it, but the result appears to be close to the 'official map', so for now I'll stick with the simple average.
Note that some of the data is in CPM and not uSv/hour. For these values I converted using the following method:
Using chart at:
usv_per_click = 0.1/12
return cpm_value * usv_per_click
Once the data is loaded into the django Measurement models, it's time to generate the map tile png files. For this I created a python3 library, tmstiler (https://github.com/monkut/tmstiles) , which contains a class, DjangoRasterTileLayerManager, that generates the tile images from a django model containing raster data as a PointField.
Using the DjangoRasterTileLayerManager() minimizes what needs to be done in django project view code. I think the legend code ended up being bigger than the tile creation view code.
The first time I created a timelapse, the image was only showing the 'current' month's data, and made the image appear choppy. There are a number of ways to do some kind of interpolation to make this look better. I decided to try the easiest thing I could think of, hold the previous month data and show it in the 'current' month image. However, I also wanted it to be clear, in some way, that the previous data is not the same as the current data. At first I thought I could adjust the transparency and gradually fade out the older data. After looking into this, it seems that with PIL (pillow) this is a bit difficult to do, and can't be done on color assignment alone. So instead I'm adjusting the color saturation level. (For legends and color manipulation HSL http://en.wikipedia.org/wiki/HSL_and_HSV makes shifting colors much easier than dealing with RGB alone)
So I've defined a "months_to_actual" field in the Measurement model, and use this value in the legend to adjust the color saturation. The effect is that the color gradually shifts to gray before being removed. Visually, I'm pretty happy with the results. At the moment it's holding the past 6 months values.
For building the time-lapse, image capture is done using phantomjs (http://phantomjs.org/). I've used it in a previous project to capture data on a headless server, it's basically a programmable webkit browser without the need for a GUI. This time around I did notice that there is a python solution called ghost.py, but I think it's only python2 and the installation is more involved than using phantomjs.
Next, the images are combined together into a video using avconv. This is all done on ubuntu 14.04 server.
I'd like to get the map "live" and browsable here, but I figure that's at least a couple of nights work, and if I do that I really want to do periodic automated updates using the safecast api, which would be a bit more work...
In any case, if anyone is interested in trying it out or making it better, I've posted all the code to github.
You can see the resulting time-lapse video at: