## start qkit and import the needed modules. we here assume an already configured qkit analysis environment

import qkit
qkit.start()

from qkit.storage.store import Data

"""
Explanation: Data readout basics i.e. for some analysis or plotting.
This notebook is intended to show the readout of created hdf5 files with python. For the handling of the measured file qkit provides a file info database (fid) for convenient access to the stored data, for more info on that see the corresponding notebook.<br>
The readout (as well as the storage in the first place) is done with the store.Data module.
End of explanation
"""


abs_path = qkit.fid.get('XXXXXX')

"""
Explanation: The qkit.start() starts the fid which searches the given qkit.conf['datadir'] for hdf5 files. A python dict is created, mapping the 6-digit timestamp of the measurement (UUID) to its absolute path on the hard drive. For getting the absolute path of the measurement file usethe qkit.fid.get command with the UUID.
End of explanation
"""


h5 = Data(qkit.fid.get('XXXXXX'))

"""
Explanation: To open a measurement and get the information a h5 object has to be created
End of explanation
"""


amp = h5.data.amplitude[:] # gets the measurement data as numpy array
pha = h5.data.phase[:]
## general rule: h5.[folder].[ds_name] gives the dataset, '[:]' gives the bare data cast to a numpy array
## already analyzed data is stored in the 'analysis' folder

# all stored metadata can be accessed by auto-complete as well
x_ds_url = h5.data.amplitude.x_ds_url
comment = h5.data.comment

"""
Explanation: The data and metadata can be accessed via the h5 object. All the needed information can be auto-compleded via tabbing.
End of explanation
"""


qkit.fid.get_date('XXXXXX')

"""
Explanation: The UUID can also be reverted back to recover the time the file was created.
End of explanation
"""


