mjhoptics / ray-optics

geometric ray tracing for optical systems
BSD 3-Clause "New" or "Revised" License
263 stars 54 forks source link

Refractive index #19

Closed borondics closed 3 years ago

borondics commented 3 years ago

Very nice package!

I am working in the IR range down to long wavelengths and I was wondering about the best way to add arbitrary refractive index data. I typically get them from refractiveindex.info and extrapolate if necessary, so I could produce a 2D list or a numpy array.

mjhoptics commented 3 years ago

Thank you for the kind comment. You could use the InterpolatedGlass class in rayoptics.seq.medium. This takes a list of wavelength/index pairs and uses the scipy.interpolate interp1d() fct to calculate the index at an arbitrary wavelength. I implemented it this way because it was expedient and have not done any rigorous checking of interpolated values vs measured ones. The results have seemed plausible for the cases I've tried (visible spectrum). I've been meaning to write a similar class that would calculate indices from coefficients from published data. I think some of the data on refractiveindex.info includes coefficients to one of several different fitting polynomials. A reasonable template for such a class is the Buchdahl class in the opticalglass.buchdahl package. I would probably add the new class to the opticalglass package directly and use it from there. If you have any further questions or ideas for better addressing your problem, please let me know.

borondics commented 3 years ago

Thanks for the help, it works perfectly.