This example shows the power of xrViz to interactively explore xarray data in geographic context.
import xarray as xr
from xrviz.dashboard import Dashboard
import logging, sys
logging.disable(sys.maxsize)
# open remote data with xarray
url = 'https://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/LOOFS/MODELS/2021/04/30/glofs.loofs.fields.forecast.20210430.t12z.nc'
data = xr.open_dataset(url)
Users can simply load an xarray dataset into xrViz and use the dashboard to set the visualization parameters, but if you know the dataset, you can set initial parameters to use as well. In this example, all usersneed to do to get started exploring the dataset is click the plot
button on the dashboard below!
initial_params = {
# Select Variable
'Variables': 'temp',
# Add Coords to list
'Set Coords': ['lon', 'lat'],
# Select Axes
'x': 'lon',
'y': 'lat',
# Style
'height': 300,
'width': 650,
'colorbar': True,
'cmap': 'Viridis',
# Projection
'is_geo': True,
'basemap': 'OSM'
}
The Dashboard function is where the xrViz magic happens, taking an xarray dataset and producing a dashboard for exploration. The initial_params
argument is not required, and is not generally used until you understand the dataset and what users might want to typically see. Try exploring the different tabs on the dashboard below to change the style and basemap type, or plot in index space (like ncview) rather than in geographic space.
dash = Dashboard(data, initial_params=initial_params)
dash.panel.servable()
Not seeing anything?
Did you click the Plot
button? :)