1
0

halo.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """Plot the encounters for the halo analysis."""
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. from analysis import utils
  5. def plotDisk(data, ax, axisOn, zoomOut=False):
  6. """Plot the disk of an encounter
  7. Parameters:
  8. ax: the matplotlib axis where the data should be plotted
  9. data: a data dictionary in the format saved by the simulation
  10. axisOn (bool): whether to include the y axis in this subplot.
  11. It can be omitted when it is shared among subplots.
  12. zoomOut (bool): scale of the plotting
  13. """
  14. r_vec = data['r_vec']
  15. theta, phi = data['CONFIG']['galaxy1']['orientation']
  16. utils.plotTracks(ax, data['tracks'])
  17. utils.plotCenterMasses(ax, data)
  18. mask = data['types'][:,0]=='disk'
  19. ax.scatter(r[mask][:,0], r[mask][:,1], c='#c40f4c', s=2, marker='.')
  20. if zoomOut: utils.setSize(x=(-10, 10), y=(-10, 10), mode='square')
  21. else: utils.setSize(x=(-5, 5), y=(-5, 5), mode='square')
  22. utils.setAxes(ax, x=r'x\' / $r_{min}$', y=r'y\' / $r_{min}$',
  23. ycoords=(-0.2, .8), mode=('bottomleft' if axisOn else 'bottom'))
  24. utils.stylizePlot([ax])
  25. # Plot all four encounters described in the report at 3 different times
  26. f, axs = plt.subplots(2, 3, figsize=(15, 10), sharey=False, sharex=False)
  27. data = utils.loadData('parabolic_nohalo', 6800)
  28. plotDisk(data, ax=axs[0,0], axisOn=True)
  29. data = utils.loadData('parabolic_nohalo', 8800)
  30. plotDisk(data, ax=axs[0,1], axisOn=False)
  31. data = utils.loadData('parabolic_nohalo', 24800)
  32. plotDisk(data, ax=axs[0,2], axisOn=True, zoomOut=True)
  33. data = utils.loadData('parabolic_halo', 9400)
  34. plotDisk(data, ax=axs[1,0], axisOn=True)
  35. data = utils.loadData('parabolic_halo', 12800)
  36. plotDisk(data, ax=axs[1,1], axisOn=False)
  37. data = utils.loadData('parabolic_halo', 20800)
  38. plotDisk(data, ax=axs[1,2], axisOn=True, zoomOut=True)
  39. f.subplots_adjust(hspace=0, wspace=0)
  40. plt.tight_layout()
  41. plt.show()