function varargout=localization(L,dom,N,J,rotb,anti) % [V,C,dels,dems,XY,Klmlmp,G]=LOCALIZATION(L,dom,N,J,rotb,anti) % % Returns bandlimited spectral eigenfunctions and their associated % eigenvalues localized to a closed domain on the unit sphere. % % INPUT: % % L Bandwidth, maximum angular spherical harmonic degree % dom 'patch', 'sqpatch', 'africa', 'eurasia', 'namerica', % 'australia', 'greenland', 'samerica', 'amazon', 'orinoco', % 'gpsnamerica', 'antarctica', 'alloceans' % OR: [lon lat] an ordered list defining a closed curve [degrees] % [N |pars] The splining smoothness [default: 10] or % The 3 or 4 parameters for 'patch' and 'sqpatch' passed to KERNELC, % go look there for the definitions % J Loads only so many eigenfuctions as required [default: all] % rotb 0 That's it, nothing else needs to be said here % 1 The obtained eigenfunctions are subsequently rotated by an % amount that is specified by the region name. Currently this % is only sometimes necessary and even then only possible for % 'antarctica'. The approach using KLMLMP2ROT though % it renders the resulting kernel slightly non-Hermitian. % anti 1 Get the region complementary to the requested region % 0 Don't, proceed as usual % % OUTPUT: % % V A list of all the eigenvalues % C A cell array with cosine/sine coefficients eigenfunctions; % note how GLMALPHA will unwrap these into a neat matrix % dels Spherical harmonic degrees % dems Spherical harmonic orders % XY Coordinates of the outlines of the region % Klmlmp The localization matrix % G The entire matrix of spectral eigenfunctions as from GLMALPHA % % EXAMPLES: % % localization('demoX') % where X=1,2,3,4, 5 or 6 % % SEE ALSO: % % KERNELC, SDWCAP, SDWCAP2, CDLKERNEL, SDWCAPT, SDWCAPT2, LOCALIZATION2D, % PLOTPLM, PLM2XYZ, PLOTSLEP, KLMLMP2ROT, GLMALPHA % % Last modified by fjsimons-at-alum.mit.edu, 10/08/2011 % Study covariance at some point? % Default inputs defval('L',18) if ~isstr(L) defval('dom','australia') defval('N',10) defval('rotb',0) defval('anti',0) % If it's been pre-done this isn't strictly necessary anymore is it % Calculates the localization kernel for this domain try [Klmlmp,XY]=kernelcp(L,dom,N); catch [Klmlmp,XY]=kernelc(L,dom,N); end % We're going to here interpret the call 'alloceans' as needing to % further subtract some continental kernels if strcmp(dom,'alloceans') regs={'samerica','africa','australia'}; for ind=1:length(regs) disp(sprintf('Removing also %s',regs{ind})) try Klmlmp=Klmlmp-kernelcp(L,regs{ind},N); catch Klmlmp=Klmlmp-kernelc(L,regs{ind},N); end end end defval('J',length(Klmlmp)) % I should build in the fact that if XY is just coordinates we should % come up with a name to store the eigenfunctions. A hash, that is. if ~isstr(dom) doms=input... ('We still need a string for the filename:\n','s'); else doms=dom; end % See if the diagonalization has been done before switch doms case 'sqpatch' fnpl=sprintf('%s/%s-%i-%i-%i-%i-%i.mat',... fullfile(getenv('IFILES'),'LOCALIZE'),doms,L,... round(N(1)*180/pi),round(N(2)*180/pi),... round(N(3)*180/pi),round(N(4)*180/pi),J); case 'patch' fnpl=sprintf('%s/%s-%i-%i-%i-%i-%i.mat',... fullfile(getenv('IFILES'),'LOCALIZE'),doms,L,... round(N(1)*180/pi),round(N(2)*180/pi),... round(N(3)*180/pi),J); otherwise fnpl=sprintf('%s/%s-%i-%i-%i.mat',... fullfile(getenv('IFILES'),'LOCALIZE'),doms,L,N,J); end if anti==1 Klmlmp=eye(size(Klmlmp))-Klmlmp; fnpl=sprintf('%s/%s-%i-%i-%i-%i.mat',... fullfile(getenv('IFILES'),'LOCALIZE'),doms,L,N,J,anti); disp(sprintf('Remember that you requested the anti-%s region',doms)) end if exist(fnpl,'file')==2 disp(sprintf('Loading %s',fnpl)) load(fnpl) else % Calculates the eigenfunctions/values for this localization problem if J