.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/scattering/04_refractive_index.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_04_refractive_index.py: Effect of optical contrast ========================== Change the sphere refractive index at fixed diameter, wavelength, and medium. The resulting cross sections describe isolated spheres, without structural correlations between particles. .. GENERATED FROM PYTHON SOURCE LINES 9-35 .. image-sg:: /gallery/scattering/images/sphx_glr_04_refractive_index_001.png :alt: Optical contrast in a medium of index 1.33 :srcset: /gallery/scattering/images/sphx_glr_04_refractive_index_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from PackLab import scattering, ureg indices = [1.36, 1.42, 1.50, 1.59, 1.70] cross_sections = [] for index in indices: dataset = scattering.compute_scattering_amplitudes( wavelength=532 * ureg.nanometer, diameters=np.array([200]) * ureg.nanometer, material=index, 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(indices, cross_sections, "o-") axis.set( xlabel="sphere refractive index", ylabel="scattering cross section (nm²)", title="Optical contrast in a medium of index 1.33", ) axis.grid(alpha=0.2) figure.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.068 seconds) .. _sphx_glr_download_gallery_scattering_04_refractive_index.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 04_refractive_index.ipynb <04_refractive_index.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 04_refractive_index.py <04_refractive_index.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: 04_refractive_index.zip <04_refractive_index.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_