def _display_pixels(x, y, counts, pixelsize):
"""
Display pixels at coordinates (x, y) coloured with "counts".
This routine is fast but not fully general as it assumes the spaxels
are on a regular grid. This needs not be the case for Voronoi binning.
"""
xmin, xmax = np.min(x), np.max(x)
ymin, ymax = np.min(y), np.max(y)
nx = int(round((xmax - xmin)/pixelsize) + 1)
ny = int(round((ymax - ymin)/pixelsize) + 1)
img = np.full((nx, ny), np.nan) # use nan for missing data
j = np.round((x - xmin)/pixelsize).astype(int)
k = np.round((y - ymin)/pixelsize).astype(int)
img[j, k] = counts
plt.imshow(np.rot90(img), interpolation='nearest', cmap='prism',
extent=[xmin - pixelsize/2, xmax + pixelsize/2,
ymin - pixelsize/2, ymax + pixelsize/2])
#----------------------------------------------------------------------
评论列表
文章目录