Color-magnitude diagram: broadband filters#

This tutorial shows how to create a color-magnitude diagram that includes data of field and young/low-gravity objects, synthetic photometry computed from isochrones and model spectra, and data of directly imaged objects.

Initiating species#

We start by importing the required modules.

[1]:
import numpy as np
from species import SpeciesInit
from species.data.database import Database
from species.read.read_color import ReadColorMagnitude
from species.read.read_isochrone import ReadIsochrone
from species.read.read_planck import ReadPlanck
from species.plot.plot_spectrum import plot_spectrum
from species.plot.plot_color import plot_color_magnitude

Next, we initiate the species workflow and create an instance of Database.

[2]:
SpeciesInit()
database = Database()
==============
species v0.8.0
==============

Working folder: /Users/tomasstolker/applications/species/docs/tutorials

Creating species_config.ini... [DONE]
Creating species_database.hdf5... [DONE]
Creating data folder... [DONE]

Configuration settings:
   - Database: /Users/tomasstolker/applications/species/docs/tutorials/species_database.hdf5
   - Data folder: /Users/tomasstolker/applications/species/docs/tutorials/data
   - Magnitude of Vega: 0.03

Multiprocessing: mpi4py installed
Process number 1 out of 1...

Adding data to the database#

Available magnitudes and spectra of directly imaged planets and brown dwarfs are added to the database with add_companion by setting name=None. These data are extracted from the companion_data and companion_spectra files in the companion_data subpackage.

[3]:
database.add_companion(name=None, verbose=False)
Add companion: ['beta Pic b', 'beta Pic c', 'HIP 65426 b', '51 Eri b', 'HR 8799 b', 'HR 8799 c', 'HR 8799 d', 'HR 8799 e', 'HD 95086 b', 'PDS 70 b', 'PDS 70 c', '2M 1207 B', 'AB Pic B', 'HD 206893 B', 'RZ Psc B', 'GQ Lup B', 'PZ Tel B', 'kappa And b', 'HD 1160 B', 'ROXs 12 B', 'ROXs 42 Bb', 'GJ 504 b', 'GJ 758 B', 'GU Psc b', '2M0103 ABb', '1RXS 1609 B', 'GSC 06214 B', 'HD 72946 B', 'HIP 64892 B', 'HD 13724 B', 'YSES 1 b', 'YSES 1 c', 'YSES 2 b', 'HD 142527 B', 'CS Cha B', 'CT Cha B', 'SR 12 C', 'DH Tau B', 'HD 4747 B', 'HR 3549 B', 'CHXR 73 B', 'HD 19467 B', 'b Cen (AB)b', 'VHS 1256 B']
Downloading data from 'https://archive.stsci.edu/hlsps/reference-atlases/cdbs/current_calspec/alpha_lyr_stis_011.fits' to file '/Users/tomasstolker/applications/species/docs/tutorials/data/alpha_lyr_stis_011.fits'.
100%|████████████████████████████████████████| 288k/288k [00:00<00:00, 776MB/s]
Adding spectrum: Vega

