.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scattering/03_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_scattering_03_wavelength_sweep.py: Single-sphere wavelength sweep ============================== Compare scattering cross sections of a fixed sphere across wavelengths in the same medium. This independent-particle optical calculation contains no packing structure or multiple scattering. .. GENERATED FROM PYTHON SOURCE LINES 9-33 .. image-sg:: /gallery/scattering/images/sphx_glr_03_wavelength_sweep_001.png :alt: Fixed 200 nm sphere :srcset: /gallery/scattering/images/sphx_glr_03_wavelength_sweep_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from PackLab import scattering, ureg wavelengths = np.array([400, 450, 500, 550, 600, 650, 700]) cross_sections = [] for wavelength in wavelengths: dataset = scattering.compute_scattering_amplitudes( wavelength=wavelength * ureg.nanometer, diameters=np.array([200]) * ureg.nanometer, material=1.59, medium=1.33, phi=np.linspace(-90, 90, 181) * ureg.degree, ) dataset.process() cross_sections.append(dataset.Csca.to("nanometer**2").magnitude[0]) figure, axis = plt.subplots() axis.plot(wavelengths, cross_sections, "o-") axis.set( xlabel="wavelength (nm)", ylabel="scattering cross section (nm²)", title="Fixed 200 nm sphere" ) axis.grid(alpha=0.2) figure.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.063 seconds) .. _sphx_glr_download_gallery_scattering_03_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: 03_wavelength_sweep.ipynb <03_wavelength_sweep.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 03_wavelength_sweep.py <03_wavelength_sweep.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 03_wavelength_sweep.zip <03_wavelength_sweep.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_