1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141 | % Created by LI Xu
% Version 1.0
% September 10, 2026
% If you have any question about this code,
% please do not hesitate to contact me via E-mail:
% jeremy456@163.com
% Blog:
% http://blog.sciencenet.cn/u/lixujeremy
% http://lixuworld.blogspot.com/
% https://aqihub.info/indices/canada
clear;
clc;
close all;
timebegin=tic;
cur_data=date;
cur_time=fix(clock);
str1=sprintf('%s %.2d:%.2d:%.2d', cur_data, cur_time(4), cur_time(5), cur_time(6));
fprintf('Time Begin: ');
fprintf(str1);
fprintf('\n');
%% ============================================================
% Canadian AQHI from NO2, O3 and PM2.5 GeoTIFF rasters
%
% Required units:
% NO2 : ppb
% O3 : ppb
% PM2.5: ug/m^3
%
% Ideally each input raster is a 3-hour rolling mean.
%% ============================================================
% Source Directory
SouDir='input';
no2files=dir(fullfile(SouDir, 'NO2*'));
o3files=dir(fullfile(SouDir, 'O3*'));
pm25files=dir(fullfile(SouDir, 'PM*'));
for ii=1:numel(no2files)
no2path=fullfile(SouDir, no2files(ii).name);
o3path=fullfile(SouDir, o3files(ii).name);
pm25path=fullfile(SouDir, pm25files(ii).name);
[~, fname, ~]=fileparts(pm25path);
fname=strsplit(fname, '_');
fname=fname{end};
otpath=fullfile(SouDir, ['AQHI_', fname, '.tif']);
GenAQHICompute(no2path, o3path, pm25path, otpath);
disp(['[', num2str(ii), '/', num2str(numel(no2files)), ']~', otpath]);
end
fprintf('Time Begin: ');
fprintf(str1);
fprintf('\n');
cur_data=date;
cur_time=fix(clock);
str2=sprintf('%s %.2d:%.2d:%.2d', cur_data, cur_time(4), cur_time(5), cur_time(6));
fprintf('Time End: ');
disp(str2);
timespan=toc(timebegin);
fprintf('Time Span: %.4f s\n', timespan);
disp('******************************************************************');
function GenAQHICompute(no2path, o3path, pm25path, otpath)
%% 1. Read pollutant rasters
[NO2, R_NO2] = readgeoraster(no2path, ...
'OutputType', 'double');
[O3, R_O3] = readgeoraster(o3path, ...
'OutputType', 'double');
[PM25, R_PM25] = readgeoraster(pm25path, ...
'OutputType', 'double');
%% 2. Make sure the rasters have the same dimensions
if ~isequal(size(NO2), size(O3), size(PM25))
error('NO2, O3 and PM2.5 rasters must have the same dimensions.');
end
%% 3. Handle physically impossible negative concentrations
% Optional but usually sensible for interpolated/modelled concentration maps.
NO2(NO2 < 0) = 0;
O3(O3 < 0) = 0;
PM25(PM25 < 0) = 0;
%% 4. Identify pixels where all three pollutants are available
valid = isfinite(NO2) & isfinite(O3) & isfinite(PM25);
AQHI_raw = nan(size(NO2));
AQHI_raw(valid) = (10 / 10.4) .* 100 .* ...
( ...
(exp(0.000537 .* O3(valid)) - 1) + ...
(exp(0.000871 .* NO2(valid)) - 1) + ...
(exp(0.000487 .* PM25(valid)) - 1) ...
);
%% 6. Calculate the reported integer AQHI
AQHI = nan(size(AQHI_raw));
AQHI(valid) = round(AQHI_raw(valid));
info = geotiffinfo(no2path);
geotiffwrite( ...
otpath, ...
single(AQHI), ...
R_NO2, ...
'GeoKeyDirectoryTag', info.GeoTIFFTags.GeoKeyDirectoryTag);
end
|