WW3 Triangular Mesh

On this page

WW3 Triangular Mesh#

This example demonstrates how to render an unstructured triangular mesh.

πŸ“‹ Summary#

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

The resulting mesh contains triangular cells. The connectivity is required to construct the cells from the unstructured points.

It uses a WAVEWATCH III (WW3) unstructured triangular mesh sea surface wave significant height data located on mesh nodes/points.

Note that, a threshold is also applied to remove land NaN cells, and a Natural Earth base layer is rendered along with Natural Earth coastlines. As data is located on the mesh nodes/points, these values are interpolated across the mesh faces/cells.

🏷 Tags: Coastlines Globe Unstructured Texture


tri
from __future__ import annotations

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


def main() -> None:
    """Plot a WW3 unstructured triangular mesh.

    Notes
    -----
    .. versionadded:: 0.1.0

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

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

    # Plot the unstructured mesh.
    plotter = gv.GeoPlotter()
    sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
    plotter.add_mesh(mesh, scalar_bar_args=sargs)
    plotter.add_base_layer(texture=gv.natural_earth_hypsometric())
    plotter.add_coastlines()
    plotter.add_axes()
    plotter.view_xy(negative=True)
    plotter.add_text(
        "WW3 Triangular Mesh (10m Coastlines)",
        position="upper_left",
        font_size=10,
        shadow=True,
    )
    plotter.camera.zoom(1.3)
    plotter.show()


if __name__ == "__main__":
    main()

Gallery generated by Sphinx-Gallery