Quickstart#

Welcome! You’ve found the documentation for cogsworth, good for you! This is an epic crossover episode of a package in which we bring the worlds of rapid population synthesis and galactic dynamics together and see what happens.

You should know that package relies heavily on cosmic and gala and I recommend you check out their respective documentation. As a general rule, anything that you can do with either of those packages, you can also do with cogsworth!

Okay, let’s get into this!

Basic imports#

For most of the examples that I give in this documentation you’re probably going to need the following basic imports. You can always read more about numpy and astropy.units at those respective links.

[1]:
import numpy as np
import astropy.units as u
import pandas as pd
import matplotlib.pyplot as plt

Here are some plotting settings as well to make sure everything looks good.

[2]:
# ensure jupyter actually uses your fancy retina display
%config InlineBackend.figure_format = 'retina'

# make pandas show *every* column
pd.set_option("display.max_columns", None)

# various adjustments to matplotlib settings
plt.rc('font', family='serif')
plt.rcParams['text.usetex'] = False
fs = 24
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)

Create your first population#

The central class in this package is Population. The class gives you access to the functionality of the entire package with one convenient interface. Let’s start by creating a small population of binaries with the default settings.

[3]:
import cogsworth
p = cogsworth.pop.Population(2000, processes=6)
p
[3]:
<Population - 2000 systems - galactic_potential=MilkyWayPotential, SFH=Wagg2022>

Though this class is initialised, we still need to actually create the population to find its present day state. We do this by running:

[4]:
p.create_population()
Run for 2000 binaries
Ended up with 2601 binaries with m1 > 0 solar masses
[6e-02s] Sample initial binaries
[2.1s] Evolve binaries (run COSMIC)
2619it [00:15, 164.21it/s]
[22.0s] Get orbits (run gala)
Overall: 24.2s

This function has just

  • Sampled the initial binaries from cosmic

  • Drawn their initial kinematics and birth times from the Galaxy model

  • Evolved the binaries from birth until present day using cosmic

  • Integrated the orbits of the binaries through the galaxy using gala

Inspect population#

Full evolution#

p now contains information about the stellar evolution of each constituent star of each binary, as well as the path of the binary through the galaxy. Let’s investigate some of those things.

Stellar Evolution#

First we can take a look at the cosmic bpp evolution table and see how the stars evolved over time.

[5]:
p.bpp
[5]:
tphys mass_1 mass_2 kstar_1 kstar_2 sep porb ecc RRLO_1 RRLO_2 evol_type aj_1 aj_2 tms_1 tms_2 massc_1 massc_2 rad_1 rad_2 mass0_1 mass0_2 lum_1 lum_2 teff_1 teff_2 radc_1 radc_2 menv_1 menv_2 renv_1 renv_2 omega_spin_1 omega_spin_2 B_1 B_2 bacc_1 bacc_2 tacc_1 tacc_2 epoch_1 epoch_2 bhspin_1 bhspin_2 bin_num
0 0.000000 1.312040 0.916052 1.0 1.0 389.347168 596.500915 0.048697 0.008480 0.006298 1.0 0.000000 0.000000 4.431838e+03 1.686870e+04 0.0 0.0 1.288946 0.812461 1.312040 0.916052 2.314598 0.411310 6298.992263 5151.227494 0.0 0.0 1.000000e-10 0.042145 1.000000e-10 0.230041 2956.940137 369.300206 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0
0 2676.059289 1.312040 0.916052 1.0 1.0 389.347168 596.500915 0.048697 0.010343 0.006498 10.0 2676.059289 2676.059289 4.431838e+03 1.686870e+04 0.0 0.0 1.572105 0.838188 1.312040 0.916052 3.259826 0.460600 6213.373532 5217.109481 0.0 0.0 6.596324e-08 0.042141 8.538053e-03 0.237351 1987.693052 346.978103 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0
1 0.000000 0.347239 0.106375 0.0 0.0 103.297516 180.660729 0.008988 0.006699 0.004736 1.0 0.000000 0.000000 2.769280e+05 3.025956e+06 0.0 0.0 0.331618 0.137021 0.347239 0.106375 0.018370 0.001203 3706.618831 2916.884470 0.0 0.0 3.472386e-01 0.053188 3.316178e-01 0.089064 0.463615 0.000106 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1
1 6537.672436 0.347239 0.106375 0.0 0.0 103.297516 180.660728 0.008988 0.006734 0.004736 10.0 6537.672436 6537.672436 2.769280e+05 3.025956e+06 0.0 0.0 0.333350 0.137021 0.347239 0.106375 0.018535 0.001204 3705.234013 2917.471334 0.0 0.0 3.472386e-01 0.053188 3.333502e-01 0.089064 0.458809 0.000106 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1
2 0.000000 0.441613 0.305573 0.0 0.0 2997.784375 22006.872240 0.199693 0.000410 0.000363 1.0 0.000000 0.000000 1.597990e+05 3.630782e+05 0.0 0.0 0.404736 0.302325 0.441613 0.305573 0.030560 0.014580 3810.400047 3664.134184 0.0 0.0 2.060029e-01 0.305573 1.908210e-01 0.302325 2.495535 0.186921 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2598 6125.119762 1.093116 0.412978 1.0 0.0 58.579628 42.341477 0.083616 0.051068 0.024116 10.0 6125.119762 6125.119762 8.102277e+03 2.071070e+05 0.0 0.0 1.274613 0.386572 1.093116 0.412978 1.839541 0.024106 5980.780039 3674.401118 0.0 0.0 2.167168e-02 0.244272 3.075838e-01 0.214464 690.631279 1.573507 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2598
2599 0.000000 0.500954 0.245336 0.0 0.0 123.025609 183.067636 0.505861 0.017062 0.013433 1.0 0.000000 0.000000 1.169159e+05 5.759382e+05 0.0 0.0 0.458292 0.260597 0.500954 0.245336 0.042761 0.009594 3894.587791 3554.561531 0.0 0.0 1.494033e-01 0.245336 1.807503e-01 0.260597 5.914073 0.038864 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2599
2599 10359.501366 0.500954 0.245336 0.0 0.0 123.025603 183.067621 0.505861 0.017394 0.013486 10.0 10359.501366 10359.501366 1.169159e+05 5.759382e+05 0.0 0.0 0.467211 0.261616 0.500954 0.245336 0.044360 0.009653 3892.794291 3553.062517 0.0 0.0 1.494033e-01 0.245336 1.842683e-01 0.261616 5.693593 0.042188 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2599
2600 0.000000 0.164596 0.150179 0.0 0.0 8.087533 4.751127 0.587051 0.156048 0.151860 1.0 0.000000 0.000000 1.363662e+06 1.638005e+06 0.0 0.0 0.201627 0.188167 0.164596 0.150179 0.003536 0.002837 3148.632794 3084.596718 0.0 0.0 8.229777e-02 0.075089 1.310577e-01 0.122309 0.002206 0.001153 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2600
2600 5515.220958 0.164596 0.150179 0.0 0.0 8.079928 4.744427 0.586676 0.156172 0.151961 10.0 5515.220958 5515.220958 1.363662e+06 1.638005e+06 0.0 0.0 0.201780 0.188286 0.164596 0.150179 0.003541 0.002840 3148.493586 3084.483652 0.0 0.0 8.229777e-02 0.075089 1.311572e-01 0.122386 85.968852 82.285239 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 2600

8702 rows × 44 columns

There are of course many things that you can do with this table! But let’s say, maybe you want get any binaries that experience mass transfer

[6]:
# get any binaries that have an evol_type indicating Roche Lobe overflow started
mt_bin_nums = p.bpp[p.bpp["evol_type"] == 3.0]["bin_num"].unique()

Let’s take a look at the evolution of the first binary in this list

