def plot_waterfall(fil, f_start=None, f_stop=None, if_id=0, logged=True,cb=False,freq_label=False,MJD_time=False, **kwargs):
""" Plot waterfall of data
Args:
f_start (float): start frequency, in MHz
f_stop (float): stop frequency, in MHz
logged (bool): Plot in linear (False) or dB units (True),
cb (bool): for plotting the colorbar
kwargs: keyword args to be passed to matplotlib imshow()
"""
matplotlib.rc('font', **font)
plot_f, plot_data = fil.grab_data(f_start, f_stop, if_id)
# Make sure waterfall plot is under 4k*4k
dec_fac_x, dec_fac_y = 1, 1
if plot_data.shape[0] > MAX_IMSHOW_POINTS[0]:
dec_fac_x = plot_data.shape[0] / MAX_IMSHOW_POINTS[0]
if plot_data.shape[1] > MAX_IMSHOW_POINTS[1]:
dec_fac_y = plot_data.shape[1] / MAX_IMSHOW_POINTS[1]
plot_data = rebin(plot_data, dec_fac_x, dec_fac_y)
if MJD_time:
extent=(plot_f[0], plot_f[-1], fil.timestamps[-1], fil.timestamps[0])
else:
extent=(plot_f[0], plot_f[-1], (fil.timestamps[-1]-fil.timestamps[0])*24.*60.*60, 0.0)
this_plot = plt.imshow(plot_data,
aspect='auto',
rasterized=True,
interpolation='nearest',
extent=extent,
cmap='viridis_r',
**kwargs
)
if cb:
plt.colorbar()
if freq_label:
plt.xlabel("Frequency [Hz]",fontdict=font)
if MJD_time:
plt.ylabel("Time [MJD]",fontdict=font)
else:
plt.ylabel("Time [s]",fontdict=font)
return this_plot
评论列表
文章目录