Guest User

Untitled

a guest
Mar 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. def plotHist(tableDict, value_range=None, xy_range=None, pixel_size=20, sigma=None, target_size=None):
  2. x = tableDict['x'][:]
  3. y = tableDict['y'][:]
  4. if xy_range:
  5. xmin, xmax = xy_range[0]
  6. ymin, ymax = xy_range[1]
  7. else:
  8. xmin, xmax, ymin, ymax = x.min(), x.max(), y.min(), y.max()
  9. xedges = np.arange(xmin, xmax, pixel_size)
  10. yedges = np.arange(ymin, ymax, pixel_size)
  11. H, xedgesO, yedgesO = np.histogram2d(y, x, bins=(yedges, xedges))
  12. if target_size is not None:
  13. if H.shape[0] < target_size[0] or H.shape[1] < target_size[1]:
  14. H = np.pad(H, ((0, target_size[0] - H.shape[0]), (0, target_size[
  15. 1] - H.shape[1])), mode='constant', constant_values=0)
  16.  
  17. if value_range:
  18. H = H.clip(value_range[0], value_range[1])
  19. if sigma:
  20. H = scipy.ndimage.filters.gaussian_filter(H, sigma=(sigma, sigma))
  21. return H
Add Comment
Please, Sign In to add comment