.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/single/scatterer/s1s2.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_single_scatterer_s1s2.py: S1 S2 Function Computation ========================== This example demonstrates how to compute and visualize the S1 and S2 scattering functions using PyMieSim. .. GENERATED FROM PYTHON SOURCE LINES 9-10 Importing the package: PyMieSim .. GENERATED FROM PYTHON SOURCE LINES 10-14 .. code-block:: Python from PyMieSim.single.scatterer import Sphere from PyMieSim.single.source import Gaussian from PyMieSim.units import nanometer, degree, watt, AU, RIU .. GENERATED FROM PYTHON SOURCE LINES 15-16 Defining the source .. GENERATED FROM PYTHON SOURCE LINES 16-23 .. code-block:: Python source = Gaussian( wavelength=450 * nanometer, # 450 nm polarization=0 * degree, # Linear polarization angle in radians optical_power=1 * watt, # Arbitrary units NA=0.3 * AU # Numerical Aperture ) .. GENERATED FROM PYTHON SOURCE LINES 24-25 Defining the scatterer .. GENERATED FROM PYTHON SOURCE LINES 25-32 .. code-block:: Python scatterer = Sphere( diameter=6 * nanometer, # 6 nm source=source, medium_property=1.0 * RIU, # Refractive property of the surrounding medium property=1.4 * RIU # Refractive property of the scatterer ) .. GENERATED FROM PYTHON SOURCE LINES 33-34 Computing the data .. GENERATED FROM PYTHON SOURCE LINES 34-36 .. code-block:: Python data = scatterer.get_spf(sampling=200) # Specify the number of sampling points .. GENERATED FROM PYTHON SOURCE LINES 37-38 Plotting the data .. GENERATED FROM PYTHON SOURCE LINES 38-39 .. code-block:: Python figure = data.plot() .. image-sg:: /gallery/single/scatterer/images/sphx_glr_s1s2_001.png :alt: s1s2 :srcset: /gallery/single/scatterer/images/sphx_glr_s1s2_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.259 seconds) .. _sphx_glr_download_gallery_single_scatterer_s1s2.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: s1s2.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: s1s2.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: s1s2.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_