Skip to content
Snippets Groups Projects
Commit e8f0f4fd authored by Nils-Arne Dreier's avatar Nils-Arne Dreier
Browse files

feat(hiopy): add kwargs to hiopy-configure add-variable

The arguments are forwrded to `create_dataset`, this yields more
flexibility for creating the arrays like passing a compressor or storage_transformers.
parent 37f724a0
No related branches found
No related tags found
No related merge requests found
Pipeline #92202 passed
......@@ -59,25 +59,23 @@ def add_variable(
chunk_shape=None,
frac_mask=None,
yac_name=None,
**kwargs,
):
for g in _collect_groups(dataset):
ntime = g.time.shape[0]
ncells = healpy.nside2npix(g.crs.attrs["healpix_nside"])
if zaxis is None:
shape = (ntime, ncells)
_chunk_shape = np.minimum(chunk_shape, shape) if chunk_shape is not None else None
v = g.create_dataset(
name, shape=shape, dtype=np.float32, fill_value=np.nan, chunks=_chunk_shape
)
v.attrs["_ARRAY_DIMENSIONS"] = ("time", "cell")
dimensions = ("time", "cell")
else:
nheight = g[zaxis].shape[0]
shape = (ntime, nheight, ncells)
_chunk_shape = np.minimum(chunk_shape, shape) if chunk_shape is not None else None
v = g.create_dataset(
name, shape=shape, dtype=np.float32, fill_value=np.nan, chunks=_chunk_shape
)
v.attrs["_ARRAY_DIMENSIONS"] = ("time", zaxis, "cell")
dimensions = ("time", zaxis, "cell")
_chunk_shape = np.minimum(chunk_shape, shape) if chunk_shape is not None else None
v = g.create_dataset(
name, shape=shape, dtype=np.float32, fill_value=np.nan, chunks=_chunk_shape, **kwargs
)
v.attrs["_ARRAY_DIMENSIONS"] = dimensions
if time_method is not None:
v.attrs["hiopy::time_method"] = time_method
if yac_name is not None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment