Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Obtain discovery dates for all confirmed exoplanets in the NASA Exoplanet Archive
"""Obtain discovery dates for all confirmed exoplanets.
This script combines the NASA Exoplanet Archive and ADS API to obtain the
publication date for the discovery paper of all the confirmed exoplanets.
Author: Geert Barentsen
import requests
import pandas as pd
# Configure your personal ADS API key below
ADS_TOKEN = open('/home/gb/.ads/dev_key', 'r').readlines()[0].strip()
# Extract the discovery bibcode for all confirmed exoplanets in the archive
planets = pd.read_csv('nexsci-confirmed-planets-20160913.csv')
bibcodes = []
for ref in planets.pl_disc_reflink:
if 'bibcode' in ref:
bibcode = ref.split('bibcode=')[1].split(' ')[0]
elif '/abs/' in ref:
bibcode = ref.split('/abs/')[1].split(' ')[0]
planets['discovery_bibcode'] = bibcodes
# Fetch the publication date for these bibcodes from the ADS API
query_data = "bibcode\n"+"\n".join(planets['discovery_bibcode'].unique())
r ='',
params={'q': '*:*', 'wt': 'json', 'fq': '{!bitset}',
'fl': 'bibcode,pubdate', 'rows': 2*len(bibcodes)},
headers={'Authorization': 'Bearer ' + ADS_TOKEN},
ads_response = pd.DataFrame(r.json()['response']['docs'])
# Merge the discovery dates with the original exoplanet archive table
planets_with_discovery_dates = planets.merge(ads_response,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.