Ejemplo n.º 1
0
def get_positions(times, pass_obj):

    spacecraft = twoline2rv(pass_obj['TLE'][0], pass_obj['TLE'][1], wgs84)
    telescope_ecef = AF.lla_to_ecef(LAT, LON, ALT, geodetic=True)
    utc0 = pass_obj['EPOCH']

    telescope_ecis = []
    spacecraft_ecis = []
    sun_ecis = []

    for time in times:

        now = utc0 + datetime.timedelta(seconds=time)

        sun_vec = AF.vect_earth_to_sun(now)

        sc_eci, _ = spacecraft.propagate(now.year, now.month, now.day,
                                         now.hour, now.minute, now.second)
        sc_eci = asarray(sc_eci)

        lst = AF.local_sidereal_time(now, LON)

        telescope_eci = AF.Cz(lst) @ telescope_ecef
        obs_vec = telescope_eci - sc_eci

        telescope_ecis.append(telescope_eci)
        spacecraft_ecis.append(sc_eci)
        sun_ecis.append(sun_vec)

    return vstack(spacecraft_ecis), vstack(telescope_ecis), vstack(sun_ecis)
Ejemplo n.º 2
0
def states_to_lightcurve(times, states, pass_obj, quats=False):

    lightcurve = []
    spacecraft = twoline2rv(pass_obj['TLE'][0], pass_obj['TLE'][1], wgs84)
    telescope_ecef = AF.lla_to_ecef(LAT, LON, ALT, geodetic=True)
    utc0 = pass_obj['EPOCH']

    for time, state in zip(times, states):

        now = utc0 + datetime.timedelta(seconds=time)

        sun_vec = AF.vect_earth_to_sun(now)

        sc_eci, _ = spacecraft.propagate(now.year, now.month, now.day,
                                         now.hour, now.minute, now.second)
        sc_eci = asarray(sc_eci)

        # if AF.shadow(sc_eci,sun_vec):
        #     #if the spacecraft is in shadow its brightness is zero
        #     print("IN SHADOW")
        #     lightcurve.append(0)
        #     continue

        lst = AF.local_sidereal_time(now, LON)

        telescope_eci = AF.Cz(lst) @ telescope_ecef
        obs_vec = telescope_eci - sc_eci

        if quats:
            eta = state[0]
            eps = state[1:4]
            dcm_body2eci = R.from_quat(hstack([eps, eta])).as_dcm().T
        else:
            eulers = state[:3]
            dcm_body2eci = R.from_euler(ROTATION, eulers).as_dcm().T

        power = 0
        for facet, area in zip(FACETS, AREAS):
            normal = dcm_body2eci @ facet

            if dot(normal, sun_vec) > 0 and dot(normal, obs_vec) > 0:
                power += phong_brdf(obs_vec, sun_vec, normal, area)

        lightcurve.append(power)

    lightcurve = hstack(lightcurve)

    return lightcurve
Ejemplo n.º 3
0
def measurement_function(state, time):

    print(state)
    eulers = state[:3]
    dcm_body2eci = R.from_euler(ROTATION, eulers).as_dcm().T
    power = 0

    now = UTC0 + datetime.timedelta(seconds=time)
    sc_eci, _ = SPACECRAFT.propagate(now.year, now.month, now.day, now.hour,
                                     now.minute, now.second)
    sc_eci = asarray(sc_eci)

    lst = AF.local_sidereal_time(now, LON)
    telescope_eci = AF.Cz(lst) @ TELESCOPE_ECEF
    obs_vec = telescope_eci - sc_eci

    sun_vec = AF.vect_earth_to_sun(now)

    for facet, area in zip(FACETS, AREAS):
        normal = dcm_body2eci @ facet
        power += phong_brdf(OBS_VEC, SUN_VEC, normal, area)

    return array([power])
Ejemplo n.º 4
0
def main():

    angular_velocity0 = array([0, 0.1, 0])
    # eta0 = 1
    # eps0 = array([0,0,0])

    q0 = R.random(random_state=1111).as_quat()
    eta0 = q0[3]
    eps0 = q0[0:3]

    eulers = array([0, 0, 0])

    state0 = hstack([eta0, eps0, angular_velocity0])

    solver = ode(propagate_quats)
    solver.set_integrator('lsoda')
    solver.set_initial_value(state0, 0)
    solver.set_f_params(INERTIA, False)

    newstate = []
    time = []

    tspan = PASS['TIME'][-1]

    while solver.successful() and solver.t < tspan:

        newstate.append(solver.y)
        time.append(solver.t)

        solver.integrate(solver.t + DT)

    newstate = vstack(newstate)
    time = hstack(time)

    #Generate lightcurve

    lightcurve = states_to_lightcurve(time, newstate, PASS, quats=True)

    #lightcurve += random.normal(0, MEASUREMENT_VARIANCE, size = lightcurve.shape)

    #Save Data

    save('true_lightcurve', lightcurve)
    save('true_states', newstate)
    save('time', time)

    sc_pos, tel_pos, sun_pos = get_positions(time, PASS)
    save('sc_pos', sc_pos)
    save('tel_pos', tel_pos)
    save('sun_pos', sun_pos)

    colors = []
    for x, y in zip(sc_pos, sun_pos):
        if AF.shadow(x, y) == 0:
            colors.append('k')
        else:
            colors.append('b')

    fig = plt.figure()
    ax = Axes3D(fig)
    AP.plot_earth(ax)
    ax.scatter(sc_pos[:, 0], sc_pos[:, 1], sc_pos[:, 2], c=colors)
    AP.plot_orbit(ax, tel_pos)
    AP.scale_plot(ax)

    azimuth, elevation = AF.pass_az_el(tel_pos, sc_pos)

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='polar')
    #matplotlib takes azimuth in radians and elevation in degrees for some reason :/
    ax.scatter(radians(azimuth), 90 - elevation, c=colors)
    ax.set_ylim([0, 90])

    plt.figure()
    plt.plot(time, lightcurve)
    plt.show()
