.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/extras/plot_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_plot_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-67 .. image-sg:: /gallery/extras/images/sphx_glr_plot_coupling_heatmap_001.png :alt: Coupling power [Watt] :srcset: /gallery/extras/images/sphx_glr_plot_coupling_heatmap_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy from PyMieSim.experiment.detector import Photodiode from PyMieSim.experiment.scatterer import Sphere from PyMieSim.experiment.source import Gaussian from PyMieSim.experiment import Setup from PyMieSim.units import degree, watt, AU, nanometer, RIU import matplotlib.pyplot as plt index = numpy.linspace(1.3, 2.1, 100) * RIU diameter = numpy.linspace(1, 2000, 100) * nanometer source = Gaussian( wavelength=400 * nanometer, polarization=90 * degree, optical_power=1e-3 * watt, NA=0.2 * AU ) scatterer = Sphere( diameter=diameter, property=index, medium_property=1 * RIU, source=source ) detector = Photodiode( polarization_filter=0 * degree, NA=0.3 * RIU, phi_offset=0 * degree, gamma_offset=0 * degree, sampling=400 * 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.274 seconds) .. _sphx_glr_download_gallery_extras_plot_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: plot_coupling_heatmap.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_coupling_heatmap.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_coupling_heatmap.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_