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

Annotation of /MITgcm/verification/fizhi-cs-aqualev20/scripts/average_ML.m

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


Revision 1.1 - (hide annotations) (download)
Mon Apr 3 20:55:29 2006 UTC (18 years, 2 months 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 molod 1.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     ML_files
22    
23     vars = { ...
24     {'u','UVEL','masku'} ...
25     {'v','VVEL','maskv'} ...
26     {'w','WVEL','mask'} ...
27     {'phi','PHIHYD','mask'} ...
28     {'q','SALT','mask'} ...
29     {'rh','RELHUM','mask'} ...
30     {'th','THETA','mask'} ...
31     };
32    
33     %======================================================================
34     %
35     % Interpolate to the reference pressure levels and then compute the
36     % derived fields and the temporal sums of all fields on the original
37     % MITgcm grid
38     %
39     disp('Computing Sums')
40    
41     itile = 1;
42     for itile = 1:6
43    
44     it0 = 0;
45     for iv = 1:length(vars)
46     eval(sprintf('clear %s', vars{iv}{1} ));
47     end
48    
49     fi = 1;
50     for fi = [ 1:length(files) ]
51    
52     fib = 0;
53    
54     fname = sprintf(files{fi}{1},itile);
55     disp([ ' fname = "' fname '"' ]);
56     nc = netcdf(fname, 'nowrite');
57     times = nc{'T'}(:);
58    
59     it = 1;
60     for it = 1:length(times)
61    
62     for iv = 1:length(vars)
63     eval(sprintf('%s = squeeze(nc{ ''%s'' }(it,:,:,:));', ...
64     vars{iv}{1},vars{iv}{2}));
65     eval(sprintf('mr = max(abs(%s(:)));', vars{iv}{1}));
66     if mr > 1e10
67     % error('values heading out of range!!!');
68     fib = 1;
69     end
70     end
71    
72     mask = double(th ~= 0.0);
73     masku = ones(size(th) + [0 0 1]);
74     masku(:,:,1:(end-1)) = masku(:,:,1:(end-1)) .* mask;
75     masku(:,:,2:end ) = masku(:,:,2:end ) .* mask;
76     maskv = ones(size(th) + [0 1 0]);
77     maskv(:,1:(end-1),:) = maskv(:,1:(end-1),:) .* mask;
78     maskv(:,2:end, :) = maskv(:,2:end, :) .* mask;
79    
80     if it0 == 0
81     it0 = 1;
82     for iv = 1:length(vars)
83     eval(sprintf('%s_ave = zeros(size(%s));', ...
84     vars{iv}{1},vars{iv}{1}));
85     end
86     mask_sum = zeros(size(mask));
87     masku_sum = zeros(size(masku));
88     maskv_sum = zeros(size(maskv));
89     end
90     for iv = 1:length(vars)
91     eval(sprintf('%s_ave = %s_ave + (%s .* %s);', ...
92     vars{iv}{1}, vars{iv}{1}, ...
93     vars{iv}{3}, vars{iv}{1}));
94     end
95     mask_sum = mask_sum + mask;
96     masku_sum = masku_sum + masku;
97     maskv_sum = maskv_sum + maskv;
98    
99     end
100    
101     if fib == 1
102     disp([ 'BAD :: "' fname '"' ]);
103     end
104    
105     nc = close(nc);
106    
107     end
108    
109     for iv = 1:length(vars)
110     eval(sprintf('%s_ave = %s_ave ./ %s_sum;', ...
111     vars{iv}{1}, vars{iv}{1}, vars{iv}{3} ));
112     end
113    
114     nc = netcdf(sprintf('ML_ave_%d.nc',itile), 'clobber');
115    
116     nc('T') = 0;
117     nc('Z') = 17;
118     nc('X') = 32; nc('Xp1') = 33;
119     nc('Y') = 32; nc('Yp1') = 33;
120    
121     for iv = 1:length(vars)
122     switch vars{iv}{3}
123     case 'mask'
124     nc{ vars{iv}{2} } = ncdouble( 'T', 'Z', 'Y', 'X' );
125     case 'masku'
126     nc{ vars{iv}{2} } = ncdouble( 'T', 'Z', 'Y', 'Xp1' );
127     case 'maskv'
128     nc{ vars{iv}{2} } = ncdouble( 'T', 'Z', 'Yp1', 'X' );
129     end
130     eval(sprintf('nc{ vars{iv}{2} }(1,:,:,:) = %s_ave;',vars{iv}{1}));
131     end
132     nc{ 'mask_sum' } = ncdouble( 'T', 'Z', 'Y', 'X' );
133     nc{ 'mask_sum' }(1,:,:,:) = mask_sum;
134     nc{ 'masku_sum' } = ncdouble( 'T', 'Z', 'Y', 'Xp1' );
135     nc{ 'masku_sum' }(1,:,:,:) = masku_sum;
136     nc{ 'maskv_sum' } = ncdouble( 'T', 'Z', 'Yp1', 'X' );
137     nc{ 'maskv_sum' }(1,:,:,:) = maskv_sum;
138     nc = close(nc);
139    
140     end
141    

  ViewVC Help
Powered by ViewVC 1.1.22