예제 #1
0
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./fpa.dill', default_sol=-1, default_step=-1)

plots.add_plot().line('theta*180/3.14','h/1000')                    \
                .xlabel('theta (deg)').ylabel('h (km)')      \
                .title('Altitude vs. Downrange')

plots.add_plot().line('t','alfa*180/3.14')                    \
                .xlabel('t (s)').ylabel('alfa (degrees)')      \
                .title('Angle of attack vs. Time')

plots.add_plot().line('t','k*sqrt(rho0*exp(-h/H)/rn)*v**3/1e4')                    \
                .xlabel('t (s)').ylabel('Heat-rate (W/cm^2)')      \
                .title('Stagnation point heat rate vs. Time')

rho = 'rho0*exp(-h/H)'
Cl = '(1.5658*alfa + -0.0000)'
Cd = '(1.6537*alfa**2 + 0.0612)'

D = '(0.5*' + rho + '*v**2*' + Cd + '*Aref)'
L = '(0.5*' + rho + '*v**2*' + Cl + '*Aref)'

plots.add_plot().line('t','sqrt('+D+'**2+'+L+'**2)/(mass*g0)') \
                .xlabel('t (s)').ylabel('G-Loading')      \
                .title('G-Loading vs. Time')

# plots.add_plot().line('theta*re/1000','h/1000',label='Foo')       \
#                 .line('theta*re/1000','h/1000',label='Bar',step=1,sol=5)   \
#                 .xlabel('Downrange (km)')                   \
#                 .ylabel('h (km)')                           \
예제 #2
0
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./data_dubin.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

plots.add_plot().line('x','y')                    \
                .xlabel('x [m]').ylabel('y [m]')      \
                .title('Trajectory')

plots.add_plot().line('t','delta')                    \
                .xlabel('t (s)').ylabel('delta (m/s)')      \
                .title('Control history')

plots.render()
예제 #3
0
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./cart120.dill', default_sol=-1, default_step=-1)

plots.add_plot().line('x_n*x_s','y_n*y_s')                    \
                # .xlabel('t (s)').ylabel('h (km)')      \

# .title('Altitude vs. Time')

plots.add_plot().line('t', 'sin(w)') \
    # .xlabel('t (s)').ylabel('h (km)')      \

# .title('Altitude vs. Time')

plots.add_plot().line('t', 'theta_n') \

plots.add_plot().line('t', 'p22_n*p22_s') \

plots.add_plot().line('t', 'p11_n*p11_s') \

# plots.add_plot().line('t','alfa*180/3.14')                    \
#                 .xlabel('t (s)').ylabel('alfa (degrees)')      \
#                 .title('Angle of attack vs. Time')

# plots.add_plot().line('theta*re/1000','h/1000',legend='Foo')       \
#                 .line('theta*re/1000','h/1000',legend='Bar',step=1,sol=5)   \
#                 .xlabel('Downrange (km)')                   \
#                 .ylabel('h (km)')                           \
#                 .title('Altitude vs. Downrange')

plots.render()
예제 #4
0
from beluga.visualization import BelugaPlot
from beluga.visualization.datasources import Dill
# from beluga.visualization.renderers import ToyPlot

ds_constraint = Dill('./data-1k2-eps4-eps4.dill') # 26 steps
ds_epsHR = Dill('./data-1k2-eps6-eps4.dill') # 36 steps
ds_epsAlfa = Dill('./data-1k2-eps6-eps7.dill') # 36 steps

# toyplot = ToyPlot(backend = 'png')
# plots = BelugaPlot(datasource=ds_constraint,default_sol=-1,default_step=-1,renderer='bokeh')
plots = BelugaPlot('./data-1k2-eps4-eps4.dill',default_sol=-1,default_step=-1,renderer='matplotlib')

qdot = 'k*v**3*sqrt(rho0*exp(-h/H)/rn)'
# 90
plots.add_plot(mesh_size=512).line_series('theta*re/1000','h/1000', skip=5, datasource=ds_constraint)   \
                .xlabel('Downrange (km)').ylabel('Altitude (km)')      \
                .title('Altitude vs. Downrange')

plots.add_plot(mesh_size=512).line_series('t','qdot/1e4', skip=5, datasource=ds_constraint)              \
                .xlabel('t (s)').ylabel('Heat Rate (W/cm^2)')      \
                .title('Heat Rate vs. Time')

plots.add_plot(mesh_size=512).line_series('t','alfa*180/3.14', skip=5, datasource=ds_constraint) \
                .line('t','alfaMax*180/3.14', datasource=ds_epsAlfa) \
                .xlabel('t (s)').ylabel('Alpha (deg)')      \
                .title('Control History')

