Add xugrid extension for TriMesh plots from unstructured grid data#1724
Open
rsignell wants to merge 6 commits into
Open
Add xugrid extension for TriMesh plots from unstructured grid data#1724rsignell wants to merge 6 commits into
rsignell wants to merge 6 commits into
Conversation
Add hvplot.xugrid module that patches .hvplot onto xu.UgridDataArray and xu.UgridDataset, enabling users to create TriMesh plots directly from xugrid objects (e.g. uda.hvplot.trimesh()). Supports rasterize, geo/tiles, face-to-node averaging, quad mesh triangulation, and extra dimension reduction. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Use isel for integer values and sel only for non-integer values like time strings, so dimensions like FVCOM's siglay that lack a simple 1D index are handled correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…t selection Extra dimensions (time, siglay, etc.) now automatically become interactive slider widgets, matching standard hvplot behavior. Users can still fix a dimension by passing it explicitly (e.g. siglay=0). The xugrid data is passed as xarray to the converter so its existing groupby/DynamicMap machinery handles widget creation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Only include proper 1D dimension coordinates when building the xarray Dataset for the converter. 2D coords like FVCOM's siglay(siglay, node) were being copied through, breaking the groupby slider machinery. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Previously, face data (e.g. u-velocity) was converted to nodes via to_node().mean() on the full multi-dimensional array before the groupby machinery sliced by time/level, causing hangs on large datasets like FVCOM. Now the conversion is deferred to the converter's trimesh() method where the data has already been reduced to a single slice. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers node data, face data (with face-to-node interpolation), extra time dimensions creating DynamicMap groupby sliders, and UgridDataset inputs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Holoviz folks, as you can tell, I made this with Claude Code, and I've been using it for the past few months for many applications. But I have no idea how well it's coded.
@Huite did give it a quick look and didn't raise any red flags.
There is discussion on the xugrid repo here: Deltares/xugrid#204 (comment)
Please let me know if there is anything else I can do -- I'd love to see trimesh supported by hvplot!
Summary
hvplot/xugrid.py— registers.hvplotonxugrid.UgridDataArrayandxugrid.UgridDataset, enablinguda.hvplot.trimesh()for unstructured triangular mesh plotsHoloViewsConverter(converter.py) with atrimesh()method that supportsrasterize=True,geo=True,tiles=,cmap=, etc.hvPlotinplotting/core.pywith thehvPlotXugridsubclass;_get_converter()extracts mesh topology (node coords, face-node connectivity) and stores it inkwdshvplot/tests/testxugrid.pywith 243 lines of tests covering node-data, face-data, time/depth groupby, geo projection, and rasterizationFVCOM_xugrid.ipynb,STOFS_xugrid.ipynb) demonstrating real-world FVCOM and STOFS coastal ocean model outputUsage
Test plan
pytest hvplot/tests/testxugrid.py— all tests passimport hvplot.xugridis a no-op (clean ImportError) when xugrid is not installed🤖 Generated with Claude Code