From d1c3e203d03051e9cdbcc7d6f20862147665936f Mon Sep 17 00:00:00 2001 From: Bill Little Date: Sat, 23 Dec 2023 00:18:18 +0000 Subject: [PATCH] smc sphinx-gallery examples --- docs/src/conf.py | 2 +- src/geovista/examples/unstructured/smc.py | 48 ++++++++++------- .../examples/unstructured/smc_sinu.py | 52 +++++++++++-------- 3 files changed, 61 insertions(+), 41 deletions(-) diff --git a/docs/src/conf.py b/docs/src/conf.py index b8a1ad43..79a4c976 100644 --- a/docs/src/conf.py +++ b/docs/src/conf.py @@ -209,7 +209,7 @@ "filename_pattern": "/.*", "ignore_pattern": ( "(__init__)|(clouds)|(earthquakes)|(from_1d__synthetic)|(from_2d__synthetic)" - "|(fesom)|(smc)|(tri)" + "|(fesom)|(tri)" ), "examples_dirs": "../../src/geovista/examples", "gallery_dirs": "generated/gallery", diff --git a/src/geovista/examples/unstructured/smc.py b/src/geovista/examples/unstructured/smc.py index 4a035244..05f44a8b 100755 --- a/src/geovista/examples/unstructured/smc.py +++ b/src/geovista/examples/unstructured/smc.py @@ -4,13 +4,26 @@ # This file is part of GeoVista and is distributed under the 3-Clause BSD license. # See the LICENSE file in the package root directory for licensing details. -"""Importable and runnable geovista example. +""" +Spherical Multi-Cell Mesh +------------------------- -Notes ------ -.. versionadded:: 0.1.0 +This example demonstrates how to render an unstructured quadrilateral mesh. -""" +📋 Summary +^^^^^^^^^^ + +Creates a mesh from 2-D latitude and longitude unstructured cell bounds. + +The resulting mesh contains quad cells. + +It uses WAVEWATCH III (WW3) unstructured Spherical Multi-Cell (SMC) sea surface +wave significant height data located on mesh faces/cells. + +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. + +""" # noqa: D205,D212,D400 from __future__ import annotations import geovista as gv @@ -19,30 +32,27 @@ def main() -> None: - """Create a mesh from 2-D latitude and longitude unstructured cell bounds. - - The resulting mesh contains quad cells. + """Plot an SMC unstructured mesh. - It uses WAVEWATCH III (WW3) unstructured Spherical Multi-Cell (SMC) sea surface - wave significant height data located on mesh faces/cells. - - 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. + Notes + ----- + .. versionadded:: 0.1.0 """ - # load the sample data + # Load the sample data. sample = ww3_global_smc() - # create the mesh from the sample data + # Create the mesh from the sample data. mesh = gv.Transform.from_unstructured(sample.lons, sample.lats, data=sample.data) - - # provide mesh diagnostics via logging + # sphinx_gallery_start_ignore + # Provide mesh diagnostics via logging. gv.logger.info("%s", mesh) + # sphinx_gallery_end_ignore - # threshold the mesh of NaNs + # Threshold the mesh of NaNs. mesh = mesh.threshold() - # plot the mesh + # Plot the unstructured mesh. plotter = gv.GeoPlotter() sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True} plotter.add_mesh(mesh, scalar_bar_args=sargs) diff --git a/src/geovista/examples/unstructured/smc_sinu.py b/src/geovista/examples/unstructured/smc_sinu.py index 2751dd7e..86d988c7 100755 --- a/src/geovista/examples/unstructured/smc_sinu.py +++ b/src/geovista/examples/unstructured/smc_sinu.py @@ -4,13 +4,28 @@ # This file is part of GeoVista and is distributed under the 3-Clause BSD license. # See the LICENSE file in the package root directory for licensing details. -"""Importable and runnable geovista example. +""" +Spherical Multi-Cell Mesh (Projected) +------------------------------------- -Notes ------ -.. versionadded:: 0.1.0 +This example demonstrates how to render a projected unstructured quadrilateral mesh. -""" +📋 Summary +^^^^^^^^^^ + +Creates a mesh from 2-D latitude and longitude unstructured cell bounds. + +The resulting mesh contains quad cells. + +It uses WAVEWATCH III (WW3) unstructured Spherical Multi-Cell (SMC) sea surface +wave significant height data located on mesh faces/cells. + +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. The mesh +is also transformed to the Sinusoidal (Sanson-Flamsteed) pseudo-cylindrical +projection. + +""" # noqa: D205,D212,D400 from __future__ import annotations import geovista as gv @@ -19,32 +34,27 @@ def main() -> None: - """Create a mesh from 2-D latitude and longitude unstructured cell bounds. - - The resulting mesh contains quad cells. + """Plot a projected SMC unstructured mesh. - It uses WAVEWATCH III (WW3) unstructured Spherical Multi-Cell (SMC) sea surface - wave significant height data located on mesh faces/cells. - - 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. The mesh - is also transformed to the Sinusoidal (Sanson-Flamsteed) pseudo-cylindrical - projection. + Notes + ----- + .. versionadded:: 0.1.0 """ - # load the sample data + # Load the sample data. sample = ww3_global_smc() - # create the mesh from the sample data + # Create the mesh from the sample data. mesh = gv.Transform.from_unstructured(sample.lons, sample.lats, data=sample.data) - - # provide mesh diagnostics via logging + # sphinx_gallery_start_ignore + # Provide mesh diagnostics via logging. gv.logger.info("%s", mesh) + # sphinx_gallery_end_ignore - # threshold the mesh of NaNs + # Threshold the mesh of NaNs. mesh = mesh.threshold() - # plot the mesh + # Plot the unstructured mesh. crs = "+proj=sinu" plotter = gv.GeoPlotter(crs=crs) sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}