tailEvolution.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. """Plot the evolution of the length of the tail as a function
  2. of time for different companion masses
  3. """
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. from scipy.signal import savgol_filter
  7. from analysis import utils
  8. from analysis.segmentation import segmentEncounter
  9. # Masses are given relative to 100, with respect to the main mass
  10. masses = [50, 100, 200, 400]
  11. labels = ['1:0.5', '1:1', '1:2', '1:4'] # main:companion
  12. f, ax = plt.subplots(1, 1, sharey=True)
  13. for j, style in zip(range(len(masses)), [':', '-.','-','--']):
  14. ts = np.linspace(4000, 10000, 61) # time range
  15. lengths = [] # length of the tail
  16. for t in ts:
  17. data = utils.loadData('{}mass'.format(masses[j]), int(t))
  18. _, _, length = segmentEncounter(data)
  19. lengths.append(length)
  20. # For some masses we manually omit some misbehaved points
  21. if masses[j]==50: ax.plot(ts[20:], savgol_filter(lengths[20:], 21, 3),
  22. label=labels[j], c='black', linestyle=style)
  23. else: ax.plot(ts, savgol_filter(lengths, 21, 3),
  24. label=labels[j], c='black', linestyle=style)
  25. ax.legend(title='main:companion', fontsize=14)
  26. utils.setAxes(ax, x='Time', y='Tail length',
  27. xcoords=(.9,-0.08), ycoords=(-0.08,.7))
  28. utils.setSize(ax, x=(5000,10000))
  29. utils.stylizePlot([ax])
  30. plt.show()