apps160222_jdc.scenario_plot

Senario file to be plotted.

scenario1.txt for example is plotted.

Format of the file is

datetime mpldates et vx_JSE vy_JSE vz_JSE vx_SC vy_SC vz_SC …

""" Senario file to be plotted.

scenario1.txt for example is plotted.

Format of the file is

datetime mpldates et vx_JSE vy_JSE vz_JSE vx_SC vy_SC vz_SC ...
"""
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mpldates

def main(fname):
    dat = np.genfromtxt(fname)

    t = dat[:, 1]    # matplotlib epoch
    td = mpldates.num2date(t)

    vx_jse = dat[:, 3]
    vy_jse = dat[:, 4]
    vz_jse = dat[:, 5]

    vx_sc = dat[:, 6]
    vy_sc = dat[:, 7]
    vz_sc = dat[:, 8]

    viewx_sc = -vx_sc
    viewy_sc = -vy_sc
    viewz_sc = -vz_sc

    v_sc = np.sqrt(vx_sc ** 2 + vy_sc ** 2 + vz_sc ** 2)
    v_long = np.rad2deg(np.arctan2(viewy_sc, viewx_sc))
    v_lat =np.rad2deg(np.arcsin(viewz_sc / v_sc))

    fig = plt.figure()
    axes = []

    ax = fig.add_subplot(211)
    axes.append(ax)
    ax.plot(v_long, v_lat, 'o:')

    ax.set_xlim(-180, 180)
    ax.set_ylim(-90, 90)

    ax.set_xlabel('Longitude (S/C)')
    ax.set_ylabel('Latitude (S/C)')

    import fovplot

    fovplot.frame_plot_limit(ax=ax, alpha=0.1)
    ax.text(0, 0, 'Tilt=0', color='r')
    fovplot.frame_plot_limit(ax=ax, tilt=15, alpha=0.1)
    ax.text(0, 15, 'Tilt=15', color='r')
    fovplot.frame_plot_limit(ax=ax, tilt=30, alpha=0.1)
    ax.text(0, 30, 'Tilt=30', color='r')
    fovplot.frame_plot_limit(ax=ax, tilt=45, alpha=0.1)
    ax.text(0, 45, 'Tilt=45', color='r')


    ax = fig.add_subplot(413)
    ax.plot_date(t, v_lat, 'g.')
    ax.plot_date(t, v_long, 'r.')
    ax.set_xlabel('Time')
    ax.set_ylabel('Angle (g-lat/r-lon)')
    ax.set_ylim(-180, 180)

    fig.savefig(fname + '.png')

    return fig, axes

if __name__ == '__main__':
    rval = main(sys.argv[1])