# csdms-contrib/slepian_alpha

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
102 lines (95 sloc) 2.97 KB
 function [Nm,Nsum]=nsubm(N,m,method,L) % [Nm,Nsum]=NSUBM(N,m,method,L) % % Calculates the partial Shannon number, Nm, at a given angular order, m, % from the full Shannon number, N, by a variety of (approximate) % formulations. % % INPUT: % % N Full Shannon number % m Maximum angular order; all will be computed % method 1 Using Bessel functions [default] (exact for 2D Cartesian) % 2 Using hypergeometric functions (asymptotic; slower) % 3 Exact formula using GL integration (requires L) % L Bandwidth (only required for exact formulation) or passband % % OUTPUT: % % Nm The partial Shannon number at angular order m % Nsum The sum of all Nm taking into account degeneracy % % EXAMPLE: % % L=18; TH=20; N=(L+1)^2*(1-cos(TH/180*pi))/2; % [Nm,Nsum]=nsubm(N,L,3,L); N-Nsum % % Last modified by fjsimons-at-alum.mit.edu, 05/21/2009 % Use this to figure out how many tapers to take at a particular angular % order if you have the full Shannon number (the area of the region and % the bandwidth will calculate this for you). This is useful for the % axisymmetric single-order cases where you'll want to calculate the % tapers using Grunbaum's fast method and you might not bother with the % exact eigenvalues at all. defval('N',30) defval('m',3) defval('method',1) defval('L',m) % Figure out if it's lowpass or bandpass lp=length(L)==1; bp=length(L)==2; % Override method if bp; method=3; warning('Need to still fix this') ; end switch method case 1 s=2*sqrt(N); J=besselj(0:m+1,s); Nm=2*N*[J(1:m+1).^2+J(2:m+2).^2]-... (2*[0:m]+1)*sqrt(N).*J(1:m+1).*J(2:m+2)-... 1/2*[0:m].*[1-J(1)^2-2*cumsum([0 J(2:m+1).^2])]; %disp('Asymptotic (Bessel) formalism') case 2 if(~isempty(help('symbolic'))) for ml=0:m Nm(ml+1)=N^(ml+1)*... double(hypergeom(... [1/2+ml,1+ml],... [1+2*ml,2+ml,2+ml],-4*N))/... [(1+ml)*gamma(2+ml)*gamma(1+ml)]; % Note that the last thing is [gamma(2+ml)^2]; end disp('Asymptotic (hypergeometric) formalism') else error('Need symbolic math toolbox') end case 3 % The area, must be smaller than 4 pi of course A=4*pi*N/(L+1)^2; % What's the rough colatitude TH0=acos(1-A/2/pi); if ~isreal(TH0) Nm=repmat(NaN,1,m+1); warning('Area must be smaller than unit sphere; NaNs returned') else Nm=repmat(0,1,m+1); if L