-
Notifications
You must be signed in to change notification settings - Fork 0
/
jiheApril.m
254 lines (241 loc) · 8.34 KB
/
jiheApril.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
%this program is for jiheuybao
clear all;
clc;
datadir='./Ensemble/129/'; %指定批量数据所在文件
filelist=dir([datadir,'*.nc']);
a=filelist(1).name;
b=filelist(2).name;
k=length(filelist);
%创建g500数据(g500(lat.73, lon.144, time.1960-2005, institution.6(E、I、M、U、C), referencr.3 02 05 11 ))
G_500=rand(73,144,46,6,4);
%E: ECWMF, I: IMF-GEOM,
%M: Meteo-France, U: UK_Met_Office,
%C: CMCC-Bologna
%创建G_02系列数据
G_02_E=rand(73,144,4);
G_02_I=rand(73,144,4);
G_02_M=rand(73,144,4);
G_02_U=rand(73,144,4);
G_02_C=rand(73,144,4);
G_02=rand(73,144,4);
%创建G_05系列数据
G_05_E=rand(73,144,4);
G_05_I=rand(73,144,4);
G_05_M=rand(73,144,4);
G_05_U=rand(73,144,4);
G_05_C=rand(73,144,4);
G_05=rand(73,144,4);
%创建G_08系列数据
G_08_E=rand(73,144,4);
G_08_I=rand(73,144,4);
G_08_M=rand(73,144,4);
G_08_U=rand(73,144,4);
G_08_C=rand(73,144,4);
G_08=rand(73,144,4);
%创建G_11系列数据
G_11_E=rand(73,144,4);
G_11_I=rand(73,144,4);
G_11_M=rand(73,144,4);
G_11_U=rand(73,144,4);
G_11_C=rand(73,144,4);
G_11=rand(73,144,4);
%读取G_02数据并做成员平均
for s=1:4:k-3
filename=[datadir,filelist(s).name];
filename;
ncid=netcdf.open(filename,'NC_NOWRITE');
LonData=ncread(filename,'longitude');
LatData=ncread(filename,'latitude');
TimeData=ncread(filename,'leadtime');
%读取ECWMF数据并平均
Gdata_E=ncread(filename,'g',[1 1 2 1 7],[144 73 1 9 1]);
%取相应模态的值 其中level=850(1), time=June(4)
G_E=reshape(Gdata_E,[144 73 9]);
G_E_1=flipud(rot90(mean(G_E,3)));%画图格式[73 144 time]
G_02_E(:,:,(s+3)/4)=G_E_1(:,:);%按照时间填入(应该是+3/4)
%读取IFM-GEOM数据并平均
Gdata_I=ncread(filename,'g',[1 1 2 10 7],[144 73 1 9 1]);
G_I=reshape(Gdata_I,[144 73 9]);
G_I_1=flipud(rot90(mean(G_I,3)));
G_02_I(:,:,(s+3)/4)=G_I_1(:,:);
%读取Meteo-France数据并平均
Gdata_M=ncread(filename,'g',[1 1 2 19 7],[144 73 1 9 1]);
G_M=reshape(Gdata_M,[144 73 9]);
G_M_1=flipud(rot90(mean(G_M,3)));
G_02_M(:,:,(s+3)/4)=G_M_1(:,:);
%读取UK_Met_Office数据并平均
Gdata_U=ncread(filename,'g',[1 1 2 28 7],[144 73 1 9 1]);
G_U=reshape(Gdata_U,[144 73 9]);
G_U_1=flipud(rot90(mean(G_U,3)));
G_02_U(:,:,(s+3)/4)=G_U_1(:,:);
%读取CMCC-Bologna数据并平均
Gdata_C=ncread(filename,'g',[1 1 2 37 7],[144 73 1 9 1]);
G_C=reshape(Gdata_C,[144 73 9]);
G_C_1=flipud(rot90(mean(G_C,3)));
G_02_C(:,:,(s+3)/4)=G_C_1(:,:);
%读取所有Ensemble数据
Gdata=ncread(filename,'g',[1 1 2 1 7],[144 73 1 45 1]);
G=reshape(Gdata,[144 73 45]);
G_1=flipud(rot90(mean(G,3)));
G_02(:,:,(s+3)/4)=G_1(:,:);
end
%读取G_05数据并做成员平均
for s=2:4:k-2
filename=[datadir,filelist(s).name];
ncid=netcdf.open(filename,'NC_NOWRITE');
LonData=ncread(filename,'longitude');
LatData=ncread(filename,'latitude');
TimeData=ncread(filename,'leadtime');
%读取ECWMF数据并平均
Gdata_E=ncread(filename,'g',[1 1 2 1 4 ],[144 73 1 9 1]);
%取相应模态的值 其中level=850(1), time=June(4)
G_E=reshape(Gdata_E,[144 73 9]);
G_E_1=flipud(rot90(mean(G_E,3)));%画图格式[73 144 time]
G_05_E(:,:,(s+2)/4)=G_E_1(:,:);%按照时间填入(应该是+3/4)
%读取IFM-GEOM数据并平均
Gdata_I=ncread(filename,'g',[1 1 2 10 4],[144 73 1 9 1]);
G_I=reshape(Gdata_I,[144 73 9]);
G_I_1=flipud(rot90(mean(G_I,3)));
G_05_I(:,:,(s+2)/4)=G_I_1(:,:);
%读取Meteo-France数据并平均
Gdata_M=ncread(filename,'g',[1 1 2 19 4],[144 73 1 9 1]);
G_M=reshape(Gdata_M,[144 73 9]);
G_M_1=flipud(rot90(mean(G_M,3)));
G_05_M(:,:,(s+2)/4)=G_M_1(:,:);
%读取UK_Met_Office数据并平均
Gdata_U=ncread(filename,'g',[1 1 2 28 4],[144 73 1 9 1]);
G_U=reshape(Gdata_U,[144 73 9]);
G_U_1=flipud(rot90(mean(G_U,3)));
G_05_U(:,:,(s+2)/4)=G_U_1(:,:);
%读取CMCC-Bologna数据并平均
Gdata_C=ncread(filename,'g',[1 1 2 37 4],[144 73 1 9 1]);
G_C=reshape(Gdata_C,[144 73 9]);
G_C_1=flipud(rot90(mean(G_C,3)));
G_05_C(:,:,(s+2)/4)=G_C_1(:,:);
%读取所有Ensemble数据
Gdata=ncread(filename,'g',[1 1 2 1 4],[144 73 1 45 1]);
G=reshape(Gdata,[144 73 45]);
G_1=flipud(rot90(mean(G,3)));
G_05(:,:,(s+2)/4)=G_1(:,:);
end
%读取G_08数据并做成员平均
for s=3:4:k-1
filename=[datadir,filelist(s).name];
ncid=netcdf.open(filename,'NC_NOWRITE');
LonData=ncread(filename,'longitude');
LatData=ncread(filename,'latitude');
TimeData=ncread(filename,'leadtime');
%读取ECWMF数据并平均
Gdata_E=ncread(filename,'g',[1 1 2 1 1],[144 73 1 9 1]);
%取相应模态的值 其中level=850(1), time=June(4)
G_E=reshape(Gdata_E,[144 73 9]);
G_E_1=flipud(rot90(mean(G_E,3)));%画图格式[73 144 time]
G_08_E(:,:,(s+1)/4)=G_E_1(:,:);%按照时间填入(应该是+3/4)
%读取IFM-GEOM数据并平均
Gdata_I=ncread(filename,'g',[1 1 2 10 1],[144 73 1 9 1]);
G_I=reshape(Gdata_I,[144 73 9]);
G_I_1=flipud(rot90(mean(G_I,3)));
G_08_I(:,:,(s+1)/4)=G_I_1(:,:);
%读取Meteo-France数据并平均
Gdata_M=ncread(filename,'g',[1 1 2 19 1],[144 73 1 9 1]);
G_M=reshape(Gdata_M,[144 73 9]);
G_M_1=flipud(rot90(mean(G_M,3)));
G_08_M(:,:,(s+1)/4)=G_M_1(:,:);
%读取UK_Met_Office数据并平均
Gdata_U=ncread(filename,'g',[1 1 2 28 1],[144 73 1 9 1]);
G_U=reshape(Gdata_U,[144 73 9]);
G_U_1=flipud(rot90(mean(G_U,3)));
G_08_U(:,:,(s+1)/4)=G_U_1(:,:);
%读取CMCC-Bologna数据并平均
Gdata_C=ncread(filename,'g',[1 1 2 37 1],[144 73 1 9 1]);
G_C=reshape(Gdata_C,[144 73 9]);
G_C_1=flipud(rot90(mean(G_C,3)));
G_08_C(:,:,(s+1)/4)=G_C_1(:,:);
%读取所有Ensemble数据
Gdata=ncread(filename,'g',[1 1 2 1 1],[144 73 1 45 1]);
G=reshape(Gdata,[144 73 45]);
G_1=flipud(rot90(mean(G,3)));
G_08(:,:,(s+1)/4)=G_1(:,:);
end
%读取G_11数据并做成员平均
for s=4:4:k
filename=[datadir,filelist(s).name];
ncid=netcdf.open(filename,'NC_NOWRITE');
LonData=ncread(filename,'longitude');
LatData=ncread(filename,'latitude');
TimeData=ncread(filename,'leadtime');
%读取ECWMF数据并平均
Gdata_E=ncread(filename,'g',[1 1 2 1 10],[144 73 1 9 1]);
%取相应模态的值 其中level=850(1), time=June(4)
G_E=reshape(Gdata_E,[144 73 9]);
G_E_1=flipud(rot90(mean(G_E,3)));%画图格式[73 144 time]
G_11_E(:,:,(s+0)/4)=G_E_1(:,:);%按照时间填入(应该是+3/4)
%读取IFM-GEOM数据并平均
Gdata_I=ncread(filename,'g',[1 1 2 10 10],[144 73 1 9 1]);
G_I=reshape(Gdata_I,[144 73 9]);
G_I_1=flipud(rot90(mean(G_I,3)));
G_11_I(:,:,(s+0)/4)=G_I_1(:,:);
%读取Meteo-France数据并平均
Gdata_M=ncread(filename,'g',[1 1 2 19 10],[144 73 1 9 1]);
G_M=reshape(Gdata_M,[144 73 9]);
G_M_1=flipud(rot90(mean(G_M,3)));
G_11_M(:,:,(s+0)/4)=G_M_1(:,:);
%读取UK_Met_Office数据并平均
Gdata_U=ncread(filename,'g',[1 1 2 28 10],[144 73 1 9 1]);
G_U=reshape(Gdata_U,[144 73 9]);
G_U_1=flipud(rot90(mean(G_U,3)));
G_11_U(:,:,(s+0)/4)=G_U_1(:,:);
%读取CMCC-Bologna数据并平均
Gdata_C=ncread(filename,'g',[1 1 2 37 10],[144 73 1 9 1]);
G_C=reshape(Gdata_C,[144 73 9]);
G_C_1=flipud(rot90(mean(G_C,3)));
G_11_C(:,:,(s+0)/4)=G_C_1(:,:);
%读取所有Ensemble数据
Gdata=ncread(filename,'g',[1 1 2 1 10],[144 73 1 45 1]);
G=reshape(Gdata,[144 73 45]);
G_1=flipud(rot90(mean(G,3)));
G_11(:,:,(s+0)/4)=G_1(:,:);
end
%创建6个成员的集合 Var_g850
%填充20数据
G_500(:,:,:,1,1)=G_02_E;
G_500(:,:,:,2,1)=G_02_I;
G_500(:,:,:,3,1)=G_02_M;
G_500(:,:,:,4,1)=G_02_U;
G_500(:,:,:,5,1)=G_02_C;
G_500(:,:,:,6,1)=G_02;
%填充05数据
G_500(:,:,:,1,2)=G_05_E;
G_500(:,:,:,2,2)=G_05_I;
G_500(:,:,:,3,2)=G_05_M;
G_500(:,:,:,4,2)=G_05_U;
G_500(:,:,:,5,2)=G_05_C;
G_500(:,:,:,6,2)=G_05;
%填充08数据
G_500(:,:,:,1,3)=G_08_E;
G_500(:,:,:,2,3)=G_08_I;
G_500(:,:,:,3,3)=G_08_M;
G_500(:,:,:,4,3)=G_08_U;
G_500(:,:,:,5,3)=G_08_C;
G_500(:,:,:,6,3)=G_08;
%填充11数据
G_500(:,:,:,1,4)=G_11_E;
G_500(:,:,:,2,4)=G_11_I;
G_500(:,:,:,3,4)=G_11_M;
G_500(:,:,:,4,4)=G_11_U;
G_500(:,:,:,5,4)=G_11_C;
G_500(:,:,:,6,4)=G_11;
ncid2=netcdf.create('./Ensemble/129EnsembleApril.nc','clobber');
% Create NetCDF file,输入文件名.
lon=netcdf.defDim(ncid2,'longitude',144);%定义维
lat=netcdf.defDim(ncid2,'latitude',73);
time=netcdf.defDim(ncid2,'time',46);
id=netcdf.defDim(ncid2,'institude',6);
ref=netcdf.defDim(ncid2,'reference',4);
g_500=netcdf.defVar(ncid2,'g500','double',[lat lon time id ref]);%定义变量
netcdf.endDef(ncid2);%关闭定义
netcdf.putVar(ncid2,g_500,G_500);%填值
netcdf.close(ncid2);
clear G_E G_I G_M G_U G_C ;
clear G_E_1 G_I_1 G_M_1 G_U_1 G_C_1 ;
clear Gdata_E Gdata_I Gdata_M Gdata_U Gdata_C;