# Discrete Spherical Harmonic Transform from Cartesian grid

I have a grid of data on a 3D Cartesian grid and I would like to find a routine that will allow me to input this data and output a spherical harmonic transform for specific values of radial distances. Does anyone know if such a routine exists??

Thanks

• Welcome to SciComp.SE! Can you provide more information about what you want to do? An example would be really helpful. – nicoguaro May 15 '15 at 19:29

Another possibility, and a generalization of the above, would be to define a spherical basis set with the spherical harmonics as the $(\theta, \phi)$-varying functions, and some sort of radial basis function defined on $r \in \left[0,a\right]$, where $a$ is the radius of the largest sphere that will fit inside your grid box. You can then solve for the coefficients of these functions via a point-matching testing procedure and inverting the coefficient matrix. This will give you a continuous function whose value coincides with your grid data at the grid points and interpolates the grid data between grid points, and which you can evaluate at each radius of interest to give you the data you want.