https://github.com/nunorc/yspacepy
Y-Space companion Python package
https://github.com/nunorc/yspacepy
astronomy python
Last synced: about 1 month ago
JSON representation
Y-Space companion Python package
- Host: GitHub
- URL: https://github.com/nunorc/yspacepy
- Owner: nunorc
- License: mit
- Created: 2018-09-30T12:26:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-24T16:51:00.000Z (about 4 years ago)
- Last Synced: 2025-04-09T21:54:43.343Z (about 1 month ago)
- Topics: astronomy, python
- Language: Python
- Homepage: http://y-space.pw/
- Size: 2.72 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
yspacepy
========Installation
------------.. code-block:: bash
$ pip install yspacepy
Astronomical Bodies
-------------------.. code-block:: python
>>> from yspacepy.bodies import earth
>>> earth
Body(name='Earth', mass=5.972e+24 kg, radius=6371000.0 m, mu=398589196000000.0 m3 / s2)
>>> earth.radius
>>> earth.radius.to('km')
>>> earth.radius.to('km').value
6371.0Orbital Mechanics
-----------------Earth orbit around the Sun example.
.. code-block:: python
import numpy as np
from yspacepy.bodies import sun, earth
from yspacepy.orbmech import OrbitPropagator, plot_orbits# initial conditions of orbital parameters
r_mag = sun.radius.value + 1.496e11
v_mag = 30000# initial position and velocity vectors
state0 = np.array([r_mag, 0, 0, 0, v_mag, 0])# timespan
tspan = 3.5e7# time step
dt = 86400.0# propagate orbit
sun_earth = OrbitPropagator(state0, tspan, dt, sun, coes=False)# plot orbit
plot_orbits([sun_earth], labels=['Earth'], cb=sun)# plot orbitISS low earth orbit around the Earth example.
.. code-block:: python
import numpy as np
from yspacepy.bodies import sun, earth
from yspacepy.orbmech import OrbitPropagator, plot_orbits# initial conditions of orbital parameters
r_mag = earth.radius.value + 4e5
v_mag = np.sqrt(earth.mu.value/r_mag)# initial position and velocity vectors
state0 = np.array([r_mag, 0, 0, 0, v_mag, 0])# timespan
tspan = 100 * 60.0# time step
dt = 100.0earth_iis = OrbitPropagator(state0, tspan, dt, earth, coes=False)
# plot orbit
plot_orbits([earth_iis], labels=['IIS'], cb=earth)Acknowledgements
----------------Thank you Alfonso Gonzalez for
`Orbital Mechanics with Python `_
that are the base for the orbital mechanics modules.