Polygons


Unstructured Grids are often used in the Dynamical Cores of climate models because of their ability to represent complex geometries effectively. However, the way unstructured grids are represented makes it difficult to produce quick visualizations.

Previously, we have discussed that data variables are typically mapped to the elements that compose unstructured grids (nodes, edges, and faces). When data is mapped to the faces, each face is shaded with the value of the data variable. We can treat these faces as Polygons on a plane for visualization.

This notebook showcases UXarray’s Polygon Visualization methods.

Setup

import uxarray as ux
fig_size = 400
plot_kwargs = {"backend": "matplotlib", "aspect": 2, "fig_size": fig_size}
file_dir = "../../meshfiles/"
grid_filename_mpas = file_dir + "oQU480.grid.nc"
data_filename_mpas = file_dir + "oQU480.data.nc"
uxds = ux.open_dataset(grid_filename_mpas, data_filename_mpas)

Vector Polygon Plots

The UxDataArray.plot.polygons() method produces a Vector Polygon plot, where each face is represent as a polygon.

uxds["bottomDepth"].plot.polygons(**plot_kwargs)
WARNING:param.main: fig_size option not found for polygons plot with matplotlib; similar options include: []

Interactive Example

In the plot below, take some time to zoom and pan around the plot to observe some of the defining characteristics of a Vector Polygon Plot:

  • Hovering over a polygon (face) displays the value mapped to it, which is the same as the original value stored in our UxDataArray

  • There is no drop in quality when zooming in

  • Each polygon is bounded by edges that are drawn as lines

uxds["bottomDepth"].plot.polygons(
    backend="bokeh", width=1000, height=500, tools=["hover"]
)