In [1]:
from datetime import datetime
from matplotlib.dates import date2num, num2date
import h5py
import matplotlib.pylab as plt
from modest_image import imshow
import numpy as np
import os
In [9]:
def plot_Sv(h5_fname,save_path,deci_len):
f = h5py.File(h5_fname,"r")
# Get time stamp
time_format = '%Y-%m-%d\n%H:%M:%S'
time_length = f['data_times'].size/deci_len
# 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*deci_len)])] + [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,:,::deci_len],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(16)
fig.set_figheight(10)
# Save figure
save_fname = os.path.join(save_path,h5_fname+'.png')
print 'saving figure...'
fig.savefig(save_fname)
plt.close(fig)
In [10]:
h5_fname='/Volumes/wjlee_apl_2/2015_0901-10_80m.h5'
In [11]:
save_path='/Volumes/wjlee_apl_2/'
In [13]:
plot_Sv(h5_fname,save_path,50)
In [ ]: