-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdailySIF.m
More file actions
executable file
·181 lines (157 loc) · 8.09 KB
/
Copy pathdailySIF.m
File metadata and controls
executable file
·181 lines (157 loc) · 8.09 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
% Calculate the daily sum of SIF
% Calculate SIF and VPD at a specific time: 0930,1400
clear variables
clc
datapath = '/Volumes/XiYangBackUp/Projects/9.Fluorescence/11.Matlab_data/';
load([datapath,'SIF760_result_2013_with750nm_Apr12-2017_ModifiedCoeff.mat'],'final_result_time');
% load([datapath,'SIF760daily.mat'],'vpd15fill');
% load('SIF760_2014_result.mat','final_result_time');
% load('hf_2013_svd.mat','final_svd');
% load([datapath,'hf_barn_2013_env.mat'],'cloud_ratio_daily');
% Only data from year 2012 is multiplied by 0.6
%final_result_time(:,2) = final_result_time(:,2) *0.8;
% DOY 170-299: 130 ; 2014: 127-300; 2012: 215-293
daily_raw_result = zeros(130,3); %174,3 %79,3 % 130,3
daily_raw_result(:,1) = 170:1:299; %170:1:299;127:1:299; 215:1:293
halfhourly_result = zeros(130*48,2); %174*48,2; 79*48 130*48
halfhourly_result(:,1) = 170:(1/48):(300-1/48); %127:(1/24):(301-1/24);170:(1/48):(300-1/48);215:(1/48):(294-1/48)
hourly_result = zeros(130*24,2); %130*24; 79*24 174*24
hourly_result(:,1) = 170:(1/24):(300-1/48); %127:(1/24):(301-1/24);215:(1/24):(294-1/24);170:(1/24):(300-1/48)
hh_rad755 = zeros(130*48,2);
hh_rad755(:,1) = 170:(1/48):(300-1/48); %127:(1/24):(301-1/24);170:(1/48):(300-1/48);215:(1/48):(294-1/48)
hh_irrad755 = zeros(130*48,2);
hh_irrad755(:,1) = 170:(1/48):(300-1/48); %127:(1/24):(301-1/24);170:(1/48):(300-1/48);215:(1/48):(294-1/48)
% vpd_30min = zeros(130*48,2);
% vpd_30min(:,1) = 170:(1/48):(300-1/48);
% fivemin_result = zeros(130*48*6,2);
% fivemin_result(:,1) = 170:(1/288):(300-1/288);
% SIF_0930 = zeros(130,4); %130
% SIF_0930(:,1) = 170:1:299; %170:1:299 ; 127:1:288
%
% SIF_1330 = zeros(130,4);
% SIF_1330(:,1) = 170:1:299;
%
% SIF_1400 = zeros(130,4);
% SIF_1400(:,1) = 170:1:299;
%
% SIF_1430 = zeros(130,4);
% SIF_1430(:,1) = 170:1:299;
%
% SIF_mean = zeros(79,4);
% SIF_mean(:,1) = 215:1:293; %170:1:299
%
% SIF_max = zeros(130,4);
% SIF_max(:,1) = 170:1:299;
% VPD_0930 = zeros(130,4);
% SIF_0930(:,1) = 170:1:299;
%
% VPD_1400 = zeros(130,4);
% VPD_1400(:,1) = 170:1:299;
for uni_i = 1:130 %1:130; 1:174; 1:79
% Define the time
lb = uni_i-1.0+170; %127 %215 %170
ub = uni_i+170;
% step 1: select good days
sub_temp = final_result_time(:,1) >= lb & final_result_time(:,1) <= ub & final_result_time(:,3) >=0.90 & final_result_time(:,2) <=3.0 & final_result_time(:,2) >= 0.0;
morning_sub = final_result_time(:,1) >= lb & final_result_time(:,1) <= (lb+0.5) & final_result_time(:,3) >=0.90 & final_result_time(:,2) <=3.0 & final_result_time(:,2) >= 0.0;
afternoon_sub = final_result_time(:,1) >= (lb+0.5) & final_result_time(:,1) <= ub & final_result_time(:,3) >=0.90 & final_result_time(:,2) <=3.0 & final_result_time(:,2) >= 0.0;
if (sum(sub_temp) == 0) || (sum(morning_sub) < 3) || (sum(afternoon_sub) < 3)
continue
end
% sub_temp = final_svd(:,1) >= lb & final_svd(:,1) <= ub & final_svd(:,2) <=3.0;
% morning_sub = final_svd(:,1) >= lb & final_svd(:,1) <= (lb+0.5) & final_svd(:,2) <=3.0;
% afternoon_sub = final_svd(:,1) >= (lb+0.5) & final_svd(:,1) <= ub & final_svd(:,2) <=3.0;
% if (sum(sub_temp) == 0) | (sum(morning_sub) < 10) | (sum(afternoon_sub) < 10)
% continue
% end
% step 2: linear-interpolation to every 30 minutes between 6am to 6pm
temp_time = final_result_time(sub_temp, 1);
temp_array = final_result_time(sub_temp, 2);
temp_rad755 = final_result_time(sub_temp, 6);
temp_irrad755= final_result_time(sub_temp, 7);
% temp_time = final_svd(sub_temp, 1);
% temp_array = final_svd(sub_temp, 2);
% vpd_array = vpd15fill(sub_temp,1);
% negative values are assigned to zero
temp_array(temp_array<=0) = NaN;
temp_rad755(temp_rad755<=0) = NaN;
temp_irrad755(temp_irrad755<=0) = NaN;
% sub_0930 = knnsearch(temp_time,9.5/24+lb,'K',1);
% SIF_0930(uni_i,2) = temp_array(sub_0930);
% SIF_mean(uni_i,2) = mean(temp_array(temp_array>0));
% SIF_max(uni_i,2) = max(temp_array(temp_array>0));
% sub_1330 = knnsearch(temp_time,13.5/24+lb,'K',1);
% SIF_1330(uni_i,2) = temp_array(sub_1330);
% sub_1400 = knnsearch(temp_time,14/24+lb,'K',1);
% SIF_1400(uni_i,2) = temp_array(sub_1400);
% sub_1430 = knnsearch(temp_time,14.5/24+lb,'K',1);
% SIF_1430(uni_i,2) = temp_array(sub_1430);
% For VPD
% VPD_0930(uni_i,2) = vpd_array(sub_0930);
% VPD_1400(uni_i,2) = vpd_array(sub_1400);
%
%
% if cloud_ratio_daily(uni_i) < 0.50
% SIF_0930(uni_i,3) = temp_array(sub_0930);
% SIF_mean(uni_i,3) = mean(temp_array(temp_array>0));
% SIF_max(uni_i,3) = max(temp_array(temp_array>0));
% SIF_1330(uni_i,3) = temp_array(sub_1330);
% SIF_1400(uni_i,3) = temp_array(sub_1400);
% SIF_1430(uni_i,3) = temp_array(sub_1430);
% % VPD_0930(uni_i,3) = vpd_array(sub_0930);
% % VPD_1400(uni_i,3) = vpd_array(sub_1400);
% else
% SIF_0930(uni_i,4) = temp_array(sub_0930);
% SIF_mean(uni_i,4) = mean(temp_array(temp_array>0));
% SIF_max(uni_i,4) = max(temp_array(temp_array>0));
% SIF_1330(uni_i,4) = temp_array(sub_1330);
% SIF_1400(uni_i,4) = temp_array(sub_1400);
% SIF_1430(uni_i,4) = temp_array(sub_1430);
% % VPD_0930(uni_i,4) = vpd_array(sub_0930);
% % VPD_1400(uni_i,4) = vpd_array(sub_1400);
% end
% %
% time_sub = find(halfhourly_result(((uni_i-1)*48+1):(uni_i*48),1)<temp_time(1) | halfhourly_result(((uni_i-1)*48+1):(uni_i*48),1)>temp_time(end));
%
for jj = 1:48
if (halfhourly_result((uni_i-1)*48+jj,1)<lb+6.0/24 || halfhourly_result((uni_i-1)*48+jj,1)>lb+18.0/24)
halfhourly_result((uni_i-1)*48+jj,2) = 0.00;
hh_rad755((uni_i-1)*48+jj,2) = 0.00;
hh_irrad755((uni_i-1)*48+jj,2) = 0.00;
%vpd_30min((uni_i-1)*48+jj,2) = 0.00;
else
halfhourly_result((uni_i-1)*48+jj,2) = nanmean(temp_array(temp_time >= halfhourly_result((uni_i-1)*48+jj,1) & temp_time < halfhourly_result((uni_i-1)*48+jj,1)+1/48));
hh_rad755((uni_i-1)*48+jj,2) = nanmean(temp_rad755(temp_time >= hh_rad755((uni_i-1)*48+jj,1) & temp_time < hh_rad755((uni_i-1)*48+jj,1)+1/48));
hh_irrad755((uni_i-1)*48+jj,2) = nanmean(temp_irrad755(temp_time >= hh_irrad755((uni_i-1)*48+jj,1) & temp_time < hh_irrad755((uni_i-1)*48+jj,1)+1/48));
%vpd_30min((uni_i-1)*48+jj,2) = mean(vpd_array(temp_time >= vpd_30min((uni_i-1)*48+jj,1) & temp_time < vpd_30min((uni_i-1)*48+jj,1)+1/48));
end
end
for jj = 1:24
if (hourly_result((uni_i-1)*24+jj,1)<lb+6.0/24 || hourly_result((uni_i-1)*24+jj,1)>lb+18.0/24)
hourly_result((uni_i-1)*24+jj,2) = 0.00;
% vpd_30min((uni_i-1)*48+jj,2) = 0.00;
else
hourly_result((uni_i-1)*24+jj,2) = nanmean(temp_array(temp_time >= hourly_result((uni_i-1)*24+jj,1) & temp_time < hourly_result((uni_i-1)*24+jj,1)+1/24));
% vpd_30min((uni_i-1)*48+jj,2) = mean(vpd_array(temp_time >= vpd_30min((uni_i-1)*48+jj,1) & temp_time < vpd_30min((uni_i-1)*48+jj,1)+1/48));
end
end
%
% for kk = 1:288
% if (fivemin_result((uni_i-1)*288+kk,1)<temp_time(1) | fivemin_result((uni_i-1)*288+kk,1)>temp_time(end))
% fivemin_result((uni_i-1)*288+kk,2) = 0.00;
% else
% [subs_2,dists_2] = knnsearch(temp_time,fivemin_result((uni_i-1)*288+kk,1),'K',2);
% weight1 = 1/abs(temp_time(subs_2(1))-fivemin_result((uni_i-1)*288+kk,1));
% weight2 = 1/abs(temp_time(subs_2(2))-fivemin_result((uni_i-1)*288+kk,1));
% if weight1 == Inf
% fivemin_result((uni_i-1)*288+kk,2) = temp_array(subs(1));
% elseif weight2 == Inf
% fivemin_result((uni_i-1)*288+kk,2) = temp_array(subs(2));
% else
% fivemin_result((uni_i-1)*288+kk,2) = (weight1*temp_array(subs_2(1))+weight2*temp_array(subs_2(2)))/(weight1+weight2);
% end
% end
% end
%
end
save([datapath,'SIF760daily_2013_090thresh_withRad750.mat']);%,'-append');