/[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.6 by gforget, Thu Jan 28 01:54:59 2016 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-tmp1);
48        %round up tim_prof to prevent interpolation in time:
49        %  tmp3=tim_prof*ones(1,length(tim_fld))-ones(length(tim_prof),1)*tim_fld;
50        %  tmp4=sum(tmp3>0,2);
51        %  tim_prof=tim_fld(tmp4)';
52  elseif strcmp(fldIn.tim,'const')|strcmp(fldIn.tim,'std');  elseif strcmp(fldIn.tim,'const')|strcmp(fldIn.tim,'std');
53      tim_fld=[1 2]; rec_fld=[1 1];      tim_fld=[1 2]; rec_fld=[1 1];
54      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 61  depIn=-mygrid.RC; depOut=profIn.prof_dep
61  profOut=NaN*ones(profIn.np,profIn.nr);  profOut=NaN*ones(profIn.np,profIn.nr);
62    
63  %2) loop over record pairs  %2) loop over record pairs
64    if ~strcmp(method,'bindata'); gcmfaces_bindata; end;
65  for tt=1:length(rec_fld)-1;  for tt=1:length(rec_fld)-1;
66        tt
67        %
68      fld0=mygrid.mskC.*read_bin(fldIn.fil,rec_fld(tt));      fld0=mygrid.mskC.*read_bin(fldIn.fil,rec_fld(tt));
69      fld1=mygrid.mskC.*read_bin(fldIn.fil,rec_fld(tt+1));      fld1=mygrid.mskC.*read_bin(fldIn.fil,rec_fld(tt+1));
70      ndim=length(size(fld0{1}));      ndim=length(size(fld0{1}));
# Line 55  for tt=1:length(rec_fld)-1; Line 72  for tt=1:length(rec_fld)-1;
72      %      %
73      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));
74      if ~isempty(ii);      if ~isempty(ii);
75          if ~strcmp(method,'bindata');
76          arr=gcmfaces_interp(fld,lon(ii),lat(ii),method);          arr=gcmfaces_interp(fld,lon(ii),lat(ii),method);
77          arr2=gcmfaces_interp_1d(2,depIn,arr,depOut);          arr2=gcmfaces_interp_1d(2,depIn,arr,depOut);
78      end;                  %now linear in time:
79      %              k0=floor(tim_prof(ii)); k1=k0+1;
80      k0=floor(tim_prof(ii)); k1=k0+1;          a0=tim_prof(ii)-k0; a0=a0*ones(1,profIn.nr);
81      a0=tim_prof(ii)-k0; a0=a0*ones(1,profIn.nr);          profOut(ii,:)=(1-a0).*arr2(:,:,1)+a0.*arr2(:,:,2);
82      profOut(ii,:)=(1-a0).*arr2(:,:,1)+a0.*arr2(:,:,2);        else;
83      if strcmp(fldIn.tim,'std');          [prof_i,prof_j]=gcmfaces_bindata(lon(ii),lat(ii));
84            FLD=convert2array(fld(:,:,:,1));
85            nk=length(mygrid.RC); kk=ones(1,nk);
86            np=length(ii); pp=ones(np,1);
87            ind2prof=sub2ind(size(FLD),prof_i*kk,prof_j*kk,pp*[1:nk]);
88            arr=FLD(ind2prof);
89            arr2=gcmfaces_interp_1d(2,depIn,arr,depOut);
90            profOut(ii,:)=arr2;
91          end;
92          %    
93          if strcmp(fldIn.tim,'std');
94          profOut(ii,:)=profOut(ii,:).*randn(size(profOut(ii,:)));          profOut(ii,:)=profOut(ii,:).*randn(size(profOut(ii,:)));
95          end;
96      end;      end;
97  end;  end;
98    

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

  ViewVC Help
Powered by ViewVC 1.1.22