Illustrating individual binary evolution#
Understanding and investigating your populations of binaries becomes much easier when you know how to illustrate the evolution of a given binary. In this tutorial we’ll talk all about that.
Learning Goals#
By the end of this tutorial you should know how to:
Plot a simple cartoon of a binary’s evolution
Use
COSMICto plot detailed evolution of particular binary parameters
[1]:
import cogsworth
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import astropy.units as u
[2]:
# this all just makes plots look nice
%config InlineBackend.figure_format = 'retina'
plt.rc('font', family='serif')
plt.rcParams['text.usetex'] = False
fs = 24
# update various fontsizes to match
params = {'figure.figsize': (12, 8),
'legend.fontsize': fs,
'axes.labelsize': fs,
'xtick.labelsize': 0.9 * fs,
'ytick.labelsize': 0.9 * fs,
'axes.linewidth': 1.1,
'xtick.major.size': 7,
'xtick.minor.size': 4,
'ytick.major.size': 7,
'ytick.minor.size': 4}
plt.rcParams.update(params)
pd.options.display.max_columns = 999
Cartoon binary evolution#
Many of the tables that cogsworth outputs may be hard to interpret, even for long-time users. For a quick at-a-glance analysis of a particular binary, it can be useful to see each stage of its evolution visually. That’s where plot_cartoon_binary() comes in handy.
Let’s run a population, pick out a fun binary and plot up its evolution.
[3]:
p = cogsworth.pop.Population(5000, final_kstar1=[13, 14], use_default_BSE_settings=True)
p.sample_initial_binaries()
p.perform_stellar_evolution()
[22]:
had_mt = p.bpp[p.bpp["evol_type"] == 3]["bin_num"].unique()
had_ce = p.bpp[p.bpp["evol_type"] == 7]["bin_num"].unique()
had_sn1 = p.bpp[p.bpp["evol_type"] == 15]["bin_num"].unique()
had_sn2 = p.bpp[p.bpp["evol_type"] == 16]["bin_num"].unique()
disrupted = p.bin_nums[p.disrupted]
[23]:
# find all the binaries that have experienced all of these events
uni, count = np.unique(np.concatenate([had_mt, had_ce, had_sn1,
had_sn2, disrupted]),
return_counts=True)
cool_binaries = uni[count == 5]
complicated_binary = np.random.choice(cool_binaries)
[24]:
p.plot_cartoon_binary(complicated_binary);
Detailed parameter evolution#
In some cases you may want more detail than the cartoon supplies and in this case we can turn to the more detailed plotting functionality of COSMIC. This uses the bcm of a table to create a multi-panelled evolution plot.
Let’s take our complicated binary, re-run it in more detail and plot the results.
[25]:
# reduce the population to just the complicated binary
small_pop = p[int(complicated_binary)]
# get the bcm table to contain every timestep
small_pop.bcm_timestep_conditions = [["binstate=0", "dtp=0.0"]]
# drop old BSE_settings that are now in the initial_binaries table
small_pop.BSE_settings = {}
# re-perform evolution
small_pop.perform_stellar_evolution()
Now p.bcm contains all of timesteps for our complicated binary and we can use the COSMIC plotting routine to investigate it.
[26]:
# import the plotting routine from COSMIC
from cosmic.plotting import plot_binary_evol
# reset plotting style to avoid fontsize issues
plt.style.use("default")
In this case I trim it to only include timesteps within the first 1000 Myr, but you could also apply a lower limit to zoom in on more detail.
[30]:
plot_binary_evol(small_pop.bcm[small_pop.bcm["tphys"] < 1000])
plt.show()
Wrap-up#
And now you know all about how to plot the evolution of your favourite binary! Go run your own cogsworth simulations and investigate a binary :D Keep reading for more visualisation tutorials!
Note
This tutorial was generated from a Jupyter notebook that can be found here.