Skip to content

Assigning connectivities based on UGRID conventions - #1736

Merged
dylannelson merged 9 commits into
mainfrom
n2-naming
Sep 18, 2026
Merged

dylannelson merged 9 commits into
mainfrom
n2-naming

Conversation

@dylannelson

@dylannelson dylannelson commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Closes #1717
Closes #1725
Why two in one? The reason for closing both in one PR is due to them being caused by the same problem. Having 3 dimensions in pre-existing connectivities results in swap_dims quietly breaking, causing both the issues seen above. By applying some cleaning both before and after swap_dims is called, both issues are solved together. As far as I can see, there is no evidence we would see one of the above errors without the other, and since the solution is in the same location, we may as well solve it once and here. Originally I solved the first one alone, but solving the 2nd would basically require deleting the whole original solution, and replacing it with a more general one. So rather than pushing 1 solution to main, deleting it, and pushing another, I say we just push this single refined solution (assuming it works as intended)

Overview

_read_ugrid renamed the trailing dimension of face_node_connectivity to n_max_face_nodes and left every other connectivity's equivalent dimension as whatever the source file called it. Reading fesom.mesh.diag.nc, which names those axes n3 and n2:

Connectivity File's name for the axis dims Before dims After
face_node_connectivity n3 ('n_face', 'n_max_face_nodes') unchanged
face_edge_connectivity n3 ('n_face', 'n_max_face_nodes') ('n_face', 'n_max_face_edges')
face_face_connectivity n3 ('n_face', 'n_max_face_nodes') ('n_face', 'n_max_face_faces')
edge_node_connectivity n2 ('n_edge', 'n2') ('n_edge', 'two')
edge_face_connectivity n2 ('n_edge', 'n2') ('n_edge', 'two')

Each connectivity's trailing dimension is now mapped to the name ugrid.CONNECTIVITY gives it, rather than one being hardcoded and the rest left alone. In this FESOM file (which is read in through the UGRID path) it uses one size-3 n3 for all three face connectivities. swap_dims call cannot express all 3, so the first connectivity renames it for the whole dataset and the remainder are renamed per variable. face_node_connectivity is first, so variables that are not connectivity all get n_max_face_nodes

Expected Usage

import uxarray as ux

uxgrid = ux.open_grid("fesom.mesh.diag.nc")

# the edge connectivities carried the file's own name for the trailing axis
uxgrid.edge_node_connectivity.dims
# before: ('n_edge', 'n2')
# after:  ('n_edge', 'two')

uxgrid.edge_face_connectivity.dims
# before: ('n_edge', 'n2')
# after:  ('n_edge', 'two')

# the face connectivities all shared one size-3 dimension
uxgrid.face_edge_connectivity.dims
# before: ('n_face', 'n_max_face_nodes')
# after:  ('n_face', 'n_max_face_edges')

# so indexing those axes by name now works
uxgrid.edge_node_connectivity.isel(two=0)
# before: ValueError: Dimensions {'two'} do not exist
# after:  the first node of every edge

PR Checklist

General

  • An issue is created and linked
  • Added appropriate labels (if your uxarray repo permissions allow it)
  • Filled out Overview and Expected Usage (if applicable) sections

Testing & Benchmarking

  • There is adequate test coverage of changes from this PR (add new tests if needed)
  • If this PR could affect performance, ran ASV benchmarks and confirmed they show expected behavior (add a new benchmark if necessary)

Documentation and Examples

  • [N/A] Docstrings updated with any function changes, and included in all new functions
  • [N/A] User (public) functions added to docs/api.rst; internal (private) function names start with an underscore (_)
  • [N/A] If touched any notebook files, cleared the output of all cells before committing
  • [N/A] If added new notebook files, put into appropriate directories and referenced in appropriate files

AI Disclosure

AI Usage: Claude

  • I have tested and take responsibility for all AI-generated content in my PR.

contains test and explanation for how edge_node_connectivity and edge_face_connectivity interact with the trailing dimension "two"
@dylannelson dylannelson added run-benchmark Run ASV benchmark workflow extra dims Handling of non-grid dimensions, such as time or altitude labels Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

ASV Benchmarking

Benchmark Comparison Results

Benchmarks that have stayed the same:

