Skip to content

Commit

Permalink
commit updates for new release 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
aschleg committed Jan 1, 2020
1 parent 156d277 commit bb01e17
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 51 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG.md
@@ -1,9 +1,14 @@
# Version History

# Version 0.2.3
## Version 0.2.4

- Adds `exoplanet` function for providing access to [NASA's Exoplanet Archive](https://exoplanetarchive.ipac.caltech.edu/index.html>).

## Version 0.2.3

- Fixes bug in `nhats` function when `return_df` parameter is set to `True`.

# Version 0.2.2
## Version 0.2.2

- An optional `return_df` parameter has been implemented in the listed functions below. When set
as `True`, the resulting JSON data will be coerced into a pandas DataFrame to allow easier and more straightforward
Expand All @@ -19,11 +24,11 @@
- General bug fixes
* The `sentry` function should now operate correctly when passing a `des` or `spk` parameter.

# Version 0.2.1
## Version 0.2.1

- Added `sentry` function that wraps the [CNEOS Sentry System API](https://cneos.jpl.nasa.gov/sentry/) for providing
Near-Earth Object impact risk assessment data.

# Version 0.2.0
## Version 0.2.0

Initial release.
Binary file modified docs/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/build/doctrees/versions.doctree
Binary file not shown.
6 changes: 6 additions & 0 deletions docs/build/html/_sources/versions.rst.txt
Expand Up @@ -4,6 +4,12 @@
Version History
===============

Version 0.2.4
-------------

- Adds :code:`exoplanet` function for providing access to
`NASA's Exoplanet Archive <https://exoplanetarchive.ipac.caltech.edu/index.html>`_.

Version 0.2.3
-------------

Expand Down
2 changes: 1 addition & 1 deletion docs/build/html/searchindex.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions docs/build/html/versions.html
Expand Up @@ -88,6 +88,7 @@
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="api.html">API Reference</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Version History</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#version-0-2-4">Version 0.2.4</a></li>
<li class="toctree-l2"><a class="reference internal" href="#version-0-2-3">Version 0.2.3</a></li>
<li class="toctree-l2"><a class="reference internal" href="#version-0-2-2">Version 0.2.2</a></li>
<li class="toctree-l2"><a class="reference internal" href="#version-0-2-1">Version 0.2.1</a></li>
Expand Down Expand Up @@ -160,6 +161,13 @@

<div class="section" id="version-history">
<span id="versions"></span><h1>Version History<a class="headerlink" href="#version-history" title="Permalink to this headline"></a></h1>
<div class="section" id="version-0-2-4">
<h2>Version 0.2.4<a class="headerlink" href="#version-0-2-4" title="Permalink to this headline"></a></h2>
<ul class="simple">
<li>Adds <code class="code docutils literal notranslate"><span class="pre">exoplanet</span></code> function for providing access to
<a class="reference external" href="https://exoplanetarchive.ipac.caltech.edu/index.html">NASA’s Exoplanet Archive</a>.</li>
</ul>
</div>
<div class="section" id="version-0-2-3">
<h2>Version 0.2.3<a class="headerlink" href="#version-0-2-3" title="Permalink to this headline"></a></h2>
<ul class="simple">
Expand Down
6 changes: 6 additions & 0 deletions docs/source/versions.rst
Expand Up @@ -4,6 +4,12 @@
Version History
===============

Version 0.2.4
-------------

- Adds :code:`exoplanet` function for providing access to
`NASA's Exoplanet Archive <https://exoplanetarchive.ipac.caltech.edu/index.html>`_.

Version 0.2.3
-------------

Expand Down
2 changes: 1 addition & 1 deletion nasapy/__init__.py
Expand Up @@ -5,4 +5,4 @@
"""

from nasapy.api import tle, close_approach, fireballs, media_search, media_asset_captions, media_asset_metadata, \
media_asset_manifest, Nasa, mission_design, julian_date, nhats, scout, sentry
media_asset_manifest, Nasa, mission_design, julian_date, nhats, scout, sentry, exoplanets
86 changes: 67 additions & 19 deletions nasapy/api.py
Expand Up @@ -1328,25 +1328,6 @@ def mars_rover(self, sol=None, earth_date=None, camera='all', rover='curiosity',

return r.json()['photos']

def exoplanets(self, table, select, count, colset, where, order, ra, dec):
host = 'https://exoplanetarchive.ipac.caltech.edu/cgi-bin/nstedAPI/nph-nstedAPI?'

r = requests.get(host,
params={
'api_key': self.__api_key,
'table': table,
'select': select,
'count': count,
'colset': colset,
'where': where,
'order': order,
'ra': ra,
'dec': dec,
'format': 'json'
})

return r

def genelab_search(self, term=None, database='cgene', page=0, size=25, sort=None, order='desc',
ffield=None, fvalue=None):
r"""
Expand Down Expand Up @@ -1539,6 +1520,73 @@ def techport(self, project_id=None, last_updated=None, return_format='json'):
# return r


def exoplanets(table='exoplanets', select=None, count=None, colset=None, where=None, order=None, ra=None, dec=None,
aliastable=None, objname=None, return_df=False):
r"""
Provides access to NASA's Exoplanet Archive.
Parameters
----------
table : str, default 'exoplanets'
Specifies which table to query.
select : str
Specifies which columns within the chosen table to return. Multiple columns can be returned by comma-separating
the column names and distinct values can be returned by adding 'distinct ' in front of the desired column
names.
count : str
Can be used to return the number of rows which fulfill the given query, including queries using where
clauses or cone searches.
colset : str
Returns a set of pre-defined columns that have been created by the archive. Currently, this keyword is only
used by the Composite Planet Data ('compositepars') table.
where : str
Takes a SQL-like query string to filter the returned results. Please see the examples section for more.
order : str
Returns the data sorted by the specified column. Append ' desc' for descending or ' asc' for ascending values.
ra : str
Specifies an area of the sky to search for all objects within that area.
dec : str
Specifies an area of the sky to search for all objects within that area.
aliastable : str
Requests a list of aliases for a particular confirmed planet.
objname : str
When parameter `aliastable` is specified, `objname` must also be passed with the planet's name.
return_df : bool, default False
If True, returns the JSON data as a pandas DataFrame.
Returns
-------
dict or pandas DataFrame
If parameter `return_df` is `True`, a pandas DataFrame of the returned results. Otherwise, a dictionary
representing the returned JSON data from the API is returned.
Examples
--------
"""
host = 'https://exoplanetarchive.ipac.caltech.edu/cgi-bin/nstedAPI/nph-nstedAPI?'

r = requests.get(host,
params={
'table': table,
'select': select,
'count': count,
'colset': colset,
'where': where,
'order': order,
'ra': ra,
'dec': dec,
'aliastable': aliastable,
'objname': objname,
'format': 'json'
}).json()

if return_df:
r = DataFrame(r)

return r


def tle(search_satellite=None, satellite_number=None):
r"""
Returns two-line element set records provided by CelesTrak. A two-line element set (TLE) is a data format
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -4,7 +4,7 @@

setup(
name='nasapy',
version='0.2.3',
version='0.2.4',
author='Aaron Schlegel',
author_email='aaron@aaronschlegel.me',
description='Python wrapper for the NASA API',
Expand Down
49 changes: 24 additions & 25 deletions tests/test_api.py
@@ -1,4 +1,3 @@
import datetime
import os
import pandas as pd

Expand All @@ -18,6 +17,25 @@
key = os.environ.get('NASA_KEY')


def nasa_api():
nasa = Nasa(key=key)

return nasa


nasa = nasa_api()


def test_julian_date():
j1 = julian_date(year=2019, modified=False)
j2 = julian_date(year=2019)
j3 = julian_date()

assert j1 == 2458467.5
assert j2 == 58467.0
assert isinstance(j3, (int, float))


@vcr.use_cassette('tests/cassettes/media_search.yml')
def test_media_search():
s = media_search(query='apollo 11', description='moon landing')
Expand Down Expand Up @@ -290,30 +308,6 @@ def test_scout():
scout(return_df='true')


@vcr.use_cassette('tests/cassettes/sentry.yml')
def test_sentry():
pass


def test_julian_date():
j1 = julian_date(year=2019, modified=False)
j2 = julian_date(year=2019)
j3 = julian_date()

assert j1 == 2458467.5
assert j2 == 58467.0
assert isinstance(j3, (int, float))


def nasa_api():
nasa = Nasa(key=key)

return nasa


nasa = nasa_api()


@vcr.use_cassette('tests/cassettes/initialization.yml')
def test_initialization():
nasa_demo = Nasa()
Expand Down Expand Up @@ -650,3 +644,8 @@ def test_techport():
@vcr.use_cassette('tests/cassettes/exoplanets.yml')
def test_exoplanets():
pass


@vcr.use_cassette('tests/cassettes/sentry.yml')
def test_sentry():
pass

0 comments on commit bb01e17

Please sign in to comment.