forked from csdms-contrib/slepian_alpha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
coef2lmcosi.m
35 lines (28 loc) · 875 Bytes
/
coef2lmcosi.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
function lmcosi=coef2lmcosi(coef,onorout)
% lmcosi=coef2lmcosi(coef,onorout)
%
% Transform coefficients given as a vector "coef" into the lmcosi format.
% Requires the coef vector to be "complete" as in having (L+1)^2 entries.
%
% INPUT:
%
% coef the spherical-harmonic coefficients ordered in either addmon or
% addmout format.
% onorout if coef in addmout format, set this to 1. Otherwise (addmon)
% leave out or set it to zero
%
% OUTPUT:
%
% lmcosi the coefficients ordered in lmcosi format (l m cos sin)
%
% See also lmcosi2coef, coef2blmclm, blmclm2coef
%
% Last modified by plattner-at-alumni.ethz.ch, 12/09/2014
defval('onorout',0)
coef=coef(:);
Lmax=sqrt(length(coef))-1;
if onorout
coef=out2on(coef,Lmax);
end
[demsz,delsz,mz,lmc,mzin]=addmon(Lmax);
lmcosi=[delsz demsz reshape(insert(coef,0,mzin),2,length(demsz))'];