efficiency-plasmon-plot.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/usr/bin/env python3
  2. # -*- coding: UTF-8 -*-
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. file_ext="pdf"
  6. #dirname="Si-sphere-step2.5-dipole"
  7. #distance = [100,200,400,800,1200,1600,2000]
  8. #dirname="Si-sphere-step5-dipole-far"
  9. # distance = [1,2,3,4,5,6,7,8,9,10]
  10. # dirname="Si-sphere-step5-dipole-far-long"
  11. distance = [2,4,6,8,10,12,14,16,18,20,22]
  12. dirname="Si-sphere-step5-dipole-far-long22"
  13. data = []
  14. for i in distance:
  15. # print(i, dirname+"/d%i.txt"%i)
  16. data.append(
  17. np.transpose(
  18. np.loadtxt(dirname+"/r%i.txt"%i, delimiter=", ",skiprows=3)
  19. )#[-2]
  20. )
  21. for i in range(len(distance)):
  22. R = distance[i]
  23. print(R)
  24. plt.semilogy(data[i][0,:], data[i][1,:]*np.sqrt(R))
  25. plt.xlabel(r'$\lambda$, nm')
  26. plt.ylabel(r'$Abs(E_x) \sqrt{R}$')
  27. plt.savefig(dirname+"_plot."+file_ext)
  28. plt.clf()
  29. WLs=[300,350,400,450,600,700,800]
  30. #WLs=[300,350,400,450,600,700]
  31. def find_nearest(array,value):
  32. idx = (np.abs(array-value)).argmin()
  33. return array[idx],idx
  34. WLs_idx = []
  35. for wl in WLs:
  36. val, idx = find_nearest(data[0][0,:],wl/1000)
  37. WLs_idx.append(idx)
  38. # print(val,idx, " --> ", data[0][0,idx])
  39. legend = []
  40. for i in range(len(WLs)):
  41. pl_data = []
  42. idx = WLs_idx[i]
  43. legend.append(str(WLs[i])+" nm")
  44. for point in range(len(distance)):
  45. R = distance[point]
  46. pl_data.append(data[point][1,idx]*np.sqrt(R))
  47. plt.semilogy(distance, pl_data,marker="o")
  48. plt.legend(legend)
  49. # #plt.xlabel(r'THz')
  50. plt.xlabel(r'Monitor R, $\mu$m')
  51. plt.ylabel(r'$Abs(E_x) \sqrt{R}$',labelpad=-5)
  52. # plt.title(' r = '+str(core_r))
  53. plt.savefig(dirname+"_WLs."+file_ext)
  54. plt.clf()
  55. plt.close()