-
Notifications
You must be signed in to change notification settings - Fork 1
/
capTanSlepianBorC.m
97 lines (80 loc) · 2.24 KB
/
capTanSlepianBorC.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
function [GB,V]=capTanSlepianBorC(L,TH)
% [GB,V]=capTanSlepianBorC(L,TH)
%
% Calculates the Slepian transformation matrix if we are only interested
% in the concentration of either the Blm or Clm
%
% INPUT:
%
% L maximum spherical-harmonic degree
% TH spherical cap opening angle or two angles for ring
%
% OUTPUT:
%
% GB Slepian transformation matrix
% V concentration factors
%
% Last modified by plattner-at-alumni.ethz.ch, 11/19/2018
if ~ischar(L)
% Fromvectanglmalpha.m
mvec=0:L;
sizesBC=max(L+1-max(mvec,1), zeros(size(mvec)) );
siztot=sizesBC;%2*sizesBC;
deM=addmout(L);
alpha=cumsum([1 siztot(1) gamini(siztot(2:end),2) ]);
nelems=(L+1)^3 - L*(L+1)^2 +L*(L+1)*(2*L+1)/6;
%GB=sparse((L+1)^2,2*(L+1)^2 - 2);
GB=sparse([],[],[],(L+1)^2,(L+1)^2 - 1, nelems);
% Treat Blm,Clm like Plm and remove the zero part later
V=nan(1,(L+1)^2-1);
parfor mm=1:L+1
m=mm-1;
[~,~,Bm]=kerneltancapm(TH,L,m);
[Cm,Vm]=eig(Bm);
[Vm,isrtm]=sort(sum(Vm,1),'descend');
Cm=Cm(:,isrtm);
Vppos{mm}=Vm;
Vpneg{mm}=Vm;
CBpos{mm}=Cm;
CBneg{mm}=Cm;
end
CBpos{1} = [zeros(1,size(CBpos{1},2)); CBpos{1}];
CBneg{1} = [zeros(1,size(CBpos{1},2)); CBpos{1}];
for m=0:L
if m>0
GB(deM==-m,alpha(2*m):alpha(2*m+1)-1)=CBneg{m+1};
V(alpha(2*m):alpha(2*m+1)-1)=Vpneg{m+1};
end
%keyboard
GB(deM==m,alpha(2*m+1):alpha(2*m+2)-1)=CBpos{m+1};
V(alpha(2*m+1):alpha(2*m+2)-1)=Vppos{m+1};
end
GB=GB(2:end,:);
% Now sort
[V,isrt]=sort(V,'descend');
GB=GB(:,isrt);
elseif strcmp(L,'demo')
index=3;
L=20;
TH=20;
[GB,V]=capTanSlepianBorC(L,TH);
% Assume it's Blm or Clm
blmcosi=fcoef2flmcosi(GB(:,index),1);
clmcosi=blmcosi;
%clmcosi(:,3:4)=zeros(size(clmcosi(:,3:4)));
blmcosi(:,3:4)=zeros(size(blmcosi(:,3:4)));
% Eval and plot
[r,lon,lat]=blmclm2xyz(blmcosi,clmcosi,1);
caxis([-1,1]*max(abs(caxis)))
kelicol(1)
subplot(1,2,1)
title('colatitudinal component')
plotplm(r(:,:,2),lon*pi/180,lat*pi/180,2);
view(90,90)
subplot(1,2,2)
title('longitudinal component')
plotplm(r(:,:,1),lon*pi/180,lat*pi/180,2);
view(90,90)
caxis([-1,1]*max(abs(caxis)))
kelicol(1)
end