Change Before [06ec278] After [e2d43c1] Ratio Benchmark (Parameter)
5.79±0.02ms 5.77±0.05ms 1.00 bench_connectivity.Connectivity.time_edge_face('120km')
2.03±0.02ms 2.06±0.01ms 1.01 bench_connectivity.Connectivity.time_edge_face('480km')
4.70±0.08ms 4.63±0.05ms 0.99 bench_connectivity.Connectivity.time_edge_node('120km')
1.62±0.01ms 1.58±0.02ms 0.97 bench_connectivity.Connectivity.time_edge_node('480km')
4.64±0.02ms 4.69±0.05ms 1.01 bench_connectivity.Connectivity.time_face_edge('120km')
1.61±0.03ms 1.60±0.02ms 1.00 bench_connectivity.Connectivity.time_face_edge('480km')
6.89±0.05ms 6.87±0.08ms 1.00 bench_connectivity.Connectivity.time_face_face('120km')
2.48±0.02ms 2.51±0.01ms 1.01 bench_connectivity.Connectivity.time_face_face('480km')
70.0±2μs 68.8±0.9μs 0.98 bench_connectivity.Connectivity.time_face_node('120km')
67.9±0.7μs 67.3±1μs 0.99 bench_connectivity.Connectivity.time_face_node('480km')
476±10μs 481±8μs 1.01 bench_connectivity.Connectivity.time_n_nodes_per_face('120km')
407±10μs 420±10μs 1.03 bench_connectivity.Connectivity.time_n_nodes_per_face('480km')
6.21±0.06ms 6.23±0.09ms 1.00 bench_connectivity.Connectivity.time_node_edge('120km')
2.04±0.03ms 2.03±0.01ms 1.00 bench_connectivity.Connectivity.time_node_edge('480km')
83.5±1ms 82.7±1ms 0.99 bench_connectivity.Connectivity.time_node_face('120km')
5.16±0.03ms 5.12±0.03ms 0.99 bench_connectivity.Connectivity.time_node_face('480km')
8.37±0.01ms 8.47±0.2ms 1.01 face_bounds.FaceBounds.time_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/mpas/QU/oQU480.231010.nc'))
2.71±0.08ms 2.80±1ms 1.03 face_bounds.FaceBounds.time_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/scrip/outCSne8/outCSne8.nc'))
10.6±10s 10.1±10ms ~0.00 face_bounds.FaceBounds.time_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/geoflow-small/grid.nc'))
2.23±0.02ms 2.16±0.03ms 0.97 face_bounds.FaceBounds.time_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/quad-hexagon/grid.nc'))
57.3k 57.3k 1.00 face_bounds.FaceBounds.track_nbytes_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/mpas/QU/oQU480.231010.nc'))
12.3k 12.3k 1.00 face_bounds.FaceBounds.track_nbytes_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/scrip/outCSne8/outCSne8.nc'))
123k 123k 1.00 face_bounds.FaceBounds.track_nbytes_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/geoflow-small/grid.nc'))
128 128 1.00 face_bounds.FaceBounds.track_nbytes_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/quad-hexagon/grid.nc'))
1.27M 1.27M 1.00 face_bounds.FaceBounds.track_nbytes_grid_with_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/mpas/QU/oQU480.231010.nc'))
50.1k 50.1k 1.00 face_bounds.FaceBounds.track_nbytes_grid_with_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/scrip/outCSne8/outCSne8.nc'))
1.48M 1.48M 1.00 face_bounds.FaceBounds.track_nbytes_grid_with_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/geoflow-small/grid.nc'))
712 712 1.00 face_bounds.FaceBounds.track_nbytes_grid_with_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/quad-hexagon/grid.nc'))
1.99M 1.99M 1.00 face_bounds.FaceBounds.track_peakmem_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/mpas/QU/oQU480.231010.nc'))
1.99M 1.99M 1.00 face_bounds.FaceBounds.track_peakmem_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/scrip/outCSne8/outCSne8.nc'))
2.16M 2.16M 1.00 face_bounds.FaceBounds.track_peakmem_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/geoflow-small/grid.nc'))
38.4k 38.3k 1.00 face_bounds.FaceBounds.track_peakmem_face_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/quad-hexagon/grid.nc'))
330M 330M 1.00 face_bounds.FaceBoundsColdStartRss.peakmem_open_and_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/mpas/QU/oQU480.231010.nc'))
360M 360M 1.00 face_bounds.FaceBoundsColdStartRss.peakmem_open_and_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/scrip/outCSne8/outCSne8.nc'))
331M 331M 1.00 face_bounds.FaceBoundsColdStartRss.peakmem_open_and_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/geoflow-small/grid.nc'))
331M 330M 1.00 face_bounds.FaceBoundsColdStartRss.peakmem_open_and_bounds(PosixPath('/home/runner/work/uxarray/uxarray/test/meshfiles/ugrid/quad-hexagon/grid.nc'))
1.22±0.04μs 1.21±0.04μs 0.99 geometry_kernels.AccucrossKernels.time_accucross
2.64±0.01μs 2.66±0.03μs 1.01 geometry_kernels.AccucrossKernels.time_accucross_pair
471±20ns 456±10ns 0.97 geometry_kernels.EFTPrimitives.time_acc_sqrt_re
431±20ns 671±300ns ~1.56 geometry_kernels.EFTPrimitives.time_diff_of_products
396±10ns 420±20ns 1.06 geometry_kernels.EFTPrimitives.time_two_prod
391±9ns 386±20ns 0.99 geometry_kernels.EFTPrimitives.time_two_sum
682±4ns 701±9ns 1.03 geometry_kernels.GCAConstLatIntersection.time_accux_constlat_kernel
747±20ns 761±30ns 1.02 geometry_kernels.GCAConstLatIntersection.time_gca_const_lat_intersection
816±30ns 857±30ns 1.05 geometry_kernels.GCAConstLatIntersection.time_try_gca_const_lat_intersection
842±20ns 821±20ns 0.98 geometry_kernels.GCAGCAIntersection.time_accux_gca_kernel
942±10ns 952±20ns 1.01 geometry_kernels.GCAGCAIntersection.time_gca_gca_intersection
1.10±0.03μs 1.06±0.03μs 0.96 geometry_kernels.GCAGCAIntersection.time_try_gca_gca_intersection
54.6±1μs 52.0±0.4μs 0.95 geometry_kernels.OrientPredicates.time_on_minor_arc
1.18±0.02μs 1.15±0.03μs 0.97 geometry_kernels.OrientPredicates.time_orient3d_on_sphere
3.07±0.01ms 3.06±0ms 1.00 geometry_samebody.SameBodyConstLat.time_accux_dispatch
1.17±0.01ms 1.17±0ms 1.00 geometry_samebody.SameBodyConstLat.time_accux_kernel
2.31±0.01ms 2.31±0ms 1.00 geometry_samebody.SameBodyConstLat.time_fp64_dispatch
152±3μs 151±0.8μs 0.99 geometry_samebody.SameBodyConstLat.time_fp64_kernel
29.5±0.06ms 29.4±0.04ms 1.00 geometry_samebody_gcagca.SameBodyGcaGca.time_accux_dispatch
6.33±0ms 6.31±0ms 1.00 geometry_samebody_gcagca.SameBodyGcaGca.time_accux_kernel
23.9±0.09ms 23.7±0ms 0.99 geometry_samebody_gcagca.SameBodyGcaGca.time_fp64_dispatch
896±10μs 890±0.5μs 0.99 geometry_samebody_gcagca.SameBodyGcaGca.time_fp64_kernel
875±8ms 873±9ms 1.00 import.Imports.timeraw_import_uxarray
288M 288M 1.00 import.Imports.track_peakmem_import_uxarray
2.76±0.04ms 2.74±0.04ms 0.99 mpas_ocean.CheckNorm.time_check_norm('120km')
2.26±0.03ms 2.23±0.04ms 0.99 mpas_ocean.CheckNorm.time_check_norm('480km')
1.23±0.01ms 1.24±0.01ms 1.00 mpas_ocean.ConnectivityConstruction.time_face_face_connectivity('120km')
576±9μs 583±10μs 1.01 mpas_ocean.ConnectivityConstruction.time_face_face_connectivity('480km')
695±10μs 705±10μs 1.01 mpas_ocean.ConnectivityConstruction.time_n_nodes_per_face('120km')
626±10μs 626±10μs 1.00 mpas_ocean.ConnectivityConstruction.time_n_nodes_per_face('480km')
5.37±0.03ms 5.40±0.02ms 1.01 mpas_ocean.ConstructFaceLatLon.time_cartesian_averaging('120km')
3.91±0.02ms 3.88±0.01ms 0.99 mpas_ocean.ConstructFaceLatLon.time_cartesian_averaging('480km')
100±0.6ms 99.6±0.08ms 1.00 mpas_ocean.ConstructFaceLatLon.time_welzl('120km')
10.9±0.06ms 10.5±0.3ms 0.96 mpas_ocean.ConstructFaceLatLon.time_welzl('480km')
18.3±0.2ms 18.2±0.02ms 0.99 mpas_ocean.ConstructTreeStructures.time_ball_tree('120km')
1.07±0.02ms 1.05±0.01ms 0.98 mpas_ocean.ConstructTreeStructures.time_ball_tree('480km')
12.1±2ms 10.6±0.03ms ~0.87 mpas_ocean.ConstructTreeStructures.time_kd_tree('120km')
730±8μs 723±4μs 0.99 mpas_ocean.ConstructTreeStructures.time_kd_tree('480km')
597±10ms 586±4ms 0.98 mpas_ocean.CrossSections.time_const_lat('120km', 1)
296±2ms 298±2ms 1.01 mpas_ocean.CrossSections.time_const_lat('120km', 2)
155±0.6ms 154±1ms 0.99 mpas_ocean.CrossSections.time_const_lat('120km', 4)
544±3ms 530±1ms 0.97 mpas_ocean.CrossSections.time_const_lat('480km', 1)
274±1ms 269±2ms 0.98 mpas_ocean.CrossSections.time_const_lat('480km', 2)
138±2ms 138±0.6ms 1.00 mpas_ocean.CrossSections.time_const_lat('480km', 4)
356M 356M 1.00 mpas_ocean.CrossSectionsPeakMem.peakmem_const_lat('120km', 1)
356M 356M 1.00 mpas_ocean.CrossSectionsPeakMem.peakmem_const_lat('120km', 2)
356M 356M 1.00 mpas_ocean.CrossSectionsPeakMem.peakmem_const_lat('120km', 4)
335M 336M 1.00 mpas_ocean.CrossSectionsPeakMem.peakmem_const_lat('480km', 1)
335M 335M 1.00 mpas_ocean.CrossSectionsPeakMem.peakmem_const_lat('480km', 2)
335M 335M 1.00 mpas_ocean.CrossSectionsPeakMem.peakmem_const_lat('480km', 4)
24.8±0.2ms 25.5±0.09ms 1.03 mpas_ocean.DualMesh.time_dual_mesh_construction('120km')
3.15±0.07ms 3.05±0.03ms 0.97 mpas_ocean.DualMesh.time_dual_mesh_construction('480km')
14.1±0.1ms 14.3±0.2ms 1.02 mpas_ocean.FaceAreas.time_face_areas('120km')
4.37±3ms 4.38±0.05ms 1.00 mpas_ocean.FaceAreas.time_face_areas('480km')
229k 229k 1.00 mpas_ocean.FaceAreas.track_nbytes_face_areas('120km')
14.3k 14.3k 1.00 mpas_ocean.FaceAreas.track_nbytes_face_areas('480km')
2.12M 2.12M 1.00 mpas_ocean.FaceAreas.track_peakmem_face_areas('120km')
729k 729k 1.00 mpas_ocean.FaceAreas.track_peakmem_face_areas('480km')
failed failed n/a mpas_ocean.GeoDataFrame.time_to_geodataframe('120km', False)
failed failed n/a mpas_ocean.GeoDataFrame.time_to_geodataframe('120km', True)
failed failed n/a mpas_ocean.GeoDataFrame.time_to_geodataframe('480km', False)
failed failed n/a mpas_ocean.GeoDataFrame.time_to_geodataframe('480km', True)
14.8±0.08ms 14.9±0.1ms 1.00 mpas_ocean.Gradient.time_gradient('120km')
2.09±0.01ms 2.07±0.02ms 0.99 mpas_ocean.Gradient.time_gradient('480km')
457k 457k 1.00 mpas_ocean.Gradient.track_nbytes_gradient('120km')
28.7k 28.7k 1.00 mpas_ocean.Gradient.track_nbytes_gradient('480km')
3.43M 3.43M 1.00 mpas_ocean.Gradient.track_peakmem_gradient('120km')
218k 218k 1.00 mpas_ocean.Gradient.track_peakmem_gradient('480km')
348M 348M 1.00 mpas_ocean.GradientColdStartRss.peakmem_gradient('120km')
327M 327M 1.00 mpas_ocean.GradientColdStartRss.peakmem_gradient('480km')
382±10μs 375±20μs 0.98 mpas_ocean.HoleEdgeIndices.time_construct_hole_edge_indices('120km')
202±6μs 213±10μs 1.06 mpas_ocean.HoleEdgeIndices.time_construct_hole_edge_indices('480km')
528±20μs 533±20μs 1.01 mpas_ocean.Integrate.time_integrate('120km')
454±10μs 479±8μs 1.06 mpas_ocean.Integrate.time_integrate('480km')
18.4M 18.4M 1.00 mpas_ocean.Integrate.track_nbytes_integrate('120km')
1.2M 1.2M 1.00 mpas_ocean.Integrate.track_nbytes_integrate('480km')
failed failed n/a mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('120km', 'exclude')
failed failed n/a mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('120km', 'include')
failed failed n/a mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('120km', 'split')
failed failed n/a mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('480km', 'exclude')
failed failed n/a mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('480km', 'include')
failed failed n/a mpas_ocean.MatplotlibConversion.time_dataarray_to_polycollection('480km', 'split')
237±0.3ms 239±0.9ms 1.01 mpas_ocean.NeighborhoodBuild.time_build('120km', 1.0)
1.27±0s 1.27±0.01s 1.00 mpas_ocean.NeighborhoodBuild.time_build('120km', 15.0)
491±2ms 492±2ms 1.00 mpas_ocean.NeighborhoodBuild.time_build('120km', 5.0)
12.9±0.02ms 13.0±0.04ms 1.00 mpas_ocean.NeighborhoodBuild.time_build('480km', 1.0)
24.8±0.1ms 24.8±0.08ms 1.00 mpas_ocean.NeighborhoodBuild.time_build('480km', 15.0)
16.0±0.07ms 16.0±0.06ms 1.00 mpas_ocean.NeighborhoodBuild.time_build('480km', 5.0)
234±2ms 234±0.8ms 1.00 mpas_ocean.NeighborhoodBuild.time_query_radius('120km', 1.0)
1.25±0s 1.25±0s 1.00 mpas_ocean.NeighborhoodBuild.time_query_radius('120km', 15.0)
487±0.8ms 485±1ms 1.00 mpas_ocean.NeighborhoodBuild.time_query_radius('120km', 5.0)
12.5±0.02ms 12.6±0.01ms 1.01 mpas_ocean.NeighborhoodBuild.time_query_radius('480km', 1.0)
24.1±0.05ms 24.1±0.1ms 1.00 mpas_ocean.NeighborhoodBuild.time_query_radius('480km', 15.0)
15.8±0.1ms 15.7±0.02ms 0.99 mpas_ocean.NeighborhoodBuild.time_query_radius('480km', 5.0)
1.19 1.19 1.00 mpas_ocean.NeighborhoodBuild.track_mean_neighbors('120km', 1.0)
612.76 612.76 1.00 mpas_ocean.NeighborhoodBuild.track_mean_neighbors('120km', 15.0)
74.17 74.17 1.00 mpas_ocean.NeighborhoodBuild.track_mean_neighbors('120km', 5.0)
1.0 1.0 1.00 mpas_ocean.NeighborhoodBuild.track_mean_neighbors('480km', 1.0)
37.29 37.29 1.00 mpas_ocean.NeighborhoodBuild.track_mean_neighbors('480km', 15.0)
6.57 6.57 1.00 mpas_ocean.NeighborhoodBuild.track_mean_neighbors('480km', 5.0)
728k 728k 1.00 mpas_ocean.NeighborhoodBuild.track_nbytes_neighbors('120km', 1.0)
141M 141M 1.00 mpas_ocean.NeighborhoodBuild.track_nbytes_neighbors('120km', 15.0)
17.4M 17.4M 1.00 mpas_ocean.NeighborhoodBuild.track_nbytes_neighbors('120km', 5.0)
43k 43k 1.00 mpas_ocean.NeighborhoodBuild.track_nbytes_neighbors('480km', 1.0)
563k 563k 1.00 mpas_ocean.NeighborhoodBuild.track_nbytes_neighbors('480km', 15.0)
123k 123k 1.00 mpas_ocean.NeighborhoodBuild.track_nbytes_neighbors('480km', 5.0)
5.72M 5.72M 1.00 mpas_ocean.NeighborhoodBuild.track_peakmem_build('120km', 1.0)
145M 145M 1.00 mpas_ocean.NeighborhoodBuild.track_peakmem_build('120km', 15.0)
21.5M 21.5M 1.00 mpas_ocean.NeighborhoodBuild.track_peakmem_build('120km', 5.0)
362k 362k 1.00 mpas_ocean.NeighborhoodBuild.track_peakmem_build('480km', 1.0)
825k 825k 1.00 mpas_ocean.NeighborhoodBuild.track_peakmem_build('480km', 15.0)
384k 384k 1.00 mpas_ocean.NeighborhoodBuild.track_peakmem_build('480km', 5.0)
44.7±0.9ms 44.3±0.5ms 0.99 mpas_ocean.NeighborhoodDask.time_mean('120km', 'grid_chunks')
22.7±0.1ms 22.6±0.04ms 1.00 mpas_ocean.NeighborhoodDask.time_mean('120km', 'numpy')
41.1±0.9ms 41.2±0.6ms 1.00 mpas_ocean.NeighborhoodDask.time_mean('120km', 'time_chunks')
12.1±0.1ms 12.2±0.1ms 1.01 mpas_ocean.NeighborhoodDask.time_mean('480km', 'grid_chunks')
689±30μs 655±30μs 0.95 mpas_ocean.NeighborhoodDask.time_mean('480km', 'numpy')
8.88±0.2ms 8.84±0.3ms 0.99 mpas_ocean.NeighborhoodDask.time_mean('480km', 'time_chunks')
5.75M 5.75M 1.00 mpas_ocean.NeighborhoodDask.track_peakmem_mean('120km', 'grid_chunks')
2.75M 2.75M 1.00 mpas_ocean.NeighborhoodDask.track_peakmem_mean('120km', 'numpy')
5.69M 5.67M 1.00 mpas_ocean.NeighborhoodDask.track_peakmem_mean('120km', 'time_chunks')
177k 177k 1.00 mpas_ocean.NeighborhoodDask.track_peakmem_mean('480km', 'numpy')
545k 536k 0.98 mpas_ocean.NeighborhoodDask.track_peakmem_mean('480km', 'time_chunks')
12.3±0.02s 12.3±0s 1.00 mpas_ocean.NeighborhoodReduce.time_dataset_reduce('120km', 'mean')
13.0±0s 13.0±0.03s 1.00 mpas_ocean.NeighborhoodReduce.time_dataset_reduce('120km', 'median')
225±0.3ms 226±0.2ms 1.00 mpas_ocean.NeighborhoodReduce.time_dataset_reduce('480km', 'mean')
234±0.2ms 233±0.7ms 1.00 mpas_ocean.NeighborhoodReduce.time_dataset_reduce('480km', 'median')
1.30±0s 1.30±0s 1.00 mpas_ocean.NeighborhoodReduce.time_neighborhood_reduce('120km', 'mean')
1.50±0s 1.50±0s 1.00 mpas_ocean.NeighborhoodReduce.time_neighborhood_reduce('120km', 'median')
25.3±0.07ms 25.3±0.07ms 1.00 mpas_ocean.NeighborhoodReduce.time_neighborhood_reduce('480km', 'mean')
26.9±0.2ms 26.9±0.04ms 1.00 mpas_ocean.NeighborhoodReduce.time_neighborhood_reduce('480km', 'median')
40.2±0.03ms 40.2±0.07ms 1.00 mpas_ocean.NeighborhoodReduce.time_reduce('120km', 'mean')
233±0.7ms 233±0.2ms 1.00 mpas_ocean.NeighborhoodReduce.time_reduce('120km', 'median')
666±10μs 628±60μs 0.94 mpas_ocean.NeighborhoodReduce.time_reduce('480km', 'mean')
2.06±0.07ms 2.00±0.04ms 0.97 mpas_ocean.NeighborhoodReduce.time_reduce('480km', 'median')
239k 239k 1.00 mpas_ocean.NeighborhoodReduce.track_peakmem_reduce('120km', 'mean')
245k 245k 1.00 mpas_ocean.NeighborhoodReduce.track_peakmem_reduce('120km', 'median')
19.4k 19.4k 1.00 mpas_ocean.NeighborhoodReduce.track_peakmem_reduce('480km', 'mean')
19.9k 19.9k 1.00 mpas_ocean.NeighborhoodReduce.track_peakmem_reduce('480km', 'median')
410±10μs 395±10μs 0.96 mpas_ocean.PointInPolygon.time_face_search_lonlat('120km')
413±8μs 386±10μs 0.93 mpas_ocean.PointInPolygon.time_face_search_lonlat('480km')
376±10μs 377±9μs 1.00 mpas_ocean.PointInPolygon.time_face_search_xyz('120km')
385±8μs 375±10μs 0.97 mpas_ocean.PointInPolygon.time_face_search_xyz('480km')
243±0.2ms 237±1ms 0.98 mpas_ocean.RemapDownsample.time_bilinear_remapping
288±2ms 287±3ms 1.00 mpas_ocean.RemapDownsample.time_inverse_distance_weighted_remapping
16.0±0.05ms 15.8±0.07ms 0.99 mpas_ocean.RemapDownsample.time_nearest_neighbor_remapping
1.36±0s 1.38±0.02s 1.02 mpas_ocean.RemapUpsample.time_bilinear_remapping
37.1±0.3ms 36.9±0.2ms 0.99 mpas_ocean.RemapUpsample.time_inverse_distance_weighted_remapping
12.3±0.3ms 12.2±0.05ms 0.99 mpas_ocean.RemapUpsample.time_nearest_neighbor_remapping
9.62±0.07ms 9.58±0.1ms 1.00 mpas_ocean.ZonalAverage.time_zonal_average('120km')
5.46±0.06ms 5.42±0.03ms 0.99 mpas_ocean.ZonalAverage.time_zonal_average('480km')
358M 358M 1.00 mpas_ocean.ZonalAveragePeakMem.peakmem_zonal_average('120km')
337M 337M 1.00 mpas_ocean.ZonalAveragePeakMem.peakmem_zonal_average('480km')
6.84±0.06ms 6.84±0.04ms 1.00 quad_hexagon.QuadHexagon.time_open_dataset
5.80±0.02ms 5.82±0.1ms 1.00 quad_hexagon.QuadHexagon.time_open_grid
408 408 1.00 quad_hexagon.QuadHexagon.track_nbytes_open_dataset
392 392 1.00 quad_hexagon.QuadHexagon.track_nbytes_open_grid
73.9k 73.6k 1.00 quad_hexagon.QuadHexagon.track_peakmem_open_dataset
73k 72.2k 0.99 quad_hexagon.QuadHexagon.track_peakmem_open_grid

