seismograph-data-analysis



In [3]:
%matplotlib inline

import matplotlib
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

In [37]:
df = pd.read_csv("accel.csv", header=None)
df.columns = ["millis", "time", "x", "y", "z"]
#del df['millis']

In [5]:
#df["time"] = df["time"].apply(lambda x: x/1000); # millis to seconds

In [38]:
#with pd.option_context('display.max_rows', None, 'display.max_columns', 4):
    #print(df)
df


Out[38]:
millis time x y z
0 6570 2017-3-7T4:37 9 0 89
1 6825 2017-3-7T4:37 10 0 90
2 7080 2017-3-7T4:37 9 0 91
3 7838 2017-3-7T4:37 10 0 91
4 8093 2017-3-7T4:37 11 0 90
5 8348 2017-3-7T4:37 11 0 89
6 8899 2017-3-7T4:37 13 2 89
7 9154 2017-3-7T4:37 14 2 90
8 9410 2017-3-7T4:37 15 2 90
9 9998 2017-3-7T4:37 16 1 90
10 10253 2017-3-7T4:37 15 0 90
11 10508 2017-3-7T4:37 14 1 90
12 11080 2017-3-7T4:37 13 1 90
13 11335 2017-3-7T4:37 12 2 91
14 12072 2017-3-7T4:37 13 2 90
15 12327 2017-3-7T4:37 14 1 89
16 12984 2017-3-7T4:37 14 1 90
17 13239 2017-3-7T4:37 14 0 88
18 13809 2017-3-7T4:37 14 0 87
19 14064 2017-3-7T4:37 12 0 88
20 14586 2017-3-7T4:37 12 0 88
21 14841 2017-3-7T4:37 13 1 90
22 15395 2017-3-7T4:37 12 2 91
23 15650 2017-3-7T4:37 13 2 90
24 15905 2017-3-7T4:37 13 2 90
25 16161 2017-3-7T4:37 12 2 89
26 16416 2017-3-7T4:37 13 2 89
27 16671 2017-3-7T4:37 13 2 89
28 16926 2017-3-7T4:37 13 2 88
29 17199 2017-3-7T4:37 14 2 89
... ... ... ... ... ...
561126 143266587 2017-3-8T5:12 11 0 88
561127 143266842 2017-3-8T5:12 10 2 88
561128 143267097 2017-3-8T5:12 10 2 88
561129 143267352 2017-3-8T5:12 10 2 88
561130 143267607 2017-3-8T5:12 11 2 88
561131 143267862 2017-3-8T5:12 13 -1 88
561132 143268117 2017-3-8T5:12 13 -1 88
561133 143268372 2017-3-8T5:12 13 -1 88
561134 143268627 2017-3-8T5:12 13 -1 88
561135 143268882 2017-3-8T5:12 11 1 88
561136 143269137 2017-3-8T5:12 11 1 88
561137 143269392 2017-3-8T5:12 10 1 88
561138 143269647 2017-3-8T5:12 10 0 89
561139 143269902 2017-3-8T5:12 11 -1 89
561140 143270157 2017-3-8T5:12 12 -2 88
561141 143270413 2017-3-8T5:12 13 -2 87
561142 143270668 2017-3-8T5:12 11 -1 86
561143 143270923 2017-3-8T5:12 12 -1 86
561144 143271178 2017-3-8T5:12 11 0 87
561145 143271433 2017-3-8T5:12 11 0 89
561146 143271688 2017-3-8T5:12 13 -1 89
561147 143271943 2017-3-8T5:12 13 -2 89
561148 143272198 2017-3-8T5:12 12 -2 89
561149 143272453 2017-3-8T5:12 13 -2 88
561150 143272708 2017-3-8T5:12 13 0 89
561151 143272963 2017-3-8T5:12 11 2 89
561152 143273218 2017-3-8T5:12 12 2 89
561153 143273473 2017-3-8T5:12 11 2 89
561154 143273728 2017-3-8T5:12 10 2 88
561155 143273983 2017-3-8T5:12 11 2 88

561156 rows × 5 columns


In [7]:
#df.plot(figsize=(20,10), colormap='Accent')
len(df)


Out[7]:
561156

In [8]:
#df = df[0:100000]
#plt.figure(figsize=(20,10))
#with pd.plot_params.use('x_compat', True):
        #df.x.plot()
        #df.y.plot()
        #df.z.plot()

In [9]:
interp = True
#plt.figure(figsize=(20,10))
#sns.tsplot(df.x, df.index, interpolate=interp, color="red")
#sns.tsplot(df.y, df.index, interpolate=interp, color="blue")
#sns.tsplot(df.z, df.index, interpolate=interp, color="green")

In [11]:
roll = 10
mean = df.rolling(roll).mean()
std = df.rolling(roll).std()

collected_mean = mean.x + mean.y + mean.z
collected_std = std.x + std.y + std.z

df['mean'] = collected_mean

list_x = list(std.x)
max_std = list_x.index(np.nanmax(list_x))
len(df)
print(max_std)


380138

In [ ]:
plt.figure()
df.plot(figsize=(700,10))
df.plot(figsize=(700,10)).x.rolling(10).std().plot()
#plt.fill_between(df.index, collected_mean-.5*collected_std, collected_mean+.5*collected_std, color='b', alpha=0.2)

In [39]:
std = df.x.rolling(roll).std().pow(2)
std.plot(figsize=(200,10))


Out[39]:
<matplotlib.axes._subplots.AxesSubplot at 0x7fcf93d936d8>

In [29]:
print("Hello")


Hello