Preliminaries

  1. pip install jplephem
  2. pip install sgp4
  3. Put de430.bsp ephemeris into Spacecraft_Testbed/Information/Celestial_Bodies/Ephemerides.

In [1]:
# Import the Celestial Body class
from Spacecraft_Testbed.Body import Celestial_Body
# Importy NumPy tools for math stuff
from numpy import linspace

In [2]:
# Instantiate Earth and Jupiter
Earth = Celestial_Body('Earth')
Jupiter = Celestial_Body('Jupiter')

In [3]:
# Define Julian date of interest (March 20)
March20  = 2457832.5 # Initial time

In [4]:
# Calculate position and velocity of Earth
# with respect to the solar system barycentre

# On March 20
p, v = Earth.Position_and_Velocity(March20)
print "Position: " + str(p)
print "Velocity: " + str(v)


Position: [ -1.48489812e+11   2.21189805e+09   9.34648913e+08]
Velocity: [  -848.17837498 -27419.97431137 -11886.18017189]

In [5]:
# Examine the Chinese weather satellite Fengyun 1C debris fragements
frag1 = Earth.Satellites.Fengyun_1C.Fengyun_1C_Deb_102
frag2 = Earth.Satellites.Fengyun_1C.Fengyun_1C_Deb_105
# Examine the Iridium debris fragement 4
frag3 = Earth.Satellites.Iridium_33.Iridium_33_Deb_4
# and Breeze debris fragement 1
frag4 = Earth.Satellites.Cosmos_2251.Cosmos_2251_Deb_1

In [6]:
# These positions and velocities can be shown as well
print frag1.Position_and_Velocity(March20) # WRT SS barycentre


[[ -1.48485429e+11   2.20762439e+09   9.38126603e+08]
 [  1.01969851e+03  -3.09831481e+04  -1.82752110e+04]]

In [7]:
# WRT other planets and fragements (all derrived from the body class)
print frag3.Position_and_Velocity_WRT(Earth, March20) # WRT Earth


[[  4.43878512e+06  -4.06131326e+06   3.82475823e+06]
 [ -2.57981748e+03   3.11725590e+03   6.29035932e+03]]

In [8]:
# WRT another fragement
print frag4.Position_and_Velocity_WRT(frag1, March20)


[[  1.28717072e+06   5.51727170e+06   6.76550714e+05]
 [ -6.42861377e+03   5.15034098e+03   1.20931045e+04]]

In [9]:
# WRT Jupiter
print frag2.Position_and_Velocity_WRT(Jupiter, March20)


[[  6.33120497e+11   2.22664442e+11   7.64038207e+10]
 [ -5.51975218e+03  -1.35438198e+04  -3.96318645e+02]]

In [10]:
# Earth WRT Mars
print Earth.Position_and_Velocity_WRT(Celestial_Body('Mars'), March20)


[[ -2.57966193e+11  -1.77399718e+11  -7.84660765e+10]
 [  1.94062670e+04  -3.98292685e+04  -1.81245049e+04]]

Remeber that position and velocity are given in $m$ and $\frac{m}{s}$, respectively.