Skip to content

Make coordinates.solar_system_ephemeris accept local ephemeris file #8750

Closed

Description

@rhandberg

astropy.coordinates.solar_system_ephemeris.set() currently (version 3.1) has the possibility of accepting one of the presets (e.g. 'builtin', 'de430') or an URL pointing to another ephemeris to use. But if I have an ephemeris already downloaded to a local file, it does not allow me to pass the path to this local file to use.

It doesn't work to specify the local file in URL format either i.e. "file://path/to/file.bsp".

My suggestion would be to either make it possible to specify a local file either using the URL format specified above or allowing to pass the path to the local file directly.

Activity

  1. pllim commented on May 24, 2019

    @pllim
    Member

    Yes, that is a reasonable request and should be supported IMHO. It looks like this logic below does not yet support a local data file:

    else:
    try:
    urlparse(value)
    except Exception:
    raise ValueError('{} was not one of the standard strings and '
    'could not be parsed as a URL'.format(value))
    try:
    from jplephem.spk import SPK
    except ImportError:
    raise ImportError("Solar system JPL ephemeris calculations require "
    "the jplephem package "
    "(https://pypi.python.org/pypi/jplephem)")
    return SPK.open(download_file(value, cache=True))

    The workaround for now, I guess, is to upload your data file to the internet, so it can be downloaded back and cached... 😬

  2. Cadair commented on May 24, 2019

    @Cadair
    Member

    or just run python -m http.server in the directory it is in so you can put in a localhost:8000 url?!

  3. pllim commented on May 24, 2019

    @pllim
    Member

    @Cadair , you mean http.server or http.severe? :trollface:

  4. mhvk commented on May 24, 2019

    @mhvk
    Contributor

    Very much in favour - this was an oversight in the implementation. Possibly the way to go would be to do the download_file(value) only in the branch where a URL is detected, and otherwise just try SPK.open(value) directly.

    @rhandberg - would you be able to try this, and perhaps make a PR?

  5. rhandberg commented on May 28, 2019

    @rhandberg
    ContributorAuthor

    @mhvk - I'll give it a try... PR coming soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions