Discussion:
spherical harmonics
(too old to reply)
parama mukherjee
14 years ago
Permalink
Hi,
Does anybody know how to compute spherical harmonic transforms in IDL.
Other than doing FFT followed by legendre transform?
I have tried looking for it without much success so any help would be
appreciated.
Thanks,
-Parama
Kenneth P. Bowman
14 years ago
Permalink
In article
Post by parama mukherjee
Hi,
Does anybody know how to compute spherical harmonic transforms in IDL.
Other than doing FFT followed by legendre transform?
I have tried looking for it without much success so any help would be
appreciated.
Thanks,
-Parama
Have you looked at SPHER_HARM? I haven't used it and don't know
anything about its efficiency. It looks like it only
computes the values of the spherical harmonics, but that
is an essential step in computing the transform.

There are a number of technical issues with spherical harmonic
transforms that you might need to be aware of. For example,
global atmospheric models generally use a non-regular Gaussian
grid in the meridional direction to improve the efficiency and
accuracy of the Legendre transforms.

NCAR provides a very mature and complete SH transform
library called SPHEREPACK.

http://www.cisl.ucar.edu/css/software/spherepack/

It is a collection of Fortran programs, but could probably
be compiled and called from IDL. It will handle both
Gaussian and regular grids.

Ken Bowman
parama mukherjee
14 years ago
Permalink
Hi,
I downloaded the Spherepack application but meanwhile also chanced
upon the following code (I am posting only parts of it) in IDL that
claims to do spherical harmonic transforms. I did not want to use a
fortran/C code as I need to do transforms at every time step of my
calculation and thought going to and fro between IDL and Fortran may
not be very efficient. So if I can get this to work it will be really
helpful. The problem with the code right now is I cannot follow what
it means by collocation points, or the cp parameter that it lists as
one of its input. I post below the parts where it mentions about
collocation points :

; spherical_transform.pro - This routine performs a spherical
harmonic
; transform on a 2-D array.
;
; usage: B = spherical_transform(A,cp,lmax=lmax,period=period)
; where B(lmax,lmax) = transformed array ordered (l,m)
; A(n_phi,n_theta) = array to be transformed ordered
(phi,theta)
; cp = cosine of theta collocation points for theta grid
; lmax = maximum l in expansion (default is (2*n_theta-1)/
3)
; period = periodicity factor in phi

; This routine performs a spherical harmonic transformation on a 2-D
; (N_phi,N_theta) array. Currently all the work is done in idl, but
future
; versions may want to call C or Fortran routines for efficiency
reasons.
; The input parameters include the array A and the colocation points
for the
; grid (cos(theta)), which is of length N_theta, along with an
optional
; specification of lmax.

; preliminaries
costheta=double(cp)
----------------------------------------------------------------------------------
Now I was thinking maybe cp is an array of cos(theta) values for all
theta 0 - 180 but the costheta = double(cp) is unclear to me.
Please advice.
Thanks,
-Parama
Kenneth P. Bowman
14 years ago
Permalink
In article
Post by parama mukherjee
Hi,
I downloaded the Spherepack application but meanwhile also chanced
upon the following code (I am posting only parts of it) in IDL that
claims to do spherical harmonic transforms. I did not want to use a
fortran/C code as I need to do transforms at every time step of my
calculation and thought going to and fro between IDL and Fortran may
not be very efficient.
Note the comment in the code snippet you provided: "Currently all
work is done in idl, but future version may want to call C or Fortran
routines for efficiency reasons."

SH transforms (like the FFTs they include) are complex. You have to
weight the benefits of having a well-tested and highly-efficient
implementation in Fortran against the difficulty of linking an
external library.

You might want to start with Ronn Kling's book on calling C and
C++ from IDL.
Post by parama mukherjee
The problem with the code right now is I cannot follow what
it means by collocation points.
Collocation points are the points at which the functions are
evaluated.

See, for example

http://en.wikipedia.org/wiki/Collocation_method

Ken Bowman
parama mukherjee
14 years ago
Permalink
Hi,
Thanks for the piece of advice. So I downloaded the Sphere pack
application but at the same time would want to see this code work too.
Maybe can do a comparison later on.
Going by the definition in wikipedia for collocation point, I cannot
place it in the scheme of things here. Like my input array has data
points in a latitude-longitude grid and the ourput would be
coefficients for various l and m so what are collocation points and
what has cos(theta) to do with it. I tried cos(theta) : theta from -90
to 90 but does not work.
Could you please reflect on this?
Thanks,
-Parama
parama mukherjee
14 years ago
Permalink
Thanks for the word of advice.
I am trying to work it out with Spherepack, alongside, I also want to
work with this code so maybe I can even go on and compare both results
at some point.
I cannot apply the concept of collocation points in wikipedia to this
case. I have a data set with data at every longitude and latitude grid
point, thats my input array. Now the output array will be of order
lmax,lmax with coefficients for various l's and m's. So where does
collocation point come into picture? and what does cosine(theta) have
to do with it? I tried using cp as an array with cos(theta( values for
theta : 90 : -90 but getting NaN answers.
-Parama

Continue reading on narkive:
Loading...