{"action":"created","comment":{"url":"https://api.github.com/repos/astropy/astropy/pulls/comments/63205271","id":63205271,"diff_hunk":"@@ -0,0 +1,276 @@\n+# Licensed under a 3-clause BSD style license - see LICENSE.rst\n+\"\"\"\n+This module contains convenience functions for retrieving solar system\n+ephemerides from jplephem.\n+\"\"\"\n+\n+from __future__ import (absolute_import, division, print_function,\n+                        unicode_literals)\n+\n+import numpy as np\n+import six\n+from .sky_coordinate import SkyCoord\n+from ..utils.data import download_file\n+from .. import units as u\n+from ..constants import c as speed_of_light\n+from .representation import CartesianRepresentation\n+from .builtin_frames import GCRS, ICRS\n+from .builtin_frames.utils import get_jd12, cartrepr_from_matmul\n+from .. import _erfa\n+\n+__all__ = [\"get_body\", \"get_moon\", \"get_barycentric_body_position\"]\n+\n+KERNEL = None\n+\n+\"\"\"\n+each value in the BODIES dictionary a list of kernel pairs needed\n+to find the barycentric position of that object from the JPL kernel.\n+\"\"\"\n+BODIES = {'sun': [(0, 10)],\n+          'mercury': [(0, 1), (1, 199)],\n+          'venus': [(0, 2), (2, 299)],\n+          'earth-moon-barycenter': [(0, 3)],\n+          'earth':  [(0, 3), (3, 399)],\n+          'moon': [(0, 3), (3, 301)],\n+          'mars': [(0, 4)],\n+          'jupiter': [(0, 5)],\n+          'saturn': [(0, 6)],\n+          'uranus': [(0, 7)],\n+          'neptune': [(0, 8)],\n+          'pluto': [(0, 9)]}\n+\n+\n+def _download_spk_file(show_progress=True):\n+    \"\"\"\n+    Get the Satellite Planet Kernel (SPK) file `de430.bsp` from NASA JPL.\n+\n+    Download the file from the JPL webpage once and subsequently access a\n+    cached copy. This file is ~120 MB, and covers years ~1550-2650 CE [1]_.\n+\n+    .. [1] http://naif.jpl.nasa.gov/pub/naif/generic_kernels/spk/planets/aareadme_de430-de431.txt\n+    \"\"\"\n+    de430_url = ('http://naif.jpl.nasa.gov/pub/naif/'\n+                 'generic_kernels/spk/planets/de430.bsp')\n+    return download_file(de430_url, cache=True, show_progress=show_progress)","path":"astropy/coordinates/solar_system.py","position":54,"original_position":54,"commit_id":"17ed2d428318afeab4cb3f3fa21e314709068b51","original_commit_id":"48f676554d4b627259b116d637953c398e22c9ef","user":{"login":"mhvk","id":2789820,"avatar_url":"https://avatars.githubusercontent.com/u/2789820?v=3","gravatar_id":"","url":"https://api.github.com/users/mhvk","html_url":"https://github.com/mhvk","followers_url":"https://api.github.com/users/mhvk/followers","following_url":"https://api.github.com/users/mhvk/following{/other_user}","gists_url":"https://api.github.com/users/mhvk/gists{/gist_id}","starred_url":"https://api.github.com/users/mhvk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhvk/subscriptions","organizations_url":"https://api.github.com/users/mhvk/orgs","repos_url":"https://api.github.com/users/mhvk/repos","events_url":"https://api.github.com/users/mhvk/events{/privacy}","received_events_url":"https://api.github.com/users/mhvk/received_events","type":"User","site_admin":false},"body":"These should not be changed; rather a new `de*` solution would be published. Indeed, for this reason I would suggest to eventually make the file used an option (but this can be done later; I'd also like `erfa.plan94` to be an option)","created_at":"2016-05-13T15:44:58Z","updated_at":"2016-05-13T15:44:58Z","html_url":"https://github.com/astropy/astropy/pull/4890#discussion_r63205271","pull_request_url":"https://api.github.com/repos/astropy/astropy/pulls/4890","_links":{"self":{"href":"https://api.github.com/repos/astropy/astropy/pulls/comments/63205271"},"html":{"href":"https://github.com/astropy/astropy/pull/4890#discussion_r63205271"},"pull_request":{"href":"https://api.github.com/repos/astropy/astropy/pulls/4890"}}},"pull_request":{"url":"https://api.github.com/repos/astropy/astropy/pulls/4890","id":69976587,"html_url":"https://github.com/astropy/astropy/pull/4890","diff_url":"https://github.com/astropy/astropy/pull/4890.diff","patch_url":"https://github.com/astropy/astropy/pull/4890.patch","issue_url":"https://api.github.com/repos/astropy/astropy/issues/4890","number":4890,"state":"open","locked":false,"title":"Solar system and lunar ephemerides via jplephem take 2","user":{"login":"StuartLittlefair","id":4570807,"avatar_url":"https://avatars.githubusercontent.com/u/4570807?v=3","gravatar_id":"","url":"https://api.github.com/users/StuartLittlefair","html_url":"https://github.com/StuartLittlefair","followers_url":"https://api.github.com/users/StuartLittlefair/followers","following_url":"https://api.github.com/users/StuartLittlefair/following{/other_user}","gists_url":"https://api.github.com/users/StuartLittlefair/gists{/gist_id}","starred_url":"https://api.github.com/users/StuartLittlefair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StuartLittlefair/subscriptions","organizations_url":"https://api.github.com/users/StuartLittlefair/orgs","repos_url":"https://api.github.com/users/StuartLittlefair/repos","events_url":"https://api.github.com/users/StuartLittlefair/events{/privacy}","received_events_url":"https://api.github.com/users/StuartLittlefair/received_events","type":"User","site_admin":false},"body":"This PR supersedes #4746. @bmorris3 's description of that PR is included here, slightly modified.\r\n\r\nThis PR implements an interface for grabbing solar system ephemerides from [jplehem](https://pypi.python.org/pypi/jplephem) (MIT licensed), after caching a copy of the DE430 table (see the jplephem docs for info). There are three new public functions in this PR. The two expected to see most use are ```get_moon(time, [location])``` and ```get_body(time, body_key, [location])```. Both return SkyCoord objects with GCRS frames, the former for Earth's moon and the latter for the Sun and solar system \"planets\" Mercury through Pluto inclusive. The final new functions is ```get_barycentric_body_position(time, body_key)``` which returns a CartesianRepresentation of the ICRS coordinate of the solar system body in question.\r\n\r\nHere are the new functions in action:\r\n\r\n```python\r\nIn [1]: from astropy.coordinates import (get_moon, get_body, EarthLocation,\r\n                                                              get_barycentric_body_position)\r\nIn [2]: from astropy.time import Time\r\nIn [6]: loc = EarthLocation.of_site('Apache Point')\r\nIn [7]: moon = get_moon(Time.now(), loc)\r\nIn [8]: moon\r\nOut[8]:\r\n<SkyCoord (GCRS: obstime=2016-03-29 06:35:36.927857, obsgeoloc=[-1463969.30185172 -5166673.34223433  3434985.71204565] m, obsgeovel=[ 0.  0.  0.] m / s): (ra, dec, distance) in (deg, deg, km)\r\n    (250.94788165, -17.04585998, 400244.30166804)>\r\n\r\nIn [9]: jupiter = get_body(Time.now(), 'jupiter', loc)\r\nIn [10]: jupiter\r\nOut[10]:\r\n<SkyCoord (GCRS: obstime=2016-03-29 06:36:28.310851, obsgeoloc=[-1463969.30185172 -5166673.34223433  3434985.71204565] m, obsgeovel=[ 0.  0.  0.] m / s): (ra, dec, distance) in (deg, deg, km)\r\n    (167.22360841, 7.07220939, 673151288.66240811)>\r\nIn [11]: icrs_moon = get_barycentric_body_position(Time.now(), 'moon')\r\nIn [12]: icrs_moon\r\nOut[12]: \r\n<CartesianRepresentation (x, y, z) in km\r\n    (-90980973.95347136, -110026376.34185831, -47742071.3962695)>\r\n```\r\n\r\nI am comparing the outputs to [JPL Horizons](http://ssd.jpl.nasa.gov/horizons.cgi) and [Skyfield](http://rhodesmill.org/skyfield/). Comparisons against JPL Horizons are awkward to get right because the ra and dec returned are not in the GCRS coordinate frame but are w.r.t to the Earth's true equator and poles. You can get the same results from Skyfield py passing epoch='date' to the radec function. I made a brief wrapper function to convert to ra and dec w.r.t to Earth's true equator and poles for comparison.\r\n\r\nFor geocentric observers I get compatible answers (to <1 arcsec) to both Horizons and Skyfield. The situation is worse when we have a non-geocentric observer. Errors can be as large as 1 degree for the Moon, but are much smaller for planets. I believe this is a bug in the astropy transformation chain for GCRS frames. I am shortly about to submit another pull request to fix that.\r\n\r\n(This PR addresses #3219, #2244, #4269 and overlaps in functionality with PRs #4724, #4736.)","created_at":"2016-05-13T10:44:53Z","updated_at":"2016-05-13T15:44:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"25a629acb73192d2a83fd7143268e884bb5cc405","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/astropy/astropy/pulls/4890/commits","review_comments_url":"https://api.github.com/repos/astropy/astropy/pulls/4890/comments","review_comment_url":"https://api.github.com/repos/astropy/astropy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/4890/comments","statuses_url":"https://api.github.com/repos/astropy/astropy/statuses/17ed2d428318afeab4cb3f3fa21e314709068b51","head":{"label":"StuartLittlefair:solarsystem","ref":"solarsystem","sha":"17ed2d428318afeab4cb3f3fa21e314709068b51","user":{"login":"StuartLittlefair","id":4570807,"avatar_url":"https://avatars.githubusercontent.com/u/4570807?v=3","gravatar_id":"","url":"https://api.github.com/users/StuartLittlefair","html_url":"https://github.com/StuartLittlefair","followers_url":"https://api.github.com/users/StuartLittlefair/followers","following_url":"https://api.github.com/users/StuartLittlefair/following{/other_user}","gists_url":"https://api.github.com/users/StuartLittlefair/gists{/gist_id}","starred_url":"https://api.github.com/users/StuartLittlefair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StuartLittlefair/subscriptions","organizations_url":"https://api.github.com/users/StuartLittlefair/orgs","repos_url":"https://api.github.com/users/StuartLittlefair/repos","events_url":"https://api.github.com/users/StuartLittlefair/events{/privacy}","received_events_url":"https://api.github.com/users/StuartLittlefair/received_events","type":"User","site_admin":false},"repo":{"id":34852236,"name":"astropy","full_name":"StuartLittlefair/astropy","owner":{"login":"StuartLittlefair","id":4570807,"avatar_url":"https://avatars.githubusercontent.com/u/4570807?v=3","gravatar_id":"","url":"https://api.github.com/users/StuartLittlefair","html_url":"https://github.com/StuartLittlefair","followers_url":"https://api.github.com/users/StuartLittlefair/followers","following_url":"https://api.github.com/users/StuartLittlefair/following{/other_user}","gists_url":"https://api.github.com/users/StuartLittlefair/gists{/gist_id}","starred_url":"https://api.github.com/users/StuartLittlefair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StuartLittlefair/subscriptions","organizations_url":"https://api.github.com/users/StuartLittlefair/orgs","repos_url":"https://api.github.com/users/StuartLittlefair/repos","events_url":"https://api.github.com/users/StuartLittlefair/events{/privacy}","received_events_url":"https://api.github.com/users/StuartLittlefair/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/StuartLittlefair/astropy","description":"Repository for the Astropy core package","fork":true,"url":"https://api.github.com/repos/StuartLittlefair/astropy","forks_url":"https://api.github.com/repos/StuartLittlefair/astropy/forks","keys_url":"https://api.github.com/repos/StuartLittlefair/astropy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/StuartLittlefair/astropy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/StuartLittlefair/astropy/teams","hooks_url":"https://api.github.com/repos/StuartLittlefair/astropy/hooks","issue_events_url":"https://api.github.com/repos/StuartLittlefair/astropy/issues/events{/number}","events_url":"https://api.github.com/repos/StuartLittlefair/astropy/events","assignees_url":"https://api.github.com/repos/StuartLittlefair/astropy/assignees{/user}","branches_url":"https://api.github.com/repos/StuartLittlefair/astropy/branches{/branch}","tags_url":"https://api.github.com/repos/StuartLittlefair/astropy/tags","blobs_url":"https://api.github.com/repos/StuartLittlefair/astropy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/StuartLittlefair/astropy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/StuartLittlefair/astropy/git/refs{/sha}","trees_url":"https://api.github.com/repos/StuartLittlefair/astropy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/StuartLittlefair/astropy/statuses/{sha}","languages_url":"https://api.github.com/repos/StuartLittlefair/astropy/languages","stargazers_url":"https://api.github.com/repos/StuartLittlefair/astropy/stargazers","contributors_url":"https://api.github.com/repos/StuartLittlefair/astropy/contributors","subscribers_url":"https://api.github.com/repos/StuartLittlefair/astropy/subscribers","subscription_url":"https://api.github.com/repos/StuartLittlefair/astropy/subscription","commits_url":"https://api.github.com/repos/StuartLittlefair/astropy/commits{/sha}","git_commits_url":"https://api.github.com/repos/StuartLittlefair/astropy/git/commits{/sha}","comments_url":"https://api.github.com/repos/StuartLittlefair/astropy/comments{/number}","issue_comment_url":"https://api.github.com/repos/StuartLittlefair/astropy/issues/comments{/number}","contents_url":"https://api.github.com/repos/StuartLittlefair/astropy/contents/{+path}","compare_url":"https://api.github.com/repos/StuartLittlefair/astropy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/StuartLittlefair/astropy/merges","archive_url":"https://api.github.com/repos/StuartLittlefair/astropy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/StuartLittlefair/astropy/downloads","issues_url":"https://api.github.com/repos/StuartLittlefair/astropy/issues{/number}","pulls_url":"https://api.github.com/repos/StuartLittlefair/astropy/pulls{/number}","milestones_url":"https://api.github.com/repos/StuartLittlefair/astropy/milestones{/number}","notifications_url":"https://api.github.com/repos/StuartLittlefair/astropy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/StuartLittlefair/astropy/labels{/name}","releases_url":"https://api.github.com/repos/StuartLittlefair/astropy/releases{/id}","deployments_url":"https://api.github.com/repos/StuartLittlefair/astropy/deployments","created_at":"2015-04-30T12:02:25Z","updated_at":"2016-04-25T08:51:05Z","pushed_at":"2016-05-13T15:19:35Z","git_url":"git://github.com/StuartLittlefair/astropy.git","ssh_url":"git@github.com:StuartLittlefair/astropy.git","clone_url":"https://github.com/StuartLittlefair/astropy.git","svn_url":"https://github.com/StuartLittlefair/astropy","homepage":"www.astropy.org","size":45260,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"astropy:master","ref":"master","sha":"1551fe56d5cc03791f7c855ea1efb67261e456f3","user":{"login":"astropy","id":847984,"avatar_url":"https://avatars.githubusercontent.com/u/847984?v=3","gravatar_id":"","url":"https://api.github.com/users/astropy","html_url":"https://github.com/astropy","followers_url":"https://api.github.com/users/astropy/followers","following_url":"https://api.github.com/users/astropy/following{/other_user}","gists_url":"https://api.github.com/users/astropy/gists{/gist_id}","starred_url":"https://api.github.com/users/astropy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astropy/subscriptions","organizations_url":"https://api.github.com/users/astropy/orgs","repos_url":"https://api.github.com/users/astropy/repos","events_url":"https://api.github.com/users/astropy/events{/privacy}","received_events_url":"https://api.github.com/users/astropy/received_events","type":"Organization","site_admin":false},"repo":{"id":2081289,"name":"astropy","full_name":"astropy/astropy","owner":{"login":"astropy","id":847984,"avatar_url":"https://avatars.githubusercontent.com/u/847984?v=3","gravatar_id":"","url":"https://api.github.com/users/astropy","html_url":"https://github.com/astropy","followers_url":"https://api.github.com/users/astropy/followers","following_url":"https://api.github.com/users/astropy/following{/other_user}","gists_url":"https://api.github.com/users/astropy/gists{/gist_id}","starred_url":"https://api.github.com/users/astropy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astropy/subscriptions","organizations_url":"https://api.github.com/users/astropy/orgs","repos_url":"https://api.github.com/users/astropy/repos","events_url":"https://api.github.com/users/astropy/events{/privacy}","received_events_url":"https://api.github.com/users/astropy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/astropy/astropy","description":"Repository for the Astropy core package","fork":false,"url":"https://api.github.com/repos/astropy/astropy","forks_url":"https://api.github.com/repos/astropy/astropy/forks","keys_url":"https://api.github.com/repos/astropy/astropy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/astropy/astropy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/astropy/astropy/teams","hooks_url":"https://api.github.com/repos/astropy/astropy/hooks","issue_events_url":"https://api.github.com/repos/astropy/astropy/issues/events{/number}","events_url":"https://api.github.com/repos/astropy/astropy/events","assignees_url":"https://api.github.com/repos/astropy/astropy/assignees{/user}","branches_url":"https://api.github.com/repos/astropy/astropy/branches{/branch}","tags_url":"https://api.github.com/repos/astropy/astropy/tags","blobs_url":"https://api.github.com/repos/astropy/astropy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/astropy/astropy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/astropy/astropy/git/refs{/sha}","trees_url":"https://api.github.com/repos/astropy/astropy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/astropy/astropy/statuses/{sha}","languages_url":"https://api.github.com/repos/astropy/astropy/languages","stargazers_url":"https://api.github.com/repos/astropy/astropy/stargazers","contributors_url":"https://api.github.com/repos/astropy/astropy/contributors","subscribers_url":"https://api.github.com/repos/astropy/astropy/subscribers","subscription_url":"https://api.github.com/repos/astropy/astropy/subscription","commits_url":"https://api.github.com/repos/astropy/astropy/commits{/sha}","git_commits_url":"https://api.github.com/repos/astropy/astropy/git/commits{/sha}","comments_url":"https://api.github.com/repos/astropy/astropy/comments{/number}","issue_comment_url":"https://api.github.com/repos/astropy/astropy/issues/comments{/number}","contents_url":"https://api.github.com/repos/astropy/astropy/contents/{+path}","compare_url":"https://api.github.com/repos/astropy/astropy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/astropy/astropy/merges","archive_url":"https://api.github.com/repos/astropy/astropy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/astropy/astropy/downloads","issues_url":"https://api.github.com/repos/astropy/astropy/issues{/number}","pulls_url":"https://api.github.com/repos/astropy/astropy/pulls{/number}","milestones_url":"https://api.github.com/repos/astropy/astropy/milestones{/number}","notifications_url":"https://api.github.com/repos/astropy/astropy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/astropy/astropy/labels{/name}","releases_url":"https://api.github.com/repos/astropy/astropy/releases{/id}","deployments_url":"https://api.github.com/repos/astropy/astropy/deployments","created_at":"2011-07-21T01:33:49Z","updated_at":"2016-05-12T13:07:18Z","pushed_at":"2016-05-13T15:35:45Z","git_url":"git://github.com/astropy/astropy.git","ssh_url":"git@github.com:astropy/astropy.git","clone_url":"https://github.com/astropy/astropy.git","svn_url":"https://github.com/astropy/astropy","homepage":"www.astropy.org","size":64735,"stargazers_count":853,"watchers_count":853,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":546,"mirror_url":null,"open_issues_count":713,"forks":546,"open_issues":713,"watchers":853,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/astropy/astropy/pulls/4890"},"html":{"href":"https://github.com/astropy/astropy/pull/4890"},"issue":{"href":"https://api.github.com/repos/astropy/astropy/issues/4890"},"comments":{"href":"https://api.github.com/repos/astropy/astropy/issues/4890/comments"},"review_comments":{"href":"https://api.github.com/repos/astropy/astropy/pulls/4890/comments"},"review_comment":{"href":"https://api.github.com/repos/astropy/astropy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/astropy/astropy/pulls/4890/commits"},"statuses":{"href":"https://api.github.com/repos/astropy/astropy/statuses/17ed2d428318afeab4cb3f3fa21e314709068b51"}}}}