uxarray icon indicating copy to clipboard operation
uxarray copied to clipboard

Handling Duplicate Node Indices

Open philipc2 opened this issue 7 months ago • 4 comments

Some of our testing grids include duplicates of certain nodes, meaning that there existing multiple nodes that share the same latitude and longitude location, but each have their own index within our connectivity and data variables.

Example

Consider the following simple grid (

node_lon = (-180, 0, -180, 180) node_lat = (-90, 0, -90, 90) data_on_nodes = [1, 2, 1, 3]

Indices 0 and 1 contain the same latitude, longitude, and data value. This causes issues when constructing certain connectivity's (such as node_face, since some nodes will only belong to one face.

Affected Grids

The following grid files in our testing suite each have duplicate nodes. geos-cs/c1/test-c12.native.nc4 ugrid/geoflow-small/grid.nc esmf/ne30/ne30pg3.grid.nc

All of these are some form of a cube-sphere (or variation)

Proposed Solution

Instead of deleting the duplicates (which would require a complete re-ordering of connectivity and to modify the size of all node-centered data variables), a simple masking and merging of node indices at the connectivity level should do the trick.

Example

Let's say node indicies [0, 5, 10, 23] all share the same data value and lat/lon coordinates. We can itterate over the face_node, edge_node and node_node connectivity arrays and set the values of [5, 10, 23] to point to 0. This would allow us to leave the data arrays untouched and do a single pass over our connectivity's arrays with a direct replacement, without needing to reshape them in any way.

philipc2 avatar Jul 26 '24 18:07 philipc2