source: issm/oecreview/Archive/19101-20495/ISSM-19296-19297.diff@ 20498

Last change on this file since 20498 was 20498, checked in by Mathieu Morlighem, 9 years ago

CHG: done with Archive/19101-20495

File size: 1.4 KB
  • ../trunk-jpl/src/m/psl/sharmonics.m

     
     1function sh = sharmonics(lat,lon,lMax)
     2
     3%SHarmonics :: a function to compute (ortho-)normalized shperical harmonics
     4%
     5%USAGE: sh = sharmonics(lat,lon,lmax);
     6%
     7%lat (latitude in [0,180] degrees from the north pole)
     8%lon (longitude in [0 360] degrees)
     9%lmax (maximum SH degree you wish to compute)
     10%
     11%sh (spherical harmonics of degree and orders up to "lmax"...
     12%...numbered as 1(l=0), 2(l=1,m=-1), 3(l=1,m=0), 4(l=1,m=1)...)
     13%
     14
     15q=0;
     16%       
     17lat=lat*pi/180;
     18lon=lon*pi/180;
     19
     20%ortho-normalized SH
     21for l=0:lMax
     22        plm = legendre(l,cos(lat),'norm');
     23   for m=-l:l
     24                if(m<0)
     25                        sh(:,1+q)=(-1)^(abs(m))*2.*plm(abs(m)+1,:)'.*sin(abs(m).*lon);
     26      elseif(m==0)
     27         sh(:,1+q)=sqrt(2)*plm(abs(m)+1,:)';
     28      else
     29         sh(:,1+q)=(-1)^(abs(m))*2.*plm(abs(m)+1,:)'.*cos(abs(m).*lon);
     30      end
     31      q=q+1;
     32   end
     33   %disp(['Spherical Harmonics of degree ',num2str(l),' (of ',num2str(lMax),') computed!']);
     34end
     35disp(['Spherical Harmonics of degree and orders up to ',num2str(lMax),' computed!']);
     36
     37
Note: See TracBrowser for help on using the repository browser.