tailShapePlot.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """Make a plot of the shape of the tails as a function of
  2. mass of the perturbing mass, time and ring size
  3. """
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. from analysis import utils
  7. from analysis.segmentation import segmentEncounter
  8. def plotShape(ax, distances, angle, style, label):
  9. """Plot the shape curves, normalized to maximum radius = 1
  10. Parameters:
  11. ax: the matplotlib axis where the data should be plotted
  12. distances (arr): the distances of each point in the shape of the tail
  13. angle (arr): the angle of each point in the shape curve of the tail
  14. style (string): style (dotted, dashed...) for the line, passed to
  15. matplotlib.
  16. label (string): label of the encounter. Used for the legend.
  17. """
  18. ax.plot(-angles+np.min(angles), distances/np.max(distances),
  19. label=label, linestyle=style, c='k', alpha=0.7)
  20. f, axs = plt.subplots(1, 3, figsize=(12, 3), sharey=True)
  21. # Varying the mass of the encounter
  22. for m, st in zip([50, 100, 200], [':', '-','--']):
  23. data = utils.loadData('{}mass70radius'.format(m), 14000)
  24. _, (distances, angles), _ = segmentEncounter(data, plot=False)
  25. plotShape(axs[0], distances, angles, st, m/100)
  26. axs[0].legend(title=r'$m_{companion}$')
  27. utils.setAxes(axs[0], x=r'Angle / rad', y=r'Radius / $r_{max}$',
  28. ycoords=(-0.1,.7))
  29. # Varying the time since the start of the encounter
  30. for t, st in zip([4400, 7400, 10400], [':', '-','--']):
  31. data = utils.loadData('200mass70radius'.format(200), t)
  32. _, (distances, angles), _ = segmentEncounter(data, plot=False)
  33. plotShape(axs[1], distances, angles, st, t)
  34. axs[1].legend(title=r'$t$')
  35. utils.setAxes(axs[1], x=r'Angle / rad')
  36. # Varying the radius of the ring
  37. for r, st in zip([50, 60, 70, 80, 90], [':', '-.','-','--']):
  38. data = utils.loadData('200mass{}radius'.format(r), 10000)
  39. _, (distances, angles), _ = segmentEncounter(data, plot=False)
  40. plotShape(axs[2], distances, angles, st, r)
  41. axs[2].legend(title=r'Disk radius')
  42. utils.setAxes(axs[2], x=r'Angle / rad')
  43. # Some styling
  44. utils.stylizePlot(axs)
  45. f.subplots_adjust(hspace=0, wspace=0)
  46. plt.show()