Benchmarks that have got worse:

Change Before [06ec278] After [e2d43c1] Ratio Benchmark (Parameter)
+ 617k 696k 1.13 mpas_ocean.NeighborhoodDask.track_peakmem_mean('480km', 'grid_chunks')

@dylannelson

Copy link
Copy Markdown
Member Author

This branch

image

Older Versions:

image

@dylannelson dylannelson changed the title IO for fesom not converting n2 to two during open_grid Assigning connectivities based on UGRID conventions Sep 11, 2026
@dylannelson
dylannelson marked this pull request as ready for review September 11, 2026 16:54
@Sevans711
Sevans711 self-requested a review September 14, 2026 12:53

@cmdupuis3 cmdupuis3 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine, the tests pass and all the cases highlighted here are covered.

@Sevans711 Sevans711 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, and makes sense to aim to close both issues with a single PR like this! Left small inline comment.

Aside from that, I'm referring back to my earlier comment in #1725 which flagged this page as related: https://uxarray.readthedocs.io/en/latest/user-guide/representation.html#connectivity

I would suggest to also fix that page (i.e. the Connectivity section of representation.rst) as follows:

  • The Dimensions column should use "two", not "2".
  • The table is missing a Node Node connectivity row. (Or, maybe the Edge Edge connectivity row should be removed? uxarray/conventions/ugrid.py says edge_edge_connectivity is not yet supported.)
  • The table mentions "n_max_edge_faces", however no part of uxarray actually uses that dimension. Grid.edge_face_connectivity actually has dimensions "n_edge", "two", in agreement with EDGE_FACE_CONNECTIVITY_DIMS in uxarray. The table in your PR overview also shows that you use "two" as part of this fix as well, not "n_max_edge_faces".

