A "CubeSphere object" is simply an xarray DataSet with a specific format:

- Data variables must contain dimensions (tile, y, x), to represent 6 tiles of the cubed-sphere. There's no restriction on additional dimensions.
- Those coordinate variables are
**required**for any visualizations:- lon (tile, y, x)
- lat (tile, y, x)
- lon_b (tile, y+1, x+1)
- lat_b (tile, y+1, x+1)

- The area information is not required but strongly recommended for taking conservative binning:
area (tile, y, x)

Below is an example from the GFDL-FV3 output.

Loading output library...

With coordinate information available, we can plot the data with one function, without regridding to lat-lon.

plotCS_quick( ) simply calls plt.colormesh( ) 6 times. It only works with the PlateCarree projection and does not show the cells near map boundaries. But it is very fast and can be used for rough checking.

To-do list:

- A better-looking (but possibly slower) method that correctly shows all cells and works with other projections.
- A cleaner wrapper to avoid passing ds twice (need to solve https://github.com/pydata/xarray/issues/1475).
- Hook the plotting method to DataArray or to Axis.

Loading output library...

Loading output library...

**Note**: For the rest of this notebook we use the wrapper function plotCS( ) for convenience. Will need to decide which method should be default based on both appearance and performance.

All details including colormap, colorbar and gridline can be tuned as usual. There's nothing special with the cubesphere plot.

Loading output library...

xarray's multi-dimensional groupby allows us to take zonal/meridonal average without regridding to lat-lon. This is **much** faster and more accurate than first regridding to lat-lon and then taking average.

If the "area" coordinate variable is present, the binning will be weighted by area; otherwise uniform weights will be used.

Loading output library...

We can set up subplots as usual -- nothing special with cubed-sphere. However, as Cartopy documentation is not very comprehensive (especially about subplots), we make some examples here.

Suggested by https://github.com/SciTools/cartopy/issues/900

Loading output library...

Loading output library...

Loading output library...

Loading output library...