/[MITgcm]/MITgcm/verification/fizhi-cs-aqualev20/scripts/average2_ML.m
ViewVC logotype

Contents of /MITgcm/verification/fizhi-cs-aqualev20/scripts/average2_ML.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Mon Apr 3 20:55:29 2006 UTC (18 years ago) by molod
Branch: MAIN
CVS Tags: checkpoint64y, checkpoint64x, checkpoint58l_post, checkpoint64z, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f, checkpoint58e_post, checkpoint58u_post, checkpoint58w_post, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63l, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint63h, checkpoint63i, checkpoint63j, checkpoint63k, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint64, checkpoint65, checkpoint60, checkpoint61, checkpoint62, checkpoint63, checkpoint58r_post, checkpoint66g, checkpoint66f, checkpoint66e, checkpoint66d, checkpoint66c, checkpoint66b, checkpoint66a, checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint66i, checkpoint66h, checkpoint58n_post, checkpoint58x_post, checkpoint58t_post, checkpoint58h_post, checkpoint65z, checkpoint65x, checkpoint65y, checkpoint65r, checkpoint65s, checkpoint65p, checkpoint65q, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint65j, checkpoint65k, checkpoint65h, checkpoint65i, checkpoint65n, checkpoint65o, checkpoint65l, checkpoint65m, checkpoint65b, checkpoint65c, checkpoint65a, checkpoint65f, checkpoint65g, checkpoint65d, checkpoint65e, checkpoint58q_post, checkpoint59q, checkpoint59p, checkpoint59r, checkpoint58j_post, checkpoint59e, checkpoint59d, checkpoint59g, checkpoint59f, checkpoint59a, checkpoint59c, checkpoint59b, checkpoint59m, checkpoint59l, checkpoint59o, checkpoint59n, checkpoint59i, checkpoint59h, checkpoint59k, checkpoint59j, checkpoint59, checkpoint58f_post, checkpoint58d_post, checkpoint58i_post, checkpoint58g_post, checkpoint58o_post, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint58y_post, checkpoint58k_post, checkpoint58v_post, checkpoint58s_post, checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61b, checkpoint61c, checkpoint58p_post, checkpoint61a, checkpoint61n, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61q, checkpoint61z, checkpoint61x, checkpoint61y, checkpoint58m_post, HEAD
New check-in for fizhi aquaplanet experiment to match the APE control (will replace fizhi-cs-aqualev10)

