Exemplo n.º 1
0
def plot_radar_scan(SC, earth=False, ax=None):
    '''Plot a full cycle of the scan pattern based on the :code:`_scan_time` and the :code:`_function_data['dwell_time']` variable.
    
        :param RadarScan SC: Scan to plot.
        :param bool earth: Plot the surface of the Earth.
    '''
    if 'dwell_time' in SC._function_data:
        dwell_time = n.min(SC._function_data['dwell_time'])
    else:
        dwell_time = 0.05

    if SC._scan_time is None:
        scan_time = dwell_time * 100.0
    else:
        scan_time = SC._scan_time

    t = n.linspace(0.0, scan_time, num=n.round(2 * scan_time / dwell_time))

    if ax is None:
        fig = plt.figure(figsize=(15, 15))
        ax = fig.add_subplot(111, projection='3d')
        ax.grid(False)
        ax.view_init(15, 5)

        plt.title(SC.name)
        plt.tight_layout()
        _figs = (fig, ax)
    else:
        _figs = (None, ax)

    if earth:
        plothelp.draw_earth_grid(ax)
    plothelp.draw_radar(ax, SC._lat, SC._lon)

    max_range = 4000e3

    for i in range(len(t)):
        p0, k0 = SC.antenna_pointing(t[i])

        p1 = p0 + k0 * max_range * 0.8
        if k0[2] < 0:
            ax.plot([p0[0], p1[0]], [p0[1], p1[1]], [p0[2], p1[2]],
                    alpha=0.5,
                    color="red")
        else:
            ax.plot([p0[0], p1[0]], [p0[1], p1[1]], [p0[2], p1[2]],
                    alpha=0.5,
                    color="green")

    ax.set_xlim(p0[0] - max_range, p0[0] + max_range)
    ax.set_ylim(p0[1] - max_range, p0[1] + max_range)
    ax.set_zlim(p0[2] - max_range, p0[2] + max_range)

    return _figs
Exemplo n.º 2
0
                     e=0.0,
                     i=69,
                     raan=0,
                     aop=0,
                     mu0=0,
                     C_D=2.3,
                     A=1.0,
                     m=1.0) as o:
    t = n.linspace(0, 24 * 3600, num=10000)
    ecefs = o.get_orbit(t)

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(111, projection='3d')
    ax.view_init(15, 5)
    plothelp.draw_earth(ax)
    plothelp.draw_radar(ax, 69, 19)
    ax.plot(ecefs[0, :],
            ecefs[1, :],
            ecefs[2, :],
            ".",
            alpha=0.5,
            color="black")
    plt.title("Orbital propagation test")
    #plt.savefig("orbitprop.png")
    plt.show()

with so.space_object(a=7000,
                     e=0.0,
                     i=72,
                     raan=0,
                     aop=0,
Exemplo n.º 3
0
def plot_radar_scan_movie(SC, earth=False, rotate=False, save_str=''):
    '''Create a animation of the scan pattern based on the :code:`_scan_time` and the :code:`_function_data['dwell_time']` variable.
    
        :param RadarScan SC: Scan to plot.
        :param bool earth: Plot the surface of the Earth.
        :param str save_str: String of path to output movie file. Requers an avalible ffmpeg encoder on the system. If string is empty no movie is saved.
    '''
    if 'dwell_time' in SC._function_data:
        dwell_time = n.min(SC._function_data['dwell_time'])
    else:
        dwell_time = 0.05

    if SC._scan_time is None:
        scan_time = dwell_time * 100.0
    else:
        scan_time = SC._scan_time

    t = n.linspace(0.0, scan_time, num=n.round(2 * scan_time / dwell_time))

    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(111, projection='3d')
    ax.view_init(15, 5)

    def update_text(SC, t):
        return SC.name + ', t=%.4f s' % (t * 1e0, )

    titl = fig.text(0.5,
                    0.94,
                    update_text(SC, t[0]),
                    size=22,
                    horizontalalignment='center')

    max_range = 4000e3

    p0, k0 = SC.antenna_pointing(0)
    p1 = p0 + k0 * max_range * 0.8

    if earth:
        plothelp.draw_earth_grid(ax)
    else:
        plothelp.draw_earth(ax)
    plothelp.draw_radar(ax, SC._lat, SC._lon)
    if k0[2] < 0:
        beam = ax.plot([p0[0], p1[0]], [p0[1], p1[1]], [p0[2], p1[2]],
                       alpha=0.5,
                       color="red")
    else:
        beam = ax.plot([p0[0], p1[0]], [p0[1], p1[1]], [p0[2], p1[2]],
                       alpha=0.5,
                       color="green")

    ax.set_xlim(p0[0] - max_range, p0[0] + max_range)
    ax.set_ylim(p0[1] - max_range, p0[1] + max_range)
    ax.set_zlim(p0[2] - max_range, p0[2] + max_range)

    interval = scan_time * 1e3 / float(len(t))
    rotations = n.linspace(0., 360. * 2, num=len(t)) % 360.0

    def update(ti, beam):
        _t = t[ti]
        p0, k0 = SC.antenna_pointing(_t)
        p1 = p0 + k0 * max_range * 0.8
        titl.set_text(update_text(SC, _t))
        beam.set_data([p0[0], p1[0]], [p0[1], p1[1]])
        beam.set_3d_properties([p0[2], p1[2]])
        if k0[2] < 0:
            beam.set_color("red")
        else:
            beam.set_color("green")

        if rotate:
            ax.view_init(15, rotations[ti])

        return beam,

    ani = animation.FuncAnimation(fig,
                                  update,
                                  frames=range(len(t)),
                                  fargs=(beam),
                                  interval=interval,
                                  blit=False)

    if len(save_str) > 0:

        # Set up formatting for the movie files
        Writer = animation.writers['ffmpeg']
        writer = Writer(metadata=dict(artist='Daniel Kastinen'), bitrate=1800)
        ani.save(save_str, writer=writer)

    plt.tight_layout()
    plt.show()
Exemplo n.º 4
0
import radar_scans as rs
import radar_scan_library as rslib

uhf = rslib.beampark_model(90.0, 75.0, lat=69.58, lon=19.23)
esr = rslib.beampark_model(90.0, 75.0, lat=78.15, lon=16.02)

scans.append(uhf)
scans.append(esr)

fig = plt.figure(figsize=(8, 8))
ax = fig.add_subplot(111, projection='3d')
ax.view_init(15, 5)
plothelp.draw_earth_grid(ax)

plothelp.draw_radar(ax, 69.58, 19.23, name="UHF", color="red")
plothelp.draw_radar(ax, 78.15, 16.02, name="ESR", color="blue")

p0, k0 = uhf.antenna_pointing(0.0)
p1 = p0 + k0 * 3000e3
ax.plot([p0[0], p1[0]], [p0[1], p1[1]], [p0[2], p1[2]],
        alpha=0.5,
        color="green")

p0, k0 = esr.antenna_pointing(0.0)
p1 = p0 + k0 * 3000e3
ax.plot([p0[0], p1[0]], [p0[1], p1[1]], [p0[2], p1[2]],
        alpha=0.5,
        color="green")

plt.title("2018 EISCAT Beampark pointings")