hapsira - Astrodynamics in Python


hapsira is an open source (MIT) pure Python library for interactive Astrodynamics and Orbital Mechanics, with a focus on ease of use, speed, and quick visualization. It provides a simple and intuitive API, and handles physical quantities with units. It’s a fork of poliastro, aiming at continuing its development.

View the source code of hapsira!

Some of its awesome features are:

  • Analytical and numerical orbit propagation

  • Conversion between position and velocity vectors and classical orbital elements

  • Coordinate frame transformations

  • Hohmann and bielliptic maneuvers computation

  • Trajectory plotting

  • Initial orbit determination (Lambert problem)

  • Planetary ephemerides (using SPICE kernels via Astropy)

  • Computation of Near-Earth Objects (NEOs)

And more to come!

hapsira is developed by an open, international community. Release announcements and general discussion take place on our mailing list and chat.

Molniya Orbit

Plot of a Molniya orbit around the Earth
(\(a = 26600~\mathrm{km}, e = 0.75, i = 63.4\mathrm{^\circ}\)).

The source code and issue tracker are hosted on GitHub, and all contributions and feedback are more than welcome.

hapsira works on the recent Python versions and is released under the MIT license, allowing commercial use of the library.

from hapsira.examples import molniya

Success stories from the original poliastro

“My team and I used Poliastro for our final project in our Summer App Space program. This module helped us in plotting asteroids by using the data provided to us. It was very challenging finding a module that can take orbits from the orbital elements, plot planets, and multiple ones. This module helped us because we were able to understand the code as most of us were beginners and make some changes the way we wanted our project to turn out. We made small changes such as taking out the axis and creating a function that will create animations. I am happy we used Poliastro because it helped us directs us in a direction where we were satisfied of our final product.”

– Nayeli Ju (2017)

“We are a group of students at University of Illinois at Urbana-Champaign, United States. We are currently working on a student AIAA/AAS satellite competition to design a satellite perform some science missions on asteroid (469219) 2016 HO3. We are using your hapsira python package in designing and visualizing the trajectory from GEO into asteroid’s orbit. Thank you for your work on hapsira, especially the APIs that are very clear and informational, which helps us significantly.”

– Yufeng Luo (University of Illinois at Urbana-Champaign, United States, 2017)

“We, at the Institute of Space and Planetary Astrophysics (ISPA, University of Karachi), are using Poliastro as part of Space Flight Dynamics Text Book development program. The idea is to develop a book suitable for undergrad students which will not only cover theoretical background but will also focus on some computational tools. We chose Poliastro as one of the packages because it was very well written and provided results with good accuracy. It is especially useful in covering some key topics like the Lambert’s problem. We support the use of Poliastro and open source software because they are easily accessible to students (without any charges, unlike some other tools). A great plus point for Poliastro is that it is Python based and Python is now becoming a very important tool in areas related to Space Sciences and Technologies.”

– Prof. Jawed iqbal, Syed Faisal ur Rahman (ISPA, University of Karachi, 2016)



Older versions of poliastro, from which hapsira was forked, relied on some Fortran subroutines written by David A. Vallado for his book “Fundamentals of Astrodynamics and Applications” and available on the Internet as the companion software of the book. The author explicitly gave permission to redistribute these subroutines in this project under a permissive license.