function lmcosif=plmfilt(lmcosi,L,wlen) % lmcosif=plmfilt(lmcosi,L,wlen) % % A very simple filtering routine for spherical harmonics % % INPUT: % % lmcosi Standard [degree order cosine sine] coefficients, not % necessarily starting at zero degree % L Single degree with lowpass degree of halfway point % or two degrees for a bandpass filter, NaN for nothing % wlen The odd length of the transition band [default: 5] % % OUTPUT: % % lmcosid Filtered equivalent of the input array % % Last modified by fjsimons-at-alum.mit.edu, 06/22/2011 % Specify defaults defval('wlen',5) defval('L',180) if isnan(L) lmcosif=lmcosi; return end % Make sure it's sorted descending; only lowpass or highpass just yet L=sort(L,'descend'); if ~mod(wlen,2) error('Total filter length must be odd') end % What is the half length of the filter whalf=(wlen-1)/2; % Generate the window as filter coefficients [w,wl,wr]=fhanning(2*wlen); % Initialize lmcosif=lmcosi; % Where does it all start, that determines the offset lofs=addmup(lmcosi(1)-1); % Repeat them the right number of times for the center degree for index=1:length(L) if L(index)+whalf>lmcosi(end,1) | L(index)-whalf