All Projects → qsantos → Spyce

qsantos / Spyce

Licence: gpl-3.0
Python library for space enthusiasts

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Labels

Projects that are alternatives of or similar to Spyce

new-ospgl
A space exploration game in OpenGL. Devblog: https://tatjam.github.io/index.html
Stars: ✭ 17 (-69.09%)
Mutual labels:  space
Spacekit
Javascript library for 3D space visualizations
Stars: ✭ 340 (+518.18%)
Mutual labels:  space
Tower Defense Game
this is a game made with Unity, the goal is to protect the tower against robots.
Stars: ✭ 25 (-54.55%)
Mutual labels:  space
earthin24
Source code for my twitter bot https://twitter.com/earthin24
Stars: ✭ 19 (-65.45%)
Mutual labels:  space
Apod Api
Astronomy Picture of the Day API service
Stars: ✭ 290 (+427.27%)
Mutual labels:  space
Poliastro
poliastro - 🚀 Astrodynamics in Python
Stars: ✭ 462 (+740%)
Mutual labels:  space
StarshipAcademy
a Multiplayer WebVR Space Shooter made with A-Frame and Socket.io
Stars: ✭ 24 (-56.36%)
Mutual labels:  space
Pioneer
A game of lonely space adventure
Stars: ✭ 979 (+1680%)
Mutual labels:  space
Awesome Sentinel
curated list of awesome tools, tutorials and APIs for Copernicus Sentinel satellite data
Stars: ✭ 335 (+509.09%)
Mutual labels:  space
Gpredict
Gpredict satellite tracking application
Stars: ✭ 484 (+780%)
Mutual labels:  space
Open Notify Api
Source code for api.open-notify.org
Stars: ✭ 272 (+394.55%)
Mutual labels:  space
Asterank
asteroid database, interactive visualizations, and discovery tools
Stars: ✭ 290 (+427.27%)
Mutual labels:  space
Godot 2d Space Game
A 2D space exploration and mining game made with Godot and our AI framework
Stars: ✭ 462 (+740%)
Mutual labels:  space
space-dotnet-sdk
The .NET SDK for JetBrains Space is a .NET library to work with the JetBrains Space API.
Stars: ✭ 13 (-76.36%)
Mutual labels:  space
Make Space
💾 [WIP] Free up space from the command line
Stars: ✭ 21 (-61.82%)
Mutual labels:  space
kami
🍰 Kami is mx-space's web frontend theme. Cute and lovely.
Stars: ✭ 92 (+67.27%)
Mutual labels:  space
Termtrack
Track satellites in your terminal
Stars: ✭ 375 (+581.82%)
Mutual labels:  space
Trusat Orbit
Python utilities for processing satellite position observations and managing TLEs
Stars: ✭ 51 (-7.27%)
Mutual labels:  space
Space Trivia
🚀 A space-themed trivia app for Android.
Stars: ✭ 21 (-61.82%)
Mutual labels:  space
Naev
Naev is a 2d action/rpg space game that combines elements from the action, rpg and simulation genres.
Stars: ✭ 482 (+776.36%)
Mutual labels:  space

Spyce

Spyce intends to be used as a Python library to help compute information about space travel or plan trajectories in Kerbal Space Program.

This program is distributed under the GPL licence. The credits for the markdown formatting of the licence file go to IQAndreas.

Usage

Installing Spyce

$ git clone "https://github.com/qsantos/spyce"

The only dependency is the Python interpreter itself (either Python 2 or 3), unless you intend to use the graphical interface or C extensions.

Starting an interactive session

$ python spyce

Comparing the Kerbol System to the Solar System

Bodies of the Kerbol system are smaller and closer than those of the Solar System:

>>> Kerbol.radius / Sun.radius
0.3758620689655172
>>> Kerbin.radius / Earth.radius
0.09417673834562863
>>> Mun.radius / Moon.radius
0.11510791366906475
>>> Kerbin.orbit.periapsis / Earth.orbit.periapsis
0.09245340411755291
>>> Mun.orbit.periapsis / Moon.orbit.periapsis
0.03304836098856901

However, their surface gravities are similar:

>>> Kerbin.gravity() / Earth.gravity()
0.9989555850252271
>>> Mun.gravity() / Moon.gravity()
1.0027263771794397

This is because they are denser:

>>> (Kerbin.mass/Kerbin.radius**3) / (Earth.mass/Earth.radius**3)
10.60724338699287
>>> (Mun.mass/Mun.radius**3) / (Moon.mass/Moon.radius**3)
8.711185401746382

Also, real gas giants have lots of moons:

>>> len(Jool.satellites)
5
>>> len(Jupiter.satellites)
67

Getting information about orbits

>>> Orbit(Kerbin, Kerbin.radius+80e3).speed(0)
2278.931638238564
>>> o = Orbit.ask()
Primary [Kerbin]: Mun
== Orbit shape ==
   1 Periapsis and eccentricity
   2 Semi-major axis and eccentricity
   3 Periapsis and apoapsis
   4 Period and eccentricity
   5 Period and an apsis
   6 Position and velocity
Choose a method [1]: 1
Periapsis: Mun.radius + 20e3
Eccentricity [0]: 0
== Orbital plane ==
To use degrees, enter `radians(45)` for example
Inclination [0]: radians(90)
Longitude of ascending node [0]:
Argument of periapsis [0]:
== Position ==
Epoch [0]:
Mean anomaly [0]:
>>> o
Orbit(Mun, 220000, 0, 1.5708, 0, 0, 0, 0)
>>> o.speed(0)
544.1356679123854

Computing surface and orbital velocities

>>> Kerbin.surface_velocity
174.5336361449068
>>> Orbit(Kerbin, Kerbin.radius+80e3).speed(0)
2278.931638238564
>>> Mun.surface_velocity
9.041570660012562
>>> Orbit(Mun, Mun.radius+10e3).speed(0)
556.9406120378104
>>> Earth.surface_velocity
464.5806481876878
>>> Orbit(Earth, Earth.radius+120e3).speed(0)
7836.338986369195

Notes

  • works similarly with either Python 2 or Python 3
  • auto-completion is enabled
  • command history is preserved
  • only imports Sun, planets, dwarf planets and moons from NASA (no asteroids)
  • most of the API is documented and the code is commented; should you find missing information, feel free to get in contact or send a pull request

Graphical interface (Work-In-Progress)

The graphical interface requires the python package OpenGL and uses PIL if available (for textures). To install both on Debian (Ubuntu), run the relevant command:

$ sudo apt-get install python-opengl python-pil
$ sudo apt-get install python3-opengl python3-pil

You can visualize the Kerbol or Solar system with:

$ cd spyce
$ python -m gui.system
$ python -m gui.system Earth

It also works for stars (Sun and Kerbol), the other planets and the moons. Similarly, you can run gui.simulation to look at a rocket get into orbit.

C extensions

To improve performance, a small (but heavily used) part of the Python code also has a C implementation in cext/. To enable this optimization, you will need gcc, make and libpython-dev (or libpython3-dev); then, run make in the cext/ directory.

Data

Time

Time is measured in seconds and dates are given in the J2000 date scale. This corresponds to the number of seconds since 2000-01-01T12:00:00 TT (Terrestrial Time), or 2000-01-01T11:59:27.816 TAI, or 2000-01-01T11:58:55.816 UTC.

Note that Unix Time is not the number of seconds since 1970-01-01T00:00:00 because it skips leap seconds.

Solar System

Information on the Solar System is publicly made available at Solar System Dynamics by the Jet Propulsion Laboratory (NASA):

This information is included in Spyce in the file solar.json. For osculating orbits, use the HORIZONS system.

Kerbol System

Information on the Kerbol System can be accessed on KSP official wiki or from the game by using a plugin to dump data. The information is included in Spyce as kerbol.json.

KSP parts

The rocket simulation script requires importing parts from KSP. Those are not included in this repository and will be fetched in the installation folder of KSP, which should be detected automatically.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].