Skip to content

Instantly share code, notes, and snippets.

@smoh
Created August 10, 2020 11:28
Show Gist options
  • Save smoh/d9f498a218c019211be85be30ad0333a to your computer and use it in GitHub Desktop.
Save smoh/d9f498a218c019211be85be30ad0333a to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Querying NASA Exoplanet Archive for all available stellar ages"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"- https://astroquery.readthedocs.io/en/latest/nasa_exoplanet_archive/nasa_exoplanet_archive.html\n",
"- https://exoplanetarchive.ipac.caltech.edu/docs/program_interfaces.html\n",
"\n",
"The relevant table is `exomultpars`: \"Extended Planet Data\"\n",
"> All sets of planet and stellar parameters for confirmed planets and hosts in the archive\n",
"\n",
"The schema is described in https://exoplanetarchive.ipac.caltech.edu/docs/API_exomultpars_columns.html"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from astroquery.nasa_exoplanet_archive import NasaExoplanetArchive"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"r = NasaExoplanetArchive.query_criteria(table='exomultpars', select='mpl_hostname,mst_age,mpl_reflink' )\n",
"df = r.to_pandas()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"14041 rows\n"
]
}
],
"source": [
"print(len(r), 'rows')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Even the full table is 14k lines so you might just download the full table (no need for astroquery). There is link to download the full table in various formats on [this page](https://exoplanetarchive.ipac.caltech.edu/docs/program_interfaces.html).\n",
"\n",
"But let's just check that we have all ages of Kepler-39:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>mpl_hostname</th>\n",
" <th>mst_age</th>\n",
" <th>mpl_reflink</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>3218</th>\n",
" <td>Kepler-39</td>\n",
" <td>4.40</td>\n",
" <td>&lt;a refstr=BOUCHY_ET_AL__2011 href=https://ui.a...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3621</th>\n",
" <td>Kepler-39</td>\n",
" <td>2.10</td>\n",
" <td>&lt;a refstr=BONOMO_ET_AL__2015 href=https://ui.a...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4477</th>\n",
" <td>Kepler-39</td>\n",
" <td>4.40</td>\n",
" <td>&lt;a refstr=SOUTHWORTH_2012 href=https://ui.adsa...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6719</th>\n",
" <td>Kepler-39</td>\n",
" <td>3.02</td>\n",
" <td>&lt;a refstr=MORTON_ET_AL__2016 href=https://ui.a...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7391</th>\n",
" <td>Kepler-39</td>\n",
" <td>0.00</td>\n",
" <td>&lt;a refstr=BERGER_ET_AL__2018 href=https://ui.a...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9121</th>\n",
" <td>Kepler-39</td>\n",
" <td>0.00</td>\n",
" <td>&lt;a refstr=HOLCZER_ET_AL__2016 href=https://ui....</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10527</th>\n",
" <td>Kepler-39</td>\n",
" <td>0.00</td>\n",
" <td>&lt;a refstr=GAJDO_SCARON__ET_AL__2019 href=https...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11646</th>\n",
" <td>Kepler-39</td>\n",
" <td>2.10</td>\n",
" <td>&lt;a refstr=BONOMO_ET_AL__2017 href=https://ui.a...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" mpl_hostname mst_age mpl_reflink\n",
"3218 Kepler-39 4.40 <a refstr=BOUCHY_ET_AL__2011 href=https://ui.a...\n",
"3621 Kepler-39 2.10 <a refstr=BONOMO_ET_AL__2015 href=https://ui.a...\n",
"4477 Kepler-39 4.40 <a refstr=SOUTHWORTH_2012 href=https://ui.adsa...\n",
"6719 Kepler-39 3.02 <a refstr=MORTON_ET_AL__2016 href=https://ui.a...\n",
"7391 Kepler-39 0.00 <a refstr=BERGER_ET_AL__2018 href=https://ui.a...\n",
"9121 Kepler-39 0.00 <a refstr=HOLCZER_ET_AL__2016 href=https://ui....\n",
"10527 Kepler-39 0.00 <a refstr=GAJDO_SCARON__ET_AL__2019 href=https...\n",
"11646 Kepler-39 2.10 <a refstr=BONOMO_ET_AL__2017 href=https://ui.a..."
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[df['mpl_hostname'] == 'Kepler-39']"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Check how many age estimates are available for each star:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Kepler-11 49\n",
"Kepler-32 46\n",
"Kepler-186 46\n",
"55 Cnc 41\n",
"Kepler-296 39\n",
" ..\n",
"K2-265 1\n",
"HD 55696 1\n",
"K2-173 1\n",
"HAT-P-67 1\n",
"HIP 8541 1\n",
"Name: mpl_hostname, Length: 3115, dtype: int64"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df['mpl_hostname'].value_counts()"
]
}
],
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment