35 |
tim_prof=(profIn.prof_date-tmp2); |
tim_prof=(profIn.prof_date-tmp2); |
36 |
tim_prof(tim_prof>365)=365; |
tim_prof(tim_prof>365)=365; |
37 |
tim_prof=tim_prof/365*12;%neglecting differences in months length |
tim_prof=tim_prof/365*12;%neglecting differences in months length |
38 |
elseif strcmp(fldIn.tim,'const'); |
elseif strcmp(fldIn.tim,'monloop'); |
39 |
tim_fld=[1 2]; rec_fld=[1 2]; |
tmp1=dir(fldIn.fil); |
40 |
|
nt=tmp1.bytes/prod(mygrid.ioSize)/length(mygrid.RC)/4; |
41 |
|
tmp1=[1:nt]'; tmp2=ones(nt,1)*[1992 1 15 0 0 0]; tmp2(:,2)=tmp1; |
42 |
|
tim_fld=datenum(tmp2); |
43 |
|
tim_fld=[tim_fld(1)-31 tim_fld' tim_fld(end)+31]; |
44 |
|
rec_fld=[nt 1:nt 1]; |
45 |
|
tmp1=datenum([1992 1 1 0 0 0]); |
46 |
|
tmp2=datenum([1992+nt/12 1 1 0 0 0]);; |
47 |
|
tim_prof=tmp1+mod(profIn.prof_date-tmp1,tmp2); |
48 |
|
elseif strcmp(fldIn.tim,'const')|strcmp(fldIn.tim,'std'); |
49 |
|
tim_fld=[1 2]; rec_fld=[1 1]; |
50 |
tim_prof=1.5*ones(profIn.np,1); |
tim_prof=1.5*ones(profIn.np,1); |
51 |
else; |
else; |
52 |
error('this case remains to be implemented'); |
error('this case remains to be implemented'); |
57 |
profOut=NaN*ones(profIn.np,profIn.nr); |
profOut=NaN*ones(profIn.np,profIn.nr); |
58 |
|
|
59 |
%2) loop over record pairs |
%2) loop over record pairs |
60 |
|
if ~strcmp(method,'bindata'); gcmfaces_bindata; end; |
61 |
for tt=1:length(rec_fld)-1; |
for tt=1:length(rec_fld)-1; |
62 |
|
tt |
63 |
|
% |
64 |
fld0=mygrid.mskC.*read_bin(fldIn.fil,rec_fld(tt)); |
fld0=mygrid.mskC.*read_bin(fldIn.fil,rec_fld(tt)); |
65 |
fld1=mygrid.mskC.*read_bin(fldIn.fil,rec_fld(tt+1)); |
fld1=mygrid.mskC.*read_bin(fldIn.fil,rec_fld(tt+1)); |
66 |
ndim=length(size(fld0{1})); |
ndim=length(size(fld0{1})); |
68 |
% |
% |
69 |
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)); |
70 |
if ~isempty(ii); |
if ~isempty(ii); |
71 |
arr=gcmfaces_interp(fld,lon(ii),lat(ii),'polygons'); |
if ~strcmp(method,'bindata'); |
72 |
|
arr=gcmfaces_interp(fld,lon(ii),lat(ii),method); |
73 |
|
arr2=gcmfaces_interp_1d(2,depIn,arr,depOut); |
74 |
|
%now linear in time: |
75 |
|
k0=floor(tim_prof(ii)); k1=k0+1; |
76 |
|
a0=tim_prof(ii)-k0; a0=a0*ones(1,profIn.nr); |
77 |
|
profOut(ii,:)=(1-a0).*arr2(:,:,1)+a0.*arr2(:,:,2); |
78 |
|
else; |
79 |
|
[prof_i,prof_j]=gcmfaces_bindata(lon(ii),lat(ii)); |
80 |
|
FLD=convert2array(fld(:,:,:,1)); |
81 |
|
nk=length(mygrid.RC); kk=ones(1,nk); |
82 |
|
np=length(ii); pp=ones(np,1); |
83 |
|
ind2prof=sub2ind(size(FLD),prof_i*kk,prof_j*kk,pp*[1:nk]); |
84 |
|
arr=FLD(ind2prof); |
85 |
arr2=gcmfaces_interp_1d(2,depIn,arr,depOut); |
arr2=gcmfaces_interp_1d(2,depIn,arr,depOut); |
86 |
end; |
profOut(ii,:)=arr2; |
87 |
% |
end; |
88 |
k0=floor(tim_prof(ii)); k1=k0+1; |
% |
89 |
a0=tim_prof(ii)-k0; a0=a0*ones(1,profIn.nr); |
if strcmp(fldIn.tim,'std'); |
90 |
profOut(ii,:)=(1-a0).*arr2(:,:,1)+a0.*arr2(:,:,2); |
profOut(ii,:)=profOut(ii,:).*randn(size(profOut(ii,:))); |
91 |
|
end; |
92 |
|
end; |
93 |
end; |
end; |
94 |
|
|
95 |
%3) deal with file output |
%3) deal with file output |