Skip to content

Commit

Permalink
use sample meshes for examples (#1339)
Browse files Browse the repository at this point in the history
* use sample meshes for examples

* add changelog news fragment
  • Loading branch information
bjlittle authored Feb 15, 2025
1 parent d63f59a commit dc2002d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 75 deletions.
3 changes: 3 additions & 0 deletions changelog/1339.documentation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Simplified several :ref:`gv-examples` by using ``geovista.pantry.meshes``
instead of loading ``geovista.pantry.data`` to construct sample
meshes. (:user:`bjlittle`)
6 changes: 2 additions & 4 deletions src/geovista/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ from .pantry.textures import (
)
from .report import Report


__version__: str
GEOVISTA_IMAGE_TESTING: bool


__all__ = [
"__version__",
"GeoPlotter",
"GEOVISTA_IMAGE_TESTING",
"GeoPlotter",
"Report",
"Transform",
"__version__",
"black_marble",
"blue_marble",
"checkerboard",
Expand Down
2 changes: 1 addition & 1 deletion src/geovista/cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
BASE_URL: str = "https://github.com/bjlittle/geovista-data/raw/{version}/assets/"
"""Base URL for :mod:`geovista` resources."""

DATA_VERSION: str = "2025.02.1"
DATA_VERSION: str = "2025.02.2"
"""The ``geovista-data`` repository version for :mod:`geovista` resources."""

GEOVISTA_CACHEDIR: str = "GEOVISTA_CACHEDIR"
Expand Down
24 changes: 12 additions & 12 deletions src/geovista/cache/registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@ rasters/bahamas_rgb.tif.bz2 b4798063e478ad25398a2bf8a464f68f9890c5295ba70ad28b42
rasters/fuji_dem.tif.bz2 2e51a278e62304d671e15be8f6cdbea0cb7d477643b97b95c4d4706fa58b4f0a
rasters/japan_map.png.bz2 7b39023b5d26e79475d2dba92269593d5ce46c14ed5859079c79d1fa0ec0987f

tests/images/examples.test__clouds.png 571b052c2bfe6e16bcbb3405a91082feb3c08c901bb869e9cb61d558826adf0d
tests/images/examples.test__clouds.png e41d62c3d11add1f9928efef9b784b35d67b59d181bd6fa6d71c04467c46e089
tests/images/examples.test__clouds_robin.png dd4b9cd16f735e55aa67f5b6ff90eeb7646bdb65bbb1c6df524a5746d9efc36c
tests/images/examples.test__contour.banded_contour.png cb8a092afa55098e0b2ddacf4fc860619ed7e6938e1e5bc54567d0b85b04ad7d
tests/images/examples.test__contour.banded_contour.png d34d24f1442007a0bdd7abe9f5df7fdff98b7c6744e02b600170bc0360abee81
tests/images/examples.test__curvilinear.from_2d__orca_moll.png 2d218333c1033f37fc899e6ff4785cf61fbdda1d3e1d95449fd6c5e6e766a63a
tests/images/examples.test__curvilinear.from_2d__orca.png 22442553c36ba79180db6a07178613b77fce7f84232c848995b3021ce7cd93a8
tests/images/examples.test__extraction.wedge_manifold.png 17d71ec72d0e496924a69ed9be9dc42003a8339e5fee44f77329f5d8efb311f4
tests/images/examples.test__extraction.wedge_manifold.png 7da4e392b3da445b215221ffa9b51d8117699da3a2f3810b624dee731c959640
tests/images/examples.test__point_cloud.from_points__orca_cloud_eqc.png d7cbc1365588e6b4cfc3e393776e2ca18671d45121e83a6450beebe7e6bfa4a8
tests/images/examples.test__point_cloud.from_points__orca_cloud.png 5473cc27d56b3ccb7bc59c98fbb01737f3290971072dae769ba26f264f059747
tests/images/examples.test__rectilinear.from_1d__oisst_eqc.png f2ec2b420a621ea69b764ee00e5fb271174013c9018c4396a3fb48fd53a6f6af
tests/images/examples.test__rectilinear.from_1d__oisst.png 674f25f62cd416002315ec1a583a4118681ebcc47afe89879da36f0f6bd5004e
tests/images/examples.test__rectilinear.from_1d__synthetic_face_m1_n1.png a4bf7bb7aa9ecf861c2f7fa5ea68e3e9ec5750ad347915b13bfb502c122f46d3
tests/images/examples.test__rectilinear.from_1d__synthetic_face_m1_n1_robin.png f7572747f575b0f6a9fa96661219312bd7f2a3082b4a2e0f8449089b75618df4
tests/images/examples.test__rectilinear.from_1d__synthetic_node_m1_n1_moll.png a36b01283ffac2ae8f1a6642fdea177f1aaf3c4558a9670e26e54205fa14cc04
tests/images/examples.test__rectilinear.from_1d__synthetic_node_m1_n1.png b194552e2328f09691aef0c757a166204c09e692c341c1787bf4315bf4ef0934
tests/images/examples.test__rectilinear.from_2d__synthetic_face_m1n1.png eb8a81c7fa779f4bb8c886c1898dc0b5fc8b471f6a6b045db40abd1cf5a351e5
tests/images/examples.test__rectilinear.from_1d__synthetic_node_m1_n1_moll.png d37abc2b311b75b72e519787369f11aff86132acb8094eda48f5023a23d1815c
tests/images/examples.test__rectilinear.from_1d__synthetic_node_m1_n1.png e2b13ebdb355926d3591df726235a97c8cd4396c001b2f2e2e9b7bf4f56e95e2
tests/images/examples.test__rectilinear.from_2d__synthetic_face_m1n1.png 0a31754360b3af9d7282a97c0afeec69046ae2346c96b342b9daa306323e164e
tests/images/examples.test__rectilinear.from_2d__synthetic_face_m1n1_robin.png 0a542a94392f51d76fe1f0e80ab61108d16fc2367bd52063358768e851e087aa
tests/images/examples.test__rectilinear.from_2d__synthetic_node_m1n1_moll.png 0e5f1350b0d90fa6cca0ef0e0a6e0fa2963c9e8879a7633ca60835734bf9c759
tests/images/examples.test__rectilinear.from_2d__synthetic_node_m1n1.png e4801d13f076251e395ce1b1e9c5ffedbc38332b72ace2d829e941a23c0d691d
tests/images/examples.test__scalar_data.earthquakes.png 12c75a49b0668691063b7895a63bb63d29b618792652f86ddb99e0b80e69ed36
tests/images/examples.test__scalar_data.earthquakes.png 61342f57dd1dac1cc7d9eb3bfa5cecf053bb56e354f3bad658fdf628cef10b8e
tests/images/examples.test__scalar_data.earthquakes_wink1.png c5ec52c697e572b8a3e67be7772a1e2659b5954ba5932a68e9781a9c197b18ab
tests/images/examples.test__scalar_data.from_tiff__dem.png 6a927cec0c68f5b7adbb07f7b8a8253b43d028d3a5f610636ffcf565410139aa
tests/images/examples.test__scalar_data.from_tiff__rgb.png 52b04c390500417f69cb2a40eda7e6b473620cdd74b2524f158644c04d528514
tests/images/examples.test__spatial_index.uber_h3.png d93a475382420059d2f79f722351e9078a8e13d8f6e174a32cabc68de1b12995
tests/images/examples.test__spatial_index.uber_h3.png 8e8deb4418aeb530d0a3fdd5e43819426eed8f9680d18590f96d0087d8a18170
tests/images/examples.test__unstructured.dynamico.png 0eed8e6e5c87fdf65291e8b1ed8c7aa642fd6e6d57e27f05e37793a97f9c75ac
tests/images/examples.test__unstructured.dynamico_poly.png cad9c8baa23ac7e7563bfedcd538d2850f154a6ee468fdc84651ba3bbc3e6c91
tests/images/examples.test__unstructured.fesom_fouc.png 50df3477fe8b6d5189eb3071a1b910c6c57cb59145e2a0611a4bf3690446548c
tests/images/examples.test__unstructured.fesom.png a2a36b2480ce76780a91bb0ae6e8711c26e1f89b698e662c9a7f0441f14c3148
tests/images/examples.test__unstructured.fesom.png cc8b1896f0931cf0c832ddb15f874a503f2104019c77421db494d5f06d7d7d6c
tests/images/examples.test__unstructured.icon_eqc.png 600b2efd3be6f67409ffa2deb192984c17231c304b08e544816f5bbceebbbb64
tests/images/examples.test__unstructured.icon.png 1cca507842b07c5a7c4d49b91adfffa07f926189fbc4e9d4b9c53d6fc42992d6
tests/images/examples.test__unstructured.icon.png d0bece98005ca2528a6721801286f80a9cceb61d71fdea3f074f142ee642587b
tests/images/examples.test__unstructured.lam_pacific_moll.png bfe0b2269f343ca10bdea10a695a5bc696ca8f329fc1305bc16616d0686254aa
tests/images/examples.test__unstructured.lam_pacific.png 3c0abe5ccc0fa55f06982402bf23fd47c072b34c378997c8f21b339254b59ac9
tests/images/examples.test__unstructured.lfric_sst_bonne.png db2631001aed41029e7293726b89cfee8de75ad70393b8cf64b0423aa05e45a8
Expand All @@ -78,8 +78,8 @@ tests/images/examples.test__vector_data.vectors.png 72f1a30dd57b8c6cc635e866aa1f
tests/images/examples.test__vector_data.wind_arrows.png e73f77f2cb804e7d629be36ef8b0fcef1d64d653db005d29d2a2188575734809
tests/images/examples.test__vector_data.winds_3d.png eb08f0d00a89d3429ab4e541d1b6c791d569d6bc6e359bf98d43f2937dff6753
tests/images/examples.test__warp.from_unstructured__fvcom.png 18ae7a4041f847760f4baf5e549156231867639893767010c8c03ba65306942f
tests/images/examples.test__warp.from_unstructured__lfric_orog_eqc.png f15eed048b1c7ed45e2b831f0c794a519bea7a5eba537b2a2c5abb3999c57308
tests/images/examples.test__warp.from_unstructured__lfric_orog.png 5e0aa856d978057d547d32afd885fb1eb13c0bbf6b9470dbf6454b635460a64b
tests/images/examples.test__warp.from_unstructured__lfric_orog_eqc.png 9a2f2878914d817dc2780968eafa438aa120eb655029593843597e779be6c26c
tests/images/examples.test__warp.from_unstructured__lfric_orog.png 93edeee02f044f83c977849d8c07824687242d6c0984d4dd53eb4c39ef52d706
tests/images/geoplotter.test_view_poi.test_lam_polar__eqc.png 602bba11b641ac202308adf9d0833152af6ccc370123dc8d618424172119a092
tests/images/geoplotter.test_view_poi.test_lam_polar__moll.png 429b2a7fa80aba2b712f49341ccb0daa6f70a0a5141da014618ac5cad17e50c9
tests/images/geoplotter.test_view_poi.test_lam_polar__None.png 5f2ec2b36c900946cdfab0b52615e7c955692573f788691f0de2bfd6753ddf16
Expand Down
1 change: 1 addition & 0 deletions src/geovista/examples/contour/banded_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
📋 Summary
^^^^^^^^^^
Uses an unstructured Met Office LFRic C48 cubed-sphere mesh of surface altitude
data.
Expand Down
23 changes: 6 additions & 17 deletions src/geovista/examples/extraction/wedge_manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
📋 Summary
^^^^^^^^^^
Creates a mesh from 1-D latitude and longitude unstructured points and
connectivity.
It uses an unstructured Met Office LFRic C48 cubed-sphere of surface altitude
Uses an unstructured Met Office LFRic C48 cubed-sphere mesh of surface altitude
data.
Three separate geodesic wedge manifolds are constructed to extract the cells of the
Expand Down Expand Up @@ -43,7 +41,7 @@
component: coastlines, component: manifold, component: texture,
domain: orography,
load: unstructured
sample: unstructured
----
Expand All @@ -53,7 +51,7 @@

import geovista as gv
from geovista.geodesic import wedge
from geovista.pantry.data import lfric_orog
from geovista.pantry.meshes import lfric_orog
import geovista.theme


Expand All @@ -65,17 +63,8 @@ def main() -> None:
.. versionadded:: 0.6.0
"""
# Load the sample data.
sample = lfric_orog()

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

# Calculate the sample data range.
clim = mesh.get_data_range()
Expand All @@ -92,7 +81,7 @@ def main() -> None:
region_3 = bbox_3.enclosed(mesh, preference="center")

p = gv.GeoPlotter()
sargs = {"title": f"{sample.name} / {sample.units}", "fmt": "%.1f"}
sargs = {"title": "Surface Altitude / m", "fmt": "%.0f"}

# Add the 3 extracted regions.
p.add_mesh(region_1, clim=clim, scalar_bar_args=sargs)
Expand Down
29 changes: 9 additions & 20 deletions src/geovista/examples/warp/from_unstructured__lfric_orog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
📋 Summary
^^^^^^^^^^
Creates a mesh from 1-D latitude and longitude unstructured points and
connectivity.
It uses an unstructured Met Office LFRic C48 cubed-sphere of surface altitude
Uses an unstructured Met Office LFRic C48 cubed-sphere mesh of surface altitude
data.
The resulting mesh contains quad cells and is constructed from CF UGRID
unstructured cell points and connectivity.
The mesh contains quad cells and is constructed from CF UGRID unstructured cell
points and connectivity.
Note that the scalar elevation values are located on the mesh nodes/points
which results in the rendered colours being interpolated across the cell faces.
Expand All @@ -35,7 +33,7 @@
domain: orography,
filter: warp,
load: unstructured
sample: unstructured
----
Expand All @@ -44,7 +42,7 @@
from __future__ import annotations

import geovista as gv
from geovista.pantry.data import lfric_orog
from geovista.pantry.meshes import lfric_orog
import geovista.theme


Expand All @@ -56,25 +54,16 @@ def main() -> None:
.. versionadded:: 0.1.0
"""
# Load the sample data.
sample = lfric_orog()

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

# Warp the mesh nodes by the surface altitude.
mesh.compute_normals(cell_normals=False, point_normals=True, inplace=True)
mesh.warp_by_scalar(scalars=sample.name, inplace=True, factor=2e-5)
mesh.warp_by_scalar(inplace=True, factor=2e-5)

# Plot the unstructured mesh.
p = gv.GeoPlotter()
sargs = {"title": f"{sample.name} / {sample.units}"}
sargs = {"title": "Surface Altitude / m", "fmt": "%.0f"}
p.add_mesh(mesh, scalar_bar_args=sargs)
p.add_axes()
p.add_text(
Expand Down
30 changes: 9 additions & 21 deletions src/geovista/examples/warp/from_unstructured__lfric_orog_eqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
📋 Summary
^^^^^^^^^^
Creates a mesh from 1-D latitude and longitude unstructured points and
connectivity.
It uses an unstructured Met Office LFRic C48 cubed-sphere of surface altitude
Uses an unstructured Met Office LFRic C48 cubed-sphere mesh of surface altitude
data.
The resulting mesh contains quad cells and is constructed from CF UGRID unstructured
cell points and connectivity.
The mesh contains quad cells and is constructed from CF UGRID unstructured cell
points and connectivity.
The mesh is transformed onto an Equidistant Cylindrical (Plate Carrée)
projection.
Expand All @@ -40,7 +37,7 @@
domain: orography,
filter: warp,
load: unstructured,
sample: unstructured,
projection: crs, projection: transform
----
Expand All @@ -50,7 +47,7 @@
from __future__ import annotations

import geovista as gv
from geovista.pantry.data import lfric_orog
from geovista.pantry.meshes import lfric_orog
import geovista.theme
from geovista.transform import transform_mesh

Expand All @@ -63,28 +60,19 @@ def main() -> None:
.. versionadded:: 0.1.0
"""
# Load the sample data.
sample = lfric_orog()

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

# Transform the mesh to the Plate Carrée projection.
mesh = transform_mesh(mesh, crs := "esri:54001")

# Warp the mesh nodes by the surface altitude.
mesh.compute_normals(cell_normals=False, point_normals=True, inplace=True)
mesh.warp_by_scalar(scalars=sample.name, inplace=True, factor=200)
mesh.warp_by_scalar(inplace=True, factor=200)

# Plot the unstructured mesh.
p = gv.GeoPlotter(crs=crs)
sargs = {"title": f"{sample.name} / {sample.units}"}
sargs = {"title": "Surface Altitude / m", "fmt": "%.0f"}
p.add_mesh(mesh, scalar_bar_args=sargs)
p.add_axes()
p.add_text(
Expand Down

0 comments on commit dc2002d

Please sign in to comment.