plots.add_plot(mesh_size=512).line_series('v/1000','h/1000', skip=5, datasource=ds_constraint) \
                .xlabel('Velocity (km/s)').ylabel('Altitude (km)')      \
                .title('Altitude vs. Velocity')
예제 #5
0
파일: plot.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot
from beluga.visualization.datasources import Dill
# plots = BelugaPlot('./data.dill',default_sol=-1,default_step=0)
unc_ds = Dill('../../mpbvp/boundedBrachistochrone/data.dill')
plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

plots.add_plot().line('x','y',label='Solution', sol=-1, step=-1,style={'lw':2.0})               \
                .line('x','y',label='Unconstrained Solution', datasource=unc_ds, step=0, sol=-1,style={'lw':2.0})\
                .line('x','xlim-x',label='Constraint1',step=-1,sol=-1) \
                .xlabel('x(t)').ylabel('y(t)')      \
                .title('Trajectory')
# .line('x','-2-0.75*x',label='Constraint2',step=-1,sol=-1) \
plots.add_plot().line('t','theta*180/3.14')                    \
                .xlabel('t (s)').ylabel('theta (degrees)')      \
                .title('Control history')

plots.add_plot().line('t','lamX')                    \
                .xlabel('t (s)').ylabel('lamX')      \
                .title('lamX')
plots.render()
예제 #6
0
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

plot1 = plots.add_plot()
plot1.line_series('x', 'y')
plot1.xlabel('x(t)')
plot1.ylabel('y(t)')
plot1.title('Trajectory time history')

plot2 = plots.add_plot()
plot2.line('t', '180/pi*theta')
plot2.xlabel('t (s)')
plot2.ylabel('theta (degrees)')
plot2.title('Control time history')

plots.render()
예제 #7
0
import matplotlib as mpl

mpl.rcParams['axes.labelsize'] = 'x-large'
mpl.rcParams['legend.fontsize'] = 'x-large'
mpl.rcParams['xtick.labelsize'] = 'x-large'
mpl.rcParams['ytick.labelsize'] = 'x-large'

output_dir = './plots/'
def save_pic(renderer, fig, p, suffix):
    fh = renderer._get_figure(fig);
    plt.tight_layout()
    plt.savefig(f'{output_dir}/planarHypersonic_{suffix}.eps')

# mpbvp_ds = Dill('../../mpbvp/boundedBrachistochrone/data.dill')
icrm_ds = Dill('../planarHypersonic/data_thesis.dill')
plots = BelugaPlot('./data.dill',default_sol=-1,default_step=-1, renderer='matplotlib')

plots.add_plot().line('theta*re/1000','h/1000',label='QCPI', sol=-1, step=-1, style={'lw':0.0, 'marker':'o'})\
                .line('theta*re/1000','h/1000',label='Shooting', sol=-1, step=-1, style={'lw':2.0})\
                .xlabel('Downrange distance [km]').ylabel('$h$ [km]') \
                .postprocess(ft.partial(save_pic,suffix='qcpi_ht'))

plots.add_plot().line('t','alfa*180/3.14',label='QCPI', style={'lw':0.0, 'marker':'o'})\
                .line('t','alfa*180/3.14',label='Shooting', datasource=icrm_ds, step=-1, sol=-1, style={'lw':2.0})\
                .xlabel('$t$ [s]').ylabel('$\\theta$ [deg]') \
                .postprocess(ft.partial(save_pic,suffix='qcpi_alfa'))

plots.add_plot(colormap=cmx.viridis).line_series('theta*re/1000','h/1000',step=-1,skip=5,  style={'lw':1.5})\
                .xlabel('Downrange distance [km]').ylabel('$h$ [km]') \
                .postprocess(ft.partial(save_pic,suffix='qcpi_evol_ht'))
예제 #8
0
def save_pic(renderer, fig, p, suffix):
    fh = renderer._get_figure(fig)
    # tikz_save(f'{output_dir}/brachisto_{suffix}.tex', figureheight='\\figureheight', figurewidth='\\figurewidth')
    plt.tight_layout()
    plt.savefig(f'{output_dir}/brachisto_{suffix}.eps')


def postprocess_ham(r, f, p):
    plt.ticklabel_format(style='sci', axis='y', scilimits=(0, 0))
    save_pic(r, f, p, 'qcpi_ham')


mpbvp_ds = Dill('../../1-brachistochrone/data.dill')
plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

plots.add_plot(mesh_size=None).line('x','y',label='QCPI', sol=-1, step=-1, style={'lw': 0.0, 'marker':'o'}) \
                .line('x','y',label='Multiple Shooting', datasource=mpbvp_ds, step=-1, sol=-1, style={'lw': 2.0})\
                .xlabel('$x(t)$ [m]').ylabel('$y(t)$ [m]')      \
                .postprocess(ft.partial(save_pic, suffix='qcpi_xy'))

