MPAS Vertex-centered Voronoi plots

This example draws MPAS vertex-centered scalar data on the dual polygons around each vertex with easyclimate.plot.mpas.plot_vertex_voronoi.

If cell-centered data are supplied, the helper can average neighboring cell values to vertices before plotting.

import xarray as xr
import numpy as np
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
import easyclimate as ecl

from easyclimate.plot.mpas import plot_vertex_voronoi

Open the sample MPAS output and use a selected relative-vorticity field for the vertex-based examples.

data = ecl.open_tutorial_dataset("mpas_JWwave_T10_nVertLevels10")
data
mpas_JWwave_T10_nVertLevels10.nc ━━━━━━━━ 100.0% • 2.3/2.3  • 20.2     • 0:00:00
                                                   MB         MB/s
<xarray.Dataset> Size: 6MB
Dimensions:                 (nCells: 40962, nVertices: 81920, maxEdges: 10,
                             nEdges: 122880, TWO: 2, vertexDegree: 3)
Coordinates:
  * nCells                  (nCells) int64 328kB 0 1 2 3 ... 40959 40960 40961
    Time                    int64 8B ...
    nVertLevels             int64 8B ...
Dimensions without coordinates: nVertices, maxEdges, nEdges, TWO, vertexDegree
Data variables:
    uReconstructZonal       (nCells) float32 164kB ...
    uReconstructMeridional  (nCells) float32 164kB ...
    vorticity               (nVertices) float32 328kB ...
    divergence              (nCells) float32 164kB ...
    lonCell                 (nCells) float32 164kB ...
    latCell                 (nCells) float32 164kB ...
    lonVertex               (nVertices) float32 328kB ...
    latVertex               (nVertices) float32 328kB ...
    verticesOnCell          (nCells, maxEdges) int32 2MB ...
    nEdgesOnCell            (nCells) int32 164kB ...
    verticesOnEdge          (nEdges, TWO) int32 983kB ...
    cellsOnVertex           (nVertices, vertexDegree) int32 983kB ...
Attributes: (12/180)
    model_name:                             mpas
    core_name:                              atmosphere
    version:                                8.4.0
    source:                                 MPAS
    Conventions:                            MPAS
    git_version:                            v8.4.0
    ...                                     ...
    config_noahmp_iopt_crop:                0
    config_noahmp_iopt_irr:                 0
    config_noahmp_iopt_irrm:                0
    config_noahmp_iopt_infdv:               1
    config_noahmp_iopt_tdrn:                0
    file_id:                                m02zbs7ciw


Draw vertex dual polygons over a broad region.

plot_vertex_voronoi(
    data,
    data.vorticity,
    lon_min=130,
    lon_max=320,
    lat_min=10,
    lat_max=80,
)
Relative vorticity at vertices
<matplotlib.collections.PolyCollection object at 0x7a8797572540>

The helper can also draw on an existing Cartopy axes.

fig, ax = plt.subplots(subplot_kw= {"projection": ccrs.PlateCarree(-120)})

plot_vertex_voronoi(
    data,
    data.vorticity,

    ax = ax,
    transform = ccrs.PlateCarree(),

    lon_min=130,
    lon_max=320,
    lat_min=10,
    lat_max=80,

    cbar_kwargs = {'location': 'bottom', 'aspect': 60}
)

ax.set_title("JW Wave Relative Vorticity (plot_vertex_voronoi)")
ax.coastlines(resolution="110m", linewidth=0.6, color = "b")
ax.gridlines(draw_labels=True, alpha = 0)
JW Wave Relative Vorticity (plot_vertex_voronoi)
<cartopy.mpl.gridliner.Gridliner object at 0x7a8793f56e40>

Show polygon edges in a smaller region to inspect the dual mesh structure.

fig, ax = plt.subplots(subplot_kw= {"projection": ccrs.PlateCarree(160)})

plot_vertex_voronoi(
    data,
    data.vorticity,

    transform = ccrs.PlateCarree(),
    ax = ax,

    lon_min=200,
    lon_max=270,
    lat_min=30,
    lat_max=70,

    linewidth = 0.1,
    edgecolor="grey",

    cbar_kwargs = {'location': 'bottom', 'aspect': 60}
)

ax.set_title("Local JW Wave Relative Vorticity (plot_cell_voronoi)")
ax.coastlines(resolution="50m", linewidth=0.6, color = "r")
ax.gridlines(draw_labels=True, alpha = 0)
Local JW Wave Relative Vorticity (plot_cell_voronoi)
<cartopy.mpl.gridliner.Gridliner object at 0x7a8796f66000>

Total running time of the script: (0 minutes 20.581 seconds)