September 16, 2015 Chilean earthquake and tsunami

In [1]:
from pandas import read_csv
import matplotlib.pyplot as plt
from pandas import rolling_mean

%matplotlib inline

df1 = read_csv('Newport.csv', 
              parse_dates={"Datetime" : [0,1,2,3]},
              index_col=0,
              usecols=[0,1,2,3,8],
            )

df1['pandas_l'] = rolling_mean(df1, window=33, center=True)
df1['pandas_h'] = df1['Pressure (dbar)'] - df1['pandas_l']
df2 = df1[990:1349]

fig, ax = plt.subplots(figsize=(15,8))
ax.plot(df2.index.to_pydatetime(),df2['pandas_l'], 'b', label="Tide (1h ave)")
ax.plot(df2.index.to_pydatetime(),df2['Pressure (dbar)'], 'g', label="Newport Pier")
ax.legend(loc='upper left')
ax.set_xlabel('September 17, 2015 (UTC)', fontsize=18)
ax.set_ylabel('Water Column Pressure (dbar)', fontsize=18)

ax2 = ax.twinx()
ax2.plot(df2.index.to_pydatetime(),df2['pandas_h'], 'r', label="Tide Removed")
ax2.legend(loc='lower right')
for tl in ax2.get_yticklabels():
    tl.set_color('r')
ax2.set_ylabel('Water Column Pressure (dbar)', color='r',fontsize=18)

fig.autofmt_xdate()
plt.grid(b=True, which='major', color='b', linestyle='--')
plt.title('Newport Pier (2 min sample rate)', fontsize=18)
Out[1]:
<matplotlib.text.Text at 0x7f3b675026d0>