Download notebook (Right click and save): NCAR/GeoCAT-examples


MPAS with Datashader and Geoviews#

To run this notebook in a local setup, the following packages need to be installed by running:

conda install -c conda-forge datashader holoviews geoviews
conda install -c ncar geocat-datafiles  # Only for reading-in datasets

Interactively plotting unstructured grid MPAS data with Datashader and Geoviews#

This example demonstrates several key points:

  1. Making use of the MPAS file’s connectivity information to render data on the native grid, and also avoid costly Delaunay triangulation that is required if the MPAS connectivity information is not used.

  2. Rendering data that is sampled on both the ‘primal’ and ‘dual’ MPAS mesh.

  3. Using geoviews/holoviews for interactive plotting in a Jupyter Notebook. The plotting is interactive in the sense that you can pan and zoom the data. Doing so will reveal greater and greater data fidelity.

  4. Using Datashader to perform background rendering in place of Matplotlib. Unlike Matplotlib, Datashader was designed for performance with large data sets.

The data#

The global data sets used in this example are from the same experiment, but run at several resolutions from 30km to 3.75km. Due to their size, the higher resolution data sets are only distributed with two variables in them: + relhum_200hPa: Relative humidity vertically interpolated to 200 hPa + vorticity_200hPa: Relative vorticity vertically interpolated to 200 hPa

The relhum_200hPa is computed on the MPAS ‘primal’ mesh, while the vorticity_200hPa is computed on the MPAS ‘dual’ mesh. Note that data may also be sampled on the edges of the primal mesh. This example does not include/cover edge-centered data.

These data are courtesy of NCAR’s Falko Judt, and were produced as part of the DYAMOND initiative: http://dx.doi.org/10.1186/s40645-019-0304-z.

[1]:
import cartopy.crs as ccrs
import numpy as np

import dask.dataframe as dd

import holoviews as hv
from holoviews import opts

from holoviews.operation.datashader import rasterize as hds_rasterize
import geoviews.feature as gf # only needed for coastlines

hv.extension("bokeh","matplotlib")

opts.defaults(
    opts.Image(width=1200, height=600),
    opts.RGB(width=1200, height=600))