UXARRAY / uxarray

Xarray extension for unstructured climate and global weather data analysis and visualization.
https://uxarray.readthedocs.io/
Apache License 2.0
151 stars 31 forks source link

Support Xarray Plotting Routines #760

Closed philipc2 closed 5 months ago

philipc2 commented 6 months ago

Closes #759

Overview

Expected Usage

import uxarray as ux

grid_path = "/path/to/grid.nc"
data_path = "/path/to/data.nc"

uxds = ux.open_dataset(grid_path, data_path)

# call Xarray Plotting Methods
uxds['var'].plot.hist()
uxds['var'].plot.line()
# and so on
philipc2 commented 6 months ago

Examples

uxds['v1'][0][0].plot.hist(bins=60, figsize=(10, 5))

image

uxds['v1'][0].mean("n_node").plot.line("o--", figsize=(10, 5))

image

philipc2 commented 6 months ago

Update the .plot accessor docstring to mention the use of Xarray functionality.

philipc2 commented 5 months ago

I have fixed the matplotlib backend issue we were encountering. Previously, if we would call backend='matplotlib' for any of our HoloViz functionality, it would set the backend used in the matplotlib package to agg, which differs from the default one in xarray, which is set to "module://matplotlib_inline.backend_inline"

With the changes, we the xarray methods no longer have any issues when backend='matplotlib' is set for any of our HoloViz functionality

# holoviews with a matplotlib backend
uxds['t2m'].plot(backend='matplotlib')

# xarray method, would not render before, but with the change it works
uxds['t2m'].plot.hist()