plots.add_plot(mesh_size=None).line('abs(t)','theta*180/3.14',label='QCPI', style={'lw': 0.0, 'marker':'o'}) \
                .line('abs(t)','theta*180/3.14',label='Multiple Shooting', datasource=mpbvp_ds, step=-1, sol=-1, style={'lw': 2.0})\
                .xlabel('$t$ [s]').ylabel('$\\theta$ [deg]')      \
                .postprocess(ft.partial(save_pic, suffix='qcpi_theta'))

plots.add_plot(mesh_size=None)\
                .line('abs(t)','lamX',label='$\\lambda_x(t)$', style={'lw': 2.0})\
                .line('abs(t)','lamY',label='$\\lambda_y(t)$', style={'lw': 2.0})\
예제 #9
0
from beluga.visualization import BelugaPlot
import matplotlib.pyplot as plt

plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

# plots.add_plot().line('xbar*V*tfreal','ybar*V*tfreal')                    \
#                 .xlabel('x(t)').ylabel('y(t)')      \
#                 .title('Trajectory')
plots.add_plot().line('e','n',label='traj1')                    \
                .xlabel('x(t)').ylabel('y(t)')      \
                .title('Trajectory') \
                .postprocess(lambda a,b,c: plt.axis('equal'))

plots.add_plot().line('t','psi*180/3.14')                    \
                .xlabel('t (s)').ylabel('psi (deg)')      \
                .title('Heading')

plots.add_plot().line('t','gam*180/3.14',label='FPA')                    \
                .line('t','bank*180/3.14',label='Bank angle')                    \
                .xlabel('t [s]').ylabel('Control [deg]')      \
                .title('Control history')

# plots.add_plot().line('t','sqrt((xbar - xbar2)**2 + (ybar - ybar2)**2)*(V*tfreal)')                    \
#                 .xlabel('t').ylabel('Separation (m)')      \
#                 .title('Separation')

plots.render()
예제 #10
0
            # a, b = '{:.0e}'.format(x).split('e')
            # b = int(b)
            # return r'${} \times 10^{{{}}}$'.format(a, b)

        formatter = ticker.FuncFormatter(fmt)
    else:
        formatter = None
    cb = mpl.colorbar.ColorbarBase(cax,
                                   cmap=cmap,
                                   norm=norm,
                                   orientation=orient,
                                   format=formatter)
    cb.set_label(label)


plots = BelugaPlot('./data_fpa60.dill', default_sol=-1, default_step=-1)
mpbvp_ds = Dill('../../mpbvp/planarHypersonicWithHeatRate/data_1200.dill')
const_ds = Dill('./data_1200_5k_1deg_ep6.dill')
qdot_ds = Dill('./data_1200_ep4.dill')

# Remove \addlegendimage lines from tex file for dot plots

plots.add_plot(colormap=cmx.viridis_r).line_series('theta*re/1000','h/1000',step=1,skip=0,style={'lw':2.0}) \
                .xlabel('Downrange [km]').ylabel('$h$ [km]')\
                .postprocess(ft.partial(save_pic, suffix='evol1_htheta'))

plots.add_plot(colormap=cmx.viridis_r).line_series('t','gam*180/3.14159',step=1,skip=0,style={'lw':2.0}) \
                .xlabel('$t$ [s]').ylabel('$\\gamma$ [deg]')\
                .postprocess(ft.partial(save_pic, suffix='evol1_fpa'))

rho = 'rho0*exp(-h/H)'
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./data.dill', default_sol=-1, default_step=-1)

plots.add_plot().line('y','x')                    \
                .xlabel('y (m)').ylabel('x (m)')      \
                .title('Boat Trajectory')       \

plots.add_plot().line('t','hdg*57.3')                    \
                .xlabel('time (s)').ylabel('hdg (rad)')      \
                .title('Boat Heading')

plots.render()
예제 #12
0
파일: plot.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot
import matplotlib.pyplot as plt
import sys

if len(sys.argv) < 2:
    print('Usage: python plot.py <n>')
# plots = BelugaPlot('./data-3v-s15.dill',default_sol=-1,default_step=-1, renderer='matplotlib')
plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')
# 872
# plots.add_plot().line('xbar*V*tfreal','ybar*V*tfreal')\
#                 .xlabel('x(t)').ylabel('y(t)')\
#                 .title('Trajectory')
plot1 = plots.add_plot().line('xbar', 'ybar', label='traj1')
n = 10
for i in range(2, n + 1):
    plot1.line(f'xbar{i}', f'ybar{i}', label=f'traj{i}')

