コード例 #1
0
ファイル: cleaning.py プロジェクト: ausogle/astroThes
def convert_obs_from_ecef_to_eci(observation: Observation) -> Observation:
    """
    Converts Observer location from ECEF to ECI frame before calculations to limit total computational cost.

    :param observation: Observational params relevant to prediction function
    """
    assert observation.frame == Frames.ECEF
    observation.frame = Frames.ECI
    observation.position = ecef_to_eci(observation.position, observation.epoch)
    return observation
コード例 #2
0
ファイル: cleaning.py プロジェクト: ausogle/astroThes
def convert_obs_from_lla_to_ecef(observation: Observation) -> Observation:
    """
    Converts Observer location from LLA to ECEF frame before calculations to limit total computational cost.

    :param observation: Observational params relevant to prediction function
    """
    assert observation.frame == Frames.LLA
    observation.frame = Frames.ECEF
    observation.position = lla_to_ecef(observation.position)
    return observation
コード例 #3
0
def test_verify_units_lla():
    position = [math.pi*2 * u.rad, math.pi*2 * u.rad, 1000 * u.m]
    epoch = None
    obs_values = None
    obs_type = None

    obs_params_in = Observation(position, Frames.LLA, epoch, obs_values, obs_type)
    expected_position = [360 * u.deg, 360 * u.deg, 1 * u.km]
    expected_outcome = Observation(expected_position, Frames.LLA, epoch, obs_values, obs_type)
    actual_outcome = verify_locational_units(obs_params_in)
    assert expected_outcome.frame == actual_outcome.frame
    for i in range(3):
        assert expected_outcome.position[i] == actual_outcome.position[i]
コード例 #4
0
def test_verify_units_spacial():
    position = [1000 * u.m, 1000 * u.m, 1000 * u.m]
    epoch = None
    obs_values = None
    obs_type = None

    obs_params_in = Observation(position, Frames.ECI, epoch, obs_values, obs_type)
    expected_position = [1 * u.km, 1 * u.km, 1 * u.km]
    expected_outcome = Observation(expected_position, Frames.ECI, epoch, obs_values, obs_type)
    actual_outcome = verify_locational_units(obs_params_in)
    assert expected_outcome.frame == actual_outcome.frame
    for i in range(3):
        assert expected_outcome.position[i] == actual_outcome.position[i]
コード例 #5
0
def test_convert_obs_from_ecef_to_eci():
    input_pos = [1 * u.km, 2 * u.km, 3 * u.km]
    output_pos = np.array([0, 0, 0])
    epoch = None
    obs_values = None
    obs_type = None

    input = Observation(input_pos, Frames.ECEF, epoch, obs_values, obs_type)
    with patch(mockito.invocation.MatchingInvocation.compare, xcompare):
        when(cleaning).ecef_to_eci(input_pos, epoch).thenReturn(np.array(output_pos))
    expected = Observation(output_pos, Frames.ECI, epoch, obs_values, obs_type)
    actual = convert_obs_from_ecef_to_eci(input)
    assert np.array_equal(expected.position, actual.position)
    assert expected.frame == actual.frame
コード例 #6
0
ファイル: test_obs_fun.py プロジェクト: ausogle/astroThes
def test_y_with_eci_frame():
    position = np.array([100, 100, 100])
    epoch = None
    obs_values = None
    obs_type = None

    obs_params = Observation(position, Frames.ECI, epoch, obs_values, obs_type)
    x = np.array([100, 200, 100])
    expected = np.array([90, 0])
    actual = y(x, obs_params)
    assert np.array_equal(expected, actual)
コード例 #7
0
ファイル: cleaning.py プロジェクト: ausogle/astroThes
def verify_locational_units(obs_params: Observation) -> Observation:
    """
    Units are assumed to be a certain set later down the pipeline. THis function serves to ensure that the correct units
    as being assumed.
    :param obs_params: Observation units relevant to the prediction function
    """
    lla_units = [u.deg, u.deg, u.km]
    spacial_units = [u.km, u.km, u.km]
    if obs_params.frame == Frames.LLA:
        desired_units = lla_units
    else:
        assert(obs_params.frame == Frames.ECI or Frames.ECEF)
        desired_units = spacial_units
    for i in range(3):
        if obs_params.position[i].unit is not desired_units[i]:
            obs_params.position[i] = obs_params.position[i].to(desired_units[i])
    return obs_params
コード例 #8
0
import astropy.units as u
from verification.util import get_period

r = [66666, 0, 0]
v = [0, -2.144, 1]
x = np.array([r[0], r[1], r[2], v[0], v[1], v[2]])
period = get_period(x)
dt = period / 100
tf = period / 2
epoch_obs = Time(2454283.0, format="jd", scale="tdb")
epoch_i = epoch_obs - tf * u.s

x_offset = np.array([100, 50, 10, .01, .01, .03])
obs_pos = [29.2108, 81.0228,
           3.9624]  #Daytona Beach, except 13 feet above sea level
obs_params = Observation(obs_pos, Frames.LLA, epoch_obs)
obs_params = convert_obs_params_from_lla_to_eci(obs_params)
prop_params = PropParams(tf, epoch_i)
yobs = y(state_propagate(x + x_offset, prop_params), obs_params)
x_alg = milani(x, yobs, LsqParams(np.array([1 / 100, 1 / 100])), obs_params,
               prop_params)

r_init = get_satellite_position_over_time(x, epoch_obs, tf, dt)
r_offset = get_satellite_position_over_time(x + x_offset, epoch_obs, tf, dt)
r_alg = get_satellite_position_over_time(x_alg, epoch_obs, tf, dt)

n = r_alg.shape[0] - 1
print(r_offset[n, 0])

fig = plt.figure()
ax = fig.gca(projection='3d')
コード例 #9
0
ファイル: gui.py プロジェクト: ausogle/astroThes
from src.interface.cleaning import convert_obs_params_from_lla_to_eci, verify_locational_units
from astropy.time import Time
from astropy import units as u
from src.observation_function import y
from src.state_propagator import state_propagate

x = np.array([66666, 0, 0, 0, -2.6551, 1])
xoffset = np.array([100, 50, 10, .01, .01, .03])

epoch_i = Time("2018-08-17 12:05:50", scale="tdb")
epoch_i.format = "jd"
epoch_f = epoch_i + 112 * u.day
dt = (epoch_f - epoch_i).value
obs_position = [29.2108 * u.deg, 81.0228 * u.deg, 3.9624 * u.m
                ]  #Daytona Beach, except 13 feet above sea level (6378 km)
obs_params = Observation(obs_position, Frames.LLA, epoch_f)
obs_params = verify_locational_units(obs_params)
obs_params = convert_obs_params_from_lla_to_eci(obs_params)

prop_params = PropParams(dt, epoch_f)
prop_params.add_perturbation(Perturbations.J2, build_j2())

xobs = state_propagate(x + xoffset, prop_params)
yobs = y(xobs, obs_params)

xout = milani(x, yobs, LsqParams(), obs_params, prop_params)

print("The outcome of our algorithm is \nposition: ", xout[0:3],
      "\nvelocity: ", xout[3:6])
print("\nCompared to the original \nposition: ", x[0:3], "\nvelocity:", x[3:6])
print("\nDifference in observational values of x and xout")