import numpy as np
import matplotlib.pyplot as plt
import nvg.ximu.ximudata as ximudata
%matplotlib notebook

"""
Explanation: Getting started with the analysis of nvg data
This notebook assumes that data exists in a database in the hdf5 format. For instructions how to set up the database with data see [../readme.md].
Import modules
End of explanation
"""


reload(ximudata)
dbfilename = "/home/kjartan/Dropbox/Public/nvg201209.hdf5"
db = ximudata.NVGData(dbfilename);

"""
Explanation: Load the database
End of explanation
"""


dbfile = db.hdfFile;
print "Subjects: ",  dbfile.keys()
print "Trials: ", dbfile['S5'].keys()
print "IMUs: ", dbfile['S5/B'].keys()
print "Attributes of example trial", dbfile['S5/B'].attrs.keys()
print "Shape of example IMU data entry", dbfile['S5/B/N'].shape


"""
Explanation: Explore contents of the database file
End of explanation
"""


db.plot_imu_data()

"""
Explanation: The content of the raw IMU file
The columns of the IMU data contain: 
0: Packet number, 
1: Gyroscope X (deg/s),
2: Gyroscope Y (deg/s),
3: Gyroscope Z (deg/s),
4: Accelerometer X (g),
5: Accelerometer Y (g),
6: Accelerometer Z (g),
7: Magnetometer X (G),
8: Magnetometer Y (G),
9: Magnetometer Z (G)
Plot example data
End of explanation
"""


print [s for s in dir(db) if s.startswith("get")]

"""
Explanation: Implemented analysis methods
End of explanation
"""


