{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exploring Lake Ontario forecast data\n", "This example shows the power of xrViz to interactively explore xarray data in geographic context. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "from xrviz.dashboard import Dashboard\n", "import logging, sys \n", "logging.disable(sys.maxsize)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# open remote data with xarray\n", "url = 'https://opendap.co-ops.nos.noaa.gov/thredds/dodsC/NOAA/LOOFS/MODELS/2021/04/30/glofs.loofs.fields.forecast.20210430.t12z.nc' \n", "data = xr.open_dataset(url)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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!" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "initial_params = {\n", " # Select Variable\n", " 'Variables': 'temp', \n", "\n", " # Add Coords to list\n", " 'Set Coords': ['lon', 'lat'], \n", "\n", " # Select Axes\n", " 'x': 'lon', \n", " 'y': 'lat', \n", "\n", " # Style\n", " 'height': 300, \n", " 'width': 650, \n", " 'colorbar': True,\n", " 'cmap': 'Viridis', \n", " \n", " # Projection\n", " 'is_geo': True,\n", " 'basemap': 'OSM'\n", " }" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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](http://meteora.ucsd.edu/~pierce/ncview_home_page.html)) rather than in geographic space. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dash = Dashboard(data, initial_params=initial_params)\n", "dash.panel.servable()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Not seeing anything? \n", "Did you click the `Plot` button? :)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.10" } }, "nbformat": 4, "nbformat_minor": 4 }