Ejemplo n.º 5
0
AREAS = ESTIMATE.AREAS
OBS_VEC = ESTIMATE.OBS_VEC
SUN_VEC = ESTIMATE.SUN_VEC
INERTIA = ESTIMATE.INERTIA
MEASUREMENT_VARIANCE = ESTIMATE.MEASUREMENT_VARIANCE

ROTATION = VARIABLES.ROTATION
DT = VARIABLES.DT
LAT = VARIABLES.LATITUDE
LON = VARIABLES.LONGITUDE
ALT = VARIABLES.ALTITUDE
PASS = VARIABLES.PASS

SPACECRAFT = twoline2rv(PASS['TLE'][0], PASS['TLE'][1], wgs84)
UTC0 = PASS['EPOCH']
TELESCOPE_ECEF = AF.lla_to_ecef(LAT, LON, ALT, geodetic=True)


def main():

    case = 0
    for indx, arg in enumerate(sys.argv):
        if arg == '--2inertia':
            case = 1
            print('Including Inertia into state')
        elif arg == '--fullinertia':
            case = 2
        elif arg == '--inertialoffset':
            case = 3
            print('Estimating inertial offset')
        elif arg == '--constomega':
Ejemplo n.º 6
0
Noise_STD = Simulation_Configuration['Sensor STD']
Directory = Simulation_Configuration['Directory']
Exposure_Time = Simulation_Configuration['Exposure Time']
Real_Data = Simulation_Configuration['Real Data']

date = Satellite.epoch - datetime.timedelta(hours=1)

if not os.path.exists(Directory):
    os.makedirs(Directory)

pass_list = []
mid_pass_flag = False
max_el = 0
while len(pass_list) < num_passes:
    date += datetime.timedelta(seconds=1)
    lst = AF.local_sidereal_time(date, Lon)
    site = AF.observation_site(Lat, lst, Alt)
    sc_pos, sc_vel = Satellite.propagate(*date.timetuple()[0:6])
    sc_pos = asarray(sc_pos)
    range_vec = sc_pos - site
    sun_vec = AF.vect_earth_to_sun(date)

    illuminated = AF.shadow(sc_pos, sun_vec)
    above_horizon = dot(range_vec, site) > 0
    SPA_less_than_90 = dot(sun_vec, site - sc_pos) > 0

    if above_horizon and illuminated and SPA_less_than_90:
        if mid_pass_flag == False:
            print('Pass encountered', date)
            mid_pass_flag = True
            current_pass = {'Date0': date}
Ejemplo n.º 7
0
        positions = []
        for t in times:
            date_t = date0 + datetime.timedelta(seconds=t)
            solver.set_initial_value(state0, 0)
            solver.integrate(t)
            positions.append(solver.y)

        obs_vecs = []
        sun_vecs = []
        sat_poss = []
        site_poss = []
        range_vecs = []

        for t, state in zip(times, positions):
            date = date0 + datetime.timedelta(seconds=t)
            lst = AF.local_sidereal_time(date, LON)
            site = AF.observation_site(LAT, lst, ALT)
            #telescope_ecef = AF.lla_to_ecef(LAT, LON, ALT, geodetic = True)
            #site = AF.Cz(lst)@telescope_ecef
            sc_pos, sc_vel = Satellite.propagate(*date.timetuple()[0:6])
            sc_pos = state[0:3]
            sc_pos = asarray(sc_pos)
            range_vec = sc_pos - site
            sun_vec = AF.vect_earth_to_sun(date)

            obs_vecs.append(site - sc_pos)
            sun_vecs.append(sun_vec)
            sat_poss.append(sc_pos)
            site_poss.append(site)
            range_vecs.append(range_vec)
Ejemplo n.º 8
0
positions = []
for t in times:
    date_t = date0 + datetime.timedelta(seconds = t)
    sc_pos, _ = Satellite.propagate(*date_t.timetuple()[0:6])
    positions.append(sc_pos)

obs_vecs = []
sun_vecs = []
sat_poss = []
site_poss = []
range_vecs = []


for t, state in zip(times, positions):
    date = date0 + datetime.timedelta(seconds = t)
    lst = AF.local_sidereal_time(date, LON)
    #site = AF.observation_site(LAT, lst, ALT)
    sc_pos, sc_vel = Satellite.propagate(*date.timetuple()[0:6])
    #sc_pos = state[0:3]
    sc_pos = asarray(sc_pos)
    range_vec = sc_pos - site
    sun_vec = AF.vect_earth_to_sun(date)

    telescope_ecef = AF.lla_to_ecef(LAT, LON, ALT, geodetic = True)
    site = AF.Cz(lst)@telescope_ecef

    obs_vecs.append(site - sc_pos)
    sun_vecs.append(sun_vec)
    sat_poss.append(sc_pos)
    site_poss.append(site)
    range_vecs.append(range_vec)