Skip to content

Commit 6045101

Browse files
authored
hot and dirty fix for xdggs decode error (#26)
1 parent ac94b97 commit 6045101

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/earth/xdggs.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ ds = xdggs.tutorial.open_dataset("air_temperature", "healpix")
4646
ds
4747
```
4848

49+
```{code-cell} python
50+
---
51+
tags: [remove-cell]
52+
---
53+
from xdggs.utils import GRID_REGISTRY, _extract_cell_id_variable
54+
55+
def from_variables_patch(variables, *, options):
56+
_, var, _ = _extract_cell_id_variable(variables)
57+
58+
grid_name = var.attrs["grid_name"]
59+
cls = GRID_REGISTRY.get(grid_name)
60+
if cls is None:
61+
raise ValueError(f"unknown DGGS grid name: {grid_name}")
62+
63+
obj = cls.from_variables(variables, options=options)
64+
obj._pd_index.index.name = "cell_ids"
65+
return obj
66+
67+
xdggs.DGGSIndex.from_variables = from_variables_patch
68+
```
69+
4970
with that, we can decode the metadata:
5071

5172
```{code-cell} python

0 commit comments

Comments
 (0)