-
Notifications
You must be signed in to change notification settings - Fork 0
/
TairFCH4comparison_WTD_Q_FCH4_precipsubplots_ALQLos1_8_2021.m
265 lines (218 loc) · 9.37 KB
/
TairFCH4comparison_WTD_Q_FCH4_precipsubplots_ALQLos1_8_2021.m
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
%% Clear workspace, clear variables, and clear figures
clear all;close all;clc;
load('USLos2020_2019_calcresp.mat')
load('USALQ2020_2019_calcresp.mat')
load('woodruffprecip.mat')
load('dischargevars.mat')
load('aveFCH4.mat')
%% Replace placeholders for missing values with NaN
USLosHH2019.Properties.VariableNames = USLosHH2020.Properties.VariableNames;
USLos = [USLosHH2019;USLosHH2020];
for i= 3:width(USLos)
USLos.(i)(USLos.(i)==-9999) = NaN;
end
USALQ = [USALQHH2019; USALQHH2020];
for i= 3:width(USALQ)
USALQ.(i)(USALQ.(i)==-9999) = NaN;
end
%% Calculate daily averages
% US-Los
daily_CH4Los = dailyaverage2(USLos.FCH4_RF_filled);
dailyCH4Los = daily_CH4Los(:,1);
datesLos = USLos.TIMESTAMP_END(48*daily_CH4Los(:,2));
daily_WTDLos = dailyaverage2(USLos.WTD);
dailyWTDLos = daily_WTDLos(:,1);
daily_GPPLos = dailyaverage2(USLos.GPP_F);
dailyGPPLos = daily_GPPLos(:,1);
dailyNEELos = dailyaverage2(USLos.NEE_F);
dailyNEELos = dailyNEELos(:,1);
dailyTaLos = dailyaverage2(USLos.TA_F_1_1_1);
dailyTaLos = dailyTaLos(:,1);
daily_Rg = dailyaverage2(USLos.SW_IN_1_1_1);
dailyRg = daily_Rg(:,1);
daily_VPD = dailyaverage2(USLos.VPD_F_1_1_1);
dailyVPD = daily_VPD(:,1);
%% US-ALQ
dailyALQ = dailyaverage2(USALQ.FCH4_RF_filled);
dailyFCH4 = dailyALQ(:,1);
dates = dailyALQ(:,2);
dates = USALQ.TIMESTAMP_END(dates.*48);
daily_GPPALQ = dailyaverage2(USALQ.GPP_F);
dailyGPPALQ = daily_GPPALQ(:,1);
dailyNEEALQ = dailyaverage2(USALQ.NEE_F);
dailyNEEALQ = dailyNEEALQ(:,1);
dailyTaALQ = dailyaverage2(USALQ.TA_F);
dailyTaALQ = dailyTaALQ(:,1);
nanmean(dailyTaALQ(year(dates)==2019))
daily_RgALQ = dailyaverage2(USALQ.SW_IN);
dailyRgALQ = daily_RgALQ(:,1);
daily_VPDALQ = dailyaverage2(USALQ.VPD);
dailyVPDALQ = daily_VPDALQ(:,1);
%%
figure()
plot(dates,dailyNEEALQ)
nansum(dailyNEEALQ(year(dates)==2019))
%% Index for the same dates
precip = woodruffprecipS3.Precipitationin*2.54;
Losdischarge = USGSLos.discharge_cfs*0.028316847;% Convert USLos discharge from cfs to m3s (site no 5357335)
nanmean(Losdischarge(year(USGSLos.datetime)==2020))
ALQdischarge = USGSALQ.discharge_cfs*0.028316847;% Convert USALQ discharge from cfs to m3s-1 (site no 5357205)
nanmean(ALQdischarge(year(USGSALQ.datetime)==2019))
%% Plotting
fig = figure();
right_color = [0.6510 0.6510 0.6510];
left_color = [0 0 0];
set(fig,'defaultAxesColorOrder',[left_color; right_color]);
subplot(5,1,1)
yyaxis left
bar(dates,precip)% Convert from in to cm
ylabel('Precip (cm)')
yyaxis right
plot(datesLos,dailyWTDLos,'-','LineWidth',2)
ylabel('WTD (m)')
set(gca,'FontSize',17)
xlim([dates(1) dates(end)])
nanmean(dailyWTDLos(ismember(year(datesLos),2019)))
nanmean(dailyWTDLos(ismember(year(datesLos),2020)))
% left_color = [0.3020 0.7451 0.9333];
right_color = [0.8784 0.4588 0.7176];
% set(fig,'defaultAxesColorOrder',[left_color; right_color]);
subplot(5,1,2)
% yyaxis left
% US-Los
% plot(dates,Losdischarge,'^')
% ylabel('Q (m^3s^{-1})')
yyaxis right
% US-ALQ
plot(dates,ALQdischarge,'o')
ylabel('Q (m^3s^{-1})')
xlim([dates(1) dates(end)])
set(gca,'FontSize',17)
legend('US-Los','US-ALQ','Location','Northwest');
nanmean(Losdischarge(ismember(year(dates),2019)))
nanmean(Losdischarge(ismember(year(dates),2020)))
nanmean(ALQdischarge(ismember(year(dates),2019)))
nanmean(ALQdischarge(ismember(year(dates),2020)))
right_color = [0.9294 0.2235 0.5059];
left_color = [0 0 0];
set(fig,'defaultAxesColorOrder',[left_color; right_color]);
subplot(5,1,3)
yyaxis left
hold on
plot(dates,dailyTaALQ,'-','Color',[0.8784 0.4588 0.7176],'LineWidth',2)
plot(datesLos,dailyTaLos,'-','Color',[0.3020 0.7451 0.9333],'LineWidth',2)
xlim([dates(1) dates(end)])
hold off
ylabel('T_{air} (^{\circ}C)')
box on
set(gca,'FontSize',17)
yyaxis right
plot(dates,USGSALQ.Twater_mean,'-','Color',[0.9294 0.2235 0.5059],'LineWidth',2)
ylabel('T_{stream} (^{\circ}C)')
lgnd = legend('US-ALQ','US-Los','US-ALQ','Location','Northwest','NumColumns',2)
set(lgnd,'color','none');
subplot(5,1,4)
hold on
plot(dates,dailyGPPALQ,'+','Color',[0.8784 0.4588 0.7176])
xlim([dates(1) dates(end)])
plot(datesLos,dailyGPPLos,'s','Color',[0.3020 0.7451 0.9333])
hold off
ylabel('GPP')
box on
set(gca,'FontSize',17)
lgnd = legend('US-ALQ','US-Los','Location','Northwest')
set(lgnd,'color','none');
A = repmat(aveFCH4,2,1);
subplot(5,1,5)
hold on
plot(datesLos,dailyCH4Los,'-','Color',[0.3020 0.7451 0.9333],'LineWidth',2)
plot(dates,A(1:length(dates)),'Color', [ 0.5333 0.8039 0.9216 0.7],'LineWidth',2)
plot(dates,dailyFCH4,'-','Color',[0.8784 0.4588 0.7176],'LineWidth',2)
xlim([dates(1) dates(end)])
hold off
ylabel('FCH_4')% (\etamol CH_4 m^-^2s^-^1)
lgnd = legend('US-Los','US-Los 2014-18','US-ALQ','Location','Northwest');
box on
set(gca,'FontSize',17)
set(lgnd,'color','none');
nanmean(dailyCH4Los(ismember(year(datesLos),2019)))
nanmean(dailyCH4Los(ismember(year(datesLos),2020)))
nanmean(dailyFCH4(ismember(year(datesLos),2019)))
nanmean(dailyFCH4(ismember(year(datesLos),2020)))
%% Statistics
nanvar(USLos.WTD(year(USLos.TIMESTAMP_END)==2019))
nanvar(USLos.WTD(year(USLos.TIMESTAMP_END)==2020))
nanvar(Losdischarge(year(datesLos)==2019))
nanvar(Losdischarge(year(datesLos)==2020))
nanvar(ALQdischarge(year(dates)==2019))
nanvar(ALQdischarge(year(dates)==2020))
range = [min(Losdischarge(year(datesLos)==2019)) max(Losdischarge(year(datesLos)==2019))]
range = [min(Losdischarge(year(datesLos)==2020)) max(Losdischarge(year(datesLos)==2020))]
range = [min(ALQdischarge(year(datesLos)==2019)) max(ALQdischarge(year(datesLos)==2019))]
range = [min(ALQdischarge(year(datesLos)==2020)) max(ALQdischarge(year(datesLos)==2020))]
C = cov(precip,dailyWTDLos,'omitrows')
C = cov(precip,USGSALQ.Twater_mean,'omitrows')
C = cov(precip,dailyTaLos,'omitrows')
C = cov(precip,dailyTaALQ,'omitrows')
C = cov(precip,Losdischarge,'omitrows')
C = cov(precip,ALQdischarge,'omitrows')
[h,p] = ttest2(dailyRg,dailyRgALQ)
[h,p] = ttest2(Losdischarge,ALQdischarge)
[h,p] = ttest2(dailyTaLos,dailyTaALQ)
[h,p] = ttest2(dailyVPD,dailyVPDALQ)
[R,P] = corrcoef(Losdischarge(~isnan(Losdischarge)&~isnan(ALQdischarge)),ALQdischarge(~isnan(Losdischarge)&~isnan(ALQdischarge)))
[R,P] = corrcoef(ALQdischarge(~isnan(ALQdischarge)&~isnan(dailyWTDLos)),dailyWTDLos(~isnan(ALQdischarge)&~isnan(dailyWTDLos)))
[R,P] = corrcoef(dailyTaLos(~isnan(dailyTaLos)&~isnan(dailyTaALQ)),dailyTaALQ(~isnan(dailyTaLos)&~isnan(dailyTaALQ)))
[R,P] = corrcoef(dailyVPD(~isnan(dailyVPD)&~isnan(dailyVPDALQ)),dailyVPDALQ(~isnan(dailyVPD)&~isnan(dailyVPDALQ)))
nanmean(dailyCH4Los)
nanmean(dailyFCH4)
nanmean(dailyCH4Los(year(datesLos)==2019))
nanmean(dailyCH4Los(year(datesLos)==2020))
nanmean(dailyFCH4(year(dates)==2019))
nanmean(dailyFCH4(year(dates)==2020))
max(gramconvertnmolday(dailyCH4Los))
max(gramconvertnmolday(dailyFCH4))
min(gramconvertnmolday(dailyCH4Los))
min(gramconvertnmolday(dailyFCH4))
%% Cumulative FCH4 and NEE 2019
dailyCH4Los19 = dailyCH4Los(year(datesLos)==2019);
cumulativeCH4Los = cumsum(dailyCH4Los19(:,1),'omitnan');
cumulativegC_CH4Los = gramconvertnmolday(cumulativeCH4Los);
stderrorlos = std(cumulativegC_CH4Los)/sqrt(length(cumulativegC_CH4Los))
cumulativegC_CH4Los = gramconvertnmolday(cumulativeCH4Los(end))
dailyFCH419 = dailyFCH4(year(dates)==2019);
cumulativeCH4ALQ = cumsum(dailyFCH419(:,1),'omitnan');
cumulativegC_CH4ALQ = gramconvertnmolday(cumulativeCH4ALQ);
stderroralq = std(cumulativegC_CH4ALQ)/sqrt(length(cumulativegC_CH4ALQ))
cumulativegC_CH4ALQ = gramconvertnmolday(cumulativeCH4ALQ(end))
dailyNEELos19 = dailyNEELos(year(datesLos)==2019);
cumulativeNEELos = cumsum(dailyNEELos19(:,1),'omitnan');
cumulativegC_NEELos = gramconvertday(cumulativeNEELos);
stderrorlos = std(cumulativegC_NEELos)/sqrt(length(cumulativegC_NEELos))
cumulativegC_NEELos = gramconvertday(cumulativeNEELos(end))
dailyNEEALQ19 = dailyNEEALQ(year(dates)==2019);
cumulativeNEEALQ = cumsum(dailyNEEALQ19(:,1),'omitnan');
cumulativegC_NEEALQ = gramconvertday(cumulativeNEEALQ);
stderroralq = std(cumulativegC_NEEALQ)/sqrt(length(cumulativegC_NEEALQ))
cumulativegC_NEEALQ = gramconvertday(cumulativeNEEALQ(end))
%% Cumulative FCH4 and NEE 2020
dailyCH4Los20 = dailyCH4Los(year(datesLos)==2020);
cumulativeCH4Los = cumsum(dailyCH4Los20(:,1),'omitnan');
cumulativegC_CH4Los = gramconvertnmolday(cumulativeCH4Los);
stderrorlos = std(cumulativegC_CH4Los)/sqrt(length(cumulativegC_CH4Los))
cumulativegC_CH4Los = gramconvertnmolday(cumulativeCH4Los(end))
dailyFCH420 = dailyFCH4(year(dates)==2020);
cumulativeCH4ALQ = cumsum(dailyFCH420(:,1),'omitnan');
cumulativegC_CH4ALQ = gramconvertnmolday(cumulativeCH4ALQ);
stderroralq = std(cumulativegC_CH4ALQ)/sqrt(length(cumulativegC_CH4ALQ))
cumulativegC_CH4ALQ = gramconvertnmolday(cumulativeCH4ALQ(end))
dailyNEELos20 = dailyNEELos(year(datesLos)==2020);
cumulativeNEELos = cumsum(dailyNEELos20(:,1),'omitnan');
cumulativegC_NEELos = gramconvertday(cumulativeNEELos);
stderrorlos = std(cumulativegC_NEELos)/sqrt(length(cumulativegC_NEELos))
cumulativegC_NEELos = gramconvertday(cumulativeNEELos(end))
dailyNEEALQ20 = dailyNEEALQ(year(dates)==2020);
cumulativeNEEALQ = cumsum(dailyNEEALQ20(:,1),'omitnan');
cumulativegC_NEEALQ = gramconvertday(cumulativeNEEALQ);
stderroralq = std(cumulativegC_NEEALQ)/sqrt(length(cumulativegC_NEEALQ))
cumulativegC_NEEALQ = gramconvertday(cumulativeNEEALQ(end))