.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/extras/plot_system.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_extras_plot_system.py: Plot system =========== Example Script: Using the `plot_system` Function This script demonstrates how to use the `plot_system` function to create a 3D visualization of a system consisting of a light source, a scatterer, and a detector. The function leverages PyVista for rendering the 3D scene. This script is intended to be used in conjunction with the Read the Docs documentation. .. GENERATED FROM PYTHON SOURCE LINES 13-22 .. code-block:: Python from PyMieSim.single.scatterer import Cylinder from PyMieSim.single.source import Gaussian from PyMieSim.single.detector import CoherentMode from PyMieSim.single import plot_system from math import sqrt from PyMieSim.units import nanometer, degree, watt, AU, RIU .. GENERATED FROM PYTHON SOURCE LINES 23-24 Create a Gaussian light source .. GENERATED FROM PYTHON SOURCE LINES 24-31 .. code-block:: Python source = Gaussian( wavelength=1550 * nanometer, # Wavelength of 1550 nm polarization=0 * degree, # Linear polarization at 0 radians optical_power=1 * watt, # Optical power in arbitrary units NA=0.3 * AU # Numerical Aperture ) .. GENERATED FROM PYTHON SOURCE LINES 32-33 Create a Cylinder scatterer .. GENERATED FROM PYTHON SOURCE LINES 33-40 .. code-block:: Python scatterer = Cylinder( diameter=7800 * nanometer, # Diameter of 7.8 micrometers source=source, # The Gaussian source defined above medium_property=1.0 * RIU, # Refractive index of the surrounding medium property=sqrt(1.5) * RIU # Refractive index of the scatterer ) .. GENERATED FROM PYTHON SOURCE LINES 41-42 Create a Photodiode detector .. GENERATED FROM PYTHON SOURCE LINES 42-50 .. code-block:: Python detector = CoherentMode( mode_number='LP01', NA=0.2 * AU, # Numerical Aperture gamma_offset=0 * degree, # Gamma offset in degrees phi_offset=60 * degree, # Phi offset in degrees polarization_filter=0 * degree # Polarization filter angle in degrees ) .. GENERATED FROM PYTHON SOURCE LINES 51-52 Retrieve the scattering phase function (SPF) from the scatterer .. GENERATED FROM PYTHON SOURCE LINES 52-54 .. code-block:: Python spf = scatterer.get_spf() .. GENERATED FROM PYTHON SOURCE LINES 55-56 Visualize the system using the plot_system function .. GENERATED FROM PYTHON SOURCE LINES 56-57 .. code-block:: Python plot_system(source, detector) .. image-sg:: /gallery/extras/images/sphx_glr_plot_system_001.png :alt: plot system :srcset: /gallery/extras/images/sphx_glr_plot_system_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.255 seconds) .. _sphx_glr_download_gallery_extras_plot_system.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_system.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_system.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_system.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_