Skip to content

Commit

Permalink
examples dynamico rebrand (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle authored Dec 21, 2023
1 parent 69581f5 commit 46853d5
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 76 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,11 @@ plotter.show()

![oisst-avhrr](https://raw.githubusercontent.com/bjlittle/geovista-media/2023.09.1/media/readme/oisst-avhrr.png)

#### DYNAMICO Icosahedral
#### DYNAMICO

Finally, to demonstrate support for non-traditional cell geometries i.e., not triangles or quadrilaterals, we plot
the **unstructured** icosahedral mesh from the [DYNAMICO](https://gitlab.in2p3.fr/ipsl/projets/dynamico/dynamico)
project. This model uses hexagonal cells and is a new dynamical core for
the **unstructured** mesh from the [DYNAMICO](https://gitlab.in2p3.fr/ipsl/projets/dynamico/dynamico) project. This
model uses hexagonal and pentagonal cells, and is a new dynamical core for
[LMD-Z](https://www.lmd.ipsl.fr/en/modelisations/lmdz-en/), the atmospheric General Circulation Model (GCM) part of the
[IPSL-CM](https://cmc.ipsl.fr/ipsl-climate-models/) Earth System Model. The render also contains
[10m Natural Earth coastlines](https://www.naturalearthdata.com/downloads/10m-physical-vectors/10m-coastline/).
Expand All @@ -442,11 +442,11 @@ project. This model uses hexagonal cells and is a new dynamical core for

```python
import geovista as gv
from geovista.pantry import icosahedral
from geovista.pantry import dynamico
import geovista.theme

# Load sample data.
sample = icosahedral()
sample = dynamico()

# Create the mesh from the sample data.
mesh = gv.Transform.from_unstructured(sample.lons, sample.lats, data=sample.data)
Expand Down
2 changes: 1 addition & 1 deletion src/geovista/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
BASE_URL: str = "https://github.com/bjlittle/geovista-data/raw/{version}/data/"

#: Pin to use the specific geovista-data repository version for geovista resources.
DATA_VERSION: str = "2023.12.7"
DATA_VERSION: str = "2023.12.8"

#: Environment variable to override pooch cache manager path.
ENV: str = "GEOVISTA_CACHEDIR"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
from __future__ import annotations

import geovista as gv
from geovista.pantry import icosahedral
from geovista.pantry import dynamico
import geovista.theme


def main() -> None:
"""Create a mesh from 2-D latitude and longitude unstructured cell bounds.
The resulting mesh contains 6-sided (hexagonal) cells.
The resulting mesh contains both hexagonal and pentagonal cells.
It uses surface air pressure data from the DYNAMICO project, a new dynamical core
for the Laboratoire de Météorologie Dynamique (LMD-Z), the atmospheric General
Expand All @@ -32,7 +32,7 @@ def main() -> None:
"""
# load the sample data
sample = icosahedral()
sample = dynamico()

# create the mesh from the sample data
mesh = gv.Transform.from_unstructured(sample.lons, sample.lats, data=sample.data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
from __future__ import annotations

import geovista as gv
from geovista.pantry import icosahedral
from geovista.pantry import dynamico
import geovista.theme


def main() -> None:
"""Create a mesh from 2-D latitude and longitude unstructured cell bounds.
The resulting mesh contains 6-sided (hexagonal) cells.
The resulting mesh contains both hexagonal and pentagonal cells.
It uses surface air pressure data from the DYNAMICO project, a new dynamical core
for the Laboratoire de Météorologie Dynamique (LMD-Z), the atmospheric General
Expand All @@ -33,7 +33,7 @@ def main() -> None:
"""
# load the sample data
sample = icosahedral()
sample = dynamico()

# create the mesh from the sample data
mesh = gv.Transform.from_unstructured(sample.lons, sample.lats, data=sample.data)
Expand Down
72 changes: 36 additions & 36 deletions src/geovista/pantry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"CLOUD_AMOUNT_PREFERENCE",
"CloudPreference",
"cloud_amount",
"dynamico",
"fesom",
"fvcom_tamar",
"icon_soil",
"icosahedral",
"lam_equator",
"lam_falklands",
"lam_london",
Expand Down Expand Up @@ -237,6 +237,41 @@ def cloud_amount(
)


@lru_cache(maxsize=LRU_CACHE_SIZE)
def dynamico() -> SampleUnstructuredXY:
"""Download and cache unstructured surface sample data.
Load DYNAMICO icosahedral unstructured mesh.
Returns
-------
SampleUnstructuredXY
The hexagonal/pentagonal unstructured spatial coordinates and data payload.
Notes
-----
.. versionadded:: 0.3.0
"""
fname = "dynamico_icosahedral.nc"
processor = pooch.Decompress(method="auto", name=fname)
resource = CACHE.fetch(f"pantry/{fname}.bz2", processor=processor)
dataset = nc.Dataset(resource)

# load the lon/lat hex cell grid
lons = dataset.variables["lon_bnds"][:]
lats = dataset.variables["lat_bnds"][:]

# load the mesh payload
data = dataset.variables["ps"]
name = capitalise(data.long_name)
units = data.units

return SampleUnstructuredXY(
lons, lats, lons.shape, data=data, name=name, units=units
)


@lru_cache(maxsize=LRU_CACHE_SIZE)
def fesom(step: int | None = None) -> SampleUnstructuredXY:
"""Download and cache unstructured surface sample data.
Expand Down Expand Up @@ -391,41 +426,6 @@ def icon_soil() -> SampleUnstructuredXY:
)


@lru_cache(maxsize=LRU_CACHE_SIZE)
def icosahedral() -> SampleUnstructuredXY:
"""Download and cache unstructured surface sample data.
Load DYNAMICO icosahedral unstructured mesh.
Returns
-------
SampleUnstructuredXY
The hexagonal unstructured spatial coordinates and data payload.
Notes
-----
.. versionadded:: 0.3.0
"""
fname = "dynamico_icosahedral.nc"
processor = pooch.Decompress(method="auto", name=fname)
resource = CACHE.fetch(f"pantry/{fname}.bz2", processor=processor)
dataset = nc.Dataset(resource)

# load the lon/lat hex cell grid
lons = dataset.variables["lon_bnds"][:]
lats = dataset.variables["lat_bnds"][:]

# load the mesh payload
data = dataset.variables["ps"]
name = capitalise(data.long_name)
units = data.units

return SampleUnstructuredXY(
lons, lats, lons.shape, data=data, name=name, units=units
)


@lru_cache(maxsize=LRU_CACHE_SIZE)
def _gungho_lam(fname: str) -> SampleUnstructuredXY:
"""Download and cache unstructured surface sample data.
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/registry.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ tests/images/rectilinear__from_2d__synthetic_face_m1n1_robin.png c23335fd376d81b
tests/images/rectilinear__from_2d__synthetic_node_m1n1_moll.png d93e9907bd306b95c2e67b5ed99466f08edb3cdd35de85bb4026076422f9b5e3
tests/images/rectilinear__from_2d__synthetic_node_m1n1.png 9d00923e48dad39ba03d903b18a5151ffb085b98e8eba4ad0601ad8630aef5b8
tests/images/spatial_index__uber_h3.png 08cb9cbb5f3ae41d1955efe7cdcfac999b2c6e67072f57871dde85ab49205289
tests/images/unstructured__dynamico.png ba4f2f4a77f065597a9f2db3bf08d7308df7dec49916c973e55961394ed9916c
tests/images/unstructured__dynamico_poly.png 1473440458fdda137fee6d1b9c1cd57d12cc7b098e130667bfaa8faddf25e22f
tests/images/unstructured__fesom_fouc.png 8a8de06cd8f18e9758c05baf3bad77b570bca883cb7f5f2ef4f3c3164e7cfe9d
tests/images/unstructured__fesom.png 3a5463d807a8951072a33e0b8f9f83eedfea8ab9b41cd1a13ae4689478013e39
tests/images/unstructured__icon_eqc.png 442ec422eb1069041212acee9133efa5bfd5f2f9e2b15612eb2818c93887be56
tests/images/unstructured__icon.png aa880fbf486f0e760e2c9ea51ff4e6bd54222b607a2cae9b9bb4a7ee3ab398d5
tests/images/unstructured__icosahedral.png ba4f2f4a77f065597a9f2db3bf08d7308df7dec49916c973e55961394ed9916c
tests/images/unstructured__icosahedral_poly.png 1473440458fdda137fee6d1b9c1cd57d12cc7b098e130667bfaa8faddf25e22f
tests/images/unstructured__lam_pacific_moll.png aaf8a550bf37c4cb32d43c61fd6bf2aa427a5292f7e7c599392e771fac762a42
tests/images/unstructured__lam_pacific.png b3bfc839c883039dfef0db8d8e1f5e2e0833230566ddf97670277ab1b8b17261
tests/images/unstructured__lfric_orog.png 0a144ea930023718003b2e511f109111f244fbbc71e58dc5f8528477b240099a
Expand Down
52 changes: 26 additions & 26 deletions src/geovista/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"WARP_FACTOR",
"ZLEVEL_SCALE_CLOUD",
"cloud_amount",
"dynamico",
"fesom",
"fvcom_tamar",
"icon_soil",
"icosahedral",
"lam_equator",
"lam_falklands",
"lam_london",
Expand Down Expand Up @@ -141,6 +141,31 @@ def cloud_amount(preference: str | pantry.CloudPreference | None = None) -> pv.P
return mesh


def dynamico() -> pv.PolyData:
"""Create a mesh from :mod:`geovista.pantry` sample data.
Generate a DYNAMICO icosahedral mesh.
Returns
-------
PolyData
The DYNAMICO mesh.
Notes
-----
.. versionadded:: 0.3.0
"""
sample = pantry.dynamico()

return Transform.from_unstructured(
sample.lons,
sample.lats,
data=sample.data,
name=sample.name,
)


def fesom() -> pv.PolyData:
"""Create a mesh from :mod:`geovista.pantry` sample data.
Expand Down Expand Up @@ -261,31 +286,6 @@ def icon_soil() -> pv.PolyData:
)


def icosahedral() -> pv.PolyData:
"""Create a mesh from :mod:`geovista.pantry` sample data.
Generate a DYNAMICO icosahedral mesh.
Returns
-------
PolyData
The DYNAMICO mesh.
Notes
-----
.. versionadded:: 0.3.0
"""
sample = pantry.icosahedral()

return Transform.from_unstructured(
sample.lons,
sample.lats,
data=sample.data,
name=sample.name,
)


def lam_equator() -> pv.PolyData:
"""Create a mesh from :mod:`geovista.pantry` sample data.
Expand Down

0 comments on commit 46853d5

Please sign in to comment.