Monday, June 30, 2014

Monitoring in-situ PM2.5 in NYC metro area using #matlab #trendy

Matlab's Trendy feature can be used to monitor and collect hourly air quality station data directly from the source url. The data can be feed into the trendy app using the urlfilter and updatetrend commands.

Here is the basic code that gets the job done for the CCNY location. If you are interested to get multiple data, just append it to the update trend array:
% Get the data from CCNY, update the trendy
url = 'http://www.dec.ny.gov/airmon/stationStatus.php?stationNo=73';
count = urlfilter(url, 'PM25C'); % reading
PMccny = count; % PM at CCNY
updatetrend([PMccny]);
The Trendy then can be used to plot the gathered data. I had to let it gather data for few days before I could plot some nice trends. You can already see the diurnal variation in the data below.
PM2.5 trend in NYC. If the image is not available, follow the link below.

http://www.mathworks.com/matlabcentral/trendy/plots/1349
The plots can be made with the following code (the time and data will be different for your code):
% PM2.5 hourly measurements in CCNY
%   time vector is: time2322
%   data vector is: data2322
plot(time2322,data2322, 'o-');
datetick
hleg = legend('PM2.5(ug/m3)', 'Location', 'SouthWest');
set(hleg, 'FontSize', 8);
title('Air Quality at CCNY station');
I can also set up an email alert if the PM2.5 reading gets higher than some threshold, say 35ugm/m3. Now you can think about the useful applications of such tools!!

Update: well, it has been deprecated! and replaced with "trendy"