.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/interpretation/scattering_absorption_resonances.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_interpretation_scattering_absorption_resonances.py: Separate scattering and absorption resonances ============================================= A peak in extinction does not by itself say where the removed incident power goes. This wavelength scan separates ``Qext`` into ``Qsca`` and ``Qabs`` for a lossy sphere. The lower panel shows the single-scattering albedo ``Qsca / Qext``: values near one indicate that extinction is dominated by scattering, while lower values indicate a larger absorbed fraction. The calculation concerns one isolated sphere. Peak locations depend on the particle size, complex refractive index, surrounding medium, and any material dispersion included in the model. .. GENERATED FROM PYTHON SOURCE LINES 15-62 .. image-sg:: /gallery/interpretation/images/sphx_glr_scattering_absorption_resonances_001.png :alt: Extinction combines scattered and absorbed power, Single-scattering albedo :srcset: /gallery/interpretation/images/sphx_glr_scattering_absorption_resonances_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from PyMieSim import Measure, PlaneWave, PolarizationState, Simulation, Sphere, ureg wavelengths = np.linspace(350, 1000, 260) qsca = np.empty_like(wavelengths) qabs = np.empty_like(wavelengths) qext = np.empty_like(wavelengths) for index, wavelength in enumerate(wavelengths): source = PlaneWave( wavelength=wavelength * ureg.nanometer, polarization=PolarizationState(angle=0 * ureg.degree), amplitude=1 * ureg.volt / ureg.meter, ) simulation = Simulation( scatterer=Sphere( diameter=420 * ureg.nanometer, material=1.65 + 0.08j, medium=1.33, ), source=source, ) measures = simulation.get(Measure.QSCA, Measure.QABS, Measure.QEXT) qsca[index] = measures["Qsca"].magnitude qabs[index] = measures["Qabs"].magnitude qext[index] = measures["Qext"].magnitude single_scattering_albedo = qsca / qext figure, axes = plt.subplots(2, 1, figsize=(8, 6.5), sharex=True, height_ratios=(2, 1)) axes[0].plot(wavelengths, qext, color="black", linewidth=2.2, label="Qext") axes[0].plot(wavelengths, qsca, linewidth=2, label="Qsca") axes[0].plot(wavelengths, qabs, linewidth=2, label="Qabs") axes[0].set(ylabel="Efficiency", title="Extinction combines scattered and absorbed power") axes[0].legend() axes[1].plot(wavelengths, single_scattering_albedo, color="tab:green", linewidth=2) axes[1].set( xlabel="Vacuum wavelength [nm]", ylabel="Qsca / Qext", ylim=(0, 1.05), title="Single-scattering albedo", ) for axis in axes: axis.grid(alpha=0.2) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.211 seconds) .. _sphx_glr_download_gallery_interpretation_scattering_absorption_resonances.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: scattering_absorption_resonances.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: scattering_absorption_resonances.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: scattering_absorption_resonances.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_