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

Contents of /MITgcm/verification/fizhi-cs-aqualev20/scripts/assemble_GT.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:28 2006 UTC (18 years, 1 month 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: assemble_GT.m,v 1.2 2006/03/14 03:10:42 edhill Exp $
3 %
4 % Ed Hill
5 %
6 % Generate the APE GT fields:
7 %
8 % For all time steps:
9 % For all variables:
10 % Convert units as necessary:
11 % Write netCDF output with all attributes:
12 %
13
14 %======================================================================
15 %
16 % Define the connections between the APE "GT" variables and the
17 % MITgcm diagnostics output
18 %
19 months.i_start = 7;
20 months.i_end = 42;
21 bname = 'data/GTall.nc';
22 oname = { 'GT_fields.nc' };
23
24 % Get the following from:
25 % ! (cd ../../ape_data_specs/ ; ./gt_parse.sh)
26 vars = {};
27 vars{1} = {'GT01','gt_sw_toai','RADSWT_ave', ...
28 'toa_incoming_shortwave_flux','W m-2','-','1',''};
29 vars{2} = {'GT02','gt_sw_toar','OSR_ave', ...
30 'toa_outgoing_shortwave_flux','W m-2','-','-1',''};
31 vars{3} = {'GT04','gt_lw_toa','OLR_ave', ...
32 'toa_outgoing_longwave_flux','W m-2','-','1',''};
33 vars{4} = {'GT07','gt_cld_frac','CLDFRC_ave', ...
34 'cloud_area_fraction','1','-','1',''};
35 vars{5} = {'GT08','gt_cldw','---', ...
36 'atmosphere_cloud_condensed_water_co','kg m-2','-','1',''};
37 vars{6} = {'GT09','gt_cldi','---', ...
38 'atmosphere_cloud_ice_content','kg m-2','-','1',''};
39 vars{7} = {'GT11','gt_cppn','PRECON_ave', ...
40 'convective_precipitation_flux','kg m-2 s-1','-',...
41 '0.000011574074','units = PRECON / (24*3600)'};
42 vars{8} = {'GT12','gt_dppn','GT12', ...
43 'large_scale_precipitation_flux','kg m-2 s-1','-', ...
44 '0.000011574074','GT12 = PREACC - PRECON'};
45 vars{9} = {'GT13','gt_evap','EVAP_ave', ...
46 'evaporation_flux','kg m-2 s-1','-', ...
47 '0.000011574074','units = EVAP / (24*3600)'};
48 vars{10} = {'GT15','gt_sswi','GT15', ...
49 'surface_downwelling_shortwave_flux','W m-2','-', ...
50 '1','GT15 = RADSWG/(1 - (ALBNIRDF + ALBVISDF)/2)'};
51 vars{11} = {'GT16','gt_sswr','GT16', ...
52 'surface_upwelling_shortwave_flux','W m-2','-','-1', ...
53 'GT16 = RADSWG*(1/(1 - (ALBNIRDF + ALBVISDF)/2) - 1)'};
54 vars{12} = {'GT18','gt_slwd','LWGDOWN_ave', ...
55 'surface_downwelling_longwave_flux','W m-2','-','-1',''};
56 vars{13} = {'GT19','gt_slwu','LWGUP_ave', ...
57 'surface_upwelling_longwave_flux','W m-2','-','1',''};
58 vars{14} = {'GT21','gt_slh','EFLUX_ave', ...
59 'surface_upward_latent_heat_flux','W m-2','-','1',''};
60 vars{15} = {'GT22','gt_ssh','HFLUX_ave', ...
61 'surface_upward_sensible_heat_flux','W m-2','-','1',''};
62 vars{16} = {'GT24','gt_ts2m','T2M_ave', ...
63 'surface_air_temperature','K','-','1',''};
64 vars{17} = {'GT25','gt_ps','PS_ave', ...
65 'surface_air_pressure','Pa','-','100',''};
66
67
68 %======================================================================
69 %
70 % Open the input files and get the (minimum) number of time steps
71 % available across all the files
72 %
73 disp('Finding available time steps')
74
75 ncl = {};
76 nTmin = 0;
77 ifacet = 1;
78 % for ifacet = 1:nfacets
79 fname = bname;
80 nc = netcdf(fname, 'nowrite');
81 ncl{ifacet} = nc;
82 T = nc{'T'}(:);
83 nT = length(T);
84 if (ifacet == 1)
85 nTmin = nT;
86 else
87 nTmin = min(nTmin, nT);
88 end
89 nc = [];
90 % end
91 disp(sprintf(' total iterations found = %d',nTmin));
92
93
94 %======================================================================
95 %
96 % Open the input files and get the (minimum) number of time steps
97 % available across all the files
98 %
99 disp('Reading the data')
100
101 nc = ncl{1};
102 time = nc{ 'T' }(:);
103
104 for iv = 1:length(vars)
105
106 % cull unknown variables
107 if ( vars{iv}{3}(1) == '-' )
108 continue
109 end
110
111 % skip over computed quantities
112 if strcmp( vars{iv}{1} , vars{iv}{3} )
113 continue
114 end
115
116 % WARN about missing variables
117 nc = ncl{ifacet};
118 if prod(size(nc{vars{iv}{3}})) == 0
119 if it == 1
120 str = 'var "%s" does not exist in file "%s"';
121 disp(sprintf([' Warning: ' str], vars{iv}{3}, name(nc)));
122 end
123 continue
124 end
125
126 % get the data
127 t0 = squeeze( nc{ vars{iv}{3} }(:) );
128
129 dat(iv,ifacet).n = 1;
130 dat(iv,ifacet).a = t0;
131
132 end
133
134 % fill in the derived fields
135 for iv = 1:length(vars)
136 tmp = [];
137 nc = ncl{ifacet};
138
139 if strncmp(vars{iv}{1},'GT12',4)
140 % GT12 = PREACC_ave - PRECON_ave
141 tmp = squeeze( nc{ 'PREACC_ave' }(:) ) ...
142 - squeeze( nc{ 'PRECON_ave' }(:) );
143 end
144
145 if strncmp(vars{iv}{1},'GT15',4) || strncmp(vars{iv}{1},'GT16',4)
146 albedo = ( squeeze( nc{ 'ALBNIRDF_ave' }(:)) ...
147 + squeeze( nc{ 'ALBVISDF_ave' }(:)) ) ./ 2.0;
148 if vars{iv}{1} == 'GT15'
149 % GT15 = RADSWG_ave/(1 - ALBEDO_ave)
150 tmp = squeeze( nc{ 'RADSWG_ave' }(:) ) ...
151 ./ (1.0 - albedo);
152 end
153 if strncmp(vars{iv}{1},'GT16',4)
154 % GT16 = RADSWG_ave*(1/(1 - ALBEDO_ave) - 1)
155 tmp = squeeze( nc{ 'RADSWG_ave' }(:) ) ...
156 .* (1.0./(1.0 - albedo) - 1.0);
157 end
158 end
159
160 if length(tmp) > 0
161 dat(iv,ifacet).n = 1;
162 dat(iv,ifacet).a = tmp;
163 end
164
165 end
166
167 ave = [];
168 for iv = 1:length(vars)
169 ind = length(ave) + 1;
170 ifacet = 1;
171 if length(dat(iv,ifacet).n) == 0
172 continue
173 end
174 ave(ind).v(:,ifacet) = dat(iv,ifacet).a;
175 ave(ind).ivar = iv;
176 end
177
178 % close the input files
179 nc = close( ncl{1} );
180 clear ncl;
181
182
183 %======================================================================
184 %
185 % Convert units
186 %
187 disp('Converting units')
188
189 for ia = 1:length(ave)
190 if strcmp(vars{ ave(ia).ivar }{7}, '-') ~= 1
191 eval(['fac = ' vars{ ave(ia).ivar }{7} ';']);
192 if fac ~= 1
193 ave(ia).v = fac .* ave(ia).v;
194 end
195 end
196 end
197
198
199 %======================================================================
200 %
201 % Write netCDF output
202 %
203 disp('Writing netCDF output')
204
205 nc = netcdf(oname{1}, 'clobber');
206 %nc.title = [ 'Aqua Planet: ' ...
207 % 'Single-Level 2-D Means from "Example" Experiment' ];
208 nc.institution = 'MIT Dept. of EAPS, Cambridge, MA, USA';
209 nc.source = [ 'MITgcm: ' ];
210 nc.Conventions = 'CF-1.0';
211 %nc.history = [ 'Original data produced: ' '2002/08/20' ];
212
213 nc('time') = length( ave(1).v );
214 nc('bnd') = 2;
215
216 nc{'time'} = ncdouble('time');
217 nc{'time'}.standard_name = 'time';
218 nc{'time'}.units = 'days since 0000-01-01';
219 nc{'time'}.bounds = 'time_bnds';
220 nc{'time'}(:) = time / (24*3600);
221
222 %float time_bnds(time, bnd) ;
223 %time_bnds:long_name = "time interval endpoints" ;
224 nc{'time_bnds'} = ncdouble('time','bnd');
225 nc{'time_bnds'}.ape_name = 'time interval endpoints';
226 nc{'time_bnds'}.units = 'days since 0000-01-01';
227 tbds(1,:) = (time - 24*3600)/(24*3600);
228 tbds(2,:) = (time)/(24*3600);
229 nc{'time_bnds'}(:) = tbds';
230
231
232 for ii = 1:length(ave)
233
234 iv = ave(ii).ivar;
235 nc{ vars{iv}{2} } = ncfloat( 'time' );
236 nc{ vars{iv}{2} }.ape_name = vars{iv}{4};
237 nc{ vars{iv}{2} }.units = vars{iv}{5};
238 nc{ vars{iv}{2} }.FillValue_ = 1.0e20;
239
240 nc{ vars{iv}{2} }(:) = ave(ii).v;
241
242 end
243
244 nc = close(nc);

  ViewVC Help
Powered by ViewVC 1.1.22