plot_spheric.py 762 B

1234567891011121314151617181920212223
  1. """Surface plotting in spherical coordinates
  2. Spherical harmonic function is:
  3. Y(l=2, m=0) = 3 :dot cos:^2:theta - 1
  4. (red points are made NaN on purpose)"""
  5. from vedo import *
  6. from vedo.pyplot import plot
  7. import numpy as np
  8. def rhofunc(theta, phi):
  9. if theta < 0.2:
  10. return np.nan # make some points invalid
  11. #return cos(theta)**2 # Y(l=1 m=0)
  12. return (3*cos(theta)**2 - 1)**2 # Y(l=2 m=0)
  13. #return (5*cos(theta)**3 - 3*cos(theta))**2 # Y(l=3 m=0)
  14. # Build the plot,
  15. # return an Assembly of 3 meshes, the unit
  16. # grid sphere, the surface rho(theta, phi) and
  17. # the red Points where rho is a complex number:
  18. spl = plot(rhofunc, mode='spheric', cmap='viridis')
  19. show(spl, __doc__, axes=12, viewup='z').close()