.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/extras/coupling_heatmap.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_coupling_heatmap.py: Coupling heatmap of a sphere ================================= PyMieSim makes it easy to create a source and a scatterer. With these objects defined, it is possible to use PyMieSim to find the scattering efficiency of the scatterer. This feature can be used to plot a graph of the scattering efficiency of a sphere as a function of the permittivity and the size parameter. .. GENERATED FROM PYTHON SOURCE LINES 10-61 .. image-sg:: /gallery/extras/images/sphx_glr_coupling_heatmap_001.png :alt: Coupling power [Watt] :srcset: /gallery/extras/images/sphx_glr_coupling_heatmap_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy from TypedUnit import ureg import matplotlib.pyplot as plt from PyMieSim.experiment.detector import Photodiode from PyMieSim.experiment.scatterer import Sphere from PyMieSim.experiment.source import Gaussian from PyMieSim.experiment import Setup index = numpy.linspace(1.3, 2.1, 100) * ureg.RIU diameter = numpy.linspace(1, 2000, 100) * ureg.nanometer source = Gaussian( wavelength=400 * ureg.nanometer, polarization=90 * ureg.degree, optical_power=1e-3 * ureg.watt, NA=0.2 * ureg.AU, ) scatterer = Sphere( diameter=diameter, property=index, medium_property=1 * ureg.RIU, source=source ) detector = Photodiode( polarization_filter=0 * ureg.degree, NA=0.3 * ureg.RIU, phi_offset=0 * ureg.degree, gamma_offset=0 * ureg.degree, sampling=400 * ureg.AU, ) experiment = Setup(scatterer=scatterer, source=source, detector=detector) dataframe = experiment.get("coupling", add_units=False) values = dataframe.values.reshape([diameter.size, index.size]) figure, ax = plt.subplots(1, 1) image = ax.pcolormesh(index, diameter * 1e6, values, shading="auto") ax.set( xlabel="Permittivity", ylabel=r"Diameter [$\mu$m]", title="Coupling power [Watt]" ) plt.colorbar(mappable=image) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.010 seconds) .. _sphx_glr_download_gallery_extras_coupling_heatmap.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: coupling_heatmap.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: coupling_heatmap.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: coupling_heatmap.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_