Skip to content

Commit

Permalink
lfric lam sphinx-gallery example (#592)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle authored Dec 22, 2023
1 parent 566d940 commit 8445a8e
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 40 deletions.
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)|(lam)|(lfric_sst)|(smc)|(tri)"
"|(fesom)|(lfric_sst)|(smc)|(tri)"
),
"examples_dirs": "../../src/geovista/examples",
"gallery_dirs": "generated/gallery",
Expand Down
3 changes: 3 additions & 0 deletions src/geovista/examples/unstructured/icon_eqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
This example demonstrates how to render a projected unstructured triangular mesh.
📋 Summary
^^^^^^^^^^
Creates a mesh from 2-D latitude and longitude unstructured cell bounds.
The resulting mesh contains triangular cells.
Expand Down
48 changes: 29 additions & 19 deletions src/geovista/examples/unstructured/lam_pacific.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,27 @@
# 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.
"""
LFRic LAM Mesh
--------------
Notes
-----
.. versionadded:: 0.1.0
This example demonstrates how to render an unstructured quadrilateral 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 a high-resolution Local Area Model (LAM) mesh of air potential
temperature data located on the mesh faces/cells.
Note that, 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,33 +33,29 @@


def main() -> None:
"""Create 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.
"""Plot an LFRic LAM unstructured mesh.
It uses a high-resolution Local Area Model (LAM) mesh of air potential
temperature data located on the mesh faces/cells.
Note that, 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 = lam_pacific()

# create the mesh from the sample data
# Create the mesh from the sample data.
mesh = gv.Transform.from_unstructured(
sample.lons,
sample.lats,
connectivity=sample.connectivity,
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

# 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
50 changes: 30 additions & 20 deletions src/geovista/examples/unstructured/lam_pacific_moll.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.
"""
LFRic LAM Mesh (Projected)
--------------------------
Notes
-----
.. versionadded:: 0.1.0
This example demonstrates how to render a projected unstructured quadrilateral 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 a high-resolution Local Area Model (LAM) mesh of air potential
temperature data located on the mesh faces/cells.
Note that, a Natural Earth base layer is rendered along with Natural Earth
coastlines, and the mesh is transformed to the Mollweide pseudo-cylindrical
projection.
""" # noqa: D205,D212,D400
from __future__ import annotations

import geovista as gv
Expand All @@ -19,34 +34,29 @@


def main() -> None:
"""Create 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.
"""Plot a projected LFRic LAM unstructured mesh.
It uses a high-resolution Local Area Model (LAM) mesh of air potential
temperature data located on the mesh faces/cells.
Note that, a Natural Earth base layer is rendered along with Natural Earth
coastlines, and the mesh is transformed to the Mollweide pseudo-cylindrical
projection.
Notes
-----
.. versionadded:: 0.1.0
"""
# load the sample data
# Load the sample data.
sample = lam_pacific()

# create the mesh from the sample data
# Create the mesh from the sample data.
mesh = gv.Transform.from_unstructured(
sample.lons,
sample.lats,
connectivity=sample.connectivity,
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

# plot the mesh
# Plot the unstructured mesh.
crs = "+proj=moll"
plotter = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{sample.name} / {sample.units}", "shadow": True}
Expand Down

0 comments on commit 8445a8e

Please sign in to comment.