.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/sellmeier/plot_compare_glasses.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_sellmeier_plot_compare_glasses.py: Compare the Refractive Index of BK7 and Fused Silica ==================================================== This example compares two common optical glasses available in :class:`~PyOptik.material_bank.MaterialBank`. It computes and plots the refractive index of BK7 and fused silica over the visible to near infrared wavelength range. .. GENERATED FROM PYTHON SOURCE LINES 12-28 .. code-block:: Python import numpy import matplotlib.pyplot as plt from MPSPlots.styles import mps from PyOptik import MaterialBank from PyOptik.units import micrometer # Retrieve materials bk7 = MaterialBank.BK7 silica = MaterialBank.fused_silica # Prepare wavelength range wavelengths = numpy.linspace(0.4, 1.6, 300) * micrometer n_bk7 = bk7.compute_refractive_index(wavelengths) n_silica = silica.compute_refractive_index(wavelengths) .. GENERATED FROM PYTHON SOURCE LINES 29-42 .. code-block:: Python with plt.style.context(mps): fig, ax = plt.subplots() ax.set( title="BK7 vs Fused Silica", xlabel="Wavelength [µm]", ylabel="Refractive index", ) ax.plot(wavelengths.to(micrometer).magnitude, n_bk7.real, label="BK7") ax.plot(wavelengths.to(micrometer).magnitude, n_silica.real, label="Fused Silica") ax.legend() plt.show() .. image-sg:: /gallery/sellmeier/images/sphx_glr_plot_compare_glasses_001.png :alt: BK7 vs Fused Silica :srcset: /gallery/sellmeier/images/sphx_glr_plot_compare_glasses_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.201 seconds) .. _sphx_glr_download_gallery_sellmeier_plot_compare_glasses.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_compare_glasses.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_compare_glasses.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_