def encode_npz(subvol):
"""
This file format is unrelated to np.savez
We are just saving as .npy and the compressing
using zlib.
The .npy format contains metadata indicating
shape and dtype, instead of np.tobytes which doesn't
contain any metadata.
"""
fileobj = io.BytesIO()
if len(subvol.shape) == 3:
subvol = np.expand_dims(subvol, 0)
np.save(fileobj, subvol)
cdz = zlib.compress(fileobj.getvalue())
return cdz
评论列表
文章目录