"""
Gaia colour-magnitude diagram
=============================

.. admonition:: Beware - extra dependencies required here!
    :class: warning

    You'll need to have installed the extra dependencies of ``cogsworth`` to estimate source photometry. Check out the `installation page <../../pages/install.rst>`_ for more details on how to do this!

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, processes=1,
                             use_default_BSE_settings=True)
p.create_population()

p.get_observables(filters=["Gaia_G_EDR3", "Gaia_BP_EDR3", "Gaia_RP_EDR3"],
                  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()
