Exemplo n.º 1
0
def map_plot(x_filter, x_true, trans_matrix, observer):
    """
    :param x_filter: Predicted filters
    :param x_true: Ground truth
    :param trans_matrix: Transition matrix : Stochastic Matrix
    :param observer: Given Observer coordinates
    :return: Map plot showing predicted path vs groundtruth
    """
    n, m, x_dim = x_filter.shape
    lat_filter = np.empty((n, m))
    lon_filter = np.empty((n, m))
    lat_true = np.empty((n, m))
    lon_true = np.empty((n, m))
    x_filter_itrs = np.empty((n, m, 3))
    x_true_itrs = np.empty((n, m, 3))
    observer = np.degrees(observer[0]), np.degrees(
        observer[1]), observer[2]  # lat (deg), lon (deg), height (meters)

    plt.figure(figsize=(30, 30))
    # add map to figure

    for i in range(n):
        for j in range(m):
            x_filter_itrs[i, j, :] = x_filter[i, j, :3] @ trans_matrix[i]
            lat_filter[i, j], lon_filter[i, j], _ = ecef2lla(x_filter_itrs[i,
                                                                           j])
            x_true_itrs[i, j, :] = x_true[i, j, :3] @ trans_matrix[i]
            lat_true[i, j], lon_true[i, j], _ = ecef2lla(x_true_itrs[i, j])

    lat_filter = np.degrees(lat_filter)
    lon_filter = np.degrees(lon_filter)
    lat_true = np.degrees(lat_true)
    lon_true = np.degrees(lon_true)
    my_map = Basemap(projection='cyl', lon_0=0, lat_0=0, resolution='l')
    my_map.drawmapboundary()  # fill_color='aqua')
    my_map.fillcontinents(color='#dadada', lake_color='white')
    my_map.drawmeridians(np.arange(-180, 180, 30), color='gray')
    my_map.drawparallels(np.arange(-90, 90, 30), color='gray')
    for j in range(m):
        x, y = my_map(lon_filter[:, j], lat_filter[:, j])
        my_map.scatter(x, y, marker='o', zorder=3, label='Predicted Location')
        my_map.scatter(lon_true[:, j],
                       lat_true[:, j],
                       marker='x',
                       zorder=3,
                       label='Actual Location')

    plt.annotate('Observation Station',
                 xy=(observer[1], observer[0]),
                 xycoords='data',
                 xytext=(observer[1] - 180, observer[0] + 40),
                 textcoords='offset points',
                 fontsize=24,
                 color='g',
                 arrowprops=dict(arrowstyle="fancy", color='g'))

    plt.show()
Exemplo n.º 2
0
    def plot_regimes(self, save_path=None, display=True):
        s = time.time()
        lla = np.array([ecef2lla(x[:3] @ self.trans_matrix[0]) for x in self.x_true[0]])

        coes = np.array(rv2coe(k=Earth.k.to_value(u.km ** 3 / u.s ** 2), r=x[:3] / 1000, v=x[3:] / 1000) for x in self.x_true[0])

        x = lla[:, 2] / 1000
        y = coes[:, 1]

        plot_regimes(np.column_stack((x, y)), save_path=save_path, display=display)
        e = time.time()
        self.runtime['plot_visibility'] += e - s
Exemplo n.º 3
0
    "observer_lla": obs_lla
} for i in range(n)]

candidates = []
seed = 0
random_state = np.random.RandomState(seed)

for i in tqdm(range(samples)):
    regime = random_state.choice(a=['LEO', 'MEO', 'GEO', 'Tundra', 'Molniya'],
                                 p=[1 / 3, 1 / 3, 1 / 9, 1 / 9, 1 / 9])
    accepted = False
    while not accepted:
        candidate = init_state_vec(orbits=[regime], random_state=random_state)
        x_gcrs = [fx(candidate, step_size * i) for i in range(n)]
        x_itrs = [x_gcrs[i][:3] @ trans_matrix[i] for i in range(n)]
        x_lla = np.array([ecef2lla(x_itrs[i]) for i in range(n)])
        candidate_elevation = [
            hx(x_gcrs=x_gcrs[i][:3], **hx_kwargs[i])[1] for i in range(n)
        ]
        visibility = candidate_elevation >= obs_limit
        gaps = [
            sum(1 for _ in group)
            for key, group in itertools.groupby((visibility - 1) * -1) if key
        ]
        if np.all(x_lla[:, 2] > 300 * 1000):
            if not gaps == []:
                if sum(visibility[0:int(first_window * 60 / step_size)]) > 0:
                    if np.max(gaps) < max_gap * 60 * 60 / step_size:
                        candidates.append(candidate)
                        accepted = True
            else:
Exemplo n.º 4
0
                                  gcrs2irts_matrix_b(t, eop) @ xyz1)
assert test1a_error < 25, print("Failed Test 1: GCRS to ITRS transformation")
print("Test 1a: GCRS to ITRS (a) error in meters: ", test1a_error)
print("Test 1b: GCRS to ITRS (b) error in meters: ", test1b_error)

# !------------ Test 2a - ECEF (ITRS) to LLA
from envs.transformations import ecef2lla
xyz1 = np.array(itrs.cartesian.xyz._to_value(u.m), dtype=np.float64)
lla = EarthLocation.from_geocentric(x=xyz1[0] * u.m,
                                    y=xyz1[1] * u.m,
                                    z=xyz1[2] * u.m)
lat = lla.lat.to_value(u.rad)
lon = lla.lon.to_value(u.rad)
height = lla.height.to_value(u.m)
lla = [lat, lon, height]
test2_error = lla - np.asarray(ecef2lla(xyz1))
assert np.max(test2_error) < 0.0000001, print(
    "Failed Test 2a: ECEF (ITRS) to LLA transformation")
print("Test 2a: ECEF (ITRS) to LLA error in rads,rads,meters: ", test2_error)

# !------------ Test 3 - ECEF (ITRS) to Az, El, Range
from envs.transformations import ecef2aer, ecef2lla
xyz1 = np.array([1285410, -4797210, 3994830], dtype=np.float64)  # [meters x 3]
xyz2 = np.array([1202990, -4824940, 3999870], dtype=np.float64)  # [meters x 3]

observer = EarthLocation.from_geocentric(x=xyz1[0] * u.m,
                                         y=xyz1[1] * u.m,
                                         z=xyz1[2] * u.m)
target = SkyCoord(x=xyz2[0] * u.m,
                  y=xyz2[1] * u.m,
                  z=xyz2[2] * u.m,