"n_max_edge_faces" also appears in DIM_NAMES, and I believe it should be removed from there, as part of this PR, because it isn't actually supported anywhere else in uxarray. Using "two" instead of "n_max_edge_faces" contradicts a recent internal discussion, however I think that is okay, because during that discussion nobody brought up what the code is actually doing; I think everyone assumed it was following the docs page (which is incorrect!).

It would make sense to me for these fixes to the docs page and DIM_NAMES to be bundled with this PR. But, I could also understand if you would prefer to push them to another PR later. If you'd prefer to push them, could you open up a new issue report for them before this PR merges, to make sure that they don't get forgotten?

Comment thread uxarray/io/_ugrid.py Resolved
@rajeeja

rajeeja commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Looks good. I'd agree with Sam, let do those also and then merge this.

@dylannelson

Copy link
Copy Markdown
Member Author

@Sevans711 @rajeeja Yeah I think a lot of what you're saying is true but I'd prefer it be either part of a seperate PR or after an extensive discussion on what these connectivities should really be.

The issue with switching two to n_max_edge_faces

From our internal discussion, I was told

ugrid.py: EDGE_FACE_CONNECTIVITY_DIMS = ["n_edge", "two"] <- Wrong, should be n_max_edge_faces

and we simply don't see this to be the case in other grids that we have in uxarray (and Sam is saying n_max_edge_faces should be removed all together?) here's a look at some other grids in uxarray being read in (pre patch):

