def plottimestream(array, ax, xtick='time', **kwargs):
"""Plot timestream data.
Args:
array (xarray.DataArray): Array which the timestream data are included.
ax (matplotlib.axes): Axis you want to plot on.
xtick (str): Type of x axis.
'time': Time.
'index': Time index.
kwargs (optional): Plot options passed to ax.plot().
"""
logger = getLogger('decode.plot.plottimestream')
kidtpdict = {0: 'wideband', 1: 'filter', 2: 'blind'}
if xtick == 'time':
ax.plot(array.time, array, **kwargs)
elif xtick == 'index':
ax.plot(np.ogrid[:len(array.time)], array, **kwargs)
ax.set_xlabel('{}'.format(xtick), fontsize=20, color='grey')
# for label in ax.get_xticklabels():
# label.set_rotation(45)
ax.set_ylabel(str(array.datatype.values), fontsize=20, color='grey')
ax.legend()
kidid = int(array.kidid)
try:
kidtp = kidtpdict[int(array.kidtp)]
except KeyError:
kidtp = 'filter'
ax.set_title('ch #{} ({})'.format(kidid, kidtp), fontsize=20, color='grey')
logger.info('timestream data (ch={}) has been plotted.'.format(kidid))
评论列表
文章目录