# plots.add_plot().line('t','psi*180/3.14')\
#                 .line('t','psi2*180/3.14')\
#                 .line('t','psi3*180/3.14')\
#                 .line('t','psi4*180/3.14')\
#                 # .line('t','psi5*180/3.14')\
#                 # .xlabel('t (s)').ylabel('psi (deg)')\
#                 # .title('Heading')
#
# plots.add_plot().line('t','abar')\
#                 .line('t','abar2')\
#                 .line('t','abar3')\
예제 #13
0
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./data.dill',default_sol=-1,default_step=-1, renderer='matplotlib')

plots.add_plot().line('t','x')                    \
                .xlabel('t').ylabel('x [m]')      \
                .title('Trajectory')

plots.add_plot().line('t','v')                    \
                .xlabel('t (s)').ylabel('v (m/s)')      \
                .title('Velocity history')

plots.add_plot().line('t','a')                    \
                .xlabel('t (s)').ylabel('a (m/s^2)')      \
                .title('Control history')

plots.render()
예제 #14
0
    divider = make_axes_locatable(ax)
    cax = divider.append_axes(pos, size="5%", pad=0.05)

    cb = mpl.colorbar.ColorbarBase(cax, cmap=cmap, norm=norm, orientation=orient)
    cb.set_label(label)

def add_vehicle_labels(r,f,p):
    y0 = np.array([-0.05, 0.1, 0.15, -0.1,-0.15])*scale
    yf = np.array([0.0, 0.0, 0.0, -0.05,-0.05])*scale
    x0 = np.ones_like(y0)*-0.8*scale

    for i,(x,y) in enumerate(zip(x0,y0),1):
        plt.text(x-0.45,y+0.05,str(i))

# plots = BelugaPlot('data-qcpi-ulim-5v.dill',default_sol=-1,default_step=0, renderer='matplotlib')
plots = BelugaPlot('data-5v-nominal.dill',default_sol=-1,default_step=-1, renderer='matplotlib')

V = 300
scale = V*50/1e3
Zone1 = np.array([-0.6, 0.0, 0.1])*scale
Zone1a = np.array([-0.6, 0.15, 0.1])*scale

def add_circle(r,f,p,pos,rad):
    ax = plt.gca()
    ax.add_patch(Circle(pos, radius=rad, fill=False, hatch='/', color='r'))

# 
# plots.add_plot()\
#                 .line('xbar*V*tfreal/1e3','ybar*V*tfreal/1e3',step=0,sol=-1,label='Vehicle 1',style={'lw':2.0})\
#                 .line('xbar2*V*tfreal/1e3','ybar2*V*tfreal/1e3',step=0,sol=-1,label='Vehicle 2',style={'lw':2.0})\
#                 .line('xbar3*V*tfreal/1e3','ybar3*V*tfreal/1e3',step=0,sol=-1,label='Vehicle 3',style={'lw':2.0})\
예제 #15
0
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./data.dill',default_sol=-1,default_step=-1)

plots.add_plot().line('theta*re/1000','h/1000')                    \
                .xlabel('Downrange (km)').ylabel('h (km)')      \
                .title('Altitude vs. Downrange')

plots.add_plot().line('t','alfa*180/3.14')                    \
                .xlabel('t (s)').ylabel('alfa (degrees)')      \
                .title('Angle of attack vs. Time')

rho = 'rho0*exp(-h/H)'
Cl  = '(1.5658*alfa + -0.0000)'
Cd  = '(1.6537*alfa**2 + 0.0612)'

D   = '(0.5*'+rho+'*v**2*'+Cd+'*Aref)'
L   = '(0.5*'+rho+'*v**2*'+Cl+'*Aref)'

plots.add_plot().line('t','sqrt('+D+'**2+'+L+'**2)/(mass*g0)') \
                .xlabel('t (s)').ylabel('G-Loading')      \
                .title('G-Loading vs. Time')
# plots.add_plot().line('theta*re/1000','h/1000',label='Foo')       \
#                 .line('theta*re/1000','h/1000',label='Bar',step=1,sol=5)   \
#                 .xlabel('Downrange (km)')                   \
#                 .ylabel('h (km)')                           \
#                 .title('Altitude vs. Downrange')

plots.render()
예제 #16
0
파일: plot.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./data.dill', default_sol=-1, default_step=-1)

plots.add_plot().line('t','x')                    \
                .xlabel('t (s)').ylabel('x(t)')      \
                .title('Position vs. Time')
#
# plots.add_plot().line('t','(_xlim - (2*_xlim/(1+exp((2/_xlim)*xi11))))')                    \
#                 .xlabel('t (s)').ylabel('psi(t)')      \
#                 .title('psi1 vs. Time')

