Skip to main content

A python package for querying NASA's JPL HORIZONS API

Project description

Author: Behrouz Safari
License: MIT

hypatie

A python package for querying NASA's JPL HORIZONS API

Installation

You can install the latest version of hypatie from PyPI:

pip install hypatie

The only requirement is numpy.

Quick start

Let's get the positions of the sun between two times:

import hypatie as hp

t1 = '2021-03-20 08:00:00'
t2 = '2021-03-20 10:00:00'

If you want the apparent RA and DEC of the Sun with respect to Earth's center (geocentric):

obs = hp.Observer('sun', t1, t2, step=5)

Now you can access the time intervals with .time attribute:

print(obs.time)

[datetime.datetime(2021, 3, 20, 8, 0)
 datetime.datetime(2021, 3, 20, 8, 24)
 datetime.datetime(2021, 3, 20, 8, 48)
 datetime.datetime(2021, 3, 20, 9, 12)
 datetime.datetime(2021, 3, 20, 9, 36)
 datetime.datetime(2021, 3, 20, 10, 0)]

To acces the position you can use obs.pos, obs.ra, or obs.dec:

print(obs.pos)

[[ 3.59938235e+02 -2.66803120e-02]
 [ 3.59953431e+02 -2.00920520e-02]
 [ 3.59968627e+02 -1.35038600e-02]
 [ 3.59983823e+02 -6.91573600e-03]
 [ 3.59999018e+02 -3.27680000e-04]
 [ 1.42132560e-02  6.26030600e-03]]

The first column in the above array is RA and the second column is DEC.

It is possible to get the apparent RA & DEC of a targer with respect to a specified location on the surface of a body. For example, if you want to get the apparent RA & DEC of the Sun for the Eiffel Tower :

obs = hp.Observer('sun', t1, t2, step=5, center='2.2945,48.8584,300@399')

Note that 2.2945 is the longtitude, 48.8584 is the latitude and 300 (meters) is the elevation of the Eiffel Tower. We have specified '@399' at the end which means that this coordinates is situated on the Earth (399 is the Earth's code).

You can request the cartesian positions (x,y,z) of a target with Vector class.

vec = hp.Vector('sun', t1, t2, step=5)

As with the Observer class, there are two attributes .time and .pos for Vector class. Note that when creating a Vector class, you have .x, .y and .z attributes instead of .ra and .des.

For both Vector and Observer classes you can pass a single time to get position/state of a body at a single time:

vec = hp.Vector('sun', t1)

Example: animating Apollo 11 mission

import hypatie as hp

t1 = '1969-07-17 16:40:00'
t2 = '1969-07-28 00:06:00'

# get positions with respect to the barycenter of earth-moon
earth = hp.Vector('399', t1, t2, center='500@3', step=1000)
moon = hp.Vector('301', t1, t2, center='500@3', step=1000)
apollo = hp.Vector('-399110', t1, t2, center='500@3', step=1000)

bodies = [earth, moon, apollo]
names = ['Earth', 'Moon', 'Apollo 11']
colors = ['b','g','r']
sizes = [30, 10, 3]

# play the animation
hp.play(bodies, names, colors, sizes)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hypatie-1.0.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

hypatie-1.0.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file hypatie-1.0.0.tar.gz.

File metadata

  • Download URL: hypatie-1.0.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.2

File hashes

Hashes for hypatie-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7cfabf56351d66df57628e8b5eb2e4fbeb994400f47cae2ff391480d03d9f636
MD5 d25f5a824fe9d2a73595f183ebbba163
BLAKE2b-256 8af81885d05c06318c8d82dc28aea939beb57283e7846922ddc3ab12815ed770

See more details on using hashes here.

File details

Details for the file hypatie-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: hypatie-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.2

File hashes

Hashes for hypatie-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13d335150de2956c0cc118315b85e69dea5ad149636f1eae6a745f1453428245
MD5 73d15a5f648ad28aaf2ef8c8a377ca38
BLAKE2b-256 fe5411011153f3b640554d956fa0d8dcf688e49b0b82a5662a3c9eccf8d5449e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page