-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get_Annual_NLDAS_ET_PET.m
101 lines (91 loc) · 3.58 KB
/
Get_Annual_NLDAS_ET_PET.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
clc;clear all;close all;
indir = '/Volumes/Pruina_External_Elements/DroughtFireSnow/Data/NLDAS_ET_PET/Aggregated_Monthly_Grids/';
for year = 1984:2021
year
store_ET_winter = [];
store_PET_winter = [];
store_PETminusET_winter = [];
%Nov - Dec previous year
for month = 11:12
infilename = sprintf('NLDAS_ET_PET_%04d%02d.mat',year-1,month);
if exist([indir,infilename],'file') > 0
Data = load([indir,infilename]);
Data = Data.NLDAS;
ET = Data.ET;
PET = Data.PET;
PET_minus_ET = PET-ET;
store_ET_winter = cat(3,store_ET_winter,ET);
store_PET_winter = cat(3,store_PET_winter,PET);
store_PETminusET_winter = cat(3,store_PETminusET_winter,PET_minus_ET);
end
end
%jan-feb this year
for month = 1:2
infilename = sprintf('NLDAS_ET_PET_%04d%02d.mat',year,month);
if exist([indir,infilename],'file') > 0
Data = load([indir,infilename]);
Data = Data.NLDAS;
ET = Data.ET;
PET = Data.PET;
PET_minus_ET = PET-ET;
store_ET_winter = cat(3,store_ET_winter,ET);
store_PET_winter = cat(3,store_PET_winter,PET);
store_PETminusET_winter = cat(3,store_PETminusET_winter,PET_minus_ET);
end
end
ET_winter = nanmean(store_ET_winter,3);
PET_winter = nanmean(store_PET_winter,3);
PETminusET_winter = nanmean(store_PETminusET_winter,3);
%March - may
store_ET_spring = [];
store_PET_spring = [];
store_PETminusET_spring = [];
for month =3:5
infilename = sprintf('NLDAS_ET_PET_%04d%02d.mat',year,month);
if exist([indir,infilename],'file') > 0
Data = load([indir,infilename]);
Data = Data.NLDAS;
ET = Data.ET;
PET = Data.PET;
PET_minus_ET = PET-ET;
store_ET_spring = cat(3,store_ET_spring,ET);
store_PET_spring = cat(3,store_PET_spring,PET);
store_PETminusET_spring = cat(3,store_PETminusET_spring,PET_minus_ET);
end
end
ET_spring = nanmean(store_ET_spring,3);
PET_spring = nanmean(store_PET_spring,3);
PETminusET_spring = nanmean(store_PETminusET_spring,3);
%June - September
store_ET_summer = [];
store_PET_summer = [];
store_PETminusET_summer = [];
for month =6:9
infilename = sprintf('NLDAS_ET_PET_%04d%02d.mat',year,month);
if exist([indir,infilename],'file') > 0
Data = load([indir,infilename]);
Data = Data.NLDAS;
ET = Data.ET;
PET = Data.PET;
PET_minus_ET = PET-ET;
store_ET_summer = cat(3,store_ET_summer,ET);
store_PET_summer = cat(3,store_PET_summer,PET);
store_PETminusET_summer = cat(3,store_PETminusET_summer,PET_minus_ET);
end
end
ET_summer = nanmean(store_ET_summer,3);
PET_summer = nanmean(store_PET_summer,3);
PETminusET_summer = nanmean(store_PETminusET_summer,3);
Data=[];
Data.ET_winter=ET_winter;
Data.PET_winter = PET_winter;
Data.PETminusET_winter = PETminusET_winter;
Data.ET_spring = ET_spring;
Data.PET_spring = PET_spring;
Data.PETminusET_spring = PETminusET_spring;
Data.ET_summer = ET_summer;
Data.PET_summer = PET_summer;
Data.PETminusET_summer = PETminusET_summer;
outputfilename = sprintf('/Volumes/Pruina_External_Elements/DroughtFireSnow/Data/NLDAS_ET_PET/Annual/Annual_ET_PET_WY%04d.mat',year);
save(outputfilename,'Data','-v7.3');
end