[7]:
p.bpp[p.bpp["bin_num"] == mt_bin_nums[0]]
[7]:
tphys mass_1 mass_2 kstar_1 kstar_2 sep porb ecc RRLO_1 RRLO_2 evol_type aj_1 aj_2 tms_1 tms_2 massc_1 massc_2 rad_1 rad_2 mass0_1 mass0_2 lum_1 lum_2 teff_1 teff_2 radc_1 radc_2 menv_1 menv_2 renv_1 renv_2 omega_spin_1 omega_spin_2 B_1 B_2 bacc_1 bacc_2 tacc_1 tacc_2 epoch_1 epoch_2 bhspin_1 bhspin_2 bin_num
3 0.000000 1.104100 1.012107 1.0 1.0 213.830561 249.113765 0.148956 0.014566 0.013565 1.0 0.000000 0.000000 6.223421e+03 8.517492e+03 0.000000 0.000000 1.024446 0.916834 1.104100 1.012107 1.544484 1.028177 6385.883991 6097.352128 0.000000 0.000000 2.060427e-02 3.151838e-02 2.324936e-01 2.362826e-01 1186.661852 698.412380 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 0.0 0.0 3
3 6223.421651 1.104100 1.012107 2.0 1.0 213.830558 249.113760 0.148956 0.029185 0.017194 2.0 6223.421651 6223.421651 6.223421e+03 8.517492e+03 0.129662 0.000000 2.052605 1.162116 1.104100 1.012107 4.354075 1.883020 5845.759002 6300.260851 0.125672 0.000000 1.574637e-01 4.019846e-02 9.443739e-01 3.664868e-01 334.458372 434.694313 0.0 0.0 0.0 0.0 0.0 0.0 0.000000 0.000000 0.0 0.0 3
3 6464.269263 1.103697 1.012108 3.0 1.0 213.871059 249.208232 0.148956 0.032436 0.017430 2.0 6472.435241 6464.260537 6.231431e+03 8.517480e+03 0.164622 0.000000 2.281499 1.178385 1.103697 1.012108 4.177217 1.941489 5487.584724 6304.633316 0.115141 0.000000 4.695386e-01 4.122311e-02 1.408134e+00 3.805931e-01 209.992070 422.777566 0.0 0.0 0.0 0.0 0.0 0.0 -8.165978 0.008726 0.0 0.0 3
3 6958.269115 1.020508 1.021260 3.0 1.0 204.192269 236.661699 0.000000 1.000025 0.015981 3.0 6966.435092 6731.607201 6.231431e+03 8.239905e+03 0.448510 0.000000 77.361543 1.236691 1.103697 1.021260 1708.429889 2.150557 4237.954997 6313.594537 0.075342 0.000000 5.719982e-01 4.287875e-02 7.728620e+01 4.196191e-01 9.696840 9.696840 0.0 0.0 0.0 0.0 0.0 0.0 -8.165978 226.661914 0.0 0.0 3
3 6958.269115 1.020508 1.021260 3.0 1.0 204.192269 236.661699 0.000000 1.000025 0.015981 7.0 6966.435092 6731.607201 6.231431e+03 8.239905e+03 0.448510 0.000000 77.361543 1.236691 1.103697 1.021260 1708.429889 2.150557 4237.954997 6313.594537 0.075342 0.000000 5.719982e-01 4.287875e-02 7.728620e+01 4.196191e-01 9.696840 9.696840 0.0 0.0 0.0 0.0 0.0 0.0 -8.165978 226.661914 0.0 0.0 3
3 6958.269115 0.448510 1.021260 10.0 1.0 23.366916 10.798159 0.000000 1.000025 0.015981 8.0 0.000000 6731.607201 6.231431e+03 8.239905e+03 0.448510 0.000000 77.361543 1.236691 0.448510 1.021260 1708.429889 2.150557 4237.954997 6313.594537 0.075342 0.000000 5.719982e-01 4.287875e-02 7.728620e+01 4.196191e-01 9.696840 9.696840 0.0 0.0 0.0 0.0 0.0 0.0 -8.165978 226.661914 0.0 0.0 3
3 6958.269115 0.448510 1.021260 10.0 1.0 23.366916 10.798159 0.000000 0.002077 0.117206 4.0 0.000000 6731.607201 1.000000e+10 8.239905e+03 0.448510 0.000000 0.015068 1.236691 0.448510 1.021260 51.831542 2.150557 126731.845782 6313.594537 0.015068 0.000000 1.000000e-10 4.287875e-02 1.000000e-10 4.196191e-01 9.696840 9.696840 0.0 0.0 0.0 0.0 0.0 0.0 6958.269115 226.661914 0.0 0.0 3
3 8466.567314 0.448509 1.021260 10.0 2.0 23.294156 10.747763 0.000000 0.002084 0.179402 2.0 1508.298199 8239.905400 1.000000e+10 8.239905e+03 0.448509 0.121199 0.015068 1.887062 0.448510 1.021260 0.000608 3.296585 7416.918859 5687.123570 0.015068 0.128764 1.000000e-10 2.098883e-01 1.000000e-10 9.444792e-01 9.696838 238.284783 0.0 0.0 0.0 0.0 0.0 0.0 6958.269115 226.661914 0.0 0.0 3
3 8785.489392 0.448514 1.020829 10.0 3.0 23.300466 10.753690 0.000000 0.002083 0.203961 2.0 1827.220278 8571.854093 1.000000e+10 8.252677e+03 0.448514 0.160205 0.015068 2.145783 0.448510 1.020829 0.000485 3.548319 7008.941228 5432.282077 0.015068 0.116311 1.000000e-10 4.303124e-01 1.000000e-10 1.319157e+00 119.930378 144.010001 0.0 0.0 0.0 0.0 0.0 0.0 6958.269115 213.635300 0.0 0.0 3
3 9301.463232 0.448766 1.014692 10.0 3.0 21.238223 9.376902 0.000000 0.002281 1.000315 3.0 2343.194117 9087.827932 1.000000e+10 8.252677e+03 0.448766 0.256860 0.015064 9.579990 0.448510 1.020829 0.000362 60.276522 6514.971685 5219.442698 0.015064 0.096882 1.000000e-10 7.578313e-01 1.000000e-10 9.483107e+00 244.736557 244.736557 0.0 0.0 0.0 0.0 0.0 0.0 6958.269115 213.635300 0.0 0.0 3
3 9301.463232 0.448766 1.014692 10.0 3.0 21.238223 9.376902 0.000000 0.002281 1.000315 7.0 2343.194117 9087.827932 1.000000e+10 8.252677e+03 0.448766 0.256860 0.015064 9.579990 0.448510 1.020829 0.000362 60.276522 6514.971685 5219.442698 0.015064 0.096882 1.000000e-10 7.578313e-01 1.000000e-10 9.483107e+00 244.736557 244.736557 0.0 0.0 0.0 0.0 0.0 0.0 6958.269115 213.635300 0.0 0.0 3
3 9301.463232 0.448766 0.256860 10.0 10.0 0.858908 0.109826 0.000000 0.002281 1.000315 8.0 2343.194117 0.000000 1.000000e+10 8.252677e+03 0.448766 0.256860 0.015064 9.579990 0.448510 0.256860 0.000362 60.276522 6514.971685 5219.442698 0.015064 0.096882 1.000000e-10 7.578313e-01 1.000000e-10 9.483107e+00 244.736557 244.736557 0.0 0.0 0.0 0.0 0.0 0.0 6958.269115 213.635300 0.0 0.0 3
3 9301.463232 0.448766 0.256860 10.0 10.0 0.858908 0.109826 0.000000 0.040980 0.067994 4.0 2343.194117 0.000000 1.000000e+10 1.000000e+10 0.448766 0.256860 0.015064 0.019376 0.448510 0.256860 0.000362 29.683786 6514.971685 97221.385902 0.015064 0.019376 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 244.736557 244.736557 0.0 0.0 0.0 0.0 0.0 0.0 6958.269115 9301.463232 0.0 0.0 3
3 9468.684212 0.448766 0.256860 10.0 10.0 0.821833 0.102792 0.000000 0.042828 0.071061 10.0 2510.415098 167.220980 1.000000e+10 1.000000e+10 0.448766 0.256860 0.015064 0.019376 0.448510 0.256860 0.000334 0.004664 6383.831312 10884.647945 0.015064 0.019376 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 244.736783 21804.799668 0.0 0.0 0.0 0.0 0.0 0.0 6958.269115 9301.463232 0.0 0.0 3

We can also put this to use. Let’s see how the initial orbital periods are different for binaries that experience mass transfer.

[8]:
experienced_mt = p.initC["bin_num"].isin(mt_bin_nums)
plt.hist(np.log10(p.initC["porb"][experienced_mt]), bins="fd", density=True, label="Mass transfer")
plt.hist(np.log10(p.initC["porb"][~experienced_mt]), bins="fd", density=True, label="No mass transfer", alpha=0.8)
plt.legend()
plt.xlabel("Log Initial Orbital Period [days]");
../_images/pages_getting_started_16_0.png

As we can see in the plot above, systems that experience mass transfer are biased towards shorter orbital periods. This is expected as these systems are closer and therefore it is easier to initiate mass transfer.

Orbits#

We also have access to the full orbit of each binary in the population in p.orbits. I’m going to cheat and pick a fairly simple one to show from this random population (a binary that didn’t disrupt and is pretty close to us at present day).

[10]:
fig, ax = plt.subplots()
final_rho = np.sum(p.final_pos[:, :2]**2, axis=1)**(0.5)
nice_orbits = p.orbits[(final_rho > 4 * u.kpc) & (final_rho < 5 * u.kpc)]
nice_orbit = np.random.choice(nice_orbits)
nice_orbit.cylindrical.plot(["rho", "z"], axes=ax)
plt.show()
../_images/pages_getting_started_18_0.png

If this part interests you then I recommend that you go and check out the excellent gala docs about orbits and what you can do with them.

Present Day#

In many cases, you may not really care what happened over the history of the galaxy (way to let the past go!). In these cases you can instead only focus on the present day state of each binary.

For example, we could extract any binary that ended up disrupted

[11]:
p.final_bpp[p.disrupted]
[11]:
tphys mass_1 mass_2 kstar_1 kstar_2 sep porb ecc RRLO_1 RRLO_2 evol_type aj_1 aj_2 tms_1 tms_2 massc_1 massc_2 rad_1 rad_2 mass0_1 mass0_2 lum_1 lum_2 teff_1 teff_2 radc_1 radc_2 menv_1 menv_2 renv_1 renv_2 omega_spin_1 omega_spin_2 B_1 B_2 bacc_1 bacc_2 tacc_1 tacc_2 epoch_1 epoch_2 bhspin_1 bhspin_2 bin_num metallicity
14 9271.793239 1.277584 1.045460 13.0 11.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 9233.432094 9170.038423 1.000000e+10 1.000000e+10 1.277584 1.045460 0.000014 0.007542 8.290455 1.045460 2.764296e-10 4.142444e-05 6318.321503 5355.823136 0.000014 0.007542 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 1.967924e+07 8.006508e-06 6.550953e+10 0.000000e+00 0.0 0.0 0.0 0.0 38.361144 101.754816 0.0 0.0 14 0.014156
114 6918.544648 1.277584 2.186881 13.0 13.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 6906.134976 6899.532570 1.000000e+10 1.000000e+10 1.277584 2.186881 0.000014 0.000014 3.335919 6.294155 4.941294e-10 7.096979e-10 7305.766198 7997.863240 0.000014 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 6.237181e+05 1.526617e+06 4.270392e+12 1.745880e+12 0.0 0.0 0.0 0.0 12.409672 19.012079 0.0 0.0 114 0.022085
227 4624.571393 1.277584 1.277584 13.0 13.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 4603.658740 4602.126355 1.000000e+10 1.000000e+10 1.277584 1.277584 0.000014 0.000014 10.754057 10.382978 1.111999e-09 1.112740e-09 8948.118757 8949.608375 0.000014 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 9.784041e+06 1.633628e+07 5.786279e+11 3.465800e+11 0.0 0.0 0.0 0.0 20.912653 22.445039 0.0 0.0 227 0.025619
255 6990.020668 1.277584 3.265258 13.0 14.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 6976.816004 6973.751657 1.000000e+10 1.000000e+10 1.277584 3.265258 0.000014 0.000014 3.447006 7.980605 4.841682e-10 1.000000e-10 7268.665207 4927.514433 0.000014 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 2.275363e+07 2.000000e+08 1.128877e+11 0.000000e+00 0.0 0.0 0.0 0.0 13.204664 16.269011 0.0 0.0 255 0.016138
516 9242.457226 1.673253 6.759477 13.0 14.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 9231.447162 9228.204198 1.000000e+10 1.000000e+10 1.673253 6.759477 0.000014 0.000029 4.937222 10.850028 3.313422e-10 1.000000e-10 6611.115886 3424.760024 0.000014 0.000029 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 1.224536e+07 2.000000e+08 9.292913e+10 0.000000e+00 0.0 0.0 0.0 0.0 11.010064 14.253027 0.0 0.0 516 0.008719
537 2534.761692 1.628164 4.151160 13.0 14.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 2524.524013 2516.576799 1.000000e+10 1.000000e+10 1.628164 4.151160 0.000014 0.000018 4.791675 20.157112 4.350195e-09 1.000000e-10 12584.407266 4370.206338 0.000014 0.000018 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 1.399221e+07 2.000000e+08 9.504924e+11 0.000000e+00 0.0 0.0 0.0 0.0 10.237679 18.184892 0.0 0.0 537 0.011143
539 2945.427457 1.242000 1.242000 13.0 13.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 2898.312481 2875.288776 1.000000e+10 1.000000e+10 1.242000 1.242000 0.000014 0.000014 7.635984 1.409163 2.752967e-09 2.797232e-09 11224.211866 11269.060871 0.000014 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 2.045095e+07 2.097634e+06 5.400704e+11 5.283211e+12 0.0 0.0 0.0 0.0 47.114977 70.138682 0.0 0.0 539 0.007549
763 10912.362349 1.242000 1.210080 13.0 12.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 10802.590686 10802.417098 1.000000e+10 1.000000e+10 1.242000 1.210080 0.000014 0.004817 1.327798 1.210080 1.981690e-10 8.091102e-06 5813.859053 4455.562762 0.000014 0.004817 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 7.947976e+05 1.696254e-05 8.422263e+11 0.000000e+00 0.0 0.0 0.0 0.0 109.771663 109.945251 0.0 0.0 763 0.002353
877 2608.091664 1.277584 2.256181 13.0 13.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 2589.615674 2580.774104 1.000000e+10 1.000000e+10 1.277584 2.256181 0.000014 0.000014 2.993657 16.400125 3.514311e-09 5.179533e-09 11930.692247 13145.534315 0.000014 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 2.465635e+06 7.432766e+06 5.061400e+12 1.680862e+12 0.0 0.0 0.0 0.0 18.475991 27.317560 0.0 0.0 877 0.010151
988 7368.810850 1.797485 1.277584 13.0 13.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 7355.670660 7346.337629 1.000000e+10 1.000000e+10 1.797485 1.277584 0.000014 0.000014 15.228894 11.249244 5.475341e-10 4.366858e-10 7495.634143 7083.499353 0.000014 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 1.029400e+06 3.137554e+06 2.198962e+12 7.221963e+11 0.0 0.0 0.0 0.0 13.140190 22.473221 0.0 0.0 988 0.015343
1202 11020.842523 1.338653 2.174984 13.0 13.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 10999.401887 10989.225379 1.000000e+10 1.000000e+10 1.338653 2.174984 0.000014 0.000014 3.875944 15.548451 2.009831e-10 2.787349e-10 5834.389948 6331.453611 0.000014 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 5.355453e+05 1.483339e+07 1.307672e+12 4.730052e+10 0.0 0.0 0.0 0.0 21.440636 31.617144 0.0 0.0 1202 0.004518
1213 8566.608072 1.277584 0.816890 13.0 11.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 8546.469239 8285.251177 1.000000e+10 1.000000e+10 1.277584 0.816890 0.000014 0.010117 3.487948 0.816890 3.226542e-10 4.251490e-05 6567.346546 4654.504036 0.000014 0.010117 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 1.863971e+06 5.694967e-06 7.759394e+11 0.000000e+00 0.0 0.0 0.0 0.0 20.138834 281.356895 0.0 0.0 1213 0.016192
1503 4886.691967 8.716199 1.418384 14.0 13.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 4881.118867 4868.512854 1.000000e+10 1.000000e+10 8.716199 1.418384 0.000037 0.000014 12.066534 12.893160 1.000000e-10 1.066447e-09 3015.942886 8855.037185 0.000037 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 2.000000e+08 3.920919e+06 0.000000e+00 1.424520e+12 0.0 0.0 0.0 0.0 5.573100 18.179113 0.0 0.0 1503 0.009089
1617 10738.577502 1.277584 0.858966 13.0 11.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 10699.230749 10238.690282 1.000000e+10 1.000000e+10 1.277584 0.858966 0.000014 0.009639 8.352511 0.858966 2.058760e-10 1.148951e-05 5869.579965 3438.109919 0.000014 0.009639 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 7.106228e+06 5.966283e-06 9.988880e+10 0.000000e+00 0.0 0.0 0.0 0.0 39.346753 499.887220 0.0 0.0 1617 0.005590
1749 10712.374183 1.242000 1.242000 13.0 13.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 10661.142677 10658.503334 1.000000e+10 1.000000e+10 1.242000 1.242000 0.000014 0.000014 7.336366 1.418485 2.034623e-10 2.035631e-10 5852.300009 5853.024561 0.000014 0.000014 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 6.020050e+07 4.994469e+06 1.167669e+10 1.405403e+11 0.0 0.0 0.0 0.0 51.231505 53.870849 0.0 0.0 1749 0.005076
1887 7045.164959 1.277584 0.937066 13.0 11.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 7001.867311 6853.980378 1.000000e+10 1.000000e+10 1.277584 0.937066 0.000014 0.008764 7.942539 0.937066 4.807099e-10 4.032334e-05 7255.650627 4935.342188 0.000014 0.008764 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 5.794463e+07 6.616747e-06 4.396243e+10 0.000000e+00 0.0 0.0 0.0 0.0 43.297648 191.184581 0.0 0.0 1887 0.005753
2528 9475.960797 1.295946 4.583379 13.0 14.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 9462.541626 9458.335874 1.000000e+10 1.000000e+10 1.295946 4.583379 0.000014 0.000019 3.743613 23.129337 2.657343e-10 1.000000e-10 6256.298934 4159.046693 0.000014 0.000019 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 1.535968e+07 2.000000e+08 7.384291e+10 0.000000e+00 0.0 0.0 0.0 0.0 13.419171 17.624923 0.0 0.0 2528 0.010446
2588 10111.421499 1.430918 7.039752 13.0 14.0 -1.0 -1.0 -1.0 0.0001 0.0001 10.0 10097.104502 10092.406471 1.000000e+10 1.000000e+10 1.430918 7.039752 0.000014 0.000030 4.164249 22.633148 2.494010e-10 1.000000e-10 6157.864477 3355.892117 0.000014 0.000030 1.000000e-10 1.000000e-10 1.000000e-10 1.000000e-10 2.474748e+06 2.000000e+08 3.465346e+11 0.000000e+00 0.0 0.0 0.0 0.0 14.316997 19.015028 0.0 0.0 2588 0.007267

We can also look at where each binary ended up, and colour the disrupted binaries differently.

[13]:
final_coords = p.get_final_mw_skycoord()
[28]:
fig, ax = plt.subplots()
ax.scatter(final_coords[:len(p)][~p.disrupted].icrs.ra, final_coords[:len(p)][~p.disrupted].icrs.dec, s=0.5, c="yellow", label="Bound")
ax.scatter(final_coords[:len(p)][p.disrupted].icrs.ra, final_coords[:len(p)][p.disrupted].icrs.dec, s=15, c="C1")
ax.scatter(final_coords[len(p):].icrs.ra, final_coords[len(p):].icrs.dec, s=15, c="C1", label="Disrupted")
ax.set(xlabel="Right Ascension [deg]", ylabel="Declination [deg]", facecolor="black")
ax.legend(markerscale=6, handletextpad=.0, framealpha=0.5)
plt.show()
../_images/pages_getting_started_24_0.png

And we see that often (but not always) they are found off the galactic plane (due to the same supernova kick that disrupted binary)

Classify population#

The Population can also classify the present-day state of each binary. You can autogenerate these classes by accessing p.classes

[29]:
p.classes
[29]:
dco co-1 co-2 xrb walkaway-t-1 walkaway-t-2 runaway-t-1 runaway-t-2 walkaway-o-1 walkaway-o-2 runaway-o-1 runaway-o-2 widow-1 widow-2 stellar-merger-co-1 stellar-merger-co-2
0 False False False False False False False False False False False False False False False False
1 False False False False False False False False False False False False False False False False
2 False False False False False False False False False False False False False False False False
3 False False False False False False False False False False False False False False False False
4 False False False False False False False False False False False False False False False False
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2596 False False False False False False False False False False False False False False False False
2597 False False False False False False False False False False False False False False False False
2598 False False False False False False False False False False False False False False False False
2599 False False False False False False False False False False False False False False False False
2600 False False False False False False False False False False False False False False False False

2601 rows × 16 columns

This table has a flag for each class and for each binary. We can do some pandas DataFrame manipulation to get some statistics for the different classes

[30]:
p.classes.astype(int).sum()
[30]:
dco                     2
co-1                   20
co-2                   17
xrb                     0
walkaway-t-1            0
walkaway-t-2            0
runaway-t-1             0
runaway-t-2             0
walkaway-o-1            0
walkaway-o-2            0
runaway-o-1             0
runaway-o-2             0
widow-1                 0
widow-2                 0
stellar-merger-co-1     7
stellar-merger-co-2    14
dtype: int64

Inspect specific binaries#

cogsworth has simple plotting routines to understand the evolution of binaries in your population. Here’s an example for a binary that experiences a disruption.

These plots show the galactic orbit of the binary (indicating supernova events and different orbits for the primary and secondary after the disruption) and a cartoon timeline of its evolution.

[46]:
random_num = np.random.choice(p.bin_nums[p.disrupted])
p.plot_orbit(random_num, t_max=50 * u.Myr)
p.plot_cartoon_binary(random_num)
../_images/pages_getting_started_31_0.png
../_images/pages_getting_started_31_1.png
[46]:
(<Figure size 1200x2250 with 1 Axes>, <Axes: >)

Predict observables#

You can also use the Population class to predict what we might actually observe for this population in different filters. This uses dust maps to correct for extinction, applies bolometric corrections and blends the stars if necessary.

Tip

Note that you need some of the optional dependencies to run this last section - this is described more on the main Install page where you can find out how to install the optional dependencies and download the data for the dust maps and Gaia selection function.

[ ]:
p.get_observables(assume_mw_galactocentric=True, filters=["G", "BP", "RP"])
Av_1 Av_2 M_abs_1 m_app_1 M_abs_2 m_app_2 G_app_1 G_app_2 teff_obs log_g_obs secondary_brighter G_abs_1 G_abs_2 BP_app_1 BP_app_2 BP_abs_1 BP_abs_2 RP_app_1 RP_app_2 RP_abs_1 RP_abs_2
0 4.609716 6.0 3.457010 18.793058 5.581687 20.917734 22.167281 inf 6213.373532 4.163052 False 3.217009 inf 23.606863 inf 3.490352 inf 21.052861 inf 2.783254 inf
1 4.149601 6.0 9.070032 24.304126 12.038693 27.272786 27.579349 inf 3705.234013 4.932894 False 9.563646 inf 29.726378 inf 10.527712 inf 26.313477 inf 8.617683 inf
2 6.000000 6.0 8.506240 23.954165 9.322090 24.770016 27.915992 inf 3808.470780 4.859531 False 8.581067 inf 30.600001 inf 9.491915 inf 26.582832 inf 7.662284 inf
3 2.640000 6.0 13.432190 28.688393 10.568172 25.824374 30.248303 inf 6383.831312 7.734212 False 10.956415 inf 31.330705 inf 10.971066 inf 29.253035 inf 10.881733 inf
4 6.000000 6.0 8.896379 24.927311 11.036545 27.067477 29.172366 inf 3766.276995 4.920190 False 9.259249 inf 31.864843 inf 10.180998 inf 27.838403 inf 8.335461 inf
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
2596 6.000000 6.0 11.840547 27.044317 11.920082 27.123853 31.123640 inf 2937.380678 5.157263 False 12.567412 inf 35.488541 inf 14.742283 inf 29.693975 inf 11.300885 inf
2597 6.000000 6.0 9.143538 22.104229 11.302421 24.263112 26.416418 inf 3632.654232 4.928741 False 9.696250 inf 29.390216 inf 10.780614 inf 25.056891 inf 8.694578 inf
2598 1.716000 6.0 4.078223 17.209767 8.784677 21.916221 18.543946 inf 5980.780039 4.265977 False 3.977241 inf 19.213415 inf 4.266016 inf 17.764923 inf 3.524240 inf
2599 2.244000 6.0 8.122511 22.387619 9.778345 24.043453 24.385123 inf 3892.794291 4.798839 False 8.375090 inf 25.844305 inf 9.251238 inf 23.264670 inf 7.474368 inf
2600 6.000000 6.0 10.867271 25.279251 11.106774 25.518754 29.287202 inf 3148.493586 5.044728 False 11.395861 inf 33.106884 inf 13.098007 inf 27.878378 inf 10.209342 inf

2601 rows × 21 columns

[ ]:
cogsworth.plot.plot_cmd(p, "G", "BP", "RP")
../_images/pages_getting_started_35_0.png
(<Figure size 700x1000 with 2 Axes>, <Axes: xlabel='BP - RP', ylabel='G'>)

And more…!#

That’s it for your quickstart introduction to cogsworth but that’s only the beginning of what you can do with it! You can also learn how to use hydrodynamical zoom-in simulations or predict the gravitational-wave signal in LISA for your binaries. I’ve got pages of documentation ready for you to learn all of about it.

If you’re interested in learning more you’ve got a couple of options - you could:

  • Check out the other tutorials for more step-by-step guides of using cogsworth

  • Browse the gallery of examples to see how you could put cogsworth to use

  • Search through the user guide if you want to know how a specific class or function works

Hope you enjoy using cogsworth!

Note

This tutorial was generated from a Jupyter notebook that can be found here.