How to separate 2 values in a singular array point, source is an HDF5 file with no headers or dataset labels

23 Views Asked by At

I have 2 values in a single bracket of an array, left being I and right being Q values for signals. The hdf5 file is very large and currently I'm trying to just separate the 2 values within each bracket. Nothin I've looked up has been helpful with this endeavor. Like I said in the title, there is no labels or headers on anything within the file. All that is given is the axis X, Y, and Z

I've tried some experiments with np.array and pandas but I am fairly new to the more complex datasets.

1

There are 1 best solutions below

0
kcw78 On

This code creates a simple HDF5 with 5 datasets, then shows how to access them to get the dtype and shape. Note: you only need the 2nd half that read and prints. Modify the file name to match.

Once you have that info, please add to your question. Then this answer can be modified to show the rest of the solution.

import h5py
import numpy as np

with h5py.File('SO_78045268.h5','w') as h5f:
    h5f.create_dataset('signals',data=np.arange(10).reshape(5,2))
    h5f.create_dataset('axis',data=np.arange(5))
    h5f.create_dataset('X',data=np.arange(5))
    h5f.create_dataset('Y',data=np.arange(5,10))
    h5f.create_dataset('Z',data=np.arange(10,15))

with h5py.File('SO_78045268.h5') as h5f:
     for name, h5_obj in h5f.items():
        if isinstance(h5_obj, h5py.Dataset):
            print(f'For dataset: {name}; ')
            print(f'dtype: {h5_obj.dtype}, shape: {h5_obj.shape}')