.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/group_properties/plot_group_properties.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_group_properties_plot_group_properties.py: Group Index and Velocity of Fused Silica ======================================= This example demonstrates how to compute and plot the group index and group velocity of fused silica using :mod:`PyOptik`. .. GENERATED FROM PYTHON SOURCE LINES 10-24 .. 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 the material material = MaterialBank.fused_silica # Compute values over a wavelength range wavelengths = numpy.linspace(0.5, 1.6, 200) * micrometer n_g = material.compute_group_index(wavelengths) v_g = material.compute_group_velocity(wavelengths) .. GENERATED FROM PYTHON SOURCE LINES 25-47 .. code-block:: Python with plt.style.context(mps): fig, ax1 = plt.subplots() ax1.set( xlabel="Wavelength [µm]", ylabel="Group index", title="Fused Silica Group Properties", ) ax1.plot(wavelengths.to(micrometer).magnitude, n_g.magnitude, label="n_g") ax1.legend(loc="upper left") ax2 = ax1.twinx() ax2.set(ylabel="Group velocity [m/s]") ax2.plot( wavelengths.to(micrometer).magnitude, v_g.to("m/s").magnitude, color="tab:red", label="v_g", ) ax2.legend(loc="upper right") plt.show() .. image-sg:: /gallery/group_properties/images/sphx_glr_plot_group_properties_001.png :alt: Fused Silica Group Properties :srcset: /gallery/group_properties/images/sphx_glr_plot_group_properties_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.378 seconds) .. _sphx_glr_download_gallery_group_properties_plot_group_properties.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_group_properties.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_group_properties.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_