plots.add_plot().line('t','u')                    \
                .xlabel('t (s)').ylabel('u(t)')      \
                .title('Control history')

plots.add_plot().line('t','v')                    \
                .xlabel('t (s)').ylabel('v(t)')      \
                .title('v vs. t')

plots.add_plot().line('t','xi12')                    \
                .xlabel('t (s)').ylabel('xi12(t)')      \
                .title('xi12 vs. t')
plots.render()
예제 #17
0
from beluga.visualization import BelugaPlot

# plots = BelugaPlot('./data_2500_ep4.dill',default_sol=-1,default_step=-1, renderer='matplotlib')
# plots = BelugaPlot('./data-flydown.dill',default_sol=-1,default_step=-1, renderer='matplotlib')
plots = BelugaPlot('./data-1k2-eps6-eps7.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')
# plots = BelugaPlot('./data_1200_5k_1deg_ep6.dill',default_sol=-1,default_step=-1, renderer='matplotlib')

plots.add_plot().line('theta*180/3.14','h/1000')                    \
                .xlabel('Downrange (deg)').ylabel('h (km)')      \
                .title('Altitude vs. Downrange')

plots.add_plot().line('t','k*sqrt(rho0*exp(-h/H)/rn)*v**3/1e4')                    \
                .line('t','qdotMax/1e4')    \
                .xlabel('t (s)').ylabel('Heat Rate (W/cm^2)')      \
                .title('Heat Rate vs. Time')

# plots.add_plot().line('t','sqrt(D^2+L^2)/(mass*9.81)') \
#                 .xlabel('t (s)').ylabel('G-Loading')      \
#                 .title('G-Loading vs. Time')
plots.add_plot().line('t','v/1e3') \
                .xlabel('t (s)').ylabel('Heat rate')      \
                .title('Heatrate vs. Time')

plots.add_plot().line('t','gam*180/pi') \
                .xlabel('t (s)').ylabel('FPA (deg)')      \
                .title('FPA')
plots.render()
예제 #18
0
    resolution = 20
    x = np.linspace(x_center - radius, x_center + radius, resolution)
    z = np.linspace(elevation, elevation + height, resolution)
    X, Z = np.meshgrid(x, z)

    Y = np.sqrt(radius**2 -
                (X - x_center)**2) + y_center  # Pythagorean theorem

    ax.plot_surface(X, Y, Z, linewidth=0)
    ax.plot_surface(X, (2 * y_center - Y), Z, linewidth=0)
    plt.axis('equal')


