{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Color-magnitude diagram: broadband filters"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The tutorial shows how to create a color-magnitude diagram which combines the photometry from field and young/low-gravity objects, synthetic photometry computed from isochrones and model spectra, and photometry from directly imaged objects."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Initiating *species*"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import urllib.request\n",
    "import numpy as np\n",
    "import species"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Initiating species v0.1.0... [DONE]\n",
      "Creating species_config.ini... [DONE]\n",
      "Database: /Users/tomasstolker/applications/species/docs/tutorials/species_database.hdf5\n",
      "Data folder: /Users/tomasstolker/applications/species/docs/tutorials/data\n",
      "Working folder: /Users/tomasstolker/applications/species/docs/tutorials\n",
      "Creating species_database.hdf5... [DONE]\n",
      "Creating data folder... [DONE]\n"
     ]
    }
   ],
   "source": [
    "species.SpeciesInit()\n",
    "database = species.Database()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Adding data to the database"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "All available photometric data of directly imaged planets and brown dwarfs is added with `add_companion` by setting `name=None`. These data are extracted from the [dictionary with apparent magnitudes](https://github.com/tomasstolker/species/blob/master/species/data/companions.py) in the `data.companions` module."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Adding filter: LCO/VisAO.Ys... [DONE]\n",
      "Downloading Vega spectrum (270 kB)... [DONE]\n",
      "Adding Vega spectrum... [DONE]\n",
      "Adding filter: Paranal/NACO.J... [DONE]\n",
      "Adding filter: Gemini/NICI.ED286... [DONE]\n",
      "Adding filter: Paranal/NACO.H... [DONE]\n",
      "Adding filter: Paranal/NACO.Ks... [DONE]\n",
      "Adding filter: Paranal/NACO.NB374... [DONE]\n",
      "Adding filter: Paranal/NACO.Lp... [DONE]\n",
      "Adding filter: Paranal/NACO.NB405... [DONE]\n",
      "Adding filter: Paranal/NACO.Mp... [DONE]\n",
      "Adding object: beta Pic b... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_D_H23_2... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_D_H23_3... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_D_K12_1... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_D_K12_2... [DONE]\n",
      "Adding object: HIP 65426 b... [DONE]\n",
      "Adding filter: MKO/NSFCam.J... [DONE]\n",
      "Adding filter: MKO/NSFCam.H... [DONE]\n",
      "Adding filter: MKO/NSFCam.K... [DONE]\n",
      "Adding filter: Keck/NIRC2.Lp... [DONE]\n",
      "Adding filter: Keck/NIRC2.Ms... [DONE]\n",
      "Adding object: 51 Eri b... [DONE]\n",
      "Adding filter: Subaru/CIAO.z... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_B_J... [DONE]\n",
      "Adding filter: Keck/NIRC2.H... [DONE]\n",
      "Adding filter: Keck/NIRC2.Ks... [DONE]\n",
      "Adding object: HR 8799 b... [DONE]\n",
      "Adding object: HR 8799 c... [DONE]\n",
      "Adding object: HR 8799 d... [DONE]\n",
      "Adding object: HR 8799 e... [DONE]\n",
      "Adding filter: Gemini/GPI.H... [DONE]\n",
      "Adding filter: Gemini/GPI.K1... [DONE]\n",
      "Adding object: HD 95086 b... [DONE]\n",
      "Adding object: PDS 70 b... [DONE]\n",
      "Adding object: PDS 70 c... [DONE]\n",
      "Adding filter: HST/NICMOS1.F090M... [DONE]\n",
      "Adding filter: HST/NICMOS1.F110M... [DONE]\n",
      "Adding filter: HST/NICMOS1.F145M... [DONE]\n",
      "Adding filter: HST/NICMOS1.F160W... [DONE]\n",
      "Adding object: 2M1207 b... [DONE]\n",
      "Adding object: AB Pic B... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_B_H... [DONE]\n",
      "Adding object: HD 206893 B... [DONE]\n",
      "Adding filter: HST/WFPC2.f606w... [DONE]\n",
      "Adding filter: HST/WFPC2.f814w... [DONE]\n",
      "Adding filter: HST/NICMOS2.F171M... [DONE]\n",
      "Adding filter: HST/NICMOS2.F190N... [DONE]\n",
      "Adding filter: HST/NICMOS2.F215N... [DONE]\n",
      "Adding filter: Subaru/CIAO.CH4s... [DONE]\n",
      "Adding filter: Subaru/CIAO.K... [DONE]\n",
      "Adding filter: Subaru/CIAO.Lp... [DONE]\n",
      "Adding object: GQ Lup B... [DONE]\n",
      "Adding filter: Paranal/SPHERE.ZIMPOL_R_PRIM... [DONE]\n",
      "Adding filter: Paranal/SPHERE.ZIMPOL_I_PRIM... [DONE]\n",
      "Adding filter: Gemini/NIRI.H2S1v2-1-G0220... [DONE]\n",
      "Adding object: PZ Tel B... [DONE]\n",
      "Adding filter: Subaru/CIAO.J... [DONE]\n",
      "Adding filter: Subaru/CIAO.H... [DONE]\n",
      "Adding filter: Subaru/CIAO.Ks... [DONE]\n",
      "Adding filter: LBT/LMIRCam.M_77K... [DONE]\n",
      "Adding object: kappa And b... [DONE]\n",
      "Adding filter: Keck/NIRC2.J... [DONE]\n",
      "Adding object: ROXs 42 Bb... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_D_Y23_2... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_D_Y23_3... [DONE]\n",
      "Adding filter: Paranal/SPHERE.IRDIS_D_J23_3... [DONE]\n",
      "Adding filter: Subaru/IRCS.Lp... [DONE]\n",
      "Adding object: GJ 504 b... [DONE]\n",
      "Adding filter: Gemini/GMOS-S.z... [DONE]\n",
      "Adding filter: CFHT/Wircam.Y... [DONE]\n",
      "Adding filter: CFHT/Wircam.J... [DONE]\n",
      "Adding filter: CFHT/Wircam.H... [DONE]\n",
      "Adding filter: CFHT/Wircam.Ks... [DONE]\n",
      "Adding filter: WISE/WISE.W1... [DONE]\n",
      "Adding filter: WISE/WISE.W2... [DONE]\n",
      "Adding object: GU Psc b... [DONE]\n",
      "Adding object: 2M0103 ABb... [DONE]\n",
      "Adding filter: Gemini/NIRI.J-G0202w... [DONE]\n",
      "Adding filter: Gemini/NIRI.H-G0203w... [DONE]\n",
      "Adding filter: Gemini/NIRI.K-G0204w... [DONE]\n",
      "Adding filter: Gemini/NIRI.Lprime-G0207w... [DONE]\n",
      "Adding object: 1RXS 1609 B... [DONE]\n",
      "Adding filter: MKO/NSFCam.Kp... [DONE]\n",
      "Adding filter: MKO/NSFCam.Lp... [DONE]\n",
      "Adding object: GSC 06214 B... [DONE]\n"
     ]
    }
   ],
   "source": [
    "database.add_companion(name=None)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The broadband photometry and parallaxes of the [Database of Ultracool Parallaxes](http://www.as.utexas.edu/~tdupuy/plx/Database_of_Ultracool_Parallaxes.html) is added."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading Database of Ultracool Parallaxes (307 kB)... [DONE]\n",
      "Adding Database of Ultracool Parallaxes... [DONE]\n"
     ]
    }
   ],
   "source": [
    "database.add_photometry(phot_library='vlm-plx')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The isochrones from the AMES-Cond and AMES-Dusty evolutionary models are downloaded with `urllib.request`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'data/model.AMES-dusty.M-0.0.NaCo.Vega'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "urllib.request.urlretrieve('https://phoenix.ens-lyon.fr/Grids/AMES-Cond/ISOCHRONES/model.AMES-Cond-2000.M-0.0.NaCo.Vega',\n",
    "                           'data/model.AMES-Cond-2000.M-0.0.NaCo.Vega')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "urllib.request.urlretrieve('https://phoenix.ens-lyon.fr/Grids/AMES-Dusty/ISOCHRONES/model.AMES-dusty.M-0.0.NaCo.Vega',\n",
    "                           'data/model.AMES-dusty.M-0.0.NaCo.Vega')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And added to the HDF5 database."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Adding isochrones: iso_cond... [DONE]\n",
      "Adding isochrones: iso_dusty... [DONE]\n"
     ]
    }
   ],
   "source": [
    "database.add_isochrones(filename='data/model.AMES-Cond-2000.M-0.0.NaCo.Vega',\n",
    "                        tag='iso_cond',\n",
    "                        model='baraffe')\n",
    "\n",
    "database.add_isochrones(filename='data/model.AMES-dusty.M-0.0.NaCo.Vega',\n",
    "                        tag='iso_dusty',\n",
    "                        model='baraffe')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Also the synthetic spectra from the AMES-Cond and AMES-Dusty atmospheric models are dowloaded and added to the database."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading AMES-Cond model spectra (823 MB)... [DONE]\n",
      "Unpacking AMES-Cond model spectra (823 MB)... [DONE]\n",
      "Adding AMES-Cond model spectra... [DONE]                                        \n",
      "Downloading AMES-Dusty model spectra [Fe/H]=0.0 (106 MB)... [DONE]\n",
      "Unpacking AMES-Dusty model spectra [Fe/H]=0.0 (106 MB)... [DONE]\n",
      "Adding AMES-Dusty model spectra... [DONE]                                       \n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/tomasstolker/applications/species/species/util/data_util.py:268: UserWarning: Interpolation is not possible at the edge of the parameter grid. A NaN value is stored for Teff = 4000.0 K.\n",
      "  warnings.warn(f'Interpolation is not possible at the edge of the '\n"
     ]
    }
   ],
   "source": [
    "database.add_model(model='ames-cond',\n",
    "                   wavel_range=(0.5, 10.),\n",
    "                   spec_res=1000.,\n",
    "                   teff_range=(100., 4000.))\n",
    "\n",
    "database.add_model(model='ames-dusty',\n",
    "                   wavel_range=(0.5, 10.),\n",
    "                   spec_res=1000.,\n",
    "                   teff_range=(100., 4000.))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Database content"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Let's have a look at all the data that is stored in the database."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Database content:\n",
      "- filters: <HDF5 group \"/filters\" (10 members)>\n",
      "\t- CFHT: <HDF5 group \"/filters/CFHT\" (4 members)>\n",
      "\t\t- Wircam.H: <HDF5 dataset \"Wircam.H\": shape (2, 747), type \"<f4\">\n",
      "\t\t- Wircam.J: <HDF5 dataset \"Wircam.J\": shape (2, 1077), type \"<f4\">\n",
      "\t\t- Wircam.Ks: <HDF5 dataset \"Wircam.Ks\": shape (2, 791), type \"<f4\">\n",
      "\t\t- Wircam.Y: <HDF5 dataset \"Wircam.Y\": shape (2, 875), type \"<f4\">\n",
      "\t- Gemini: <HDF5 group \"/filters/Gemini\" (9 members)>\n",
      "\t\t- GMOS-S.z: <HDF5 dataset \"GMOS-S.z\": shape (2, 928), type \"<f4\">\n",
      "\t\t- GPI.H: <HDF5 dataset \"GPI.H\": shape (2, 1895), type \"<f4\">\n",
      "\t\t- GPI.K1: <HDF5 dataset \"GPI.K1\": shape (2, 2128), type \"<f4\">\n",
      "\t\t- NICI.ED286: <HDF5 dataset \"NICI.ED286\": shape (2, 387), type \"<f4\">\n",
      "\t\t- NIRI.H-G0203w: <HDF5 dataset \"NIRI.H-G0203w\": shape (2, 368), type \"<f4\">\n",
      "\t\t- NIRI.H2S1v2-1-G0220: <HDF5 dataset \"NIRI.H2S1v2-1-G0220\": shape (2, 129), type \"<f4\">\n",
      "\t\t- NIRI.J-G0202w: <HDF5 dataset \"NIRI.J-G0202w\": shape (2, 213), type \"<f4\">\n",
      "\t\t- NIRI.K-G0204w: <HDF5 dataset \"NIRI.K-G0204w\": shape (2, 423), type \"<f4\">\n",
      "\t\t- NIRI.Lprime-G0207w: <HDF5 dataset \"NIRI.Lprime-G0207w\": shape (2, 933), type \"<f4\">\n",
      "\t- HST: <HDF5 group \"/filters/HST\" (9 members)>\n",
      "\t\t- NICMOS1.F090M: <HDF5 dataset \"NICMOS1.F090M\": shape (2, 633), type \"<f4\">\n",
      "\t\t- NICMOS1.F110M: <HDF5 dataset \"NICMOS1.F110M\": shape (2, 768), type \"<f4\">\n",
      "\t\t- NICMOS1.F145M: <HDF5 dataset \"NICMOS1.F145M\": shape (2, 829), type \"<f4\">\n",
      "\t\t- NICMOS1.F160W: <HDF5 dataset \"NICMOS1.F160W\": shape (2, 1319), type \"<f4\">\n",
      "\t\t- NICMOS2.F171M: <HDF5 dataset \"NICMOS2.F171M\": shape (2, 1226), type \"<f4\">\n",
      "\t\t- NICMOS2.F190N: <HDF5 dataset \"NICMOS2.F190N\": shape (2, 375), type \"<f4\">\n",
      "\t\t- NICMOS2.F215N: <HDF5 dataset \"NICMOS2.F215N\": shape (2, 506), type \"<f4\">\n",
      "\t\t- WFPC2.f606w: <HDF5 dataset \"WFPC2.f606w\": shape (2, 1300), type \"<f4\">\n",
      "\t\t- WFPC2.f814w: <HDF5 dataset \"WFPC2.f814w\": shape (2, 1513), type \"<f4\">\n",
      "\t- Keck: <HDF5 group \"/filters/Keck\" (5 members)>\n",
      "\t\t- NIRC2.H: <HDF5 dataset \"NIRC2.H\": shape (2, 1506), type \"<f4\">\n",
      "\t\t- NIRC2.J: <HDF5 dataset \"NIRC2.J\": shape (2, 1149), type \"<f4\">\n",
      "\t\t- NIRC2.Ks: <HDF5 dataset \"NIRC2.Ks\": shape (2, 1399), type \"<f4\">\n",
      "\t\t- NIRC2.Lp: <HDF5 dataset \"NIRC2.Lp\": shape (2, 1694), type \"<f4\">\n",
      "\t\t- NIRC2.Ms: <HDF5 dataset \"NIRC2.Ms\": shape (2, 627), type \"<f4\">\n",
      "\t- LBT: <HDF5 group \"/filters/LBT\" (1 members)>\n",
      "\t\t- LMIRCam.M_77K: <HDF5 dataset \"LMIRCam.M_77K\": shape (2, 626), type \"<f4\">\n",
      "\t- LCO: <HDF5 group \"/filters/LCO\" (1 members)>\n",
      "\t\t- VisAO.Ys: <HDF5 dataset \"VisAO.Ys\": shape (2, 27), type \"<f4\">\n",
      "\t- MKO: <HDF5 group \"/filters/MKO\" (5 members)>\n",
      "\t\t- NSFCam.H: <HDF5 dataset \"NSFCam.H\": shape (2, 970), type \"<f4\">\n",
      "\t\t- NSFCam.J: <HDF5 dataset \"NSFCam.J\": shape (2, 1253), type \"<f4\">\n",
      "\t\t- NSFCam.K: <HDF5 dataset \"NSFCam.K\": shape (2, 971), type \"<f4\">\n",
      "\t\t- NSFCam.Kp: <HDF5 dataset \"NSFCam.Kp\": shape (2, 998), type \"<f4\">\n",
      "\t\t- NSFCam.Lp: <HDF5 dataset \"NSFCam.Lp\": shape (2, 1242), type \"<f4\">\n",
      "\t- Paranal: <HDF5 group \"/filters/Paranal\" (18 members)>\n",
      "\t\t- NACO.H: <HDF5 dataset \"NACO.H\": shape (2, 23), type \"<f4\">\n",
      "\t\t- NACO.J: <HDF5 dataset \"NACO.J\": shape (2, 20), type \"<f4\">\n",
      "\t\t- NACO.Ks: <HDF5 dataset \"NACO.Ks\": shape (2, 27), type \"<f4\">\n",
      "\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (2, 31), type \"<f4\">\n",
      "\t\t- NACO.Mp: <HDF5 dataset \"NACO.Mp\": shape (2, 18), type \"<f4\">\n",
      "\t\t- NACO.NB374: <HDF5 dataset \"NACO.NB374\": shape (2, 46), type \"<f4\">\n",
      "\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (2, 67), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_B_H: <HDF5 dataset \"SPHERE.IRDIS_B_H\": shape (2, 481), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_B_J: <HDF5 dataset \"SPHERE.IRDIS_B_J\": shape (2, 393), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (2, 113), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (2, 180), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_D_J23_3: <HDF5 dataset \"SPHERE.IRDIS_D_J23_3\": shape (2, 129), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (2, 175), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (2, 191), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_D_Y23_2: <HDF5 dataset \"SPHERE.IRDIS_D_Y23_2\": shape (2, 94), type \"<f4\">\n",
      "\t\t- SPHERE.IRDIS_D_Y23_3: <HDF5 dataset \"SPHERE.IRDIS_D_Y23_3\": shape (2, 89), type \"<f4\">\n",
      "\t\t- SPHERE.ZIMPOL_I_PRIM: <HDF5 dataset \"SPHERE.ZIMPOL_I_PRIM\": shape (2, 189), type \"<f4\">\n",
      "\t\t- SPHERE.ZIMPOL_R_PRIM: <HDF5 dataset \"SPHERE.ZIMPOL_R_PRIM\": shape (2, 169), type \"<f4\">\n",
      "\t- Subaru: <HDF5 group \"/filters/Subaru\" (8 members)>\n",
      "\t\t- CIAO.CH4s: <HDF5 dataset \"CIAO.CH4s\": shape (2, 150), type \"<f4\">\n",
      "\t\t- CIAO.H: <HDF5 dataset \"CIAO.H\": shape (2, 967), type \"<f4\">\n",
      "\t\t- CIAO.J: <HDF5 dataset \"CIAO.J\": shape (2, 1253), type \"<f4\">\n",
      "\t\t- CIAO.K: <HDF5 dataset \"CIAO.K\": shape (2, 958), type \"<f4\">\n",
      "\t\t- CIAO.Ks: <HDF5 dataset \"CIAO.Ks\": shape (2, 200), type \"<f4\">\n",
      "\t\t- CIAO.Lp: <HDF5 dataset \"CIAO.Lp\": shape (2, 1242), type \"<f4\">\n",
      "\t\t- CIAO.z: <HDF5 dataset \"CIAO.z\": shape (2, 200), type \"<f4\">\n",
      "\t\t- IRCS.Lp: <HDF5 dataset \"IRCS.Lp\": shape (2, 1224), type \"<f4\">\n",
      "\t- WISE: <HDF5 group \"/filters/WISE\" (2 members)>\n",
      "\t\t- WISE.W1: <HDF5 dataset \"WISE.W1\": shape (2, 141), type \"<f4\">\n",
      "\t\t- WISE.W2: <HDF5 dataset \"WISE.W2\": shape (2, 168), type \"<f4\">\n",
      "- isochrones: <HDF5 group \"/isochrones\" (2 members)>\n",
      "\t- iso_cond: <HDF5 group \"/isochrones/iso_cond\" (3 members)>\n",
      "\t\t- evolution: <HDF5 dataset \"evolution\": shape (1940, 8), type \"<f4\">\n",
      "\t\t\t- model: baraffe\n",
      "\t\t- filters: <HDF5 dataset \"filters\": shape (38,), type \"|O\">\n",
      "\t\t- magnitudes: <HDF5 dataset \"magnitudes\": shape (1940, 38), type \"<f4\">\n",
      "\t- iso_dusty: <HDF5 group \"/isochrones/iso_dusty\" (3 members)>\n",
      "\t\t- evolution: <HDF5 dataset \"evolution\": shape (1459, 8), type \"<f4\">\n",
      "\t\t\t- model: baraffe\n",
      "\t\t- filters: <HDF5 dataset \"filters\": shape (38,), type \"|O\">\n",
      "\t\t- magnitudes: <HDF5 dataset \"magnitudes\": shape (1459, 38), type \"<f4\">\n",
      "- models: <HDF5 group \"/models\" (2 members)>\n",
      "\t- ames-cond: <HDF5 group \"/models/ames-cond\" (4 members)>\n",
      "\t\t- flux: <HDF5 dataset \"flux\": shape (40, 13, 2998), type \"<f4\">\n",
      "\t\t- logg: <HDF5 dataset \"logg\": shape (13,), type \"<f4\">\n",
      "\t\t- teff: <HDF5 dataset \"teff\": shape (40,), type \"<f4\">\n",
      "\t\t- wavelength: <HDF5 dataset \"wavelength\": shape (2998,), type \"<f4\">\n",
      "\t- ames-dusty: <HDF5 group \"/models/ames-dusty\" (4 members)>\n",
      "\t\t- flux: <HDF5 dataset \"flux\": shape (36, 6, 2998), type \"<f4\">\n",
      "\t\t- logg: <HDF5 dataset \"logg\": shape (6,), type \"<f4\">\n",
      "\t\t- teff: <HDF5 dataset \"teff\": shape (36,), type \"<f4\">\n",
      "\t\t- wavelength: <HDF5 dataset \"wavelength\": shape (2998,), type \"<f4\">\n",
      "- objects: <HDF5 group \"/objects\" (22 members)>\n",
      "\t- 1RXS 1609 B: <HDF5 group \"/objects/1RXS 1609 B\" (2 members)>\n",
      "\t\t- Gemini: <HDF5 group \"/objects/1RXS 1609 B/Gemini\" (4 members)>\n",
      "\t\t\t- NIRI.H-G0203w: <HDF5 dataset \"NIRI.H-G0203w\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRI.J-G0202w: <HDF5 dataset \"NIRI.J-G0202w\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRI.K-G0204w: <HDF5 dataset \"NIRI.K-G0204w\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRI.Lprime-G0207w: <HDF5 dataset \"NIRI.Lprime-G0207w\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- 2M0103 ABb: <HDF5 group \"/objects/2M0103 ABb\" (2 members)>\n",
      "\t\t- Paranal: <HDF5 group \"/objects/2M0103 ABb/Paranal\" (4 members)>\n",
      "\t\t\t- NACO.H: <HDF5 dataset \"NACO.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.J: <HDF5 dataset \"NACO.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Ks: <HDF5 dataset \"NACO.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- 2M1207 b: <HDF5 group \"/objects/2M1207 b\" (3 members)>\n",
      "\t\t- HST: <HDF5 group \"/objects/2M1207 b/HST\" (4 members)>\n",
      "\t\t\t- NICMOS1.F090M: <HDF5 dataset \"NICMOS1.F090M\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NICMOS1.F110M: <HDF5 dataset \"NICMOS1.F110M\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NICMOS1.F145M: <HDF5 dataset \"NICMOS1.F145M\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NICMOS1.F160W: <HDF5 dataset \"NICMOS1.F160W\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/2M1207 b/Paranal\" (4 members)>\n",
      "\t\t\t- NACO.H: <HDF5 dataset \"NACO.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.J: <HDF5 dataset \"NACO.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Ks: <HDF5 dataset \"NACO.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- 51 Eri b: <HDF5 group \"/objects/51 Eri b\" (4 members)>\n",
      "\t\t- Keck: <HDF5 group \"/objects/51 Eri b/Keck\" (2 members)>\n",
      "\t\t\t- NIRC2.Lp: <HDF5 dataset \"NIRC2.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ms: <HDF5 dataset \"NIRC2.Ms\": shape (4,), type \"<f4\">\n",
      "\t\t- MKO: <HDF5 group \"/objects/51 Eri b/MKO\" (3 members)>\n",
      "\t\t\t- NSFCam.H: <HDF5 dataset \"NSFCam.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NSFCam.J: <HDF5 dataset \"NSFCam.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NSFCam.K: <HDF5 dataset \"NSFCam.K\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/51 Eri b/Paranal\" (2 members)>\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- AB Pic B: <HDF5 group \"/objects/AB Pic B\" (2 members)>\n",
      "\t\t- Paranal: <HDF5 group \"/objects/AB Pic B/Paranal\" (3 members)>\n",
      "\t\t\t- NACO.H: <HDF5 dataset \"NACO.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.J: <HDF5 dataset \"NACO.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Ks: <HDF5 dataset \"NACO.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- GJ 504 b: <HDF5 group \"/objects/GJ 504 b\" (3 members)>\n",
      "\t\t- Paranal: <HDF5 group \"/objects/GJ 504 b/Paranal\" (6 members)>\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_J23_3: <HDF5 dataset \"SPHERE.IRDIS_D_J23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_Y23_2: <HDF5 dataset \"SPHERE.IRDIS_D_Y23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_Y23_3: <HDF5 dataset \"SPHERE.IRDIS_D_Y23_3\": shape (4,), type \"<f4\">\n",
      "\t\t- Subaru: <HDF5 group \"/objects/GJ 504 b/Subaru\" (5 members)>\n",
      "\t\t\t- CIAO.CH4s: <HDF5 dataset \"CIAO.CH4s\": shape (4,), type \"<f4\">\n",
      "\t\t\t- CIAO.H: <HDF5 dataset \"CIAO.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- CIAO.J: <HDF5 dataset \"CIAO.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- CIAO.Ks: <HDF5 dataset \"CIAO.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- IRCS.Lp: <HDF5 dataset \"IRCS.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- GQ Lup B: <HDF5 group \"/objects/GQ Lup B\" (3 members)>\n",
      "\t\t- HST: <HDF5 group \"/objects/GQ Lup B/HST\" (5 members)>\n",
      "\t\t\t- NICMOS2.F171M: <HDF5 dataset \"NICMOS2.F171M\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NICMOS2.F190N: <HDF5 dataset \"NICMOS2.F190N\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NICMOS2.F215N: <HDF5 dataset \"NICMOS2.F215N\": shape (4,), type \"<f4\">\n",
      "\t\t\t- WFPC2.f606w: <HDF5 dataset \"WFPC2.f606w\": shape (4,), type \"<f4\">\n",
      "\t\t\t- WFPC2.f814w: <HDF5 dataset \"WFPC2.f814w\": shape (4,), type \"<f4\">\n",
      "\t\t- Subaru: <HDF5 group \"/objects/GQ Lup B/Subaru\" (3 members)>\n",
      "\t\t\t- CIAO.CH4s: <HDF5 dataset \"CIAO.CH4s\": shape (4,), type \"<f4\">\n",
      "\t\t\t- CIAO.K: <HDF5 dataset \"CIAO.K\": shape (4,), type \"<f4\">\n",
      "\t\t\t- CIAO.Lp: <HDF5 dataset \"CIAO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- GSC 06214 B: <HDF5 group \"/objects/GSC 06214 B\" (3 members)>\n",
      "\t\t- LBT: <HDF5 group \"/objects/GSC 06214 B/LBT\" (1 members)>\n",
      "\t\t\t- LMIRCam.M_77K: <HDF5 dataset \"LMIRCam.M_77K\": shape (4,), type \"<f4\">\n",
      "\t\t- MKO: <HDF5 group \"/objects/GSC 06214 B/MKO\" (4 members)>\n",
      "\t\t\t- NSFCam.H: <HDF5 dataset \"NSFCam.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NSFCam.J: <HDF5 dataset \"NSFCam.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NSFCam.Kp: <HDF5 dataset \"NSFCam.Kp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NSFCam.Lp: <HDF5 dataset \"NSFCam.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- GU Psc b: <HDF5 group \"/objects/GU Psc b\" (4 members)>\n",
      "\t\t- CFHT: <HDF5 group \"/objects/GU Psc b/CFHT\" (4 members)>\n",
      "\t\t\t- Wircam.H: <HDF5 dataset \"Wircam.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- Wircam.J: <HDF5 dataset \"Wircam.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- Wircam.Ks: <HDF5 dataset \"Wircam.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- Wircam.Y: <HDF5 dataset \"Wircam.Y\": shape (4,), type \"<f4\">\n",
      "\t\t- Gemini: <HDF5 group \"/objects/GU Psc b/Gemini\" (1 members)>\n",
      "\t\t\t- GMOS-S.z: <HDF5 dataset \"GMOS-S.z\": shape (4,), type \"<f4\">\n",
      "\t\t- WISE: <HDF5 group \"/objects/GU Psc b/WISE\" (2 members)>\n",
      "\t\t\t- WISE.W1: <HDF5 dataset \"WISE.W1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- WISE.W2: <HDF5 dataset \"WISE.W2\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- HD 206893 B: <HDF5 group \"/objects/HD 206893 B\" (2 members)>\n",
      "\t\t- Paranal: <HDF5 group \"/objects/HD 206893 B/Paranal\" (6 members)>\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Mp: <HDF5 dataset \"NACO.Mp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_B_H: <HDF5 dataset \"SPHERE.IRDIS_B_H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- HD 95086 b: <HDF5 group \"/objects/HD 95086 b\" (3 members)>\n",
      "\t\t- Gemini: <HDF5 group \"/objects/HD 95086 b/Gemini\" (2 members)>\n",
      "\t\t\t- GPI.H: <HDF5 dataset \"GPI.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- GPI.K1: <HDF5 dataset \"GPI.K1\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/HD 95086 b/Paranal\" (1 members)>\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- HIP 65426 b: <HDF5 group \"/objects/HIP 65426 b\" (2 members)>\n",
      "\t\t- Paranal: <HDF5 group \"/objects/HIP 65426 b/Paranal\" (7 members)>\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Mp: <HDF5 dataset \"NACO.Mp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- HR 8799 b: <HDF5 group \"/objects/HR 8799 b\" (4 members)>\n",
      "\t\t- Keck: <HDF5 group \"/objects/HR 8799 b/Keck\" (3 members)>\n",
      "\t\t\t- NIRC2.H: <HDF5 dataset \"NIRC2.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ks: <HDF5 dataset \"NIRC2.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ms: <HDF5 dataset \"NIRC2.Ms\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/HR 8799 b/Paranal\" (7 members)>\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_B_J: <HDF5 dataset \"SPHERE.IRDIS_B_J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (4,), type \"<f4\">\n",
      "\t\t- Subaru: <HDF5 group \"/objects/HR 8799 b/Subaru\" (1 members)>\n",
      "\t\t\t- CIAO.z: <HDF5 dataset \"CIAO.z\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- HR 8799 c: <HDF5 group \"/objects/HR 8799 c\" (3 members)>\n",
      "\t\t- Keck: <HDF5 group \"/objects/HR 8799 c/Keck\" (3 members)>\n",
      "\t\t\t- NIRC2.H: <HDF5 dataset \"NIRC2.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ks: <HDF5 dataset \"NIRC2.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ms: <HDF5 dataset \"NIRC2.Ms\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/HR 8799 c/Paranal\" (7 members)>\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_B_J: <HDF5 dataset \"SPHERE.IRDIS_B_J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- HR 8799 d: <HDF5 group \"/objects/HR 8799 d\" (3 members)>\n",
      "\t\t- Keck: <HDF5 group \"/objects/HR 8799 d/Keck\" (3 members)>\n",
      "\t\t\t- NIRC2.H: <HDF5 dataset \"NIRC2.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ks: <HDF5 dataset \"NIRC2.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ms: <HDF5 dataset \"NIRC2.Ms\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/HR 8799 d/Paranal\" (7 members)>\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_B_J: <HDF5 dataset \"SPHERE.IRDIS_B_J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- HR 8799 e: <HDF5 group \"/objects/HR 8799 e\" (3 members)>\n",
      "\t\t- Keck: <HDF5 group \"/objects/HR 8799 e/Keck\" (1 members)>\n",
      "\t\t\t- NIRC2.Ks: <HDF5 dataset \"NIRC2.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/HR 8799 e/Paranal\" (7 members)>\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_B_J: <HDF5 dataset \"SPHERE.IRDIS_B_J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- PDS 70 b: <HDF5 group \"/objects/PDS 70 b\" (2 members)>\n",
      "\t\t- Paranal: <HDF5 group \"/objects/PDS 70 b/Paranal\" (4 members)>\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- PDS 70 c: <HDF5 group \"/objects/PDS 70 c\" (2 members)>\n",
      "\t\t- Paranal: <HDF5 group \"/objects/PDS 70 c/Paranal\" (1 members)>\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- PZ Tel B: <HDF5 group \"/objects/PZ Tel B\" (3 members)>\n",
      "\t\t- Gemini: <HDF5 group \"/objects/PZ Tel B/Gemini\" (2 members)>\n",
      "\t\t\t- NICI.ED286: <HDF5 dataset \"NICI.ED286\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRI.H2S1v2-1-G0220: <HDF5 dataset \"NIRI.H2S1v2-1-G0220\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/PZ Tel B/Paranal\" (12 members)>\n",
      "\t\t\t- NACO.H: <HDF5 dataset \"NACO.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.J: <HDF5 dataset \"NACO.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Ks: <HDF5 dataset \"NACO.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Mp: <HDF5 dataset \"NACO.Mp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_2: <HDF5 dataset \"SPHERE.IRDIS_D_H23_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_H23_3: <HDF5 dataset \"SPHERE.IRDIS_D_H23_3\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_1: <HDF5 dataset \"SPHERE.IRDIS_D_K12_1\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.IRDIS_D_K12_2: <HDF5 dataset \"SPHERE.IRDIS_D_K12_2\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.ZIMPOL_I_PRIM: <HDF5 dataset \"SPHERE.ZIMPOL_I_PRIM\": shape (4,), type \"<f4\">\n",
      "\t\t\t- SPHERE.ZIMPOL_R_PRIM: <HDF5 dataset \"SPHERE.ZIMPOL_R_PRIM\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- ROXs 42 Bb: <HDF5 group \"/objects/ROXs 42 Bb\" (2 members)>\n",
      "\t\t- Keck: <HDF5 group \"/objects/ROXs 42 Bb/Keck\" (5 members)>\n",
      "\t\t\t- NIRC2.H: <HDF5 dataset \"NIRC2.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.J: <HDF5 dataset \"NIRC2.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ks: <HDF5 dataset \"NIRC2.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Lp: <HDF5 dataset \"NIRC2.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NIRC2.Ms: <HDF5 dataset \"NIRC2.Ms\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- beta Pic b: <HDF5 group \"/objects/beta Pic b\" (4 members)>\n",
      "\t\t- Gemini: <HDF5 group \"/objects/beta Pic b/Gemini\" (1 members)>\n",
      "\t\t\t- NICI.ED286: <HDF5 dataset \"NICI.ED286\": shape (4,), type \"<f4\">\n",
      "\t\t- LCO: <HDF5 group \"/objects/beta Pic b/LCO\" (1 members)>\n",
      "\t\t\t- VisAO.Ys: <HDF5 dataset \"VisAO.Ys\": shape (4,), type \"<f4\">\n",
      "\t\t- Paranal: <HDF5 group \"/objects/beta Pic b/Paranal\" (7 members)>\n",
      "\t\t\t- NACO.H: <HDF5 dataset \"NACO.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.J: <HDF5 dataset \"NACO.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Ks: <HDF5 dataset \"NACO.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Lp: <HDF5 dataset \"NACO.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.Mp: <HDF5 dataset \"NACO.Mp\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB374: <HDF5 dataset \"NACO.NB374\": shape (4,), type \"<f4\">\n",
      "\t\t\t- NACO.NB405: <HDF5 dataset \"NACO.NB405\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "\t- kappa And b: <HDF5 group \"/objects/kappa And b\" (4 members)>\n",
      "\t\t- Keck: <HDF5 group \"/objects/kappa And b/Keck\" (1 members)>\n",
      "\t\t\t- NIRC2.Lp: <HDF5 dataset \"NIRC2.Lp\": shape (4,), type \"<f4\">\n",
      "\t\t- LBT: <HDF5 group \"/objects/kappa And b/LBT\" (1 members)>\n",
      "\t\t\t- LMIRCam.M_77K: <HDF5 dataset \"LMIRCam.M_77K\": shape (4,), type \"<f4\">\n",
      "\t\t- Subaru: <HDF5 group \"/objects/kappa And b/Subaru\" (3 members)>\n",
      "\t\t\t- CIAO.H: <HDF5 dataset \"CIAO.H\": shape (4,), type \"<f4\">\n",
      "\t\t\t- CIAO.J: <HDF5 dataset \"CIAO.J\": shape (4,), type \"<f4\">\n",
      "\t\t\t- CIAO.Ks: <HDF5 dataset \"CIAO.Ks\": shape (4,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (2,), type \"<f4\">\n",
      "- photometry: <HDF5 group \"/photometry\" (1 members)>\n",
      "\t- vlm-plx: <HDF5 group \"/photometry/vlm-plx\" (6 members)>\n",
      "\t\t- 2MASS: <HDF5 group \"/photometry/vlm-plx/2MASS\" (3 members)>\n",
      "\t\t\t- 2MASS.H: <HDF5 dataset \"2MASS.H\": shape (618,), type \"<f4\">\n",
      "\t\t\t- 2MASS.J: <HDF5 dataset \"2MASS.J\": shape (618,), type \"<f4\">\n",
      "\t\t\t- 2MASS.Ks: <HDF5 dataset \"2MASS.Ks\": shape (618,), type \"<f4\">\n",
      "\t\t- MKO: <HDF5 group \"/photometry/vlm-plx/MKO\" (6 members)>\n",
      "\t\t\t- NSFCam.H: <HDF5 dataset \"NSFCam.H\": shape (618,), type \"<f4\">\n",
      "\t\t\t- NSFCam.J: <HDF5 dataset \"NSFCam.J\": shape (618,), type \"<f4\">\n",
      "\t\t\t- NSFCam.K: <HDF5 dataset \"NSFCam.K\": shape (618,), type \"<f4\">\n",
      "\t\t\t- NSFCam.Lp: <HDF5 dataset \"NSFCam.Lp\": shape (618,), type \"<f4\">\n",
      "\t\t\t- NSFCam.Mp: <HDF5 dataset \"NSFCam.Mp\": shape (618,), type \"<f4\">\n",
      "\t\t\t- NSFCam.Y: <HDF5 dataset \"NSFCam.Y\": shape (618,), type \"<f4\">\n",
      "\t\t- distance: <HDF5 dataset \"distance\": shape (618,), type \"<f4\">\n",
      "\t\t- flag: <HDF5 dataset \"flag\": shape (618,), type \"|O\">\n",
      "\t\t- name: <HDF5 dataset \"name\": shape (618,), type \"|O\">\n",
      "\t\t- sptype: <HDF5 dataset \"sptype\": shape (618,), type \"|O\">\n",
      "- spectra: <HDF5 group \"/spectra\" (1 members)>\n",
      "\t- calibration: <HDF5 group \"/spectra/calibration\" (1 members)>\n",
      "\t\t- vega: <HDF5 dataset \"vega\": shape (3, 8827), type \"<f4\">\n"
     ]
    }
   ],
   "source": [
    "database.list_content()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Synthetic photometry from isochrones"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Magnitudes are available in the isochrone data which 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 isochrones and the model spectra."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The isochrones will be iterpolated for three different ages and the synthetic photometry is computed for 100 logarithmically spaced masses."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "ages = [20., 100., 1000.]  # [Myr]\n",
    "masses = np.logspace(-1., 4., 100)  # [Mjup]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Object of `ReadIsochones` are initiated for both the AMES-Cond and AMES-Dusty isochrones."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "read_iso_cond = species.ReadIsochrone(tag='iso_cond')\n",
    "read_iso_dusty = species.ReadIsochrone(tag='iso_dusty')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The colors and magnitudes are computed by chosing the corresponding model spectra that are stored in the database. The results of two models are stored in `ColorMagBox` objects for the three different ages."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "boxes = []\n",
    "\n",
    "for item in ages:\n",
    "\n",
    "    modelcolor1 = read_iso_cond.get_color_magnitude(age=item,\n",
    "                                                    masses=masses,\n",
    "                                                    model='ames-cond',\n",
    "                                                    filters_color=('MKO/NSFCam.H', 'MKO/NSFCam.Lp'),\n",
    "                                                    filter_mag='MKO/NSFCam.Lp')\n",
    "\n",
    "    modelcolor2 = read_iso_dusty.get_color_magnitude(age=item,\n",
    "                                                     masses=masses,\n",
    "                                                     model='ames-dusty',\n",
    "                                                     filters_color=('MKO/NSFCam.H', 'MKO/NSFCam.Lp'),\n",
    "                                                     filter_mag='MKO/NSFCam.Lp')\n",
    "\n",
    "    boxes.append(modelcolor1)\n",
    "    boxes.append(modelcolor2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Photometry of directly imaged objects"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Before selecting the photometric data of the directly imaged planets and brown dwarfs, let's see which objects and magnitudes are stored in the database."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Object name = beta Pic b\n",
      "Distance [pc] = 19.75 +/- 0.13\n",
      "LCO/VisAO.Ys [mag] = 15.53 +/- 0.34\n",
      "Paranal/NACO.J [mag] = 14.11 +/- 0.21\n",
      "Gemini/NICI.ED286 [mag] = 13.18 +/- 0.15\n",
      "Paranal/NACO.H [mag] = 13.32 +/- 0.14\n",
      "Paranal/NACO.Ks [mag] = 12.64 +/- 0.11\n",
      "Paranal/NACO.NB374 [mag] = 11.25 +/- 0.23\n",
      "Paranal/NACO.Lp [mag] = 11.3 +/- 0.06\n",
      "Paranal/NACO.NB405 [mag] = 10.98 +/- 0.05\n",
      "Paranal/NACO.Mp [mag] = 11.1 +/- 0.12\n",
      "\n",
      "Object name = HIP 65426 b\n",
      "Distance [pc] = 109.21 +/- 0.75\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 17.94 +/- 0.05\n",
      "Paranal/SPHERE.IRDIS_D_H23_3 [mag] = 17.58 +/- 0.06\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 17.01 +/- 0.09\n",
      "Paranal/SPHERE.IRDIS_D_K12_2 [mag] = 16.79 +/- 0.09\n",
      "Paranal/NACO.Lp [mag] = 15.33 +/- 0.12\n",
      "Paranal/NACO.NB405 [mag] = 15.23 +/- 0.22\n",
      "Paranal/NACO.Mp [mag] = 14.65 +/- 0.29\n",
      "\n",
      "Object name = 51 Eri b\n",
      "Distance [pc] = 29.78 +/- 0.12\n",
      "MKO/NSFCam.J [mag] = 19.04 +/- 0.4\n",
      "MKO/NSFCam.H [mag] = 18.99 +/- 0.21\n",
      "MKO/NSFCam.K [mag] = 18.67 +/- 0.19\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 18.41 +/- 0.26\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 17.55 +/- 0.14\n",
      "Keck/NIRC2.Lp [mag] = 16.2 +/- 0.11\n",
      "Keck/NIRC2.Ms [mag] = 16.1 +/- 0.5\n",
      "\n",
      "Object name = HR 8799 b\n",
      "Distance [pc] = 41.29 +/- 0.15\n",
      "Subaru/CIAO.z [mag] = 21.22 +/- 0.29\n",
      "Paranal/SPHERE.IRDIS_B_J [mag] = 19.78 +/- 0.09\n",
      "Keck/NIRC2.H [mag] = 18.05 +/- 0.09\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 18.08 +/- 0.14\n",
      "Paranal/SPHERE.IRDIS_D_H23_3 [mag] = 17.78 +/- 0.1\n",
      "Keck/NIRC2.Ks [mag] = 17.03 +/- 0.08\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 17.15 +/- 0.06\n",
      "Paranal/SPHERE.IRDIS_D_K12_2 [mag] = 16.97 +/- 0.09\n",
      "Paranal/NACO.Lp [mag] = 15.52 +/- 0.1\n",
      "Paranal/NACO.NB405 [mag] = 14.82 +/- 0.18\n",
      "Keck/NIRC2.Ms [mag] = 16.05 +/- 0.3\n",
      "\n",
      "Object name = HR 8799 c\n",
      "Distance [pc] = 41.29 +/- 0.15\n",
      "Paranal/SPHERE.IRDIS_B_J [mag] = 18.6 +/- 0.13\n",
      "Keck/NIRC2.H [mag] = 17.06 +/- 0.13\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 17.09 +/- 0.12\n",
      "Paranal/SPHERE.IRDIS_D_H23_3 [mag] = 16.78 +/- 0.1\n",
      "Keck/NIRC2.Ks [mag] = 16.11 +/- 0.08\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 16.19 +/- 0.05\n",
      "Paranal/SPHERE.IRDIS_D_K12_2 [mag] = 15.86 +/- 0.07\n",
      "Paranal/NACO.Lp [mag] = 14.65 +/- 0.11\n",
      "Paranal/NACO.NB405 [mag] = 13.97 +/- 0.11\n",
      "Keck/NIRC2.Ms [mag] = 15.03 +/- 0.14\n",
      "\n",
      "Object name = HR 8799 d\n",
      "Distance [pc] = 41.29 +/- 0.15\n",
      "Paranal/SPHERE.IRDIS_B_J [mag] = 18.59 +/- 0.37\n",
      "Keck/NIRC2.H [mag] = 16.71 +/- 0.24\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 17.02 +/- 0.17\n",
      "Paranal/SPHERE.IRDIS_D_H23_3 [mag] = 16.85 +/- 0.16\n",
      "Keck/NIRC2.Ks [mag] = 16.09 +/- 0.12\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 16.2 +/- 0.07\n",
      "Paranal/SPHERE.IRDIS_D_K12_2 [mag] = 15.84 +/- 0.1\n",
      "Paranal/NACO.Lp [mag] = 14.55 +/- 0.14\n",
      "Paranal/NACO.NB405 [mag] = 13.87 +/- 0.15\n",
      "Keck/NIRC2.Ms [mag] = 14.65 +/- 0.35\n",
      "\n",
      "Object name = HR 8799 e\n",
      "Distance [pc] = 41.29 +/- 0.15\n",
      "Paranal/SPHERE.IRDIS_B_J [mag] = 18.4 +/- 0.21\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 16.91 +/- 0.2\n",
      "Paranal/SPHERE.IRDIS_D_H23_3 [mag] = 16.68 +/- 0.21\n",
      "Keck/NIRC2.Ks [mag] = 15.91 +/- 0.22\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 16.12 +/- 0.1\n",
      "Paranal/SPHERE.IRDIS_D_K12_2 [mag] = 15.82 +/- 0.11\n",
      "Paranal/NACO.Lp [mag] = 14.49 +/- 0.21\n",
      "Paranal/NACO.NB405 [mag] = 13.72 +/- 0.2\n",
      "\n",
      "Object name = HD 95086 b\n",
      "Distance [pc] = 86.44 +/- 0.24\n",
      "Gemini/GPI.H [mag] = 20.51 +/- 0.25\n",
      "Gemini/GPI.K1 [mag] = 18.99 +/- 0.2\n",
      "Paranal/NACO.Lp [mag] = 16.27 +/- 0.19\n",
      "\n",
      "Object name = PDS 70 b\n",
      "Distance [pc] = 113.43 +/- 0.52\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 17.94 +/- 0.24\n",
      "Paranal/SPHERE.IRDIS_D_H23_3 [mag] = 17.95 +/- 0.17\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 16.65 +/- 0.06\n",
      "Paranal/SPHERE.IRDIS_D_K12_2 [mag] = 16.44 +/- 0.05\n",
      "\n",
      "Object name = PDS 70 c\n",
      "Distance [pc] = 113.43 +/- 0.52\n",
      "Paranal/NACO.NB405 [mag] = 15.05 +/- 0.59\n",
      "\n",
      "Object name = 2M1207 b\n",
      "Distance [pc] = 64.42 +/- 0.65\n",
      "HST/NICMOS1.F090M [mag] = 22.58 +/- 0.35\n",
      "HST/NICMOS1.F110M [mag] = 20.61 +/- 0.15\n",
      "HST/NICMOS1.F145M [mag] = 19.05 +/- 0.03\n",
      "HST/NICMOS1.F160W [mag] = 18.27 +/- 0.02\n",
      "Paranal/NACO.J [mag] = 20.0 +/- 0.2\n",
      "Paranal/NACO.H [mag] = 18.09 +/- 0.21\n",
      "Paranal/NACO.Ks [mag] = 16.93 +/- 0.11\n",
      "Paranal/NACO.Lp [mag] = 15.28 +/- 0.14\n",
      "\n",
      "Object name = AB Pic B\n",
      "Distance [pc] = 50.12 +/- 0.07\n",
      "Paranal/NACO.J [mag] = 16.18 +/- 0.1\n",
      "Paranal/NACO.H [mag] = 14.69 +/- 0.1\n",
      "Paranal/NACO.Ks [mag] = 14.14 +/- 0.08\n",
      "\n",
      "Object name = HD 206893 B\n",
      "Distance [pc] = 40.81 +/- 0.11\n",
      "Paranal/SPHERE.IRDIS_B_H [mag] = 16.79 +/- 0.06\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 15.2 +/- 0.1\n",
      "Paranal/SPHERE.IRDIS_D_K12_2 [mag] = 14.88 +/- 0.09\n",
      "Paranal/NACO.Lp [mag] = 13.79 +/- 0.31\n",
      "Paranal/NACO.NB405 [mag] = 13.16 +/- 0.34\n",
      "Paranal/NACO.Mp [mag] = 12.77 +/- 0.27\n",
      "\n",
      "Object name = GQ Lup B\n",
      "Distance [pc] = 151.82 +/- 1.1\n",
      "HST/WFPC2.f606w [mag] = 19.19 +/- 0.07\n",
      "HST/WFPC2.f814w [mag] = 17.67 +/- 0.05\n",
      "HST/NICMOS2.F171M [mag] = 13.84 +/- 0.13\n",
      "HST/NICMOS2.F190N [mag] = 14.08 +/- 0.2\n",
      "HST/NICMOS2.F215N [mag] = 13.4 +/- 0.15\n",
      "Subaru/CIAO.CH4s [mag] = 13.76 +/- 0.26\n",
      "Subaru/CIAO.K [mag] = 13.37 +/- 0.12\n",
      "Subaru/CIAO.Lp [mag] = 12.44 +/- 0.22\n",
      "\n",
      "Object name = PZ Tel B\n",
      "Distance [pc] = 47.13 +/- 0.13\n",
      "Paranal/SPHERE.ZIMPOL_R_PRIM [mag] = 17.84 +/- 0.31\n",
      "Paranal/SPHERE.ZIMPOL_I_PRIM [mag] = 15.16 +/- 0.12\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 11.78 +/- 0.19\n",
      "Paranal/SPHERE.IRDIS_D_H23_3 [mag] = 11.65 +/- 0.19\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 11.56 +/- 0.09\n",
      "Paranal/SPHERE.IRDIS_D_K12_2 [mag] = 11.29 +/- 0.1\n",
      "Paranal/NACO.J [mag] = 12.47 +/- 0.2\n",
      "Paranal/NACO.H [mag] = 11.93 +/- 0.14\n",
      "Paranal/NACO.Ks [mag] = 11.53 +/- 0.07\n",
      "Paranal/NACO.Lp [mag] = 11.04 +/- 0.22\n",
      "Paranal/NACO.NB405 [mag] = 10.94 +/- 0.07\n",
      "Paranal/NACO.Mp [mag] = 10.93 +/- 0.03\n",
      "Gemini/NICI.ED286 [mag] = 11.68 +/- 0.14\n",
      "Gemini/NIRI.H2S1v2-1-G0220 [mag] = 11.39 +/- 0.14\n",
      "\n",
      "Object name = kappa And b\n",
      "Distance [pc] = 50.06 +/- 0.87\n",
      "Subaru/CIAO.J [mag] = 15.86 +/- 0.21\n",
      "Subaru/CIAO.H [mag] = 14.95 +/- 0.13\n",
      "Subaru/CIAO.Ks [mag] = 14.32 +/- 0.09\n",
      "Keck/NIRC2.Lp [mag] = 13.12 +/- 0.1\n",
      "LBT/LMIRCam.M_77K [mag] = 13.3 +/- 0.3\n",
      "\n",
      "Object name = ROXs 42 Bb\n",
      "Distance [pc] = 144.16 +/- 1.54\n",
      "Keck/NIRC2.J [mag] = 16.91 +/- 0.11\n",
      "Keck/NIRC2.H [mag] = 15.88 +/- 0.05\n",
      "Keck/NIRC2.Ks [mag] = 15.01 +/- 0.06\n",
      "Keck/NIRC2.Lp [mag] = 13.97 +/- 0.06\n",
      "Keck/NIRC2.Ms [mag] = 14.01 +/- 0.23\n",
      "\n",
      "Object name = GJ 504 b\n",
      "Distance [pc] = 17.54 +/- 0.08\n",
      "Paranal/SPHERE.IRDIS_D_Y23_2 [mag] = 20.98 +/- 0.2\n",
      "Paranal/SPHERE.IRDIS_D_Y23_3 [mag] = 20.14 +/- 0.09\n",
      "Paranal/SPHERE.IRDIS_D_J23_3 [mag] = 19.01 +/- 0.17\n",
      "Paranal/SPHERE.IRDIS_D_H23_2 [mag] = 18.95 +/- 0.3\n",
      "Paranal/SPHERE.IRDIS_D_H23_3 [mag] = 21.81 +/- 0.35\n",
      "Paranal/SPHERE.IRDIS_D_K12_1 [mag] = 18.77 +/- 0.2\n",
      "Subaru/CIAO.J [mag] = 19.78 +/- 0.1\n",
      "Subaru/CIAO.H [mag] = 20.01 +/- 0.14\n",
      "Subaru/CIAO.Ks [mag] = 19.38 +/- 0.11\n",
      "Subaru/CIAO.CH4s [mag] = 19.58 +/- 0.13\n",
      "Subaru/IRCS.Lp [mag] = 16.7 +/- 0.17\n",
      "\n",
      "Object name = GU Psc b\n",
      "Distance [pc] = 47.61 +/- 0.16\n",
      "Gemini/GMOS-S.z [mag] = 21.75 +/- 0.07\n",
      "CFHT/Wircam.Y [mag] = 19.4 +/- 0.05\n",
      "CFHT/Wircam.J [mag] = 18.12 +/- 0.03\n",
      "CFHT/Wircam.H [mag] = 17.7 +/- 0.03\n",
      "CFHT/Wircam.Ks [mag] = 17.4 +/- 0.03\n",
      "WISE/WISE.W1 [mag] = 17.17 +/- 0.33\n",
      "WISE/WISE.W2 [mag] = 15.41 +/- 0.22\n",
      "\n",
      "Object name = 2M0103 ABb\n",
      "Distance [pc] = 47.2 +/- 3.1\n",
      "Paranal/NACO.J [mag] = 15.47 +/- 0.3\n",
      "Paranal/NACO.H [mag] = 14.27 +/- 0.2\n",
      "Paranal/NACO.Ks [mag] = 13.67 +/- 0.2\n",
      "Paranal/NACO.Lp [mag] = 12.67 +/- 0.1\n",
      "\n",
      "Object name = 1RXS 1609 B\n",
      "Distance [pc] = 139.67 +/- 1.33\n",
      "Gemini/NIRI.J-G0202w [mag] = 17.9 +/- 0.12\n",
      "Gemini/NIRI.H-G0203w [mag] = 16.87 +/- 0.07\n",
      "Gemini/NIRI.K-G0204w [mag] = 16.17 +/- 0.18\n",
      "Gemini/NIRI.Lprime-G0207w [mag] = 14.8 +/- 0.3\n",
      "\n",
      "Object name = GSC 06214 B\n",
      "Distance [pc] = 108.84 +/- 0.51\n",
      "MKO/NSFCam.J [mag] = 16.24 +/- 0.04\n",
      "MKO/NSFCam.H [mag] = 15.55 +/- 0.04\n",
      "MKO/NSFCam.Kp [mag] = 14.95 +/- 0.05\n",
      "MKO/NSFCam.Lp [mag] = 13.75 +/- 0.07\n",
      "LBT/LMIRCam.M_77K [mag] = 13.75 +/- 0.3\n",
      "\n"
     ]
    }
   ],
   "source": [
    "database.list_companions()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A list with object names and filters for the colors and magnitudes is created."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "objects = [('HR 8799 b', 'Keck/NIRC2.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('HR 8799 c', 'Keck/NIRC2.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('HR 8799 d', 'Keck/NIRC2.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('HR 8799 e', 'Paranal/SPHERE.IRDIS_D_H23_2', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('kappa And b', 'Subaru/CIAO.H', 'Keck/NIRC2.Lp', 'Keck/NIRC2.Lp'),\n",
    "           ('GSC 06214 B', 'MKO/NSFCam.H', 'MKO/NSFCam.Lp', 'MKO/NSFCam.Lp'),\n",
    "           ('ROXs 42 Bb', 'Keck/NIRC2.H', 'Keck/NIRC2.Lp', 'Keck/NIRC2.Lp'),\n",
    "           ('51 Eri b', 'MKO/NSFCam.H', 'Keck/NIRC2.Lp', 'Keck/NIRC2.Lp'),\n",
    "           ('2M1207 b', 'Paranal/NACO.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('2M0103 ABb', 'Paranal/NACO.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('1RXS 1609 B', 'Gemini/NIRI.H-G0203w', 'Gemini/NIRI.Lprime-G0207w', 'Gemini/NIRI.Lprime-G0207w'),\n",
    "           ('beta Pic b', 'Paranal/NACO.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('HIP 65426 b', 'Paranal/SPHERE.IRDIS_D_H23_2', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('PZ Tel B', 'Paranal/NACO.H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp'),\n",
    "           ('HD 206893 B', 'Paranal/SPHERE.IRDIS_B_H', 'Paranal/NACO.Lp', 'Paranal/NACO.Lp')]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Reading color-magnitude data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The colors and magnitude of the Database of Ultracool Parallaxes are read from the HDF5 database by first creating an object of `ReadColorMagnitude`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "colormag = species.ReadColorMagnitude(library='vlm-plx',\n",
    "                                      filters_color=('MKO/NSFCam.H', 'MKO/NSFCam.Lp'),\n",
    "                                      filter_mag='MKO/NSFCam.Lp')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "And then extracting the `ColorMagBox` objects for field and young/low-gravity objects separately."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "color_field = colormag.get_color_magnitude(object_type='field')\n",
    "color_young = colormag.get_color_magnitude(object_type='young')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plotting a color-magnitude diagram"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The color-magnitude diagram is plotted with the `plot_color_magnitude` function. The boxes with photometric data are provided as list to the `colorbox` parameter. The boxes with synthetic photometry are provided to the `models` parameter."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Plotting color-magnitude diagram: color_mag.png... [DONE]\n"
     ]
    }
   ],
   "source": [
    "species.plot_color_magnitude(colorbox=[color_field, color_young],\n",
    "                             objects=objects,\n",
    "                             models=boxes,\n",
    "                             mass_labels=[1., 3., 5., 10., 20., 50., 100., 200.],\n",
    "                             companion_labels=False,\n",
    "                             field_range=('late M', 'late T'),\n",
    "                             label_x='H - L$^\\prime$ [mag]',\n",
    "                             label_y='M$_\\mathregular{L\\prime}$ [mag]',\n",
    "                             xlim=(0.3, 4.),\n",
    "                             ylim=(15., 7.1),\n",
    "                             offset=(-0.08, -0.09),\n",
    "                             legend=(0.04, 0.04),\n",
    "                             output='color_mag.png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 54948 characters]\n",
      "text/plain": [
       "<IPython.core.display.Image object>"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from IPython.display import Image\n",
    "Image('color_mag.png')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
