


low pass filter (33 hr)
PL66TN: pl66t for variable dt and T
xf=PL66TN(x,dt,T) computes low-passed series xf from x
using pl66 filter, with optional sample interval dt (hrs)
and filter half amplitude period T (hrs) as input for
non-hourly series.
INPUT: x=time series (must be column array)
dt=sample interval time [hrs] (Default dt=1)
T=filter half-amp period [hrs] (Default T=33)
OUTPUT: xf=filtered series

0001 function xf=pl66tn(x,dt,T); 0002 % low pass filter (33 hr) 0003 % PL66TN: pl66t for variable dt and T 0004 % xf=PL66TN(x,dt,T) computes low-passed series xf from x 0005 % using pl66 filter, with optional sample interval dt (hrs) 0006 % and filter half amplitude period T (hrs) as input for 0007 % non-hourly series. 0008 % 0009 % INPUT: x=time series (must be column array) 0010 % dt=sample interval time [hrs] (Default dt=1) 0011 % T=filter half-amp period [hrs] (Default T=33) 0012 % 0013 % OUTPUT: xf=filtered series 0014 0015 % NOTE: both pl64 and pl66 have the same 33 hr filter 0016 % half-amplitude period. pl66 includes additional filter weights 0017 % upto and including the fourth zero crossing at 2*T hrs. 0018 0019 % The PL64 filter is described on p. 21, Rosenfeld (1983), WHOI 0020 % Technical Report 85-35. Filter half amplitude period = 33 hrs., 0021 % half power period = 38 hrs. The time series x is folded over 0022 % and cosine tapered at each end to return a filtered time series 0023 % xf of the same length. Assumes length of x greater than 132. 0024 0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0026 % 10/30/00 0027 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0028 0029 % default to pl64 0030 if (nargin==1); dt=1; T=33; end 0031 0032 cutoff=T/dt; 0033 fq=1./cutoff; 0034 nw=2*T./dt; 0035 nw=round(nw); 0036 %disp(['number of weights = ',int2str(nw)]) 0037 nw2=2.*nw; 0038 0039 [npts,ncol]=size(x); 0040 if (npts<ncol);x=x';[npts,ncol]=size(x);end 0041 xf=x; 0042 0043 % generate filter weights 0044 j=1:nw; 0045 t=pi.*j; 0046 den=fq.*fq.*t.^3; 0047 wts=(2.*sin(2.*fq.*t)-sin(fq.*t)-sin(3.*fq.*t))./den; 0048 % make symmetric filter weights 0049 wts=[wts(nw:-1:1),2.*fq,wts]; 0050 wts=wts./sum(wts);% normalize to exactly one 0051 % plot(wts);grid; 0052 % title(['pl64t filter weights for dt = ',num2str(dt),' and T = ',num2str(T)]) 0053 % xlabel(['number of weights = ',int2str(nw)]);pause; 0054 0055 % fold tapered time series on each end 0056 cs=cos(t'./nw2); 0057 jm=[nw:-1:1]; 0058 0059 for ic=1:ncol 0060 % ['column #',num2str(ic)] 0061 jgd=find(~isnan(x(:,ic))); 0062 npts=length(jgd); 0063 if (npts>nw2) 0064 %detrend time series, then add trend back after filtering 0065 xdt=detrend(x(jgd,ic)); 0066 trnd=x(jgd,ic)-xdt; 0067 y=[cs(jm).*xdt(jm);xdt;cs(j).*xdt(npts+1-j)]; 0068 % filter 0069 yf=filter(wts,1.0,y); 0070 % strip off extra points 0071 xf(jgd,ic)=yf(nw2+1:npts+nw2); 0072 % add back trend 0073 xf(jgd,ic)=xf(jgd,ic)+trnd; 0074 else 0075 'warning time series is too short' 0076 end 0077 end