11-example-grid-connectivities.html

  • The connectivities for these examples (before my intervention) all pointed to what was discussed before, and what is currently present in the ugrid.py conventions:
    edge_node_connectivity -> ('n_edge', 'two')
    edge_face_connectivity -> ('n_edge', 'two')
image image

So if we were to change EDGE_FACE_CONNECTIVITY_DIMS to not be two, we would need to look at our test files and figure out why they were two as well, potentially change/update them, and change our internal conventions. I think this would be enough of a problem to warrant it's own discussion and issues and PR, and this current PR is more of a specific patch for this weird case of having extra dims (3) instead of the regular 2.

I believe the idea of changing the conventions will not be as easy as just changing a line or two on the docs and ugrid.py, without it causing some other serious confusion or mismatches in these functions and existing test grids, hence why I think we need to have a thorough discussion because the one we had didn't match current implementation and we have a few ideas already that don't align

@Sevans711

Sevans711 commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

@dylannelson I think we might all be on the same page for the most part? I wasn't suggesting to swap "two" to "n_max_edge_faces", just to update the docs to clarify that the code uses "two", not "n_max_edge_faces. There wouldn't be any functionality changes at all, the only change to the code itself would be a tiny update to DIM_NAMES, to remove "n_max_edge_faces" since it isn't being used anywhere.

