massFractions.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. """Plot the mass that, at large times, is stolen, in the tail
  2. or still orbitting the main mass for different perturbing masses
  3. """
  4. import matplotlib.pyplot as plt
  5. import numpy as np
  6. from analysis import utils
  7. from analysis.segmentation import segmentEncounter
  8. # Masses are given relative to 100, with respect to the main mass
  9. masses = np.array([20, 33, 50, 75, 100, 150, 200, 300, 400, 500, 600])
  10. tailFractions, stolenFractions = [], []
  11. f, ax = plt.subplots(1, 1, sharey=True)
  12. # For each encounter calculate the fraction of stolen and tail mass
  13. for mass in masses:
  14. data = utils.loadData('{}mass'.format(mass), 10000)
  15. masks, _, _ = segmentEncounter(data)
  16. tailFractions.append(len(masks[3])/len(data['r_vec']))
  17. stolenFractions.append(len(masks[1])/len(data['r_vec']))
  18. # Plotting
  19. ax.plot(masses/100, tailFractions, marker='+', color='black',
  20. markersize=10, label='Tail')
  21. ax.plot(masses/100, stolenFractions, marker='o', color='black',
  22. markersize=8, linestyle='dashed', label='Stolen', markerfacecolor='none')
  23. ax.legend()
  24. utils.setAxes(ax, x='Companion mass / main mass', y='Mass fraction',
  25. xcoords=(.7,-0.08) ,ycoords=(-0.08,.8))
  26. utils.stylizePlot([ax])
  27. ax.set_ylim(0,.45)
  28. plt.show()