Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the capability to query JPL HORIZONS #3113

Merged
merged 14 commits into from May 22, 2019

Conversation

Projects
None yet
4 participants
@ayshih
Copy link
Contributor

commented May 17, 2019

Here's a function to easily query JPL HORIZONS (via HTTPS) for the location of a solar-system body. This function requires the astroquery package to be installed. Be aware that the output for spacecraft may not be accurate.

Examples of querying by name

>>> from sunpy.coordinates import get_horizons_coord
>>> get_horizons_coord('SOHO', '2011-06-01 11:22:33')
<SkyCoord (HeliographicStonyhurst: obstime=2011-06-01T11:22:33.000): (lon, lat, radius) in (deg, deg, AU)
    (359.74707192, -0.70191324, 1.00451497)>
>>> get_horizons_coord('SDO', '2011-06-01 11:22:33')
<SkyCoord (HeliographicStonyhurst: obstime=2011-06-01T11:22:33.000): (lon, lat, radius) in (deg, deg, AU)
    (0.01222499, -0.65400412, 1.01407332)>
>>> get_horizons_coord('Deimos', '2011-06-01 11:22:33')
<SkyCoord (HeliographicStonyhurst: obstime=2011-06-01T11:22:33.000): (lon, lat, radius) in (deg, deg, AU)
    (137.86655038, 4.67297496, 1.42850571)>

Example of an ambiguous query and a query by ID

>>> get_horizons_coord('STEREO', '2011-06-01 11:22:33')
ValueError: Ambiguous target name; provide unique id:
  ID#      Name                               Designation  IAU/aliases/other
  -------  ---------------------------------- -----------  -------------------
     -234  STEREO-A (spacecraft)                           AHEAD

     -235  STEREO-B (spacecraft)                           BEHIND

  -234900  STEREO Third Stage (spacecraft)
>>> get_horizons_coord(-234, '2011-06-01 11:22:33', id_type='id')
<SkyCoord (HeliographicStonyhurst: obstime=2011-06-01T11:22:33.000): (lon, lat, radius) in (deg, deg, AU)
    (94.27943046, 7.34584532, 0.95739986)>

Could help address #3110

@ayshih ayshih added the coordinates label May 17, 2019

@sunpy-bot

This comment has been minimized.

Copy link

commented May 17, 2019

Thanks for the pull request @ayshih! Everything looks great!

@nabobalis nabobalis added this to the 1.0 milestone May 18, 2019

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented May 18, 2019

I think just a test and a changelog and this is good to go.

@sunpy sunpy deleted a comment from sunpy-bot bot May 18, 2019

Show resolved Hide resolved sunpy/coordinates/ephemeris.py Outdated
@pep8speaks

This comment has been minimized.

Copy link

commented May 19, 2019

Hello @ayshih! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 328:101: E501 line too long (109 > 100 characters)
Line 334:101: E501 line too long (107 > 100 characters)
Line 335:101: E501 line too long (109 > 100 characters)
Line 342:101: E501 line too long (109 > 100 characters)

Line 120:1: E303 too many blank lines (3)

Comment last updated at 2019-05-22 18:43:24 UTC
@ayshih

This comment has been minimized.

Copy link
Contributor Author

commented May 20, 2019

@Cadair @nabobalis Can one of you explain to me how to fix the test failure? (OSError: Could not find unix home directory to search for astropy config dir)

@nabobalis

This comment was marked as outdated.

Copy link
Contributor

commented May 20, 2019

It's a warning I think. I've seen it before but I didn't it breaks anything.

@nabobalis

This comment was marked as outdated.

Copy link
Contributor

commented May 20, 2019

Oh it's used for astroquery. I'll have to look at it tomorrow.

@nabobalis

This comment was marked as outdated.

Copy link
Contributor

commented May 20, 2019

Maybe if we set

        if 'HOME' in os.environ:
            homedir = os.environ['HOME'] 

