.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/results/result_plots.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_auto_examples_results_result_plots.py: Result plots and interactive 3D views ===================================== Use plotting methods directly on a result, then call ``plt.show()`` to display angular Matplotlib figures. The docs embed interactive Plotly volumes and phase surfaces; drag to rotate and scroll to zoom. The phase surface represents directions on a sphere. Its radius and color are probability densities in inverse steradians, not spatial coordinates. The ensemble angular curves show a sampled meridian about incident +z. Use result.azimuth_average() to request an averaged curve explicitly. The 3D surface retains each azimuth direction, showing directional structure in the ensemble intensity average. .. GENERATED FROM PYTHON SOURCE LINES 16-55 .. code-block:: Python from bornsim.medium.random_medium import GaussianMedium import sys import matplotlib.pyplot as plt from bornsim import EnsembleSampling, Grid, Solver, Source from bornsim.units import ureg grid = Grid( shape=(4, 4, 4), spacing=50 * ureg.nanometer, ) medium = GaussianMedium( correlation_length=100 * ureg.nanometer, background_refractive_index=1.33, refractive_index_std=0.01, ) source_configuration_1 = Source(wavelength=633 * ureg.nanometer) solver = Solver( source=source_configuration_1, order=3, ) ensemble_sampling_configuration_1 = EnsembleSampling( realizations=4, seed=42, ) result = solver.ensemble( medium=medium, grid=grid, ensemble_sampling=ensemble_sampling_configuration_1, ) .. GENERATED FROM PYTHON SOURCE LINES 56-60 Differential scattering ----------------------- Differential scattering retains its physical units of inverse metres per steradian. Ensemble results also show standard errors on this plot. .. GENERATED FROM PYTHON SOURCE LINES 60-64 .. code-block:: Python result.plot(log_y=True) plt.show() .. image-sg:: /auto_examples/results/images/sphx_glr_result_plots_001.png :alt: Finite-sample scattering · meridian phi = 0 degrees :srcset: /auto_examples/results/images/sphx_glr_result_plots_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 65-69 Normalized phase function ------------------------- Dividing by the integrated coefficient gives a density per steradian. The normalization is over solid angle, including the ``sin(theta)`` measure. .. GENERATED FROM PYTHON SOURCE LINES 69-73 .. code-block:: Python result.plot_phase_function(log_y=True) plt.show() .. image-sg:: /auto_examples/results/images/sphx_glr_result_plots_002.png :alt: Directional finite-sample phase function · meridian phi = 0 degrees :srcset: /auto_examples/results/images/sphx_glr_result_plots_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 74-77 Polar meridian cut ------------------ The incident beam points towards 0 degrees, at the top of the plot. .. GENERATED FROM PYTHON SOURCE LINES 77-81 .. code-block:: Python result.plot_phase_function(view="polar") plt.show() .. image-sg:: /auto_examples/results/images/sphx_glr_result_plots_003.png :alt: Directional finite-sample phase function · meridian phi = 0 degrees Meridian cut · incidence at 0° · p (sr⁻¹) :srcset: /auto_examples/results/images/sphx_glr_result_plots_003.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 82-86 Three-dimensional directional surface ------------------------------------- Plot the sampled polar and azimuth directions without azimuth averaging. Here four realizations contribute to the ensemble intensity average. .. GENERATED FROM PYTHON SOURCE LINES 86-91 .. code-block:: Python phase_figure = result.plot_phase_function(view="3d") if "--no-browser" not in sys.argv: phase_figure.show(renderer="browser") .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 92-97 Numerical field terms --------------------- A fixed random volume need not be axisymmetric. Its field norms can be inspected without inferring a normalized phase function from one cut. Decreasing terms do not certify Born convergence. .. GENERATED FROM PYTHON SOURCE LINES 97-108 .. code-block:: Python volume = medium.to_volume( grid=grid, seed=42, ) numerical = solver.solve(target=volume) numerical.plot_field_norms() plt.show() .. image-sg:: /auto_examples/results/images/sphx_glr_result_plots_004.png :alt: Born field terms Decreasing terms do not certify convergence :srcset: /auto_examples/results/images/sphx_glr_result_plots_004.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 109-114 Inspect the medium in 3D ------------------------ Inspect the actual finite input sample with physical spatial axes. Drag to rotate and scroll to zoom in the embedded browser view. Regions with higher refractive index are more opaque; opacity is not absorption. .. GENERATED FROM PYTHON SOURCE LINES 114-122 .. code-block:: Python medium_figure = volume.plot_3d( mode="volume", field="refractive_index", opacity_scale="increasing", ) if "--no-browser" not in sys.argv: medium_figure.show(renderer="browser") .. raw:: html .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.943 seconds) .. _sphx_glr_download_auto_examples_results_result_plots.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: result_plots.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: result_plots.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: result_plots.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_