Guest User

Untitled

a guest
May 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. def plotradialevolutionFunc(cam, axicon, begin, end, number):
  2. xDim = cam.pixelSize_x * cam.resolution_x
  3. yDim = cam.pixelSize_y * cam.resolution_y
  4.  
  5. x = np.linspace(-xDim / 2, xDim / 2, cam.resolution_x)
  6. y = np.linspace(-yDim / 2, yDim / 2, cam.resolution_y)
  7.  
  8. X, Y = np.meshgrid(x, y)
  9. R = np.sqrt(X ** 2 + Y ** 2)
  10.  
  11. fig, ax = plt.subplots()
  12.  
  13. number_list = np.linspace(begin, end, number)
  14.  
  15. def animate(i):
  16. ax.clear()
  17. Z = np.real(axicon.calc_diffraction(R, i))
  18. ax.set_aspect('equal')
  19. ax.contourf(X, Y, Z, 20)
  20. ax.tick_params(direction='inout', length=8, width=1, pad=8, labelsize=18, top=False, right=False)
  21. return [ax]
  22.  
  23. anim = animation.FuncAnimation(fig, animate, frames=number_list, interval=10, blit=True, repeat=True, repeat_delay=100)
  24. plt.show()
  25.  
  26. def plotradialevolutionArtist(cam, axicon, begin, end, number):
  27. xDim = cam.pixelSize_x * cam.resolution_x
  28. yDim = cam.pixelSize_y * cam.resolution_y
  29.  
  30. x = np.linspace(-xDim / 2, xDim / 2, cam.resolution_x)
  31. y = np.linspace(-yDim / 2, yDim / 2, cam.resolution_y)
  32.  
  33. X, Y = np.meshgrid(x, y)
  34. R = np.sqrt(X ** 2 + Y ** 2)
  35.  
  36. fig, ax = plt.subplots()
  37.  
  38. number_list = np.linspace(begin, end, number)
  39.  
  40. ims = []
  41.  
  42. for i in number_list:
  43. Z = np.real(axicon.calc_diffraction(R, i))
  44. ax.set_aspect('equal')
  45. ax.contourf(X, Y, Z, 20)
  46. ax.tick_params(direction='inout', length=8, width=1, pad=8, labelsize=18, top=False, right=False)
  47. ims.append([ax])
  48.  
  49. anim = animation.ArtistAnimation(fig, ims, interval=100, blit=True, repeat=True, repeat_delay=100)
  50. plt.show()
Add Comment
Please, Sign In to add comment