Advertisement
Guest User

Untitled

a guest
Nov 29th, 2018
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. def fun(phi, theta):
  2.     term_1 = (np.cos(phi) * np.cos(2.*theta))**2
  3.     term_2 = 0.5 * np.sin(phi)**2
  4.     return term_1 + term_2
  5.  
  6. import numpy as np
  7. import matplotlib.pyplot as plt
  8.  
  9. halfpi, pi, twopi = [f*np.pi for f in (0.5, 1, 2)]
  10.  
  11. theta = np.linspace(-halfpi, halfpi, 201)
  12. phi   = np.linspace(-pi,     pi,     401)
  13.  
  14. Theta, Phi = np.meshgrid(theta, phi, indexing='ij')
  15. print Theta.shape
  16. print Phi.shape
  17.  
  18. F = fun(Phi, Theta)
  19.  
  20. plt.figure()
  21. plt.imshow(F)
  22. plt.colorbar()
  23. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement