In [1]:
import h5py
import matplotlib.pyplot as plt
import os
import numpy as np

In [10]:
from matplotlib.dates import date2num, num2date

In [2]:
%matplotlib


Using matplotlib backend: MacOSX

In [3]:
data_path = '/Volumes/wjlee_apl_3/ooi_zplsc_all_h5/'
fname = 'CE04OSPS_20170820.h5'

In [4]:
f = h5py.File(os.path.join(data_path,fname),'r')

In [5]:
f['Sv'].shape


Out[5]:
(3, 1072, 85827)

In [7]:
f['data_times'].shape


Out[7]:
(85827,)

In [9]:
plt.plot(np.diff(f['data_times']))


Out[9]:
[<matplotlib.lines.Line2D at 0x112fb45d0>]

In [13]:
num2date(f['data_times'][-20:-1])


Out[13]:
[datetime.datetime(2017, 8, 20, 23, 54, 40, 144382, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 41, 146438, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 42, 149491, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 43, 152553, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 44, 155605, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 45, 161665, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 46, 165723, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 47, 167780, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 48, 170842, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 49, 173894, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 50, 176957, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 51, 181005, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 52, 183071, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 53, 186124, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 54, 189186, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 55, 193244, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 56, 196296, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 57, 199349, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 20, 23, 54, 58, 201405, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>)]

In [14]:
fname2 = 'CE04OSPS_20170821.h5'

In [15]:
f2 = h5py.File(os.path.join(data_path,fname2),'r')

In [16]:
num2date(f2['data_times'][0:20])


Out[16]:
[datetime.datetime(2017, 8, 21, 0, 0, 0, 55059, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 2, 64171, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 3, 67223, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 4, 70285, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 5, 73338, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 6, 76400, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 7, 79452, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 8, 81509, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 9, 85567, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 10, 88629, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 11, 91681, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 12, 94744, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 13, 97796, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 14, 100858, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 15, 103911, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 16, 106973, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 17, 110025, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 18, 113088, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 19, 114138, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 0, 0, 20, 117201, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>)]

In [17]:
num2date(f2['data_times'][-20:])


Out[17]:
[datetime.datetime(2017, 8, 21, 23, 54, 40, 607576, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 41, 611634, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 42, 613690, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 43, 617749, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 44, 620811, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 45, 622867, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 46, 625920, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 47, 628982, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 48, 633040, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 49, 635097, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 50, 637153, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 51, 641211, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 52, 643268, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 53, 646330, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 54, 650388, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 55, 652445, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 56, 685501, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 57, 688553, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 58, 691616, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>),
 datetime.datetime(2017, 8, 21, 23, 54, 59, 695674, tzinfo=<matplotlib.dates._UTC object at 0x10ad96d50>)]

In [ ]:


In [ ]:


In [ ]:
idx_jump = 1000
ping_idx = range(0,10000,idx_jump)

In [ ]:


In [ ]:


In [58]:
plt.figure(figsize=(12,6))
plt.imshow(f['Sv'][0,:,range(10000)],aspect='auto',vmin=-90,vmax=-30)


Out[58]:
<matplotlib.image.AxesImage at 0x11e39ffd0>

In [37]:
plt.plot(f['data_times'][idx])


Out[37]:
[<matplotlib.lines.Line2D at 0x112afa110>]

In [36]:
num2date(f['data_times'][0:20])


Out[36]:
[datetime.datetime(2017, 8, 10, 20, 52, 55, 497504, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 52, 57, 507511, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 52, 58, 510503, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 52, 59, 513505, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 0, 516507, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 1, 520505, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 2, 524503, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 3, 526509, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 4, 529511, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 5, 532503, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 6, 536501, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 7, 538507, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 8, 542505, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 9, 544511, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 10, 547503, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 11, 551511, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 12, 553507, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 13, 556509, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 14, 560507, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>),
 datetime.datetime(2017, 8, 10, 20, 53, 15, 563509, tzinfo=<matplotlib.dates._UTC object at 0x10ae4c190>)]

In [39]:
[num2date(f['data_times'][x])-num2date(f['data_times'][x-1]) for x in range(1,10)]


Out[39]:
[datetime.timedelta(0, 2, 10007),
 datetime.timedelta(0, 1, 2992),
 datetime.timedelta(0, 1, 3002),
 datetime.timedelta(0, 1, 3002),
 datetime.timedelta(0, 1, 3998),
 datetime.timedelta(0, 1, 3998),
 datetime.timedelta(0, 1, 2006),
 datetime.timedelta(0, 1, 3002),
 datetime.timedelta(0, 1, 2992)]

In [51]:
a=num2date(f['data_times'][1])-num2date(f['data_times'][0])
a


Out[51]:
datetime.timedelta(0, 2, 10007)

In [54]:
(a.days,a.seconds,a.microseconds)


Out[54]:
(0, 2, 10007)

In [ ]:


In [ ]:


In [ ]: