Keeping on keeping on
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
using Random, PlotlyJS, Base.Iterators
|
||||
|
||||
export plot
|
||||
export plot, plot_values, plot_thrust, plot_thrust_components
|
||||
|
||||
function random_color()
|
||||
num1 = rand(0:255)
|
||||
@@ -48,6 +48,7 @@ function standard_layout(limit::Float64, title::AbstractString; mode="dark")
|
||||
Layout(
|
||||
title=attr(
|
||||
font_color="rgb(250,250,250)",
|
||||
font_size="32",
|
||||
yanchor="top",
|
||||
y=0.95,
|
||||
text=title
|
||||
@@ -380,3 +381,97 @@ function plot(m::Union{Mission, Mission_Guess};
|
||||
PlotlyJS.plot( PlotlyJS.Plot( traces, layout ) )
|
||||
|
||||
end
|
||||
|
||||
function plot_values(m::Union{Mission, Mission_Guess},
|
||||
value::Function;
|
||||
title::String="Mission Plot",
|
||||
mode::String="dark",
|
||||
)
|
||||
i = 1
|
||||
times = Vector{Float64}()
|
||||
vals = Vector{Float64}()
|
||||
for phase in m.phases
|
||||
# First get the path
|
||||
path = prop(phase.thrust_profile, start, m.sc, phase.tof)
|
||||
push!(times, collect(LinRange(0,phase.tof,size(phase.thrust_profile)[2]))...)
|
||||
push!(vals, value.(path)...)
|
||||
end
|
||||
trace = Scatter(;xs=times, ys=vals)
|
||||
|
||||
# Determine layout details
|
||||
layout = standard_layout(0., title, mode=mode)
|
||||
|
||||
# Plot
|
||||
PlotlyJS.plot( PlotlyJS.Plot( [trace], layout ) )
|
||||
|
||||
end
|
||||
|
||||
function plot_thrust(m::Union{Mission, Mission_Guess};
|
||||
title::String="Mission Plot",
|
||||
mode::String="dark",
|
||||
)
|
||||
times = Vector{Float64}()
|
||||
vals = Vector{Float64}()
|
||||
time = datetime2julian(m.launch_date)
|
||||
start = state(Earth, time, m.launch_v∞, m.start_mass)
|
||||
for phase in m.phases
|
||||
# First get the path
|
||||
path = prop(phase.thrust_profile, start, m.sc, phase.tof)
|
||||
time += phase.tof/86400.
|
||||
mass = path[end,end]
|
||||
start = state(phase.planet, time, phase.v∞_out, mass)
|
||||
n = size(phase.thrust_profile)[1]
|
||||
println(n)
|
||||
for i in 1:n
|
||||
push!(times, time + i*phase.tof/(86400n))
|
||||
push!(vals, norm(phase.thrust_profile[i]))
|
||||
end
|
||||
end
|
||||
trace = scatter(;x=times, y=vals)
|
||||
|
||||
# Determine layout details
|
||||
layout = Layout(;title=title, xaxis_title="Time (JD)", yaxis_title="Thrust (% of Max)")
|
||||
|
||||
# Plot
|
||||
PlotlyJS.plot( PlotlyJS.Plot( [trace], layout ) )
|
||||
|
||||
end
|
||||
|
||||
function plot_thrust_components(m::Union{Mission, Mission_Guess};
|
||||
title::String="Mission Plot",
|
||||
mode::String="dark",
|
||||
)
|
||||
times = Vector{Float64}()
|
||||
vals1 = Vector{Float64}()
|
||||
vals2 = Vector{Float64}()
|
||||
vals3 = Vector{Float64}()
|
||||
time = datetime2julian(m.launch_date)
|
||||
start = state(Earth, time, m.launch_v∞, m.start_mass)
|
||||
for phase in m.phases
|
||||
# First get the path
|
||||
path = prop(phase.thrust_profile, start, m.sc, phase.tof)
|
||||
time += phase.tof/86400.
|
||||
mass = path[end,end]
|
||||
start = state(phase.planet, time, phase.v∞_out, mass)
|
||||
n = size(phase.thrust_profile)[1]
|
||||
println(n)
|
||||
for i in 1:n
|
||||
push!(times, time + i*phase.tof/(86400n))
|
||||
push!(vals1, phase.thrust_profile[i,1])
|
||||
push!(vals2, phase.thrust_profile[i,2])
|
||||
push!(vals3, phase.thrust_profile[i,3])
|
||||
end
|
||||
end
|
||||
trace1 = scatter(;x=times, y=vals1, name="x component")
|
||||
trace2 = scatter(;x=times, y=vals2, name="y component")
|
||||
trace3 = scatter(;x=times, y=vals3, name="z component")
|
||||
|
||||
# Determine layout details
|
||||
layout = Layout(;title=title,
|
||||
xaxis_title="Time (JD)",
|
||||
yaxis_title="Thrust (% of Max)")
|
||||
|
||||
# Plot
|
||||
PlotlyJS.plot( PlotlyJS.Plot( [trace1, trace2, trace3], layout ) )
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user