Skip to content

Topological aggregations drop coordinates and attributes #1665

Closed

Description

@rajeeja

While reviewing #1588 I went digging through aggregation.py and came across this, which turns out to be broken on main already, independent of that PR.

_node_to_face_aggregation and _node_to_edge_aggregation rebuild the output from data/dims/name only, so all coordinates and variable attributes are dropped. The result keeps its time dimension but loses the time coordinate:

uxda = ux.UxDataArray(data, dims=("time", "n_node"),
                      coords={"time": pd.date_range("2000-01-01", periods=6, freq="MS")},
                      uxgrid=grid, attrs={"units": "m"})

r = uxda.topological_mean(destination="face")
r.coords   # []   <- time gone
r.attrs    # {}   <- units gone

r.sel(time="2000-03-01")       # KeyError: 'time'
r.groupby("time.season")       # KeyError: 'time'
r.resample(time="QS")          # TypeError: Only valid with DatetimeIndex...

CI misses it because the existing tests use areaTriangle, which is 1-D with no leading coordinate, so there is nothing to lose.

This is also relevant to #1588: the dask paths added there go through apply_ufunc, which propagates coords and attrs for free, so on that branch the numpy and dask paths disagree and .chunk() starts deciding whether .sel(time=...) works. Fixing the numpy path on main makes them agree.

Activity

  1. added
    bug
    extra dims
    on Aug 11, 2026
  2. moved this from 📚 Backlog to 🏗 In progress in UXarray Developmenton Aug 11, 2026
  3. rajeeja commented on Aug 13, 2026

    @rajeeja
    ContributorAuthor

    Also cleaning up the root cause of the duplication while fixing this: the same coord-filtering logic existed at eight sites across dataarray.py, the aggregations, the remap backends, and the cross sections. #1666 now routes all of them through a single shared helper, which also fixes the YAC weights path that was silently dropping non-dimension coordinates in the same way.

  4. moved this from 🏗 In progress to ✅ Done in UXarray Developmenton Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugextra dims

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions