comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » spherical harmonics
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
spherical harmonics [message #21988] Fri, 13 October 2000 00:00 Go to next message
Klaus Gottschaldt is currently offline  Klaus Gottschaldt
Messages: 1
Registered: October 2000
Junior Member
Hallo!

I want to analyze data on a sphere, representing them by spherical
harmonic coefficients.
This is somehow like a Fourier transform, but based on Legendre
polynoms, which are
defined on the surface of a sphere.
Unlike wavelets, this transform is global.
My data are given in the form [longitude, latitude, data_value], where
longitude, latitude
and data_value are vectors of the same length.
Data points are randomly scattered over the sphere with a resolution of
approx. 100km
on the Earth's surface.

Does somebody know, how to do this transform with idl?

Klaus
Re: spherical harmonics [message #76536 is a reply to message #21988] Thu, 16 June 2011 13:50 Go to previous messageGo to next message
parama mukherjee is currently offline  parama mukherjee
Messages: 4
Registered: June 2011
Junior Member
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
Re: spherical harmonics [message #76537 is a reply to message #21988] Thu, 16 June 2011 10:58 Go to previous messageGo to next message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<15555635-f0d5-41cc-9550-65c5ca2600b3@n11g2000yqf.googlegroups.com>,
parama mukherjee <parama2all@gmail.com> wrote:

> 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.

> 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
Re: spherical harmonics [message #76543 is a reply to message #21988] Thu, 16 June 2011 09:03 Go to previous messageGo to next message
parama mukherjee is currently offline  parama mukherjee
Messages: 4
Registered: June 2011
Junior Member
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
Re: spherical harmonics [message #76545 is a reply to message #21988] Thu, 16 June 2011 06:42 Go to previous messageGo to next message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article
<e6e92b27-4152-413e-945a-7f57232e3b55@p13g2000yqh.googlegroups.com>,
parama mukherjee <parama2all@gmail.com> wrote:

> 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
Re: spherical harmonics [message #84618 is a reply to message #76537] Thu, 16 June 2011 14:07 Go to previous message
parama mukherjee is currently offline  parama mukherjee
Messages: 4
Registered: June 2011
Junior Member
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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Problem in creating Postscript of "Transparent Histograms"
Next Topic: Re: Converting distance to degrees

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:42:52 PDT 2025

Total time taken to generate the page: 0.00518 seconds