Skip to content

Commit

Permalink
set array dimensions so that zarrs can be read by xarray
Browse files Browse the repository at this point in the history
  • Loading branch information
jensdebruijn committed Sep 9, 2024
1 parent 4831a8d commit 5d2f0d5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions honeybees/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def __init__(self, model, folder: str) -> None:
data=time,
dtype="datetime64[ns]",
)
ds["time"].attrs["_ARRAY_DIMENSIONS"] = ["time"]

conf["_file"] = ds
conf["_time_index"] = time
Expand Down Expand Up @@ -157,18 +158,21 @@ def export_value(self, name: str, value: np.ndarray, conf: dict) -> None:
chunks = (1,)
compressor = None
dtype = type(value)
array_dimensions = ["time"]
else:
shape = (ds["time"].size, value.size)
chunks = (1, value.size)
compressor = zstd_compressor
dtype = value.dtype
array_dimensions = ["time", "agents"]
ds.create_dataset(
name,
shape=shape,
chunks=chunks,
dtype=dtype,
compressor=compressor,
)
ds[name].attrs["_ARRAY_DIMENSIONS"] = array_dimensions
index = conf["_time_index"].index(self.model.current_time)
ds[name][index] = value
else:
Expand Down

0 comments on commit 5d2f0d5

Please sign in to comment.