
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "generated/gallery/grid/reykjanes_contour.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_generated_gallery_grid_reykjanes_contour.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_generated_gallery_grid_reykjanes_contour.py:


Reykjanes Isosurface
--------------------

This example demonstrates how to render the isosurfaces of a 3D structured grid.

📋 Summary
^^^^^^^^^^

The sample data is taken from a Met Office NAME Model time-series simulation
of the Icelandic Reykjanes Peninsula eruption on 29 May 2024.

A structured grid of cubic voxels is constructed for the 1D spatial coordinates
and then thresholded to reveal the underlying volcanic plume of Sulphur Dioxide
Air Concentration.

The visualization is enhanced by rendering isosufaces of the plume using a
mixture of opacity and smooth shading to yield a semi-transparent cloud-like
effect.

The cited release location of the eruption on the peninsula is marked,
highlighting the volcanic plume's eastward transport and southerly dispersion.

.. warning::
    :class: dropdown, toggle-shown

    Structured grid projection transformation support is pending.

.. tags::

    experimental 🧪,
    component: coastlines, component: graticule, component: texture,
    domain: volcanology,
    filter: contour, filter: threshold,
    load: grid,
    version: 0.6.0

----

.. GENERATED FROM PYTHON SOURCE LINES 47-124







.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /generated/gallery/grid/images/sphx_glr_reykjanes_contour_001.png
        :alt: reykjanes contour
        :srcset: /generated/gallery/grid/images/sphx_glr_reykjanes_contour_001.png
        :class: sphx-glr-single-img
     


   .. tab-item:: Interactive Scene



       .. offlineviewer:: /home/docs/checkouts/readthedocs.org/user_builds/geovista-ja/checkouts/latest/geovista/docs/src/generated/gallery/grid/images/sphx_glr_reykjanes_contour_001.vtksz






.. code-block:: Python


    from __future__ import annotations

    import pyvista as pv

    import geovista as gv
    from geovista.pantry.data import name_reykjanes


    def main() -> None:
        """Plot the volcanic plume structured grid isosurfaces.

        Notes
        -----
        .. versionadded:: 0.6.0

        """
        # Load the sample data.
        sample = name_reykjanes()

        # Create the structured grid.
        grid = gv.Transform.to_structured_grid(
            sample.xs,
            sample.ys,
            sample.zs,
            data=sample.data,
        )

        # Remove cells from the grid with NaN values then calculate the data range.
        grid = grid.threshold()
        clim = grid.get_data_range()

        # Generate the plume isosurface.
        isosurfaces = grid.cell_data_to_point_data().contour(isosurfaces=500)

        # Now render the plotter scene.
        p = gv.GeoPlotter()
        p.add_base_layer(texture=gv.blue_marble(), zlevel=0)
        p.add_coastlines()
        p.add_graticule()
        sargs = {"title": f"{sample.name} / {sample.units}", "fmt": "%.1f"}
        p.add_mesh(
            isosurfaces,
            clim=clim,
            cmap="fire_r",
            opacity="linear_r",
            smooth_shading=True,
            scalar_bar_args=sargs,
        )
        p.add_text(
            "Reykjanes Peninsula, Iceland",
            position="upper_left",
            font_size=10,
        )

        # Mark the event release location.
        p.add_points(
            xs=sample.poi.longitude,
            ys=sample.poi.latitude,
            render_points_as_spheres=True,
            color="red",
            point_size=10,
        )

        # Define a specific camera position and orientation.
        cpos = pv.CameraPosition(
            position=(0.8957959335673299, -0.47394138433018956, 0.9968046553672109),
            focal_point=(-0.10638261870474444, 0.3538637910944052, 0.715402511958916),
            viewup=(-0.17014498616109472, 0.12623579798398435, 0.977299957531764),
        )

        p.add_axes()
        p.show(cpos=cpos)


    if __name__ == "__main__":
        main()


.. _sphx_glr_download_generated_gallery_grid_reykjanes_contour.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: reykjanes_contour.ipynb <reykjanes_contour.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: reykjanes_contour.py <reykjanes_contour.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: reykjanes_contour.zip <reykjanes_contour.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
