Ejemplo n.º 1
0
        def extrapo_intern_fct(i_ref, coef, until):
            ##
            ## backward :
            ## i_ref , coef = 0,-1
            ##
            ## forward :
            ## i_ref , coef = -1,1
            ##
            ## CORRDS ARE GIVEN IN ECI HERE !!!
            ##
            orbit_back = TwoBodyOrbit("orbit",
                                      mu=3.9860044188e14)  # create an instance
            orbit_back.setOrbCart(Tsec[i_ref], P[i_ref],
                                  V[i_ref])  # define the orbit

            if until:
                t_rang_strt, t_rang_end = list(sorted([Tutc[i_ref], until]))
                Range = conv.dt_range(t_rang_strt, t_rang_end, 0, step)
                n_step_intern = len(Range) - 1
            else:
                n_step_intern = n_step

            for t in np.arange(step, n_step_intern * step + 1, step):
                Pout, Vout = orbit_back.posvelatt(coef * t)
                epoc = Tgps[i_ref] + coef * dt.timedelta(seconds=int(t))
                DFline_new = DFline_dummy.copy()
                DFline_new[["x", "y", "z"]] = Pout
                DFline_new["epoch"] = pd.Timestamp(epoc)

                NewEpoch_stk.append(DFline_new)

            return Pout, Vout
Ejemplo n.º 2
0
def extrapolate_orbit_kepler(P, V, t, t0, mu=3.9860044188e14):
    orbit = TwoBodyOrbit("", mu=mu)  # create an instance
    orbit.setOrbCart(t0, P, V)  # define the orbit
    Pout, Vout = orbit.posvelatt(t)  # get position and velocity at t1
    kepl = orbit.elmKepl()  # get classical orbital elements

    return Pout, Vout, kepl
Ejemplo n.º 3
0
 def points(self, jd, ndata):
     sunpos, sunvel = common.SPKposvel(10, jd)
     tpos, tvel = self.posvel(jd)
     tpos -= sunpos
     tvel -= sunvel
     orbit = TwoBodyOrbit(self.name, 'Sun', common.solarmu)
     orbit.setOrbCart(0.0, tpos, tvel)
     xs, ys, zs, ts = orbit.points(ndata)
     xs += sunpos[0]
     ys += sunpos[1]
     zs += sunpos[2]
     ts /= common.secofday
     return xs, ys, zs, ts
Ejemplo n.º 4
0
import numpy as np
import tkinter
from pytwobodyorbit import TwoBodyOrbit
from pytwobodyorbit import lambert
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import matplotlib

# Standard gravitational parameter for the Sun
# With this parameter, lenght should be in meters,
# and time should be in seconds
sunmu = 1.32712440041e20

# Create instance of TwoBodyOrbit
orbit = TwoBodyOrbit('object', mu=sunmu)

# Seconds of a day
secofday = 86400.0

# prepare plotting
matplotlib.rcParams['toolbar'] = 'none'
plt.ion()  # set pyplot to the interactive mode
fig = plt.figure(figsize=(11, 11))
ax = fig.gca(projection='3d', aspect='equal')
ax.set_clip_on(True)
ax.set_xlim(-3.0e11, 3.0e11)
ax.set_ylim(-3.0e11, 3.0e11)
ax.set_zlim(-3.0e11, 3.0e11)
ax.set_xlabel('X')
ax.set_ylabel('Y')
Ejemplo n.º 5
0
 def __init__(self, pname):
     self.orbit = TwoBodyOrbit(pname, 'Sun', common.solarmu)
     return
#Apophis coordinates, plus calculation of the other anomalies.
a = 0.9222654975186300 * au.value  #in metres
e = 0.1910573105
i = 3.33132242244163  #All in DEGREES
asc_node = 204.45996801109067
a_of_p = 126.39643948747843
mean_anomaly = 61.41677858002747

eccentric_anomaly = mean_to_eccentric(m.radians(mean_anomaly), e)  #in radians

true_anomaly_r = 2 * m.atan(
    ((1 + e) / (1 - e))**.5 * m.tan(eccentric_anomaly / 2))
true_anomaly = m.degrees(true_anomaly_r)
'''Conversion 1: TwoBodyOrbit package'''
a_km = a / 1000
initial_conditions = TwoBodyOrbit("Apophis", mu=GM_sun.value)
initial_conditions.setOrbKepl(epoch_JD, a, e, i, asc_node, a_of_p,
                              mean_anomaly)
conversion_1 = initial_conditions.posvelatt(epoch_JD)[0]
print("Conversion 1:", conversion_1)
'''Conversion 2: spiceypy (based on NASA SPICE)'''

#Converts elements to radians and km, as required in spiceypy
i_r = m.radians(i)
asc_node_r = m.radians(asc_node)
a_of_p_r = m.radians(a_of_p)
mean_anomaly_r = m.radians(mean_anomaly)

r_p = a_km * (1 - e)
GM_sun_km = GM_sun.value / 10**9