From 83477c0902bd8fbd4e4698e53e5b869ba2c5e5d8 Mon Sep 17 00:00:00 2001 From: erogluorhan Date: Thu, 26 Mar 2026 17:01:06 -0600 Subject: [PATCH] Fix output coords of the conservative zonal mean --- uxarray/core/dataarray.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/uxarray/core/dataarray.py b/uxarray/core/dataarray.py index 7d980a60d..f01caa3b1 100644 --- a/uxarray/core/dataarray.py +++ b/uxarray/core/dataarray.py @@ -745,10 +745,19 @@ def zonal_mean(self, lat=(-90, 90, 10), conservative: bool = False, **kwargs): dims = list(self.dims) dims[face_axis] = "latitudes" + # Assign coords from `self` to the result except one that corresponds to `dims[face_axis]` + new_coords = { + k: v + for k, v in self.coords.items() + if self.dims[face_axis] not in v.dims + } + # Add latitudes to the resulting coords + new_coords["latitudes"] = centers + return xr.DataArray( res, dims=dims, - coords={"latitudes": centers}, + coords=new_coords, name=self.name + "_zonal_mean" if self.name is not None else "zonal_mean",