{ "cells": [ { "cell_type": "markdown", "id": "a107dfa27c1b5b7b", "metadata": { "panel-layout": { "height": 423.611, "visible": true, "width": 100 } }, "source": [ "<img src=\"https://raw.githubusercontent.com/UXARRAY/uxarray/main/docs/_static/images/logos/uxarray_logo_h_dark.svg\"\n", " width=\"30%\"\n", " alt=\"UXarray logo\"\n", " align=\"right\"\n", "/>\n", "\n", "# Plotting Libraries\n", "\n", "### In this section, you'll learn:\n", "\n", "* What general purpose visualization packages are available in the Scientific Python Ecosystem\n", "* How functionality of these packages can be useful for unstructured grids visualization\n", "\n", "### Related Documentation\n", "\n", "* No UXarray documentation is referenced here since this section covers the content from a general point of view.\n", "\n", "### Prerequisites\n", "\n", "| Concepts | Importance | Notes |\n", "| --- | --- | --- |\n", "| Python | Necessary | This notebook does not contain any Python code, but understanding those libraries comprehensively would require Python programming |\n", "\n", "**Time to learn**: 10 minutes\n", "\n", "-----\n", "\n" ] }, { "cell_type": "markdown", "id": "c6502995-401e-4f39-b789-1c39e93b02e8", "metadata": { "panel-layout": { "height": 206.753, "visible": true, "width": 100 } }, "source": [ "In this section, we will introduce two visualization libraries/technologies and their features and functionality that can be useful for unstructured grids visualization before diving deep into plotting unstructured grids with UXarray in the next chapter." ] }, { "cell_type": "markdown", "id": "aba250fa-bfe5-4e65-8f76-93bbc9466d67", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 50.816, "visible": true, "width": 100 } }, "source": [ "## HoloViz" ] }, { "cell_type": "markdown", "id": "2f0181f8-2859-4a13-853e-9f4c89b7ad8d", "metadata": { "panel-layout": { "height": 491.51, "visible": true, "width": 100 } }, "source": [ "[HoloViz](https://holoviz.org/) is a stack of tools (such as Holoviews, Datashader, Geoviews, SpatialPandas, hvPlot etc.) that provide high-level functionality to visualize even the very large datasets efficiently in Python. HoloViz packages are well-suited for unstructured grid visualization because:\n", "\n", "1. They provide rendering functionality for both vector geometries and rasterization, which will be detailed in the [next section](rendering-techniques). Such functionality is much needed for unstructured grid topology and data visualization purposes.\n", "2. Unlike Matplotlib, they support using the connectivity information that comes from the unstructured grids\n", "3. They are designed to be scalable for even the largest datasets that'd be generated as result of kilometer-scale analyses" ] }, { "cell_type": "markdown", "id": "1e2b2a13-9bc4-43fc-a3e0-0f77cfbc2efc", "metadata": { "panel-layout": { "height": 102.535, "visible": true, "width": 100 } }, "source": [ "Let us look at the particular HoloViz packages that can be useful for scalable visualization of unstructured grids." ] }, { "cell_type": "markdown", "id": "2768839a-22d2-4543-8856-763bbd737c12", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 217.5, "visible": true, "width": 100 } }, "source": [ "### HoloViews\n", "\n", "[Holoviews](https://holoviews.org/about.html) houses several elements (e.g. `Path()`, `Points()`) that enables visualization of grid geometries such as nodes and edges. Similarly, other elements of this package (e.g. `Polygons()`) can be used for various polygon vector visulization purposes." ] }, { "cell_type": "markdown", "id": "14578d1d-1582-4155-a845-9287b02937b7", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 44.0799, "visible": true, "width": 100 } }, "source": [ "### Datashader" ] }, { "cell_type": "markdown", "id": "8552a1e4-2a52-4c4c-8b1f-2171c45923e8", "metadata": { "panel-layout": { "height": 171.076, "visible": true, "width": 100 } }, "source": [ "[Datashader](https://datashader.org/about.html) is the graphics pipeline system of the HoloViz tool stack for creating meaningful representations of large datasets quickly and flexibly. Datashader's rasterization methods, transfer functions, and other shading operators can be utilized for rasterized polygon plotting." ] }, { "cell_type": "markdown", "id": "ee79d625-0694-4449-b560-14dd3b938587", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 44.0799, "visible": true, "width": 100 } }, "source": [ "### GeoViews" ] }, { "cell_type": "markdown", "id": "709f3439-e598-41b9-a3bb-e75c9c6297e9", "metadata": { "panel-layout": { "height": 273.889, "visible": true, "width": 100 } }, "source": [ "[GeoViews](https://geoviews.org/index.html) provides features and functionality to visualize geographical, meteorological, and oceanographic datasets and features." ] }, { "cell_type": "markdown", "id": "4630b0ef-3fac-4643-83c1-ad26c84d7207", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 44.0799, "visible": true, "width": 100 } }, "source": [ "### Spatialpandas" ] }, { "cell_type": "markdown", "id": "e0dbdb54-839c-48b1-9fd4-f4f93305d696", "metadata": { "panel-layout": { "height": 408.056, "visible": true, "width": 100 } }, "source": [ "Spatialpandas is a package that provides Pandas extension arrays for spatial/geometric operations. This package has an element called `GeoDataFrame`, which can be used directly by packages from the HoloViz stack such as hvPlot, Datashader, Holoviews, and Geoviews. Conversions from unstructured grids to `GeoDataFrame` can allow to perform visualizations directly in HoloViz packages." ] }, { "cell_type": "markdown", "id": "32fb6a11-21f5-42f3-8a2e-e8262298fc1c", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 50.816, "visible": true, "width": 100 } }, "source": [ "## Matplotlib" ] }, { "cell_type": "markdown", "id": "3fa8566f-2a2d-41d1-8c22-388f315ef56e", "metadata": { "panel-layout": { "height": 533.75, "visible": true, "width": 100 } }, "source": [ "Matplotlib is the workhorse of Python visualization needs, for both general and geoscientific purposes. However, when it \n", "comes to visualizing unstructured grids, Matplotlib's:\n", "\n", "1. Functionality is limited such that there is no way to use the connectivity information that comes with the unstructured grid \n", "2. Scalability especially for kilometer-scale (e.g. individual storm-resolving) resolutions is limited. \n", "\n", "Matplotlib can still serve as a visualization backend for unstriuctured grid visualization, especially for the end-user who is familiar with Matplotlib and would like to create publication-quality outputs.\n", "\n", "Moreover, just like conversion to `Spatialpandas.GeoDataFrame`, conversions to Matplotlib data structures such as `Collections` can be utilized for unstructrued grid plotting directly with the Matplotlib interface." ] }, { "cell_type": "markdown", "id": "81afad50-801f-4e8b-9022-ced33eb0bdd3", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 183.229, "visible": true, "width": 100 } }, "source": [ "### Collections \n", "Detailed information about Matplotlib's Collections API can be found [here](https://matplotlib.org/stable/api/collections_api.html). Conversions to `LineCollection` and `PolyCollection` can help visualize Grid Geometries and data variables, respectively. " ] }, { "cell_type": "markdown", "id": "f8f1b8bc-70f2-4d7c-a2cd-6c7b20f9d10b", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 44.0796, "visible": true, "width": 100 } }, "source": [ "### Cartopy" ] }, { "cell_type": "markdown", "id": "a443de93-18ef-40d6-a24b-f7abb6ab38b6", "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "panel-layout": { "height": 322.378, "visible": true, "width": 100 } }, "source": [ "Cartopy is originally a Python library for cartographic visualizations with Matplotlib; however, they provide a number of features such as `crs`, i.e. Coordinate Reference Systems (a.k.a. projections), that are significant for cartographic visualizations." ] }, { "cell_type": "markdown", "id": "29fc6539-2830-480f-81b1-e6e8d99508b0", "metadata": {}, "source": [ "## What is next?\n", "The next section will provide an overview of the rendering techniques that can be used for visualizing unstructrued grids." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.12.6" }, "panel-cell-order": [ "a107dfa27c1b5b7b", "c6502995-401e-4f39-b789-1c39e93b02e8", "aba250fa-bfe5-4e65-8f76-93bbc9466d67", "2f0181f8-2859-4a13-853e-9f4c89b7ad8d", "5d8acee1-cff1-440c-ba45-156e9c1b3d01", "1e2b2a13-9bc4-43fc-a3e0-0f77cfbc2efc", "2768839a-22d2-4543-8856-763bbd737c12", "a34f9368-1a91-4e55-bf78-962e09a65bca", "14578d1d-1582-4155-a845-9287b02937b7", "8552a1e4-2a52-4c4c-8b1f-2171c45923e8", "ee79d625-0694-4449-b560-14dd3b938587", "709f3439-e598-41b9-a3bb-e75c9c6297e9", "4630b0ef-3fac-4643-83c1-ad26c84d7207", "e0dbdb54-839c-48b1-9fd4-f4f93305d696", "32fb6a11-21f5-42f3-8a2e-e8262298fc1c", "3fa8566f-2a2d-41d1-8c22-388f315ef56e", "81afad50-801f-4e8b-9022-ced33eb0bdd3", "b5a3ffb6-d046-4830-b1ff-93eb73b74de8", "f8f1b8bc-70f2-4d7c-a2cd-6c7b20f9d10b", "a443de93-18ef-40d6-a24b-f7abb6ab38b6" ] }, "nbformat": 4, "nbformat_minor": 5 }