# plots = BelugaPlot('./data-3s3-202.dill',default_sol=-1,default_step=-1, renderer='matplotlib')
plots = BelugaPlot(filename,
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

plots.add_plot(colormap=cmx.viridis).line('xbar2*V*tfreal/1e3','ybar2*V*tfreal/1e3',label='Vehicle 2',style={'color':'red'})\
                .line_series('xbar*V*tfreal/1e3','ybar*V*tfreal/1e3',skip=2)\
                .line('xc*V*tfreal/1e3+rc*V*tfreal/1e3*cos(2*pi*t/tf)','yc*V*tfreal/1e3+rc*V*tfreal/1e3*sin(2*pi*t/tf)')\
                .xlabel('x(t) [km]').ylabel('y(t) [km]')\
                .title('Trajectory') \
                .postprocess(lambda a,b,c: plt.axis('equal'))

plots.add_plot(colormap=cmx.jet).line('t','V',label='Vehicle 1',style='r')\
                .line_series('t','vbar2*V',skip=2)\
                .xlabel('t [s]').ylabel('v(t) [m/s]')\
                .title('Speed') \

# plots.add_plot().line('xbar','ybar',label='traj1')\
예제 #19
0
파일: plot.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot

# plots = BelugaPlot('./data_fpa60_ms.dill',default_sol=-1,default_step=-1, renderer='matplotlib')
plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

plots.add_plot().line('theta*180/3.14','h/1000')                    \
                .xlabel('Downrange (deg)').ylabel('h (km)')      \
                .title('Altitude vs. Downrange')

plots.add_plot().line_series('t','qdot/1e4',step=-1)\
                .xlabel('t (s)').ylabel('Heat Rate (W/cm^2)')      \
                .title('Heat Rate vs. Time')\
                .line('t','qdotMax/1e4')    \

plots.add_plot().line_series('t','v/1e3',step=-1)\
                .xlabel('t (s)').ylabel('Speed km/s')      \
                .title('Heat Rate vs. Time')
#
# plots.add_plot().line_series('t','qdot/1e4',step=4)\
#                 .xlabel('t (s)').ylabel('Heat Rate (W/cm^2)')      \
#                 .title('Heat Rate vs. Time')
#
# plots.add_plot().line_series('t','qdot/1e4',step=5)\
#                 .xlabel('t (s)').ylabel('Heat Rate (W/cm^2)')      \
#                 .title('Heat Rate vs. Time')
#
# plots.add_plot().line_series('t','qdot/1e4',step=6)\
#                 .xlabel('t (s)').ylabel('Heat Rate (W/cm^2)')      \
예제 #20
0
mpl.rcParams['xtick.labelsize'] = 'x-large'
mpl.rcParams['ytick.labelsize'] = 'x-large'

output_dir = './plots/'


def save_pic(renderer, fig, p, suffix):
    fh = renderer._get_figure(fig)
    plt.tight_layout()
    plt.savefig(f'{output_dir}/boundedbrachisto_{suffix}.eps')


# mpbvp_ds = Dill('../../mpbvp/boundedBrachistochrone/data.dill')
icrm_ds = Dill('../../icrm/boundedBrachistochrone/data.dill')
plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

plots.add_plot().line('x','y',label='QCPI', sol=-1, step=-1, style={'lw':0.0, 'marker':'o'})               \
                .line('x','y',label='ICRM + Shooting', datasource=icrm_ds, step=-1, sol=-1, style={'lw':2.0})\
                .line('x','-1.0-x',label='x + y = 1',step=-1,sol=-1,style={'lw':2.0, 'linestyle':'--'}) \
                .xlabel('$x(t)$ [m]').ylabel('$y(t)$ [m]') \
                .postprocess(ft.partial(save_pic,suffix='qcpi_xy'))

plots.add_plot().line('t','theta*180/3.14',label='QCPI Solution', style={'lw':0.0, 'marker':'o'})                    \
                .line('t','theta*180/3.14',label='ICRM + Shooting', datasource=icrm_ds, step=-1, sol=-1, style={'lw':2.0})\
                .xlabel('$t$ [s]').ylabel('$\\theta$ [deg]') \
                .postprocess(ft.partial(save_pic,suffix='qcpi_theta'))
plots.render()
예제 #21
0
            # b = int(b)
            # return r'${} \times 10^{{{}}}$'.format(a, b)

        formatter = ticker.FuncFormatter(fmt)
    else:
        formatter = None
    cb = mpl.colorbar.ColorbarBase(cax,
                                   cmap=cmap,
                                   norm=norm,
                                   orientation=orient,
                                   format=formatter)
    cb.set_label(label)


plots = BelugaPlot('./data-1k2-eps4-eps4.dill',
                   default_sol=-1,
                   default_step=-1)

ds_constraint = Dill('./data-1k2-eps4-eps4.dill')  # 26 steps
ds_epsHR = Dill('./data-1k2-eps6-eps4.dill')  # 36 steps
ds_epsAlfa = Dill('./data-1k2-eps6-eps7.dill')  # 36 steps
ds_gpops = GPOPS('./alfa_tol_e6.mat',
                 states=('h', 'theta', 'v', 'gam'),
                 controls=('alfa', ),
                 const={
                     'H': 7.5e3,
                     'rho0': 1.2,
                     'k': 1.74153e-4,
                     'rn': 1 / 12 * 0.3048
                 })
예제 #22
0
파일: plot2.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot
import matplotlib.pyplot as plt
plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

# plots.add_plot().line('x*V*tfreal','y*V*tfreal')                    \
#                 .xlabel('x(t)').ylabel('y(t)')      \
#                 .title('Trajectory')
plots.add_plot().line('xbar','ybar',label='traj1') \
                .xlabel('x(t)').ylabel('y(t)')      \
                .title('Trajectory') \
                .postprocess(lambda a,b,c: plt.axis('equal'))
# .line('xc + rc*cos(2*3.14*t/tf)','yc + rc*sin(2*3.14*t/tf)')\
# plots.add_plot().line('t','psi*180/3.14')                    \
#                 .xlabel('t (s)').ylabel('psi (deg)')      \
#                 .title('Heading')

# plots.add_plot().line('t','u')                    \
#                 .xlabel('t (s)').ylabel('u (rad/s)')      \
#                 .title('Control history')
#
# plots.add_plot().line('t','sqrt((x - x2)**2 + (y - y2)**2)*(V*tfreal)')                    \
#                 .xlabel('t').ylabel('Separation (m)')      \
#                 .title('Separation')

plots.render()
예제 #23
0
파일: plot.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot

# plots = BelugaPlot('./data.dill',default_sol=-1,default_step=0)
plots = BelugaPlot('./data.dill',default_sol=-1,default_step=-1, renderer='matplotlib')

plots.add_plot().line('x','y',label='Solution')               \
                .xlabel('x(t)').ylabel('y(t)')      \
                .title('Trajectory')
# .line('x','-2-0.75*x',label='Constraint2',step=-1,sol=-1) \
plots.add_plot().line('t','delta*180/3.14')                    \
                .xlabel('t (s)').ylabel('delta (degrees)')      \
                .title('Steering')
#
# plots.add_plot().line('t','theta*180/3.14')                    \
#                 .xlabel('t (s)').ylabel('theta (degrees)')      \
#                 .title('Heading')
plots.render()
예제 #24
0
             format='eps'):
    fh = renderer._get_figure(fig)
    if tight:
        plt.tight_layout()
    if rasterized:
        # plt.gca().set_rasterized(True)
        plt.savefig(f'{output_dir}/bench_{suffix}.{format}',
                    rasterized=True,
                    format='pdf',
                    dpi=300)
    else:
        plt.savefig(f'{output_dir}/bench_{suffix}.{format}')


