Posts tagged “images”

From Twitter to Graph: Plotting the US Embassy's Air Quality Monitor in Beijing

There’s been a lot of dingus kerfuffle around the US Embassy monitoring air quality in Beijing and posting the results to Twitter at @BeijingAir. I personally like this kind of thing — its almost as though the government is acting as an environmental activist with infinite clout, stirring up problems by bringing known issues to light.

I thought, in passing, that it would be fun to pull the data stream from Twitter, parse it, and graph it. The embassy updates the data hourly; I figured I could make a call to Twitter’s API, without the need for any hacky AJAX refreshing. When people view the post, it’ll show the most recent two hundred tweets, representing 200 hours of data. Perhaps there’d be a need/interest to backup more to a database, but I was running out of steam - turns out that this undertaking wasn’t as easy as one would have hoped.

So, without further ado, here’s approximately the latest week of PM2.5 data from Beijing. The lower line — in red — is the PM2.5 concentration; the upper line — in green — is the air quality index (AQI). The dotted, light-grey line is the US EPA 24h PM2.5 standard. Note that Beijing is rarely, if ever, below that designation. I’ll do my best to explain what each of those lines represents below. But now, the graph:

PM2.5 is defined by the US EPA as follows:

Particles less than 2.5 micrometers in diameter are called “fine” particles. These particles are so small they can be detected only with an electron microscope. Sources of fine particles include all types of combustion, including motor vehicles, power plants, residential wood burning, forest fires, agricultural burning, and some industrial processes.

Exposure to particles of this size has been implicated in a wide range of health effects. Like other chemical exposures, at a first approximation the intensity of the health effect depends on the duration of exposure, the concentration of particles in the environment, and an individual’s proximity to the source. There’s increasing evidence that any exposure above very low levels — the types we rarely see anywhere on Earth these days — are bad for health and can exacerbate heart and lung disease, asthma, bronchitis, and the like.

The Air Quality Index (or AQI) is a summary measure that

tells you how clean or polluted your air is, and what associated health effects might be a concern for you. The AQI focuses on health effects you may experience within a few hours or days after breathing polluted air. EPA calculates the AQI for five major air pollutants regulated by the Clean Air Act: ground-level ozone, particle pollution (also known as particulate matter), carbon monoxide, sulfur dioxide, and nitrogen dioxide. For each of these pollutants, EPA has established national air quality standards to protect public health. Ground-level ozone and airborne particles are the two pollutants that pose the greatest threat to human health in this country.

Finally, the US EPA standard is pretty straightforward. For the US, there are not supposed to be 24-hour average PM levels above the 35µg/m3. Of course, as we can expect, not every locale in the country can meet this standard.

Back to China.

It’d be interesting to add some summary statistics and look at variation between weekdays and weekends — I’m working on that now. I’m also trying to find an accessible data source from China to plot along with the US data. Some comparison would be good, especially after China began posting its own data not too long ago.

The previous (and awesome) work that inspired this undertaking was done by China Air Daily. They’ve got some amazing visuals of the air pollution. One is attached below; I recommend checking out their site for more great stuff.

all rights reserved
snarglr is written & maintained by ajay pillarisetti

click here to turn on all posts