function [w,jd]=getwind(cdf,start,stop); %GETWIND gets wind stress time series from cdf file(s) % USAGE % [w,jd]=getwind(cdf,start,stop); % or % [w,jd]=getwind(cdf); % % where: cdf = string containing the name of the cdf file, or a % string array containing the names of multiple cdf files, i.e. % cdf=['cdf_file1.cdf' % 'cdf_file2.cdf' % 'junk.cdf ']; % start = [yyyy mm dd hh mi sc]; % stop = [yyyy mm dd hh mi sc]; % % if start and stop are missing, then the series overlapping in time are % returned. U and V must be var1 and var2 in cdf file. % % jd = julian day % %var1='east'; %var2='north'; %var1='east_str '; % the u component of velocity %var2='north_str'; % the v component of velocity var1='u.1'; var2='v.1'; % [m,n]=size(cdf); if nargin==1, if m==1, [start,stop]=mcgtim(cdf); %get whole file if only 1 cdf file else [start,stop]=overlap(cdf); %for multiple files, get overlapping data [icyc,ncyc,jd]=mctime(cdf(1,:),start,stop); nt=length(jd); end else jd0=julian(start); jd1=julian(stop); [icyc,ncyc,jd]=mctime(cdf(1,:),start,stop); delt=jd(2)-jd(1); nt=round((jd1-jd0)/delt)+1; % how long is the output series? jda=[jd0:delt:jd1]; end w=ones(nt,m)*NaN; for i=1:m cdfi=cdf(i,:); [icyc,ncyc,jd]=mctime(cdfi,start,stop); u=mcvgt(cdfi,var1,icyc,ncyc); v=mcvgt(cdfi,var2,icyc,ncyc); ind=length(u); if(nargin==3), ind=round((jd-jd0)/delt)+1; w(ind,i)=u+j*v; jd=jda; else w(:,i)=u+j*v; end end