In the tox ini it would work.

@nabobalis

This comment was marked as outdated.

Copy link
Contributor

commented May 21, 2019

If we add setenv = HOME = {toxinidir} it might do something? I will need to pull the PR and test it myself.

@nabobalis

This comment was marked as outdated.

Copy link
Contributor

commented May 21, 2019

Adding:

HOME = {toxinidir}/..

in the setenv seems to work locally for me.

@nabobalis nabobalis force-pushed the ayshih:astroquery branch from 1ab7d9c to 3d9b75d May 21, 2019

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented May 21, 2019

I pushed a fix but it breaks under windows, so maybe @Cadair will tell us the real fix.

@ayshih

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

@Cadair @nabobalis I fixed the environment variable so now tests work. Approve and merge?

@nabobalis

This comment has been minimized.

Copy link
Contributor

commented May 22, 2019

Theres a homedir for tox? Can't believe I didn't find it. The other changes I made in my commit are actually things we wanted. But I can redo them in a separate PR.

Show resolved Hide resolved changelog/3113.feature.rst Outdated
Show resolved Hide resolved sunpy/coordinates/ephemeris.py Outdated
Show resolved Hide resolved sunpy/coordinates/ephemeris.py Outdated
Show resolved Hide resolved tox.ini Outdated

@Cadair Cadair modified the milestones: 1.0, 1.1 May 22, 2019

@ayshih ayshih force-pushed the ayshih:astroquery branch from 94bd77c to b960444 May 22, 2019

Show resolved Hide resolved sunpy/coordinates/ephemeris.py Outdated

@Cadair Cadair modified the milestones: 1.1, 1.0 May 22, 2019

@Cadair Cadair force-pushed the ayshih:astroquery branch 2 times, most recently from 6474835 to ec03261 May 22, 2019

ayshih and others added some commits May 19, 2019

Revert "let us see if this works"
This reverts commit 3d9b75d.

@Cadair Cadair force-pushed the ayshih:astroquery branch from a130453 to 424a4b6 May 22, 2019

@Cadair

This comment has been minimized.

Copy link
Member

commented May 22, 2019

Great, the CI has died apparently because GH webhooks are having issues.

@Cadair

Cadair approved these changes May 22, 2019

@Cadair Cadair merged commit e06c234 into sunpy:master May 22, 2019

15 of 16 checks passed

codecov/patch 75% of diff hit (target 90.15%)
Details
ci/circleci: 32bit Your tests passed on CircleCI!
Details
ci/circleci: egg-info-36 Your tests passed on CircleCI!
Details
ci/circleci: egg-info-37 Your tests passed on CircleCI!
Details
ci/circleci: figure-tests-36 Your tests passed on CircleCI!
Details
ci/circleci: html-docs Your tests passed on CircleCI!
Details
ci/circleci: pip-install Your tests passed on CircleCI!
Details
codecov/project 90.13% (-0.03%) compared to c77ad4c
Details
giles Click details to preview the documentation build
Details
sunpy-bot All checks passed
sunpy.sunpy Build #20190522.26 succeeded
Details
sunpy.sunpy (Linux_36_Conda_offline) Linux_36_Conda_offline succeeded
Details
sunpy.sunpy (Linux_36_offline) Linux_36_offline succeeded
Details
sunpy.sunpy (Linux_37_online) Linux_37_online succeeded
Details
sunpy.sunpy (Windows_36_offline) Windows_36_offline succeeded
Details
sunpy.sunpy (macOS_37_offline) macOS_37_offline succeeded
Details
@ayshih

This comment has been minimized.

Copy link
Contributor Author

commented May 22, 2019

Yay!

@ayshih ayshih deleted the ayshih:astroquery branch May 22, 2019

nabobalis added a commit to nabobalis/sunpy that referenced this pull request May 22, 2019

Merge pull request sunpy#3113 from ayshih/astroquery
Added the capability to query JPL HORIZONS
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.