read_eps0.py 869 B

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. # GPL license from Smuthi project
  3. from scipy.interpolate import interp1d
  4. import numpy as np
  5. from matplotlib import pyplot as plt
  6. def read_eps0(filename, vacuum_wavelength, kind=1):
  7. data_np = np.loadtxt(filename, comments='#', delimiter=',')
  8. data_wl = data_np[:, 0]
  9. eps0 = data_np[:, 1]
  10. f = interp1d(data_wl, eps0, kind=kind)
  11. data_out = np.transpose(np.vstack(
  12. (vacuum_wavelength, f(vacuum_wavelength))))
  13. if len(data_out) == 1:
  14. return data_out[0]
  15. return data_out
  16. WLs = np.linspace(450, 650, 1001)
  17. eps0_real = read_eps0('Au_eps0_real.csv', WLs, kind=2)
  18. eps0_real1 = read_eps0('Au_eps0_real.csv', WLs, kind=1)
  19. eps0_imag = read_eps0('Au_eps0_imag.csv', WLs)
  20. plt.plot(eps0_real[:, 0], eps0_real[:, 1])
  21. plt.plot(eps0_real1[:, 0], eps0_real1[:, 1])
  22. plt.plot(eps0_imag[:, 0], eps0_imag[:, 1])
  23. plt.show()