import h5py
import numpy as np
import matplotlib.pyplot as plt

def printname(name):
    print(name)


# openning the file
hf = h5py.File('em-test-dataset-2023.h5', 'r')

# printing the attributes of the file
for item in hf.attrs.keys():
    print(item + ":", hf.attrs[item])

# viewing full data structure
hf.visit(printname)

#print(hf.keys())

'''
# reading a dataset
data = hf.get('/smartphones/iphone4s/calendar-app')
print(np.array(data).shape)

# plotting some data
fig = plt.figure()
plt.psd(data, NFFT=2048, Fs=20e6)
del data
plt.show()
'''
'''
# reading a dataset
data = hf.get('/smartphones/iphone4s/camera-photo')
print(np.array(data).shape)

# plotting some data
fig = plt.figure()
plt.psd(data, NFFT=2048, Fs=20e6)
plt.show()
del data


# reading a dataset
data = hf.get('/internet-of-things/amazon-echo-dot/asking-a-definition')
print(np.array(data).shape)

# plotting some data
fig = plt.figure()
plt.psd(data, NFFT=2048, Fs=20e6)
plt.show()
del data
'''

hf.close()