(26-11-24) EDIT: fixed typo above; it now correctly says "n_max_edge_faces", but originally said "n_max_face_edges" by accident. (See #1766 (comment))

Given that, would you still prefer to push these changes to a different PR? If it makes more sense to you to push them I wouldn't mind, as long as before this PR merges a corresponding issue gets posted to track these points.

@dylannelson

Copy link
Copy Markdown
Member Author

@Sevans711 I think we're on the same page now.

just to update the docs to clarify that the code uses "two", not "n_max_face_edges"

Done, though this is technically the opposite what the team said, we can discuss later this week

The table is missing a Node Node connectivity row. (Or, maybe the Edge Edge connectivity row should be removed?
The table mentions "n_max_edge_faces", however no part of uxarray actually uses that dimension.

I didn't change edge edge or node node docs because I'm not familiar with why they are there, and same with n_max_face_edges especially since the team said we should be using it but I'm not seeing why we would/should right now. We can get feedback from the others if we want to add node node or remove edge edge, but doesn't seem critical for this PR.

"n_max_edge_faces" also appears in DIM_NAMES, and I believe it should be removed from there

another situation where I don't see an impact to do so, but if the others want it removed too, I'm happy to do it. I feel more hesitant to touch the conventions file than the docs though.

@Sevans711 Sevans711 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good now, everything within scope of the original issues has been solved, and all of my extra slightly-out-of-scope comments have either been solved or recorded in #1766 for tracking purposes so they can be solved in a later PR. Thank you - approving!

@dylannelson
dylannelson merged commit 1e079ce into main Sep 18, 2026
17 checks passed
@dylannelson dylannelson mentioned this pull request Sep 22, 2026
12 tasks done
@dylannelson
dylannelson deleted the n2-naming branch October 29, 2026 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extra dims Handling of non-grid dimensions, such as time or altitude run-benchmark Run ASV benchmark workflow

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connectivities in different UGRID file reads can have different dimensions IO for fesom not converting n2 to two during open_grid

4 participants