NASA_ADS Module example code not working
- Dominant language
- Python
- Stars
- 791
- Forks
- 451
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 4
Description
The code in the [doc](https://astroquery.readthedocs.io/en/latest/nasa_ads/nasa_ads.html) is not working as is, but we need some modification to make it run properly:
```python
from astroquery import nasa_ads as na
# if you don't store your token as an environment variable
# or in a file, give it here
# na.ADS.TOKEN = 'your-token-goes-here'
# by default, the top 10 records are returned, sorted in
# reverse chronological order. This can be changed
# change the number of rows returned
na.ADS.NROWS = 20
# change the sort order
na.ADS.SORT = 'bibcode desc'
# change the fields that are returned (enter as strings in a list)
na.ADS.ADS_FIELDS = ['author','title','abstract','pubdate','bibcode']
# the "^" makes ADS to return only papers where Persson
# is first author
results = na.ADS.query_simple('^Persson Origin of water\
around deeply embedded low-mass protostars')
# to sort after publication date
results.sort(['pubdate'])
# get the title of the last hit
title = results[-1]['title'][0]
# printout the authors of the last hit
print(results[-1]['author'])
```
I added ``'bibcode'`` to ``na.ADS.ADS_FIELDS`` and removed an erroneous `` results[0].title`` at the end of `` around deeply embedded low-mass protostars')`` line.
Contributor guide
Assessment
This issue has not been assessed yet.