evalMie.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from scattnlay import mesomie, mie
  2. import numpy as np
  3. def eval_mie_single_spectrum_point(x,m,
  4. R=None, d_perp=None, d_parl=None):
  5. mie.SetLayersSize(x)
  6. mie.SetLayersIndex(m)
  7. mie.RunMieCalculation()
  8. return mie.GetQext(), mie.GetQsca()
  9. def eval_mesomie_single_spectrum_point(x, m, n_m, R, d_perp, d_parl):
  10. mesomie.calc_ab(R*10, # calc_ab needs R in angstrem
  11. x, # xd
  12. x * m, # xm
  13. n_m * n_m, # eps_d
  14. m * m, # eps_m
  15. d_parl, # d_parallel
  16. d_perp) # d_perp
  17. mesomie.calc_Q()
  18. return mesomie.GetQext(), mesomie.GetQsca()
  19. def eval_mie_spectrum(x, m):
  20. Qext = []
  21. Qsca = []
  22. for i in range(len(x)):
  23. ext, sca = eval_mie_single_spectrum_point(x[i], m[i])
  24. Qext.append(ext)
  25. Qsca.append(sca)
  26. return Qext, Qsca
  27. def eval_mesomie_spectrum(x, m, R, d_perp, d_parl=None, n_m=1):
  28. if np.array(d_perp == None).any():
  29. d_perp = np.zeros(len(x))
  30. if np.array(d_parl == None).any():
  31. d_parl = np.zeros(len(x))
  32. Qext = []
  33. Qsca = []
  34. for i in range(len(x)):
  35. ext, sca = eval_mesomie_single_spectrum_point(x[i], m[i], n_m, R,
  36. d_perp[i], d_parl[i])
  37. Qext.append(ext)
  38. Qsca.append(sca)
  39. return Qext, Qsca