/Users/tomasstolker/applications/species/species/data/database.py:1373: UserWarning: Found 33 fluxes with NaN in the data of GPI_YJHK. Removing the spectral fluxes that contain a NaN.
  warnings.warn(
Reference: Bohlin et al. 2014, PASP, 126
URL: https://ui.adsabs.harvard.edu/abs/2014PASP..126..711B/abstract
/Users/tomasstolker/applications/species/species/data/filter_data/filter_data.py:227: UserWarning: The minimum transmission value of Subaru/CIAO.z is smaller than zero (-1.80e-03). Wavelengths with negative transmission values will be removed.
  warnings.warn(

We also add the photometry and parallaxes of the Database of Ultracool Parallaxes.

[4]:
database.add_photometry('vlm-plx')
Downloading data from 'https://home.strw.leidenuniv.nl/~stolker/species/vlm-plx-all.fits' to file '/Users/tomasstolker/applications/species/docs/tutorials/data/vlm-plx-all.fits'.

-----------------------
Add photometric library
-----------------------

Database tag: vlm-plx
Library: Database of Ultracool Parallaxes
100%|████████████████████████████████████████| 314k/314k [00:00<00:00, 346MB/s]

Next, we add the isochrones from AMES-Cond and AMES-Dusty, which have been retrieved from https://phoenix.ens-lyon.fr/Grids/.

[5]:
database.add_isochrones('ames')
Downloading AMES-Cond isochrones (235 kB)... [DONE]
Adding isochrones: ames-cond... [DONE]
Database tag: ames-cond
Downloading AMES-Dusty isochrones (182 kB)... [DONE]
Adding isochrones: ames-dusty... [DONE]
Database tag: ames-dusty

Finally, we need to add the grid with AMES-Cond model spectra. The full grid of spectra is downloaded but spectra with a \(T_\mathrm{eff}\) outside the chosen teff_range are not added to the database.

[6]:
database.add_model(model='ames-cond',
                   teff_range=(100., 4000.))
Downloading data from 'https://home.strw.leidenuniv.nl/~stolker/species/ames-cond.tgz' to file '/Users/tomasstolker/applications/species/docs/tutorials/data/ames-cond.tgz'.

-------------------------
Add grid of model spectra
-------------------------

Database tag: ames-cond
Model name: AMES-Cond
100%|███████████████████████████████████████| 156M/156M [00:00<00:00, 66.5GB/s]
SHA256 hash of downloaded file: 325f3ea3ed13c51e08daacbd08811fde04762c29994bfbcc17f42223bf3432ea
Use this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.

Unpacking 278/439 model spectra from AMES-Cond (150 MB)... [DONE]

Wavelength range (um) = 0.5 - 40
Sampling (lambda/d_lambda) = 4000
Teff range (K) = 100.0 - 4000.0

Adding AMES-Cond model spectra... ames-cond_teff_900_logg_5.5_spec.dat

Grid points stored in the database:
   - Teff = [ 100.  200.  300.  400.  500.  600.  700.  800.  900. 1000. 1100. 1200.
 1300. 1400. 1500. 1600. 1700. 1800. 1900. 2000. 2100. 2200. 2300. 2400.
 2500. 2600. 2700. 2800. 2900. 3000. 3100. 3200. 3300. 3400. 3500. 3600.
 3700. 3800. 3900. 4000.]
   - log(g) = [2.5 3.  3.5 4.  4.5 5.  5.5]

Number of grid points per parameter:
   - teff: 40
   - logg: 7

Fix missing grid points with a linear interpolation:
   - teff = 200.0, logg = 5.5
   - teff = 900.0, logg = 2.5

Number of stored grid points: 280
Number of interpolated grid points: 2
Number of missing grid points: 0
/Users/tomasstolker/applications/species/species/util/data_util.py:394: RuntimeWarning: divide by zero encountered in log10
  flux = np.log10(flux)

Also the AMES-Dusty spectra are downloaded and imported into the database.

[7]:
database.add_model(model='ames-dusty',
                   teff_range=(100., 4000.))
Downloading data from 'https://home.strw.leidenuniv.nl/~stolker/species/ames-dusty.tgz' to file '/Users/tomasstolker/applications/species/docs/tutorials/data/ames-dusty.tgz'.

-------------------------
Add grid of model spectra
-------------------------

Database tag: ames-dusty
Model name: AMES-Dusty
100%|█████████████████████████████████████| 60.4M/60.4M [00:00<00:00, 33.7GB/s]
SHA256 hash of downloaded file: c389dd52b35bcba2d9850921c97eee043c2ff0654cc24efc47baa2345c05254e
Use this value as the 'known_hash' argument of 'pooch.retrieve' to ensure that the file hasn't changed if it is downloaded again in the future.

Unpacking 195/195 model spectra from AMES-Dusty (58 MB)... [DONE]

Wavelength range (um) = 0.5 - 40
Sampling (lambda/d_lambda) = 4000
Teff range (K) = 100.0 - 4000.0

Adding AMES-Dusty model spectra... ames-dusty_teff_900_logg_5.5_spec.dat

Grid points stored in the database:
   - Teff = [ 500.  600.  700.  800.  900. 1000. 1100. 1200. 1300. 1400. 1500. 1600.
 1700. 1800. 1900. 2000. 2100. 2200. 2300. 2400. 2500. 2600. 2700. 2800.
 2900. 3000. 3100. 3200. 3300. 3400. 3500. 3600. 3700. 3800. 3900. 4000.]
   - log(g) = [3.5 4.  4.5 5.  5.5 6. ]

Number of grid points per parameter:
   - teff: 36
   - logg: 6

Fix missing grid points with a linear interpolation:
   - teff = 900.0, logg = 6.0
   - teff = 1200.0, logg = 5.5
   - teff = 2100.0, logg = 3.5
   - teff = 2100.0, logg = 4.5
   - teff = 2200.0, logg = 3.5
   - teff = 2400.0, logg = 5.0
   - teff = 3100.0, logg = 3.5
   - teff = 3200.0, logg = 3.5
   - teff = 3300.0, logg = 3.5
   - teff = 3400.0, logg = 3.5
   - teff = 3500.0, logg = 3.5
   - teff = 3600.0, logg = 3.5
   - teff = 3700.0, logg = 3.5
   - teff = 3800.0, logg = 3.5
   - teff = 3900.0, logg = 3.5
   - teff = 3900.0, logg = 6.0
   - teff = 4000.0, logg = 3.5
   - teff = 4000.0, logg = 4.0
   - teff = 4000.0, logg = 4.5
   - teff = 4000.0, logg = 5.5
   - teff = 4000.0, logg = 6.0

The following grid points are missing:
   - teff = 3100.0, logg = 3.5
   - teff = 3200.0, logg = 3.5
   - teff = 3300.0, logg = 3.5
   - teff = 3400.0, logg = 3.5
   - teff = 3500.0, logg = 3.5
   - teff = 3600.0, logg = 3.5
   - teff = 3700.0, logg = 3.5
   - teff = 3800.0, logg = 3.5
   - teff = 3900.0, logg = 3.5
   - teff = 3900.0, logg = 6.0
   - teff = 4000.0, logg = 3.5
   - teff = 4000.0, logg = 4.0
   - teff = 4000.0, logg = 4.5
   - teff = 4000.0, logg = 5.5
   - teff = 4000.0, logg = 6.0

Number of stored grid points: 216
Number of interpolated grid points: 6
Number of missing grid points: 15
/Users/tomasstolker/applications/species/species/util/data_util.py:478: UserWarning: Could not interpolate 15 grid points so storing zeros instead.
  warnings.warn(

We are now ready with preparing the HDF5 database. The list_content method of the Database object can be used for printing an overview of all the data that are stored in the database.

Synthetic photometry from isochrones#

Magnitudes from the isochrone data can be extracted with the get_isochrone function of ReadIsochrone. However, in this example, we consistently recompute the synthetic photometry by making use of both the evolutionary tracks and the synthetic spectra.

The isochrones will be iterpolated for three different ages and the synthetic photometry is computed at 100 logarithmically-spaced masses.

[8]:
ages = [20., 100.]  # (Myr)
masses = np.logspace(0., 3., 100)  # (Mjup)

We create instances of ReadIsochrone for both the AMES-Cond and AMES-Dusty isochrones. We note though that the evolutionary data of these two models are actually the same. Only the magnitudes of the isochrones (which we do not use) are different.

[9]:
read_iso_cond = ReadIsochrone(tag='ames-cond')
read_iso_dusty = ReadIsochrone(tag='ames-dusty')

The colors and magnitudes are computed by chosing the corresponding model grids from the database. The output is stored in ColorMagBox objects for the three different ages.

[10]:
boxes = []

for item in ages:

    modelcolor1 = read_iso_cond.get_color_magnitude(age=item,
                                                    masses=masses,
                                                    filters_color=('MKO/NSFCam.H', 'MKO/NSFCam.Lp'),
                                                    filter_mag='MKO/NSFCam.Lp')

    modelcolor2 = read_iso_dusty.get_color_magnitude(age=item,
                                                     masses=masses,
                                                     filters_color=('MKO/NSFCam.H', 'MKO/NSFCam.Lp'),
                                                     filter_mag='MKO/NSFCam.Lp')

    boxes.append(modelcolor1)
    boxes.append(modelcolor2)
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 4019.3207105807364, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 4019.3207105807364, 'logg': 4.351948444496957, 'radius': 10.170788710818773, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 4164.404431717177, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 4164.404431717177, 'logg': 4.329081153206135, 'radius': 10.739016824226589, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.9180307893338338, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.3730414241427, 'logg': 2.9180307893338338, 'radius': 1.4638670830301985, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.9730768802029495, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 502.5270292688421, 'logg': 2.9730768802029495, 'radius': 1.441670727659954, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.0355631548565696, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 504.9233097703563, 'logg': 3.0355631548565696, 'radius': 1.4150903616033272, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.1025651389931803, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 507.4927628068724, 'logg': 3.1025651389931803, 'radius': 1.3865891063317703, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.207337823869265, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 520.0556848108937, 'logg': 3.207337823869265, 'radius': 1.328194511799377, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.3065271787010397, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 534.0174915985033, 'logg': 3.3065271787010397, 'radius': 1.274758290992437, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.3387964574578715, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 543.9916323051601, 'logg': 3.3387964574578715, 'radius': 1.2725698348137873, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.372282732356024, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 556.2475974396231, 'logg': 3.372282732356024, 'radius': 1.2706911157956755, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.407135965646942, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 570.8634694648467, 'logg': 3.407135965646942, 'radius': 1.269118495295348, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.444507945285873, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 586.5355899585918, 'logg': 3.444507945285873, 'radius': 1.2674322258801856, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.484580694074335, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 603.3402910634309, 'logg': 3.484580694074335, 'radius': 1.2656240944588282, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 4081.4355631859694, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 4081.4355631859694, 'logg': 4.667985184351259, 'radius': 5.914180524946677, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 4185.2608377397555, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 4185.2608377397555, 'logg': 4.656638159809863, 'radius': 6.199078262481065, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 4325.615910494432, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 4325.615910494432, 'logg': 4.641153787722841, 'radius': 6.55382759835061, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 4512.024881795706, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 4512.024881795706, 'logg': 4.610559348746733, 'radius': 7.038423776652953, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 4704.664806542345, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 4704.664806542345, 'logg': 4.571845570260296, 'radius': 7.623463332054268, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 4915.122843504473, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 4915.122843504473, 'logg': 4.527793777987827, 'radius': 8.265784389535268, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1029: UserWarning: The value of teff is 5129.6908172285885, which is above the upper bound of the model grid (4000.0). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 5129.6908172285885, 'logg': 4.487243459618406, 'radius': 8.971175402210688, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.7961969975244876, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.58438710058044, 'logg': 2.7961969975244876, 'radius': 1.5064919873572373, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.8072667505973876, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.6880174178661, 'logg': 2.8072667505973876, 'radius': 1.5031419477567405, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.820805889271204, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.6648632173275, 'logg': 2.820805889271204, 'radius': 1.4989194659748202, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.8353234638853895, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.640035727038, 'logg': 2.8353234638853895, 'radius': 1.494391837164531, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.855670027860674, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.65383479103104, 'logg': 2.855670027860674, 'radius': 1.4883035183626285, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.879927968286292, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.6892732862044, 'logg': 2.879927968286292, 'radius': 1.4811452905054687, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.905938962678162, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.7272728229761, 'logg': 2.905938962678162, 'radius': 1.473469757406555, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.9339822921321925, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 501.84752531806237, 'logg': 2.9339822921321925, 'radius': 1.465193882836573, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 2.9644919021316207, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 502.20555197078545, 'logg': 2.9644919021316207, 'radius': 1.4561883961908293, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.0026726111414517, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 503.0100115950047, 'logg': 3.0026726111414517, 'radius': 1.4449586973534068, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.0444294083637633, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 503.93545547538565, 'logg': 3.0444294083637633, 'radius': 1.4326823296312547, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.0892038533213797, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 504.92777861412816, 'logg': 3.0892038533213797, 'radius': 1.4195187829174454, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.1490344602161873, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 506.1240352668346, 'logg': 3.1490344602161873, 'radius': 1.4012157774301066, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.2286358747595356, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 506.35983582050795, 'logg': 3.2286358747595356, 'radius': 1.3753758265566598, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.331188032984285, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 505.06156677568043, 'logg': 3.331188032984285, 'radius': 1.3405155245172165, 'distance': 10.0}.
  warnings.warn(
/Users/tomasstolker/applications/species/species/read/read_isochrone.py:1004: UserWarning: The value of logg is 3.4411513507951, which is below the lower bound of the model grid (3.5). Setting the magnitudes to NaN for the following isochrone sample: {'teff': 503.6694754335613, 'logg': 3.4411513507951, 'radius': 1.3031359652909418, 'distance': 10.0}.
  warnings.warn(

Some warnings are printed when \(T_\mathrm{eff}\) or \(\log(g)\) from the evolutionary tracks are outside the parameter boundaries of the grid with spectra. Also, some of the chosen masses are below the lowest masses that are available in the evolutionary tracks. Therefore these colors and magnitudes are set to NaN and will be ignored when plotting the isochrones later one.

Synthetic photometry from blackbody spectra#

In addition to the isochrones, we also calculate colors and magnitudes for blackbody radiation. We start by creating an instance of ReadPlanck for a wavelength range between 0.5 and 10 \(\mu\)m.

[11]:
read_planck = ReadPlanck(wavel_range=(0.5, 10.))

Next, we use the get_color_magnitude methode to calculate the synthetic photometry for the same filters from before. Here we chose 100 logarithmically-spaced temperatures between 100 and 10000 K. The radius, which only impacts the absolute magnitude, is set to 1 \(R_\mathrm{J}\).

[12]:
color_planck = read_planck.get_color_magnitude(temperatures=np.logspace(2, 4, 100),
                                               radius=1.,
                                               filters_color=('MKO/NSFCam.H', 'MKO/NSFCam.Lp'),
                                               filter_mag='MKO/NSFCam.Lp')

The returned ColorMagBox is added to the list of boxes.

[13]:
boxes.append(color_planck)

Photometry of directly imaged objects#

We will also create a list with names and filters of the directly imaged planets and brown dwarfs that we want to show. The list_companions method of Database can be used to get an overview of all available photometric data in the database. We create a list with object names and filters for the colors and magnitudes that we want to include in the color-magnitude diagram.

[14]:
objects = [('HR 8799 b', 'Keck/NIRC2.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('HR 8799 c', 'Keck/NIRC2.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('HR 8799 d', 'Keck/NIRC2.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('HR 8799 e', 'Paranal/SPHERE.IRDIS_D_H23_2', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('kappa And b', 'Subaru/CIAO.H', 'Keck/NIRC2.Lp', 'Keck/NIRC2.Lp'),
           ('GSC 06214 B', 'MKO/NSFCam.H', 'MKO/NSFCam.Lp', 'MKO/NSFCam.Lp'),
           ('ROXs 42 Bb', 'Keck/NIRC2.H', 'Keck/NIRC2.Lp', 'Keck/NIRC2.Lp'),
           ('51 Eri b', 'MKO/NSFCam.H', 'Keck/NIRC2.Lp', 'Keck/NIRC2.Lp'),
           ('2M 1207 B', 'Paranal/NACO.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('2M0103 ABb', 'Paranal/NACO.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('1RXS 1609 B', 'Gemini/NIRI.H-G0203w', 'Gemini/NIRI.Lprime-G0207w', 'Gemini/NIRI.Lprime-G0207w'),
           ('beta Pic b', 'Paranal/NACO.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('HIP 65426 b', 'Paranal/SPHERE.IRDIS_D_H23_2', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('PZ Tel B', 'Paranal/NACO.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),
           ('HD 206893 B', 'Paranal/SPHERE.IRDIS_B_H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp')]

Reading color-magnitude data#

The colors and magnitude of the Database of Ultracool Parallaxes are read from the database by creating an object of ReadColorMagnitude.

[15]:
colormag = ReadColorMagnitude(library='vlm-plx',
                              filters_color=('MKO/NSFCam.H', 'MKO/NSFCam.Lp'),
                              filter_mag='MKO/NSFCam.Lp')

--------------------
Read color-magnitude
--------------------

Database tag: vlm-plx
Library type: phot_lib
Filters color: ('MKO/NSFCam.H', 'MKO/NSFCam.Lp')
Filter magnitude: MKO/NSFCam.Lp

And then extracting the ColorMagBox objects for field and young/low-gravity objects separately.

[16]:
color_field = colormag.get_color_magnitude(object_type='field')
color_young = colormag.get_color_magnitude(object_type='young')

-------------------
Get color-magnitude
-------------------

Object type: field
Returning ColorMagBox with 49 objects

-------------------
Get color-magnitude
-------------------

Object type: young
Returning ColorMagBox with 25 objects

Also these ColorMagBox objects are added to the list of boxes.

[17]:
boxes.append(color_field)
boxes.append(color_young)

Plotting a color-magnitude diagram#

The color-magnitude diagram is now plotted with the plot_color_magnitude function. The list with boxes is provided as argument of the boxes parameter. The list with objects is provided separately as argument of objects. See the API documentation of plot_color_magnitude for further details on the various parameters.

[18]:
fig = plot_color_magnitude(boxes=boxes,
                           objects=objects,
                           mass_labels={'ames-cond': [(3., 'right'), (5., 'right'), (10., 'left'), (20., 'right')],
                                        'ames-dusty': [(10., 'right'), (15., 'left'), (20., 'left')]},
                           teff_labels={'planck': [(1500., 'right'), (2000., 'right'), (3000., 'left')]},
                           companion_labels=False,
                           field_range=('late M', 'late T'),
                           label_x=r'H $-$ L$^\prime$',
                           label_y=r'M$_\mathregular{L\prime}$',
                           xlim=(0.3, 4.),
                           ylim=(15., 7.1),
                           offset=(-0.08, -0.09),
                           legend=(0.04, 0.04),
                           output=None)
Plotting color-magnitude diagram...
../_images/tutorials_color_magnitude_broadband_47_1.png
 [DONE]

The plot_color_magnitude function returned the Figure object of the plot. The functionalities of Matplotlib can be used for further customization of the plot. For example, the axes of the plot are stored at the axes attribute of Figure.

[19]:
fig.axes
[19]:
[<Axes: xlabel='H $-$ L$^\\prime$', ylabel='M$_\\mathregular{L\\prime}$'>,
 <Axes: >]