47 |
if isempty(who('method')); method='polygons'; end; |
if isempty(who('method')); method='polygons'; end; |
48 |
|
|
49 |
%0) check for file types |
%0) check for file types |
50 |
test0=~isempty(dir(fldIn.fil)); |
test0=isfield(fldIn,'fil'); |
51 |
[PATH,NAME,EXT]=fileparts(fldIn.fil); |
test1=0; |
52 |
fil_nc=fullfile(PATH,NAME,[NAME '.0001.nc']); |
if test0; |
53 |
fil_nctiles=fullfile(PATH,NAME,NAME); |
test0=~isempty(dir(fldIn.fil)); |
54 |
test1=~isempty(dir(fil_nc)); |
[PATH,NAME,EXT]=fileparts(fldIn.fil); |
55 |
|
fil_nc=fullfile(PATH,NAME,[NAME '.0001.nc']); |
56 |
|
fil_nctiles=fullfile(PATH,NAME,NAME); |
57 |
|
test1=~isempty(dir(fil_nc)); |
58 |
|
end; |
59 |
test2=~isempty(fldIn.fld); |
test2=~isempty(fldIn.fld); |
60 |
|
|
61 |
%1) deal with time line |
%1) deal with time line |
66 |
tim_prof=(profIn.prof_date-tmp2); |
tim_prof=(profIn.prof_date-tmp2); |
67 |
tim_prof(tim_prof>365)=365; |
tim_prof(tim_prof>365)=365; |
68 |
tim_prof=tim_prof/365*12;%neglecting differences in months length |
tim_prof=tim_prof/365*12;%neglecting differences in months length |
69 |
|
if test2; fldIs3d=(length(size(fldIn.fld{1}))==4); end; |
70 |
elseif strcmp(fldIn.tim,'monloop')|strcmp(fldIn.tim,'monser'); |
elseif strcmp(fldIn.tim,'monloop')|strcmp(fldIn.tim,'monser'); |
71 |
if test1; |
if test1; |
72 |
eval(['ncload ' fil_nc ' tim']); |
eval(['ncload ' fil_nc ' tim']); |
76 |
tmp1=dir(fldIn.fil); |
tmp1=dir(fldIn.fil); |
77 |
nt=tmp1.bytes/prod(mygrid.ioSize)/length(mygrid.RC)/4; |
nt=tmp1.bytes/prod(mygrid.ioSize)/length(mygrid.RC)/4; |
78 |
else; |
else; |
79 |
error('gcmfaces input case is missing here'); |
ndim=length(size(fldIn.fld{1})); |
80 |
|
fldIs3d=(ndim==4); |
81 |
|
nt=size(fldIn.fld{1},ndim); |
82 |
end; |
end; |
83 |
tmp1=[1:nt]'; tmp2=ones(nt,1)*[1992 1 15 0 0 0]; tmp2(:,2)=tmp1; |
tmp1=[1:nt]'; tmp2=ones(nt,1)*[1992 1 15 0 0 0]; tmp2(:,2)=tmp1; |
84 |
tim_fld=datenum(tmp2); |
tim_fld=datenum(tmp2); |
98 |
elseif strcmp(fldIn.tim,'const')|strcmp(fldIn.tim,'std'); |
elseif strcmp(fldIn.tim,'const')|strcmp(fldIn.tim,'std'); |
99 |
tim_fld=[1 2]; rec_fld=[1 1]; |
tim_fld=[1 2]; rec_fld=[1 1]; |
100 |
tim_prof=1.5*ones(profIn.np,1); |
tim_prof=1.5*ones(profIn.np,1); |
101 |
|
if test2; fldIs3d=(length(size(fldIn.fld{1}))==3); end; |
102 |
else; |
else; |
103 |
error('this case remains to be implemented'); |
error('this case remains to be implemented'); |
104 |
end; |
end; |
108 |
profOut=NaN*ones(profIn.np,profIn.nr); |
profOut=NaN*ones(profIn.np,profIn.nr); |
109 |
|
|
110 |
%2) loop over record pairs |
%2) loop over record pairs |
111 |
if ~strcmp(method,'bindata'); gcmfaces_bindata; end; |
if strcmp(method,'bindata'); gcmfaces_bindata; end; |
112 |
for tt=1:length(rec_fld)-1; |
for tt=1:length(rec_fld)-1; |
113 |
ii=find(tim_prof>=tim_fld(tt)&tim_prof<tim_fld(tt+1)); |
ii=find(tim_prof>=tim_fld(tt)&tim_prof<tim_fld(tt+1)); |
114 |
if ~isempty(ii); |
if ~isempty(ii); |
115 |
%tt |
%tt |
116 |
% |
% |
117 |
if test2; |
if test2&fldIs3d; |
118 |
fld0=fldIn.fld(:,:,:,rec_fld(tt)); |
fld0=fldIn.fld(:,:,:,rec_fld(tt)); |
119 |
fld1=fldIn.fld(:,:,:,rec_fld(tt+1)); |
fld1=fldIn.fld(:,:,:,rec_fld(tt+1)); |
120 |
|
elseif test2&~fldIs3d; |
121 |
|
fld0=fldIn.fld(:,:,rec_fld(tt)); |
122 |
|
fld1=fldIn.fld(:,:,rec_fld(tt+1)); |
123 |
elseif test1; |
elseif test1; |
124 |
fld0=read_nctiles(fil_nctiles,NAME,rec_fld(tt)); |
fld0=read_nctiles(fil_nctiles,NAME,rec_fld(tt)); |
125 |
fld1=read_nctiles(fil_nctiles,NAME,rec_fld(tt+1)); |
fld1=read_nctiles(fil_nctiles,NAME,rec_fld(tt+1)); |