So I want to write a 2D Numpy Array to a HDF5 file using Python (H5Py), however I am incapable of getting it work correctly. Here is what the dataset should look like
Here is the code
elements = {
'Ti': ['47Ti', '49Ti'],
'Cr': ['52Cr', '53Cr'],
'Fe': ['54Fe', '57Fe'],
'Mn': ['55Mn']}
# arg3: signalData
element_data = hdf5processor.process_signal_data(argv[3], elements)
#hdf5processor.plot_elements(element_data)
# arg4: outputFile
hdf5processor.save_dataset(argv[4], elements, element_data)
def save_dataset(filename, elements_list, element_data):
hf = h5py.File(filename, 'a')
elements_list_ascii = [n.encode("ascii", "ignore") for n in list(elements_list.keys())]
elements_list_dataset = hf.create_dataset("spWork/ElementList", (len(elements_list_ascii), 1), data=elements_list_ascii, dtype=h5py.string_dtype())
iostopes_used = np.array([['Element', 'Isotope(s)', 'Null', 'Null', 'Null'], ['Ti', '47Ti', '49Ti', 'Null', 'Null']])
iostopes_used_dataset = hf.create_dataset("spWork/IsotopesUsed", (2, 5), data=iostopes_used, dtype=h5py.string_dtype())
hf.close()
I'm trying to save the iostopes_used (2D Numpy String Array) to the HDF5 file as a variable length string like in the first and second image.