.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/single/scatterer/spf.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_spf.py: SPF Computation =============== This example demonstrates the computation and visualization of the Scattering Phase Function (SPF) 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=1000 * nanometer, # 1000 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=500 * nanometer, # 1200 nm source=source, property=1.4 * RIU, # Refractive property of the scatterer medium_property=1.0 * RIU, # Refractive property of the surrounding medium ) .. 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=300) # 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_spf_001.png :alt: spf :srcset: /gallery/single/scatterer/images/sphx_glr_spf_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.335 seconds) .. _sphx_glr_download_gallery_single_scatterer_spf.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: spf.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: spf.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: spf.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_