plots = BelugaPlot('data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

scale = 15

plot1 = plots.add_plot(colormap=cmx.tab10).line(f'xbar*{scale}',
                                                f'ybar*{scale}',
                                                label='Vehicle 1',
                                                style={'lw': 2.0})
plot2 = plots.add_plot(colormap=cmx.tab10).line('t*50',
                                                'abar',
                                                label='$\\bar{u}_1(t)$',
                                                style={'lw': 2.0})

n = 10
for i in range(2, n + 1):
예제 #25
0
from beluga.visualization import BelugaPlot
from beluga.visualization.datasources import Dill
# plots = BelugaPlot('./data.dill',default_sol=-1,default_step=0)
mpbvp_ds = Dill('../../mpbvp/planarHypersonicWithHeatRate/data_1200.dill')
plots = BelugaPlot('./data_1200_2deg15km_ep4.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')


plots.add_plot().line('theta*180/3.14','h/1000',label='ICRM Solution')                    \
                .xlabel('Downrange (deg)').ylabel('h (km)')      \
                .title('Altitude vs. Downrange') \
                .line('theta*180/3.14','h/1000',label='MPBVP Solution', datasource=mpbvp_ds, step=-1, sol=-1) \

plots.add_plot().line('t','k*sqrt(rho0*exp(-h/H)/rn)*v**3/10000',label='ICRM Solution') \
                .line('t','k*sqrt(rho0*exp(-h/H)/rn)*v**3/10000',label='MPBVP Solution', datasource=mpbvp_ds, step=-1, sol=-1) \
                .xlabel('t (s)').ylabel('Heat-rate')      \
                .title('Heat-rate vs. Time')

# plots.add_plot().line('t','theta*180/3.14',label='ICRM Solution')                    \
#                 .line('t','theta*180/3.14',label='MPBVP Solution', datasource=mpbvp_ds, step=-1, sol=-1)\
#                 .line('t','theta*180/3.14',label='Unconstrained Solution', datasource=mpbvp_ds, step=0, sol=-1)\
#                 .xlabel('t (s)').ylabel('theta (degrees)')      \
#                 .title('Control history')
#
# plots.add_plot().line('t','lamY', label='ICRM Solution')                    \
#                 .line('t','lamY', label='MPBVP Solution', datasource=mpbvp_ds, step=-1, sol=-1)\
#                 .line('t','lamY', label='Unconstrained Solution', datasource=mpbvp_ds, step=0, sol=-1) \
#                 .xlabel('t (s)').ylabel('lamY')      \
#                 .title('lamY')
예제 #26
0
파일: plot.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot
import matplotlib.pyplot as plt
# plots = BelugaPlot('./data-3s3-202.dill',default_sol=-1,default_step=-1, renderer='matplotlib')
plots = BelugaPlot('./data.dill',
                   default_sol=-1,
                   default_step=-1,
                   renderer='matplotlib')

# plots.add_plot().line('x*V*tfreal','y*V*tfreal')\
#                 .xlabel('x(t)').ylabel('y(t)')\
#                 .title('Trajectory')

plots.add_plot().line('x','y',label='traj1')\
                .line('x2','y2',label='traj2')\
                .line('xc1+rc1*cos(2*pi*t/tf)','yc1+rc1*sin(2*pi*t/tf)')\
                .line('xc2+rc2*cos(2*pi*t/tf)','yc2+rc2*sin(2*pi*t/tf)')\
                .line('xc3+rc3*cos(2*pi*t/tf)','yc3+rc3*sin(2*pi*t/tf)')\
                .xlabel('x(t)').ylabel('y(t)')\
                .title('Trajectory') \
                .postprocess(lambda a,b,c: plt.axis('equal'))

# plots.add_plot().line('t','xi11',label='xi11')\
#                 .line('t','xi21',label='xi21')\
#                 .line('t','xi31',label='xi31')
#                 .line('x2','y2',label='traj2')\
#                 .line('xc+rc*cos(2*pi*t/tf)','yc+rc*sin(2*pi*t/tf)')\
#                 .xlabel('x(t)').ylabel('y(t)')\
#                 .title('Trajectory') \
#                 .postprocess(lambda a,b,c: plt.axis('equal'))

# plots.add_plot().line('t','z')\
예제 #27
0
파일: plot.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./data.dill',default_sol=-1,default_step=-1, renderer='matplotlib')

plots.add_plot().line('x','y')                    \
                .xlabel('x(t)').ylabel('y(t)')      \
                .title('Trajectory')

plots.add_plot().line('t','theta')                    \
                .xlabel('t (s)').ylabel('theta (degrees)')      \
                .title('Control history')
plots.render()
예제 #28
0
파일: plot.py 프로젝트: jsdelivrbot/beluga
from beluga.visualization import BelugaPlot

plots = BelugaPlot('./data.dill', default_sol=-1, default_step=-1)
plots.add_plot().line('theta*re/1000','h/1000', step=-1)                    \
                .xlabel('Downrange (km)').ylabel('h (km)')      \
                .title('Altitude vs. Downrange')

plots.add_plot().line('t','alfa*180/pi')                    \
                 .xlabel('t (s)').ylabel('alfa (degrees)')      \
                 .title('Angle of attack vs. Time')

plots.add_plot().line('theta*re/1000','h/1000')                    \
                .xlabel('Downrange (km)').ylabel('h (km)')      \
                .title('Altitude vs. Downrange')

plots.add_plot().line('v/1000','h/1000')                    \
                .xlabel('v (km/s)').ylabel('h (km)')      \
                .title('Altitude vs. Velocity')

plots.render()
예제 #29
0
from beluga.visualization import BelugaPlot

plots = BelugaPlot('data.dill', default_sol=-1, default_step=-1)

plots.add_plot().line('x','y')                    \
                # .xlabel('t (s)').ylabel('h (km)')      \

# .title('Altitude vs. Time')

plots.add_plot().line('t', '(-ep*k*lamX*cos(u) - k*lamA*sin(u))') \
                .line('t','(-ep*k*lamX*cos(u))') \
                .line('t','lamX') \
                .line('t','lamA')

plots.add_plot().line('t', '-k*(lamX*v*sin(a) - lamY*v*cos(a))*cos(u)') \

# .xlabel('t (s)').ylabel('h (km)')      \
# .title('Altitude vs. Time')

# plots.add_plot().line('t','alfa*180/3.14')                    \
#                 .xlabel('t (s)').ylabel('alfa (degrees)')      \
#                 .title('Angle of attack vs. Time')

# plots.add_plot().line('theta*re/1000','h/1000',legend='Foo')       \
#                 .line('theta*re/1000','h/1000',legend='Bar',step=1,sol=5)   \
#                 .xlabel('Downrange (km)')                   \
#                 .ylabel('h (km)')                           \
#                 .title('Altitude vs. Downrange')

plots.render()
예제 #30
0
from beluga.visualization import BelugaPlot
import matplotlib.pyplot as plt
plots = BelugaPlot('./data.dill',default_sol=-1,default_step=-1, renderer='matplotlib')

# plots.add_plot().line('xbar*V*tfreal','ybar*V*tfreal')                    \
#                 .xlabel('x(t)').ylabel('y(t)')      \
#                 .title('Trajectory')
plots.add_plot().line('xbar','ybar',label='traj1')                    \
                .line('xbar2','ybar2',label='traj2')                    \
                .xlabel('x(t)').ylabel('y(t)')      \
                .title('Trajectory') \
                .postprocess(lambda a,b,c: plt.axis('equal'))

plots.add_plot().line('t','psi*180/3.14')                    \
                .line('t','psi2*180/3.14')                    \
                .xlabel('t (s)').ylabel('psi (deg)')      \
                .title('Heading')

plots.add_plot().line('t','abar*V/tfreal')                    \
                .line('t','abar2*V/tfreal')                    \
                .xlabel('t (s)').ylabel('a (rad/s)')      \
                .title('Control history')

# plots.add_plot().line('t','sqrt((xbar - xbar2)**2 + (ybar - ybar2)**2)*(V*tfreal)')                    \
#                 .xlabel('t').ylabel('Separation (m)')      \
#                 .title('Separation')


plots.render()