
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "generated/gallery/domain/clouds_robin.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_domain_clouds_robin.py>`
        to download the full example code.

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

.. _sphx_glr_generated_gallery_domain_clouds_robin.py:


Clouds (Projected)
------------------

This example demonstrates how to render a projected unstructured cloud mesh.

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

Creates a mesh from 1D latitude and longitude unstructured cell points.

The resulting mesh contains quad cells and is constructed from CF UGRID
unstructured cell points and connectivity.

It uses an unstructured Met Office high-resolution LFRic C768 cubed-sphere
of High Cloud Amount located on the mesh faces/cells. The mesh is transformed
to the Robinson pseudocylindrical projection.

Note that a threshold is applied to remove low-valued Cloud Amount cells,
and a linear opacity transfer function is applied to give a cloud-like effect.

A Natural Earth base layer is also rendered along with Natural Earth
coastlines.

.. tags::

    component: coastlines, component: texture,
    domain: meteorology,
    filter: threshold,
    load: unstructured,
    projection: crs,
    resolution: high,
    style: colormap, style: opacity,
    version: 0.4.0

----

.. GENERATED FROM PYTHON SOURCE LINES 45-118







.. tab-set::



   .. tab-item:: Static Scene



            
     .. image-sg:: /generated/gallery/domain/images/sphx_glr_clouds_robin_001.png
        :alt: clouds robin
        :srcset: /generated/gallery/domain/images/sphx_glr_clouds_robin_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/domain/images/sphx_glr_clouds_robin_001.vtksz






.. code-block:: Python


    from __future__ import annotations

    import cmocean

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

    # Multiplication factor of the zlevel for cloud surface stratification.
    ZLEVEL_FACTOR: int = 75


    def main() -> None:
        """Plot a projected unstructured cloud mesh.

        Notes
        -----
        .. versionadded:: 0.4.0

        """
        # Use the pyvista linear opacity transfer function.
        opacity = "linear"

        # Define the data range.
        clim = (cmin := 0.3, 1.0)

        # Create the plotter.
        crs = "+proj=robin"
        p = gv.GeoPlotter(crs=crs)

        # Load the sample data.
        sample = cloud_amount(preference="high")

        # Create the mesh from the sample data.
        mesh = gv.Transform.from_unstructured(
            sample.lons,
            sample.lats,
            connectivity=sample.connectivity,
            data=sample.data,
            start_index=sample.start_index,
        )

        # Remove cells from the mesh below the specified threshold.
        mesh = mesh.threshold(cmin)

        p.add_mesh(
            mesh,
            clim=clim,
            opacity=opacity,
            cmap=cmocean.cm.gray,
            show_scalar_bar=False,
            zlevel=ZLEVEL_FACTOR,
        )

        # Force zlevel alignment of coastlines and base layer.
        p.add_base_layer(texture=gv.natural_earth_1(), zlevel=0)
        p.add_coastlines()
        p.add_text(
            f"High Cloud Amount ({crs})",
            position="upper_left",
            font_size=10,
        )

        # Define a specific camera position.
        p.view_xy()
        p.camera.zoom(1.5)

        p.add_axes()
        p.show()


    if __name__ == "__main__":
        main()


.. _sphx_glr_download_generated_gallery_domain_clouds_robin.py:

.. only:: html

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

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

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

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

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

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

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


.. only:: html

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

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