Skip to content

Commit

Permalink
set fill value for zarr data explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
jensdebruijn committed Sep 18, 2024
1 parent 5d2f0d5 commit a6c1cd0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions honeybees/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,21 @@ def export_value(self, name: str, value: np.ndarray, conf: dict) -> None:
compressor = zstd_compressor
dtype = value.dtype
array_dimensions = ["time", "agents"]
if dtype in (float, np.float32, np.float64):
fill_value = np.nan
elif dtype in (int, np.int32, np.int64):
fill_value = -1
else:
raise ValueError(
f"Value {dtype} of type {type(dtype)} not recognized."
)
ds.create_dataset(
name,
shape=shape,
chunks=chunks,
dtype=dtype,
compressor=compressor,
fill_value=fill_value,
)
ds[name].attrs["_ARRAY_DIMENSIONS"] = array_dimensions
index = conf["_time_index"].index(self.model.current_time)
Expand Down

0 comments on commit a6c1cd0

Please # to comment.