In [18]:
# Required modules - do not modify
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
# User preferences - can be changed
pref_grid_visible = True
pref_plot_gravity = True
pref_save_figures = True
pref_filename = 'TREMOR12W_samples_2016_01_10_1008.csv'
In [19]:
# Create dataframe from CSV file
df = pd.read_csv(pref_filename)
params = df
# Create time column starting at zero and use as index
# Note that the 'timestamp2001_ms' column contains absolute date and time (in ms from Jan 1, 2001)
# Time is in seconds
# df['time'] = 0.001 * (df['timestamp2001_ms'] - df['timestamp2001_ms'][0])
# cols = df.columns.tolist()
# cols = cols[-1:] + cols[1:-1]
# params = df[cols].set_index('time')
# Show first 5 rows for exploratory purposes
params.head()
Out[19]:
In [20]:
# Provide basic descriptive statistics for tremor parameters
params.describe()
Out[20]:
In [23]:
def create_plot(param_values, title_value, entity_value):
'''Creates separate plots from manually entered values'''
param_plot = params[param_values].plot(figsize=(20,5), title=title_value, grid = pref_grid_visible)
param_plot.set_xlabel('Sample number')
param_plot.set_ylabel(title_value + ' (' + entity_value + ')')
plt.legend(['X', 'Y', 'Z'], loc=1)
if pref_save_figures:
plt.savefig('TREMOR12W_fig_' + title_value.lower().replace(' ', '_') + '.png', dpi=300)
return param_plot
In [24]:
# Create individual plots
create_plot(['accX', 'accY', 'accZ'], 'Acceleration', 'G')
# create_plot(['roll', 'pitch', 'yaw'], 'Rotation', 'radians')
# create_plot(['rotX', 'rotY', 'rotZ'], 'Rotation speed', 'radians / second')
# if pref_plot_gravity:
# create_plot(['gravX', 'gravY', 'gravZ'], 'Gravity', 'G')
Out[24]:
In [ ]: