/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/MITprof_resample.m
ViewVC logotype

Diff of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_misc/MITprof_resample.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.4 by gforget, Fri Oct 9 23:43:34 2015 UTC revision 1.5 by gforget, Sun Oct 11 13:37:09 2015 UTC
# Line 35  if strcmp(fldIn.tim,'monclim'); Line 35  if strcmp(fldIn.tim,'monclim');
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,'monloop');
39        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');  elseif strcmp(fldIn.tim,'const')|strcmp(fldIn.tim,'std');
49      tim_fld=[1 2]; rec_fld=[1 1];      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);
# Line 47  depIn=-mygrid.RC; depOut=profIn.prof_dep Line 57  depIn=-mygrid.RC; depOut=profIn.prof_dep
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}));
# Line 55  for tt=1:length(rec_fld)-1; Line 68  for tt=1:length(rec_fld)-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          if ~strcmp(method,'bindata');
72          arr=gcmfaces_interp(fld,lon(ii),lat(ii),method);          arr=gcmfaces_interp(fld,lon(ii),lat(ii),method);
73          arr2=gcmfaces_interp_1d(2,depIn,arr,depOut);          arr2=gcmfaces_interp_1d(2,depIn,arr,depOut);
74      end;                  %now linear in time:
75      %              k0=floor(tim_prof(ii)); k1=k0+1;
76      k0=floor(tim_prof(ii)); k1=k0+1;          a0=tim_prof(ii)-k0; a0=a0*ones(1,profIn.nr);
77      a0=tim_prof(ii)-k0; a0=a0*ones(1,profIn.nr);          profOut(ii,:)=(1-a0).*arr2(:,:,1)+a0.*arr2(:,:,2);
78      profOut(ii,:)=(1-a0).*arr2(:,:,1)+a0.*arr2(:,:,2);        else;
79      if strcmp(fldIn.tim,'std');          [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);
86            profOut(ii,:)=arr2;
87          end;
88          %    
89          if strcmp(fldIn.tim,'std');
90          profOut(ii,:)=profOut(ii,:).*randn(size(profOut(ii,:)));          profOut(ii,:)=profOut(ii,:).*randn(size(profOut(ii,:)));
91          end;
92      end;      end;
93  end;  end;
94    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.22