20 |
%listFiles={'trsp_3d_set1','trsp_3d_set2','trsp_3d_set3'}; |
%listFiles={'trsp_3d_set1','trsp_3d_set2','trsp_3d_set3'}; |
21 |
%for ff=1:length(listFiles); process2nctiles('iter12/',listFiles{ff},[],[90 90]); end; |
%for ff=1:length(listFiles); process2nctiles('iter12/',listFiles{ff},[],[90 90]); end; |
22 |
|
|
23 |
|
%replace time series with monthly climatology? |
24 |
|
doClim=0; |
25 |
|
|
26 |
%directory names |
%directory names |
27 |
listDirs={'STATE/','TRSP/'}; |
listDirs={'STATE/','TRSP/'}; |
28 |
filAvailDiag=[dirModel 'available_diagnostics.log']; |
filAvailDiag=[dirModel 'available_diagnostics.log']; |
29 |
filReadme=[dirModel 'README']; |
filReadme=[dirModel 'README']; |
30 |
dirOut=[dirModel 'nctiles/']; |
dirOut=[dirModel 'nctiles_tmp/']; |
31 |
if ~isdir(dirOut); mkdir(dirOut); end; |
if ~isdir(dirOut); mkdir(dirOut); end; |
32 |
|
|
33 |
%seacrh in subdirectories |
%search in subdirectories |
34 |
subDir=[]; |
subDir=[]; |
35 |
for ff=1:length(listDirs); |
for ff=1:length(listDirs); |
36 |
tmp1=dir([dirModel 'diags/' listDirs{ff} fileModel '*']); |
tmp1=dir([dirModel 'diags/' listDirs{ff} fileModel '*']); |
75 |
%read time series |
%read time series |
76 |
myDiag=rdmds2gcmfaces([dirIn fileModel '*'],NaN,'rec',irec); |
myDiag=rdmds2gcmfaces([dirIn fileModel '*'],NaN,'rec',irec); |
77 |
|
|
78 |
|
%replace time series with monthly climatology |
79 |
|
if doClim; myDiag=compClim(myDiag); end; |
80 |
|
|
81 |
%set ancilliary time variable |
%set ancilliary time variable |
82 |
nn=length(size(myDiag{1})); |
nn=length(size(myDiag{1})); |
83 |
nn=size(myDiag{1},nn); |
nn=size(myDiag{1},nn); |
123 |
coord='lon lat tim'; |
coord='lon lat tim'; |
124 |
end; |
end; |
125 |
|
|
126 |
|
%replace time series with monthly climatology |
127 |
|
if doClim; |
128 |
|
listTimes=listTimes(1:12); |
129 |
|
timUnits='days since year-1-1 0:0:0'; |
130 |
|
avail_diag.longNameDiag=[avail_diag.longNameDiag ' (climatology) ']; |
131 |
|
end; |
132 |
|
|
133 |
%create netcdf file using write2nctiles (works only with old matlab, thus far ...) |
%create netcdf file using write2nctiles (works only with old matlab, thus far ...) |
134 |
doCreate=1; |
doCreate=1; |
135 |
dimlist=write2nctiles(myFile,myDiag,doCreate,{'tileNo',tileNo},... |
dimlist=write2nctiles(myFile,myDiag,doCreate,{'tileNo',tileNo},... |
180 |
|
|
181 |
%read meta file |
%read meta file |
182 |
tmp1=dir([fileName '*.meta']); tmp1=tmp1(1).name; |
tmp1=dir([fileName '*.meta']); tmp1=tmp1(1).name; |
183 |
tmp2=strfind(fileName,'/'); |
tmp2=strfind(fileName,filesep); |
184 |
if ~isempty(tmp2); tmp2=tmp2(end); else; tmp2=0; end; |
if ~isempty(tmp2); tmp2=tmp2(end); else; tmp2=0; end; |
185 |
tmp1=[fileName(1:tmp2) tmp1]; fid=fopen(tmp1); |
tmp1=[fileName(1:tmp2) tmp1]; fid=fopen(tmp1); |
186 |
while 1; |
while 1; |
291 |
grid_diag.dep=reshape(grid_diag.dep,[1 1 avail_diag.nr]); |
grid_diag.dep=reshape(grid_diag.dep,[1 1 avail_diag.nr]); |
292 |
grid_diag.dz=reshape(grid_diag.dz,[1 1 avail_diag.nr]); |
grid_diag.dz=reshape(grid_diag.dz,[1 1 avail_diag.nr]); |
293 |
end; |
end; |
294 |
|
|
295 |
|
%%replace time series with monthly climatology |
296 |
|
function [FLD]=compClim(fld); |
297 |
|
|
298 |
|
gcmfaces_global; |
299 |
|
|
300 |
|
ndim=length(size(fld{1})); |
301 |
|
nyear=size(fld{1},ndim)/12; |
302 |
|
|
303 |
|
if ndim==3; FLD=NaN*fld(:,:,1:12); end; |
304 |
|
if ndim==4; FLD=NaN*fld(:,:,:,1:12); end; |
305 |
|
|
306 |
|
for mm=1:12; |
307 |
|
if ndim==3; FLD(:,:,mm)=mean(fld(:,:,mm:12:12*nyear),ndim); end; |
308 |
|
if ndim==4; FLD(:,:,:,mm)=mean(fld(:,:,:,mm:12:12*nyear),ndim); end; |
309 |
|
end; |
310 |
|
|