Clouds (Projected)

On this page

Clouds (Projected)#

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

πŸ“‹ Summary#

Creates a mesh from 1-D 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


clouds robin
from __future__ import annotations

import cmocean

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

# 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("high")

    # Create the mesh from the sample data.
    mesh = gv.Transform.from_unstructured(
        sample.lons,
        sample.lats,
        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_axes()
    p.add_text(
        f"High Cloud Amount ({crs})",
        position="upper_left",
        font_size=10,
    )
    p.view_xy()
    p.camera.zoom(1.5)
    p.show()


if __name__ == "__main__":
    main()

Gallery generated by Sphinx-Gallery