1 |
|
|
2 |
choiceStruct=1; |
choiceStruct=3; |
3 |
|
|
4 |
%=============== |
%=============== |
5 |
|
|
41 |
%=============== |
%=============== |
42 |
|
|
43 |
if choiceStruct==2; |
if choiceStruct==2; |
|
budgName='budgHo' |
|
44 |
|
|
45 |
structIn=[]; |
end; |
46 |
% |
|
47 |
load release1/mat/diags_grid_parms.mat myparms; |
%=============== |
48 |
dirMat=['release1/mat/diags_set_' budgName '/']; |
|
49 |
|
if choiceStruct==3; |
50 |
|
|
51 |
|
%budgName='budgHo'; |
52 |
|
|
53 |
|
if budgName(end)=='o'; listFlds={'tend','trU','trV','trWtop'}; |
54 |
|
else; listFlds={'tend','trU','trV','trWtop','trWbot'}; |
55 |
|
end; |
56 |
|
|
57 |
|
for ii=1:length(listFlds); |
58 |
|
fldName=listFlds{ii}; |
59 |
|
%fldName='trWtop'; |
60 |
|
[budgName ' -- ' fldName] |
61 |
|
|
62 |
|
%directories |
63 |
|
dirIn='r4it11.c65i/'; |
64 |
|
dirMat='mat_budg3d/'; |
65 |
|
dirOut=fullfile(dirIn,'nctiles_budg',filesep); |
66 |
|
if ~isdir(dirOut); mkdir(dirOut); end; |
67 |
|
dirOut=fullfile(dirOut,budgName,filesep); |
68 |
|
if ~isdir(dirOut); mkdir(dirOut); end; |
69 |
|
|
70 |
|
%load variable |
71 |
|
eval(['load ' dirIn dirMat 'diags_grid_parms.mat myparms;']); |
72 |
|
dirMat=[dirIn dirMat 'diags_set_' budgName '/']; |
73 |
fileMat=[budgName '_*.mat']; |
fileMat=[budgName '_*.mat']; |
74 |
structIn.vars=diags_read_from_mat(dirMat,fileMat); |
tic; structIn.vars=diags_read_from_mat(dirMat,fileMat,fldName); toc; |
75 |
|
|
76 |
%need vector of time increment |
%time vectors |
77 |
[listTimes]=diags_list_times({'release1/diags/BUDG/'},{'budg2d_hflux_set1'}); |
[listTimes]=diags_list_times({[dirIn 'diags/BUDG/']},{'budg2d_hflux_set1'}); |
78 |
structIn.vars.dt=diff(listTimes); |
structIn.vars.t0=3600*listTimes(1:end-2); |
79 |
structIn.vars.dt=3600*structIn.vars.dt(1:end-1)'; |
structIn.vars.t1=3600*listTimes(2:end-1); |
80 |
% |
|
81 |
specs=structIn.vars.specs(1); |
%rename trWtop as trW if adequate |
82 |
|
if strcmp(fldName,'trWtop')&(budgName(end)=='o'); |
83 |
|
structIn.vars=setfield(structIn.vars,'trW',structIn.vars.trWtop); |
84 |
|
structIn.vars=rmfield(structIn.vars,'trWtop'); |
85 |
|
structIn.vars.listDiags={'trW'}; |
86 |
|
fldName='trW'; |
87 |
|
end; |
88 |
|
|
89 |
|
%switch back to upward convention |
90 |
|
if strcmp(fldName(1:3),'trW'); |
91 |
|
tmp1=getfield(structIn.vars,fldName); |
92 |
|
structIn.vars=setfield(structIn.vars,fldName,-tmp1); |
93 |
|
end; |
94 |
|
|
95 |
|
%general description |
96 |
|
tmp1=diags_read_from_mat(dirMat,fileMat,'specs',1); |
97 |
|
specs=tmp1.specs; |
98 |
if strcmp(specs.units,'W'); |
if strcmp(specs.units,'W'); |
99 |
structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'}; |
structIn.descr={'Heat budget in extensive form (in Watt, on C-Grid)'}; |
100 |
elseif strcmp(specs.units,'kg/s'); |
elseif strcmp(specs.units,'kg/s'); |
104 |
else; |
else; |
105 |
error('unknown budget'); |
error('unknown budget'); |
106 |
end; |
end; |
107 |
structIn.descr={structIn.descr{:},'between',specs.top,'(top) and',specs.bottom,'(bottom)'}; |
|
108 |
% |
%variables description |
109 |
vars=[]; nv=length(vars)+1; |
vars=[]; nv=length(vars)+1; |
110 |
vars(nv).fldName='tend'; vars(nv).longName='tendency term'; vars(nv).units=specs.units; nv=length(vars)+1; |
vars(nv).fldName=fldName; vars(nv).units=specs.units; |
111 |
vars(nv).fldName='trU'; vars(nv).longName='horizontal transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
switch fldName; |
112 |
vars(nv).fldName='trV'; vars(nv).longName='horizontal transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
case 'tend'; vars(nv).longName='tendency term'; |
113 |
vars(nv).fldName='trWtop'; vars(nv).longName='vertical transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
case 'trU'; vars(nv).longName='horizontal transport (U)'; |
114 |
vars(nv).fldName='trWbot'; vars(nv).longName='vertical transport'; vars(nv).units=specs.units; nv=length(vars)+1; |
case 'trV'; vars(nv).longName='horizontal transport (V)'; |
115 |
vars(nv).fldName='dt'; vars(nv).longName='time increment'; vars(nv).units='s'; nv=length(vars)+1; |
case 'trW'; vars(nv).longName='upward vertical transport (W)'; |
116 |
|
case 'trWtop'; vars(nv).longName='upward vertical transport (W)'; |
117 |
|
case 'trWbot'; vars(nv).longName='upward vertical transport (W)'; |
118 |
|
end; |
119 |
|
nv=length(vars)+1; |
120 |
|
vars(nv).fldName='t0'; vars(nv).longName='initial time'; vars(nv).units='s'; nv=length(vars)+1; |
121 |
|
vars(nv).fldName='t1'; vars(nv).longName='final time'; vars(nv).units='s'; nv=length(vars)+1; |
122 |
% |
% |
123 |
structIn.defs=vars; |
structIn.defs=vars; |
124 |
% |
|
125 |
struct2nctiles('release1/',budgName,structIn,[90 90]); |
%create file |
126 |
|
tic; struct2nctiles(dirIn,fldName,structIn,[90 90]); toc; |
127 |
|
eval(['!mv ' pwd filesep dirIn filesep 'tmp_nctiles' filesep fldName ' ' pwd filesep dirOut]); |
128 |
|
|
129 |
|
end;%for fldName=listFlds; |
130 |
|
|
131 |
end; |
end; |
132 |
|
|