Skip to content

Commit 7a15636

Browse files
committed
Ayush's fix from #191
1 parent 48fbbcc commit 7a15636

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

virtualizarr/xarray.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,11 @@ def separate_coords(
387387
coord_vars: dict[
388388
str, tuple[Hashable, Any, dict[Any, Any], dict[Any, Any]] | xr.Variable
389389
] = {}
390+
found_coord_names: set[str] = set()
390391
for name, var in vars.items():
391-
if name in coord_names or var.dims == (name,):
392+
if "coordinates" in var.attrs:
393+
found_coord_names.update(var.attrs["coordinates"].split(" "))
394+
if name in coord_names or var.dims == (name,) or name in found_coord_names:
392395
# use workaround to avoid creating IndexVariables described here https://github.com/pydata/xarray/pull/8107#discussion_r1311214263
393396
if len(var.dims) == 1:
394397
dim1d, *_ = var.dims

0 commit comments

Comments
 (0)