1 %
2 % $Id: average_ML.m,v 1.3 2006/02/11 05:15:28 edhill Exp $
3 %
4 % Ed Hill
5 %
6 % Generate the APE ML01--ML07 and ME01--ME07 fields:
7 %
8 % For all facets:
9 % For all time steps:
10 % For all variables:
11 % Create a mask based on THETA == 0.0
12 % For all variables:
13 % compute partial sum wrt mask
14 % compute number contributing wrt mask
15 % Compute the averages from the partial sums & num contrib
16 % Write netCDF output for this facet:
17 %
18
19 %======================================================================
20
21 files = { ...
22 { 'mnc_out_144000/MLfields.0000136800.t%03d.nc' }; ...
23 { 'mnc_out_151200/MLfields.0000144000.t%03d.nc' }; ...
24 { 'mnc_out_158400/MLfields.0000151200.t%03d.nc' }; ...
25 { 'mnc_out_165600/MLfields.0000158400.t%03d.nc' }; ...
26 { 'mnc_out_172800/MLfields.0000165600.t%03d.nc' }; ...
27 { 'mnc_out_180000/MLfields.0000172800.t%03d.nc' }; ...
28 { 'mnc_out_187200/MLfields.0000180000.t%03d.nc' }; ...
29 { 'mnc_out_194400/MLfields.0000187200.t%03d.nc' }; ...
30 { 'mnc_out_201600/MLfields.0000194400.t%03d.nc' }; ...
31 { 'mnc_out_208800/MLfields.0000201600.t%03d.nc' }; ...
32 { 'mnc_out_216000/MLfields.0000208800.t%03d.nc' }; ...
33 { 'mnc_out_223200/MLfields.0000216000.t%03d.nc' }; ...
34 { 'mnc_out_230400/MLfields.0000223200.t%03d.nc' }; ...
35 { 'mnc_out_237600/MLfields.0000230400.t%03d.nc' }; ...
36 { 'mnc_out_244800/MLfields.0000237600.t%03d.nc' }; ...
37 { 'mnc_out_252000/MLfields.0000244800.t%03d.nc' }; ...
38 { 'mnc_out_259200/MLfields.0000252000.t%03d.nc' }; ...
39 { 'mnc_out_266400/MLfields.0000259200.t%03d.nc' }; ...
40 { 'mnc_out_273600/MLfields.0000266400.t%03d.nc' }; ...
41 { 'mnc_out_280800/MLfields.0000273600.t%03d.nc' }; ...
42 { 'mnc_out_288000/MLfields.0000280800.t%03d.nc' }; ...
43 { 'mnc_out_295200/MLfields.0000288000.t%03d.nc' }; ...
44 { 'mnc_out_302400/MLfields.0000295200.t%03d.nc' }; ...
45 { 'mnc_out_309600/MLfields.0000302400.t%03d.nc' }; ...
46 { 'mnc_out_316800/MLfields.0000309600.t%03d.nc' }; ...
47 { 'mnc_out_324000/MLfields.0000316800.t%03d.nc' }; ...
48 { 'mnc_out_331200/MLfields.0000324000.t%03d.nc' }; ...
49 { 'mnc_out_338400/MLfields.0000331200.t%03d.nc' }; ...
50 { 'mnc_out_345600/MLfields.0000338400.t%03d.nc' }; ...
51 { 'mnc_out_352800/MLfields.0000345600.t%03d.nc' }; ...
52 { 'mnc_out_360000/MLfields.0000352800.t%03d.nc' }; ...
53 { 'mnc_out_367200/MLfields.0000360000.t%03d.nc' }; ...
54 { 'mnc_out_374400/MLfields.0000367200.t%03d.nc' }; ...
55 { 'mnc_out_381600/MLfields.0000374400.t%03d.nc' }; ...
56 { 'mnc_out_388800/MLfields.0000381600.t%03d.nc' }; ...
57 { 'mnc_out_396000/MLfields.0000388800.t%03d.nc' }; ...
58 { 'mnc_out_403200/MLfields.0000396000.t%03d.nc' }; ...
59 { 'mnc_out_410400/MLfields.0000403200.t%03d.nc' }; ...
60 { 'mnc_out_417600/MLfields.0000410400.t%03d.nc' }; ...
61 { 'mnc_out_424800/MLfields.0000417600.t%03d.nc' }; ...
62 { 'mnc_out_432000/MLfields.0000424800.t%03d.nc' }; ...
63 { 'mnc_out_439200/MLfields.0000432000.t%03d.nc' }; ...
64 { 'mnc_out_446400/MLfields.0000439200.t%03d.nc' }; ...
65 { 'mnc_out_453600/MLfields.0000446400.t%03d.nc' }; ...
66 { 'mnc_out_460800/MLfields.0000453600.t%03d.nc' }; ...
67 { 'mnc_out_468000/MLfields.0000460800.t%03d.nc' }; ...
68 { 'mnc_out_475200/MLfields.0000468000.t%03d.nc' }; ...
69 { 'mnc_out_482400/MLfields.0000475200.t%03d.nc' }; ...
70 { 'mnc_out_489600/MLfields.0000482400.t%03d.nc' }; ...
71 { 'mnc_out_496800/MLfields.0000489600.t%03d.nc' }; ...
72 { 'mnc_out_504000/MLfields.0000496800.t%03d.nc' }; ...
73 { 'mnc_out_511200/MLfields.0000504000.t%03d.nc' }; ...
74 { 'mnc_out_518400/MLfields.0000511200.t%03d.nc' }; ...
75 { 'mnc_out_525600/MLfields.0000518400.t%03d.nc' }; ...
76 { 'mnc_out_532800/MLfields.0000525600.t%03d.nc' }; ...
77 { 'mnc_out_540000/MLfields.0000532800.t%03d.nc' }; ...
78 { 'mnc_out_547200/MLfields.0000540000.t%03d.nc' }; ...
79 { 'mnc_out_554400/MLfields.0000547200.t%03d.nc' }; ...
80 { 'mnc_out_561600/MLfields.0000554400.t%03d.nc' }; ...
81 { 'mnc_out_568800/MLfields.0000561600.t%03d.nc' }; ...
82 { 'mnc_out_576000/MLfields.0000568800.t%03d.nc' }; ...
83 { 'mnc_out_583200/MLfields.0000576000.t%03d.nc' }; ...
84 { 'mnc_out_590400/MLfields.0000583200.t%03d.nc' }; ...
85 { 'mnc_out_597600/MLfields.0000590400.t%03d.nc' }; ...
86 { 'mnc_out_604800/MLfields.0000597600.t%03d.nc' }; ...
87 { 'mnc_out_612000/MLfields.0000604800.t%03d.nc' }; ...
88 { 'mnc_out_619200/MLfields.0000612000.t%03d.nc' }; ...
89 { 'mnc_out_626400/MLfields.0000619200.t%03d.nc' }; ...
90 { 'mnc_out_633600/MLfields.0000626400.t%03d.nc' }; ...
91 { 'mnc_out_640800/MLfields.0000633600.t%03d.nc' }; ...
92 { 'mnc_out_648000/MLfields.0000640800.t%03d.nc' }; ...
93 { 'mnc_out_655200/MLfields.0000648000.t%03d.nc' }; ...
94 { 'mnc_out_662400/MLfields.0000655200.t%03d.nc' }; ...
95 { 'mnc_out_669600/MLfields.0000662400.t%03d.nc' }; ...
96 { 'mnc_out_676800/MLfields.0000669600.t%03d.nc' }; ...
97 { 'mnc_out_684000/MLfields.0000676800.t%03d.nc' }; ...
98 { 'mnc_out_691200/MLfields.0000684000.t%03d.nc' }; ...
99 { 'mnc_out_698400/MLfields.0000691200.t%03d.nc' }; ...
100 { 'mnc_out_705600/MLfields.0000698400.t%03d.nc' }; ...
101 { 'mnc_out_712800/MLfields.0000705600.t%03d.nc' }; ...
102 { 'mnc_out_720000/MLfields.0000712800.t%03d.nc' }; ...
103 { 'mnc_out_727200/MLfields.0000720000.t%03d.nc' }; ...
104 { 'mnc_out_734400/MLfields.0000727200.t%03d.nc' }; ...
105 { 'mnc_out_741600/MLfields.0000734400.t%03d.nc' }; ...
106 { 'mnc_out_748800/MLfields.0000741600.t%03d.nc' }; ...
107 { 'mnc_out_756000/MLfields.0000748800.t%03d.nc' }; ...
108 { 'mnc_out_763200/MLfields.0000756000.t%03d.nc' }; ...
109 { 'mnc_out_770400/MLfields.0000763200.t%03d.nc' }; ...
110 { 'mnc_out_777600/MLfields.0000770400.t%03d.nc' }; ...
111 { 'mnc_out_784800/MLfields.0000777600.t%03d.nc' }; ...
112 { 'mnc_out_792000/MLfields.0000784800.t%03d.nc' }; ...
113 { 'mnc_out_799200/MLfields.0000792000.t%03d.nc' }; ...
114 { 'mnc_out_806400/MLfields.0000799200.t%03d.nc' }; ...
115 { 'mnc_out_813600/MLfields.0000806400.t%03d.nc' }; ...
116 { 'mnc_out_820800/MLfields.0000813600.t%03d.nc' }; ...
117 { 'mnc_out_828000/MLfields.0000820800.t%03d.nc' }; ...
118 { 'mnc_out_835200/MLfields.0000828000.t%03d.nc' }; ...
119 { 'mnc_out_842400/MLfields.0000835200.t%03d.nc' }; ...
120 { 'mnc_out_849600/MLfields.0000842400.t%03d.nc' }; ...
121 { 'mnc_out_856800/MLfields.0000849600.t%03d.nc' }; ...
122 { 'mnc_out_864000/MLfields.0000856800.t%03d.nc' }; ...
123 { 'mnc_out_871200/MLfields.0000864000.t%03d.nc' }; ...
124 { 'mnc_out_878400/MLfields.0000871200.t%03d.nc' }; ...
125 { 'mnc_out_885600/MLfields.0000878400.t%03d.nc' }; ...
126 { 'mnc_out_892800/MLfields.0000885600.t%03d.nc' }; ...
127 { 'mnc_out_900000/MLfields.0000892800.t%03d.nc' }; ...
128 { 'mnc_out_907200/MLfields.0000900000.t%03d.nc' }; ...
129 };
130
131 vars = { ...
132 {'u','UVEL','masku'} ...
133 {'v','VVEL','maskv'} ...
134 {'w','WVEL','mask'} ...
135 {'phi','PHIHYD','mask'} ...
136 {'q','SALT','mask'} ...
137 {'rh','RELHUM','mask'} ...
138 {'th','THETA','mask'} ...
139 };
140
141 %======================================================================
142 %
143 % Interpolate to the reference pressure levels and then compute the
144 % derived fields and the temporal sums of all fields on the original
145 % MITgcm grid
146 %
147 disp('Computing Sums')
148
149 itile = 1;
150 for itile = 4:6
151
152 it0 = 0;
153 for iv = 1:length(vars)
154 eval(sprintf('clear %s', vars{iv}{1} ));
155 end
156
157 fi = 1;
158 for fi = [ 1:length(files) ]
159
160 fib = 0;
161
162 fname = sprintf(files{fi}{1},itile);
163 disp([ ' fname = "' fname '"' ]);
164 nc = netcdf(fname, 'nowrite');
165 times = nc{'T'}(:);
166
167 it = 1;
168 for it = 1:length(times)
169
170 for iv = 1:length(vars)
171 eval(sprintf('%s = squeeze(nc{ ''%s'' }(it,:,:,:));', ...
172 vars{iv}{1},vars{iv}{2}));
173 eval(sprintf('mr = max(abs(%s(:)));', vars{iv}{1}));
174 if mr > 1e10
175 % error('values heading out of range!!!');
176 fib = 1;
177 end
178 end
179
180 mask = double(th ~= 0.0);
181 masku = ones(size(th) + [0 0 1]);
182 masku(:,:,1:(end-1)) = masku(:,:,1:(end-1)) .* mask;
183 masku(:,:,2:end ) = masku(:,:,2:end ) .* mask;
184 maskv = ones(size(th) + [0 1 0]);
185 maskv(:,1:(end-1),:) = maskv(:,1:(end-1),:) .* mask;
186 maskv(:,2:end, :) = maskv(:,2:end, :) .* mask;
187
188 if it0 == 0
189 it0 = 1;
190 for iv = 1:length(vars)
191 eval(sprintf('%s_ave = zeros(size(%s));', ...
192 vars{iv}{1},vars{iv}{1}));
193 end
194 mask_sum = zeros(size(mask));
195 masku_sum = zeros(size(masku));
196 maskv_sum = zeros(size(maskv));
197 end
198 for iv = 1:length(vars)
199 eval(sprintf('%s_ave = %s_ave + (%s .* %s);', ...
200 vars{iv}{1}, vars{iv}{1}, ...
201 vars{iv}{3}, vars{iv}{1}));
202 end
203 mask_sum = mask_sum + mask;
204 masku_sum = masku_sum + masku;
205 maskv_sum = maskv_sum + maskv;
206
207 end
208
209 if fib == 1
210 disp([ 'BAD :: "' fname '"' ]);
211 end
212
213 nc = close(nc);
214
215 end
216
217 for iv = 1:length(vars)
218 eval(sprintf('%s_ave = %s_ave ./ %s_sum;', ...
219 vars{iv}{1}, vars{iv}{1}, vars{iv}{3} ));
220 end
221
222 nc = netcdf(sprintf('mnc_out_processed/ML_ave_%d.nc',itile), 'clobber');
223
224 nc('T') = 0;
225 nc('Z') = 17;
226 nc('X') = 32; nc('Xp1') = 33;
227 nc('Y') = 32; nc('Yp1') = 33;
228
229 for iv = 1:length(vars)
230 switch vars{iv}{3}
231 case 'mask'
232 nc{ vars{iv}{2} } = ncdouble( 'T', 'Z', 'Y', 'X' );
233 case 'masku'
234 nc{ vars{iv}{2} } = ncdouble( 'T', 'Z', 'Y', 'Xp1' );
235 case 'maskv'
236 nc{ vars{iv}{2} } = ncdouble( 'T', 'Z', 'Yp1', 'X' );
237 end
238 eval(sprintf('nc{ vars{iv}{2} }(1,:,:,:) = %s_ave;',vars{iv}{1}));
239 end
240 nc{ 'mask_sum' } = ncdouble( 'T', 'Z', 'Y', 'X' );
241 nc{ 'mask_sum' }(1,:,:,:) = mask_sum;
242 nc{ 'masku_sum' } = ncdouble( 'T', 'Z', 'Y', 'Xp1' );
243 nc{ 'masku_sum' }(1,:,:,:) = masku_sum;
244 nc{ 'maskv_sum' } = ncdouble( 'T', 'Z', 'Yp1', 'X' );
245 nc{ 'maskv_sum' }(1,:,:,:) = maskv_sum;
246 nc = close(nc);
247
248 end
249

  ViewVC Help
Powered by ViewVC 1.1.22