In [10]:
import h5py
import matplotlib.pylab as plt
from modest_image import imshow
%matplotlib inline
In [50]:
h5_fname = '/Volumes/wjlee_apl_2/2015_0901-10_80m.h5'
In [51]:
f=h5py.File(h5_fname,"r")
In [48]:
fig,ax = plt.subplots(1, sharex=True, sharey=True)
imshow(ax,f['Sv'][1,:,:],aspect='auto',vmax=-34,vmin=-80,interpolation='none')
ax.set_xlabel('time (UTC)')
ax.set_xticks(xticks)
ax.set_xticklabels(xticklabels, rotation=45, horizontalalignment='center')
ax.set_xlim(0, time_length)
Out[48]:
In [24]:
%matplotlib qt4
In [62]:
import re,os
In [61]:
os.path.join
Out[61]:
In [75]:
def plot_Sv(h5_fname,save_path):
f = h5py.File(h5_fname,"r")
# Get time stamp
time_format = '%Y-%m-%d\n%H:%M:%S'
time_length = f['data_times'].size
# X axis label
# subset the xticks so that we don't plot every one
xticks = np.linspace(0, time_length, 11)
xstep = int(round(xticks[1]))
# format trans_array_time array so that it can be used to label the x-axis
xticklabels = [i for i in num2date(f['data_times'][::xstep])] + [num2date(f['data_times'][-1])]
xticklabels = [i.strftime(time_format) for i in xticklabels]
# Plot figure
print 'plotting figure...'
fig, ax = plt.subplots(3, sharex=True)
for ff in range(f['Sv'].shape[0]):
imshow(ax[ff],f['Sv'][ff,:,:],aspect='auto',vmax=-34,vmin=-80,interpolation='none')
ax[-1].set_xlabel('time (UTC)')
ax[-1].set_xticks(xticks)
ax[-1].set_xticklabels(xticklabels, rotation=45, horizontalalignment='center')
#ax[-1].set_xlim(0, time_length)
fig.set_figwidth(12)
fig.set_figheight(10)
# Save figure
save_fname = os.path.join(save_path,h5_fname+'.png')
print 'saving figure...'
fig.savefig(filename)
plt.close(fig)
In [76]:
save_path='/Volumes/wjlee_apl_2/'
In [77]:
plot_Sv(h5_fname,save_path)
In [ ]:
In [ ]:
In [30]:
from datetime import datetime
from matplotlib.dates import date2num, num2date
import numpy as np
In [40]:
time_format = '%Y-%m-%d\n%H:%M:%S'
time_length = f['data_times'].size
# X axis label
# subset the xticks so that we don't plot every one
xticks = np.linspace(0, time_length, 10)
xstep = int(round(xticks[1]))
# format trans_array_time array so that it can be used to label the x-axis
xticklabels = [i for i in num2date(f['data_times'][::xstep])] + [num2date(f['data_times'][-1])]
xticklabels = [i.strftime(time_format) for i in xticklabels]
In [41]:
xticklabels
Out[41]:
In [42]:
xticks
Out[42]:
In [ ]: