Skip to content

Commit

Permalink
Merge pull request #97 from TomWagg/tutorials
Browse files Browse the repository at this point in the history
More tutorials
  • Loading branch information
TomWagg authored Jan 16, 2024
2 parents ed10994 + de06e49 commit 73b5011
Show file tree
Hide file tree
Showing 12 changed files with 763 additions and 22 deletions.
7 changes: 7 additions & 0 deletions cogsworth/pop.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from cosmic.sample.initialbinarytable import InitialBinaryTable
from cosmic.evolve import Evolve
from cosmic.checkstate import set_checkstates
import gala.potential as gp
import gala.dynamics as gd
from gala.potential.potential.io import to_dict as potential_to_dict, from_dict as potential_from_dict
Expand Down Expand Up @@ -529,6 +530,9 @@ def create_population(self, with_timing=True):
print(f"[{time.time() - start:1.0e}s] Sample initial binaries")
lap = time.time()

if self.bcm_timestep_conditions != []:
set_checkstates(self.bcm_timestep_conditions)

self.pool = Pool(self.processes) if self.processes > 1 else None
self.perform_stellar_evolution()
if with_timing:
Expand Down Expand Up @@ -651,6 +655,9 @@ def perform_stellar_evolution(self):
self._disrupted = None
self._escaped = None

if self.bcm_timestep_conditions != []:
set_checkstates(self.bcm_timestep_conditions)

# if no initial binaries have been sampled then we need to create some
if self._initial_binaries is None and self._initC is None:
print("Warning: Initial binaries not yet sampled, performing sampling now.")
Expand Down
106 changes: 93 additions & 13 deletions docs/tutorials/visualisation/binary_evolution.ipynb

Large diffs are not rendered by default.

607 changes: 605 additions & 2 deletions docs/tutorials/visualisation/gala.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion examples/plot_ZRt_Wagg2022.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
'xtick.major.size': 7,
'xtick.minor.size': 4,
'ytick.major.size': 7,
'ytick.minor.size': 4}
'ytick.minor.size': 4,
'savefig.dpi': 300}
plt.rcParams.update(params)
# sphinx_gallery_end_ignore

Expand Down
3 changes: 2 additions & 1 deletion examples/plot_cartoon.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
'xtick.major.size': 7,
'xtick.minor.size': 4,
'ytick.major.size': 7,
'ytick.minor.size': 4}
'ytick.minor.size': 4,
'savefig.dpi': 300}
plt.rcParams.update(params)
# sphinx_gallery_end_ignore

Expand Down
43 changes: 43 additions & 0 deletions examples/plot_cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""
Gaia colour-magnitude diagram
=============================
A colour-magnitude diagram using simulated photometry for Gaia.
Each point represents a star in the population, coloured by its stellar type. Circles are used for bound
binaries, and triangles for unbound binaries (upwards indicating the primary star, downwards indicating
the secondary star).
"""

import cogsworth
import matplotlib.pyplot as plt

# sphinx_gallery_start_ignore
plt.rc('font', family='serif')
plt.rcParams['text.usetex'] = False
fs = 24

# update various fontsizes to match
params = {'figure.figsize': (12, 8),
'legend.fontsize': 0.7*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,
'savefig.dpi': 300}
plt.rcParams.update(params)
# sphinx_gallery_end_ignore

p = cogsworth.pop.Population(2000)
p.create_population()

p.get_observables(filters=["G", "BP", "RP"],
assume_mw_galactocentric=True, ignore_extinction=True)

cogsworth.plot.plot_cmd(p, show=False)
plt.tight_layout() # <-- this is just to get rid of weird padding in online docs
plt.show()
3 changes: 2 additions & 1 deletion examples/plot_disrupted_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
'xtick.major.size': 7,
'xtick.minor.size': 4,
'ytick.major.size': 7,
'ytick.minor.size': 4}
'ytick.minor.size': 4,
'savefig.dpi': 300}
plt.rcParams.update(params)
# sphinx_gallery_end_ignore

Expand Down
3 changes: 2 additions & 1 deletion examples/plot_heights.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
'xtick.major.size': 7,
'xtick.minor.size': 4,
'ytick.major.size': 7,
'ytick.minor.size': 4}
'ytick.minor.size': 4,
'savefig.dpi': 300}
plt.rcParams.update(params)
# sphinx_gallery_end_ignore

Expand Down
3 changes: 2 additions & 1 deletion examples/plot_initial_periods.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'xtick.major.size': 7,
'xtick.minor.size': 4,
'ytick.major.size': 7,
'ytick.minor.size': 4}
'ytick.minor.size': 4,
'savefig.dpi': 300}
plt.rcParams.update(params)
# sphinx_gallery_end_ignore

Expand Down
3 changes: 2 additions & 1 deletion examples/plot_sfh_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
'xtick.major.size': 7,
'xtick.minor.size': 4,
'ytick.major.size': 7,
'ytick.minor.size': 4}
'ytick.minor.size': 4,
'savefig.dpi': 300}
plt.rcParams.update(params)
# sphinx_gallery_end_ignore

Expand Down
3 changes: 2 additions & 1 deletion examples/plot_tams_times.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
'xtick.major.size': 7,
'xtick.minor.size': 4,
'ytick.major.size': 7,
'ytick.minor.size': 4}
'ytick.minor.size': 4,
'savefig.dpi': 300}
plt.rcParams.update(params)
# sphinx_gallery_end_ignore

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test =
pytest-cov
docs =
%(observables)s
%(hydro)s
sphinx<7.2
matplotlib
nbsphinx>=0.8.6
Expand Down

0 comments on commit 73b5011

Please sign in to comment.