Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

smc sphinx-gallery examples #595

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 29 additions & 19 deletions src/geovista/examples/unstructured/smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
52 changes: 31 additions & 21 deletions src/geovista/examples/unstructured/smc_sinu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down