.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples_gallery/fields/analyze_scalar_field.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_examples_gallery_fields_analyze_scalar_field.py: Visualizing a scalar field ========================== This example displays methods for visualizing scalar fields. .. GENERATED FROM PYTHON SOURCE LINES 7-31 .. image-sg:: /examples_gallery/fields/images/sphx_glr_analyze_scalar_field_001.png :alt: Original field, Projection on axial coordinate, Smoothed field, Slice of smoothed field at $z=1$ :srcset: /examples_gallery/fields/images/sphx_glr_analyze_scalar_field_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from pde import CylindricalSymGrid, ScalarField # create a scalar field with some noise grid = CylindricalSymGrid(7, [0, 4 * np.pi], 64) data = ScalarField.from_expression(grid, "sin(z) * exp(-r / 3)") data += 0.05 * ScalarField.random_normal(grid) # manipulate the field smoothed = data.smooth() # Gaussian smoothing to get rid of the noise projected = data.project("r") # integrate along the radial direction sliced = smoothed.slice({"z": 1}) # slice the smoothed data # create four plots of the field and the modifications fig, axes = plt.subplots(nrows=2, ncols=2) data.plot(ax=axes[0, 0], title="Original field") smoothed.plot(ax=axes[1, 0], title="Smoothed field") projected.plot(ax=axes[0, 1], title="Projection on axial coordinate") sliced.plot(ax=axes[1, 1], title="Slice of smoothed field at $z=1$") plt.subplots_adjust(hspace=0.8) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.405 seconds) .. _sphx_glr_download_examples_gallery_fields_analyze_scalar_field.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: analyze_scalar_field.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: analyze_scalar_field.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: analyze_scalar_field.zip `