I am new to python and wish to calculate a wavefunction by fitting 1D data to a linear combination of spherical harmonics.
I am thinking of expressing wavefcntion as follows
wavefcuntion = aY0+bY1+c*Y2......Yn
and then fit cofficient using curve fitting fucntion in scipy.optimize
The method I tried is explained below
I am doing as follows:
y0= scipy.special.sph_harm(0,0,0,0) y1=scipy.special.sph_harm(1,2,-1,1) y2= ......
and so on.
def wavefun(a,b,c): ##a,b,c are expansion coefficients return ay0+by1+c*y2
newwave=scipy.optimize.curvefit(wavefun, x, y) ##assume I have x, y data
this approach is working, but I will have hundreds of spherical harmonics and expansion coefficients for real work. how do I make this process more efficient?