def to_hdf5(filename, *args, **kwargs):
    if len(args) == 1 and isinstance(args[0], dict):
        data = args[0]
    elif (len(args) == 2 and
          isinstance(args[0], str) and
          isinstance(args[1], Array)):
        data = {args[0]: args[1]}
    else:
        raise ValueError("Please provide {'/data/path': array} dictionary")

    chunks = kwargs.pop('chunks', True)

    import h5py
    with h5py.File(filename) as f:
        dsets = [f.require_dataset(dp, shape=x.shape, dtype=x.dtype,
                           chunks=tuple([c[0] for c in x.chunks])
                                  if chunks is True else chunks,
                                                **kwargs)
                    for dp, x in data.items()]
        store(list(data.values()), dsets)
Store arrays in HDF5 file
dataset/ETHPy150Open dask/dask/dask/array/core.py/to_hdf5