In this example, we’ll use Matlab to load and plot a time-series of V6.GL.02.02 Satellite-Derived PM2.5 around select locations for 2000 to 2022 using the global output files.
%————————————————————————
% This script plot a timeseries of annual mean
% PM2.5 within a chosen buffer
% radius at selected locations around the world
%————————————————————————
%————————————————————————
% Set/Define variables
%————————————————————————
% Name, Latitude, and Longitude of Selected Cities
Cities = cell(3,3);
Cities(1,:) = [{‘New York’} {40.71} {-74.01}];
Cities(2,:) = [{‘Beijing’} {39.92} {116.38}];
Cities(3,:) = [{‘Amsterdam’} {52.40} {4.93}];
Cities(4,:) = [{‘New Delhi’} {28.64} {77.22}];
Cities(5,:) = [{‘Mexico City’} {19.43} {99.13}];
% Buffer radius around citiesin degrees
R = 0.05;
% Years to plot
Y = 2000:2022;
% path and format of annual V6.GL.02.02 files
PM25file = ‘.\\V6.GL.02.02\\V6GL02.02.CNNPM25.Global.%d01-%d12.nc’;
% annual mean PM2.5 concentration at each location
CitiesPM25 = NaN(size(Cities,1),numel(Y));
%————————————————————————
% Main script begins here
%————————————————————————
% set initial run flag to true
init = 1;
for Yi = 1:numel(Y)
% Store coordinates and relevant pixels during initial run
if init == 1
% load coordinates
tLAT = double(ncread(sprintf(PM25file,Y(Yi),Y(Yi)),’lat’));
tLON = double(ncread(sprintf(PM25file,Y(Yi),Y(Yi)),’lon’));
% create grid of coordinates
[tLONg, tLATg] = meshgrid(tLON,tLAT);
% Identify pixels within radius for each location
CityPixels = cell(size(Cities,1),1);
for Ci = 1:size(Cities,1)
% calculate distance between each grid cell and location
d = ((tLATg – Cities{Ci,2}).^2 + (tLONg – Cities{Ci,3}).^2).^0.5;
% Identify and store pixels within given radius
CityPixels{Ci} = uint64(find(d <= R));
end
% set initial run flag to false
init = 0;
end
% load PM2.5 concentrations
tPM25 = double(ncread(sprintf(PM25file,Y(Yi),Y(Yi)),’PM25′))’;
% store annual mean PM2.5 at each location
for Ci = 1:size(Cities,1)
CitiesPM25(Ci,Yi) = nanmean(tPM25(CityPixels{Ci}));
end
end
CitiesPM25(Ci,Yi) = nanmean(tPM25(CityPixels{Ci}));
end
end
%————————————————————————
% Plot the timeseries
%————————————————————————
figure
plot(Y,CitiesPM25′,’.-‘);
plot(Y,CitiesPM25′,’.-‘);
% label and set axis limits
xlabel(‘Year’);
ylabel(‘Annual Mean PM_2_._5 [\mug/m^3]’);
xlim([min(Y)-0.5 max(Y)+0.5]);
% label location names
legend(Cities(:,1),’Location’,’NorthEastOutside’);
The resulting plot will look like this: