usnistgov / h5wasm

A WebAssembly HDF5 reader/writer library
Other
87 stars 12 forks source link

Does h5wasm support complex value write into DateSet #55

Closed jianghuife closed 1 year ago

jianghuife commented 1 year ago

when I read Dateset which is a complex value, and I want to copy it to other DataSet, it went wrong 'unguessable type for data'

bmaranville commented 1 year ago

If you are talking about a complex number like python 1 + 1j, then these are handled in h5py by mapping them onto an HDF5 Compound type, with two members named 'r' and 'i'. There is no built-in datatype for complex numbers in HDF5.

h5wasm supports reading these datasets, returning an Array of Array objects (e.g. [[1,1], [1, 0.5]...] for a complex stored value of [1+1j, 1+0.5j...]. All compound datasets are converted to nested arrays on read.

There is no support in h5wasm for writing compound datatypes, and it would take some effort to write it (requiring a method of specifying a new compound datatype, creating it in the HDF5 C API, converting the input data into the proper byte representation and writing). There is also no implemented concept of 'copying' an h5wasm.Dataset to another HDF5 file or another group in the same file.

For reference, the currently supported datatypes for creating and writing datasets in h5wasm includes:

For reading, it also supports Compound and Array datatypes.