.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/analysis/plot_structured_wavelength_sweep.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_analysis_plot_structured_wavelength_sweep.py: Structured wavelength sweep =========================== Sweep a mode without mutating the original fiber state. .. GENERATED FROM PYTHON SOURCE LINES 7-29 .. image-sg:: /gallery/analysis/images/sphx_glr_plot_structured_wavelength_sweep_001.png :alt: SMF-28 LP01 sweep :srcset: /gallery/analysis/images/sphx_glr_plot_structured_wavelength_sweep_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/hostedtoolcache/Python/3.11.17/x64/lib/python3.11/site-packages/matplotlib/cbook.py:1408: UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray. return np.asanyarray(x, float) | .. code-block:: Python from PyFiberModes.units import ureg import matplotlib.pyplot as plt import numpy as np from PyFiberModes import LP01 from PyFiberModes.fiber import load_fiber fiber = load_fiber("SMF28", wavelength=1310e-9 * ureg.meter) wavelengths = np.linspace(1260e-9, 1650e-9, 80) * ureg.meter result = fiber.sweep( wavelengths, modes=(LP01,), metrics=("effective_index", "group_index"), ) figure, axis = plt.subplots() axis.plot(wavelengths.to("nanometer").magnitude, result["effective_index"][:, 0], label="effective index") axis.plot(wavelengths.to("nanometer").magnitude, result["group_index"][:, 0], label="group index") axis.set(xlabel="Wavelength [nm]", ylabel="Index", title="SMF-28 LP01 sweep") axis.legend() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.223 seconds) .. _sphx_glr_download_gallery_analysis_plot_structured_wavelength_sweep.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_structured_wavelength_sweep.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_structured_wavelength_sweep.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_structured_wavelength_sweep.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_