Visualizing Data as Polygons#

Authors: Philip Chmielowiec

Overview#

This notebook showcases how to visualize data variables as Polygons using the UXarray Plotting API.

Note

UXarray’s Plotting API is build around the Holoviews package. For details about customization and accepted parameters, pleases refer to their documentation.

import uxarray as ux

Face-Centered Data Variable#

The first dataset in this example is taken from an MPAS Ocean Mesh, with the face-centered data variable “BottomDepth”.

base_path = "../../test/meshfiles/mpas/QU/"
grid_path = base_path + "oQU480.231010.nc"
uxds_mpas = ux.open_dataset(grid_path, grid_path)
uxds_mpas["bottomDepth"]
<xarray.UxDataArray 'bottomDepth' (n_face: 1791)> Size: 14kB
[1791 values with dtype=float64]
Dimensions without coordinates: n_face

Node-Centered Data Variable#

The second dataset in this example is taken from the NOAA Geoflow Project, with a node-centered data variable “v1”

base_path = "../../test/meshfiles/ugrid/geoflow-small/"
grid_path = base_path + "grid.nc"
data_path = base_path + "v1.nc"
uxds_ugrid = ux.open_dataset(grid_path, data_path)
uxds_ugrid["v1"]
<xarray.UxDataArray 'v1' (time: 1, meshLayers: 20, n_node: 6000)> Size: 960kB
[120000 values with dtype=float64]
Coordinates:
  * time     (time) float64 8B 13.0
Dimensions without coordinates: meshLayers, n_node
Attributes:
    units:          
    standard_name:  
    mesh:           mesh
    location:       node

Using the UxDataArray.plot() Accessor#

For face-centered data, the default plotting method returns a rasterized polygon plot.

uxds_mpas["bottomDepth"].plot(
    title="Default UXDataArray Plot for Face-Centered Data", height=350, width=700
)