Skip to content

Commit

Permalink
better annotations + auto ICAO code
Browse files Browse the repository at this point in the history
  • Loading branch information
ngomezve authored and askprash committed Oct 7, 2024
1 parent b6112b1 commit 46dbc6e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 29 deletions.
60 changes: 31 additions & 29 deletions src/IO/outputs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ function stickfig(ac::aircraft; ax = nothing, label_fs = 16,
if ax === nothing
# plt.style.use(["../miscellaneous/prash.mplstyle"]) # HACK
fig, ax = plt.subplots(figsize=(8,5), dpi = 300)
fig.subplots_adjust(right=0.6)
fig.subplots_adjust(right=0.75)
else
ax.cla()
end
Expand Down Expand Up @@ -584,7 +584,7 @@ function stickfig(ac::aircraft; ax = nothing, label_fs = 16,

# Annotations
if annotate_text
ax.text(1, 0.8, transform=ax.transAxes, @sprintf("PFEI = %5.3f\nM\$_{cruise}\$ = %.2f\nWMTO = %.1f tonnes\nSpan = %5.1f m\nco = %5.1f m\n\$ \\Lambda \$ = %.1f\$^\\circ\$\nRfuse = %5.1f m\nL/D = %3.2f",
ax.text(1.05, 0.75, transform=ax.transAxes, @sprintf("PFEI = %5.3f\nM\$_{cruise}\$ = %.2f\nWMTO = %.1f t\nSpan = %5.1f m\nco = %5.1f m\n\$ \\Lambda \$ = %.1f\$^\\circ\$\nRfuse = %5.1f m\nL/D = %3.2f",
parm[imPFEI], para[iaMach, ipcruise1],parg[igWMTO]/9.81/1000, parg[igb], parg[igco], parg[igsweep], fuselage.layout.radius, para[iaCL, ipcruise1]/para[iaCD, ipcruise1]),
fontsize = label_fs, ha="left", va="top")
end
Expand All @@ -597,34 +597,17 @@ function stickfig(ac::aircraft; ax = nothing, label_fs = 16,
ax.text(xend/2, yloc, @sprintf("l = %5.1f m", xend), bbox=Dict("ec"=>"w", "fc"=>"w"), ha="center", va="center", fontsize = 14, zorder = 31)
end
# Span annotations:
codeD = true
codeE = false
xcodeD = -2.0
xcodeE = -3.5
if codeD && annotate_group
# ICAO code D
bmaxD = 36
ax.vlines(xcodeD, -bmaxD/2, bmaxD/2, lw = 5, alpha = 0.2, color = "y")
ax.hlines( bmaxD/2, xcodeD, 40.0, lw = 5, alpha = 0.2, color = "y")
ax.hlines(-bmaxD/2, xcodeD, 40.0, lw = 5, alpha = 0.2, color = "y")
ax.text(20, bmaxD/2+1, "ICAO Code D/ FAA Group III", color = "y", alpha = 0.8, fontsize = 12, ha="center", va="center")
end
if codeE && annotate_group
# ICAO code E
bmaxE = 52
ax.vlines(xcodeE, -bmaxE/2, bmaxE/2, lw = 5, alpha = 0.2, color = "b")
ax.hlines( bmaxE/2, xcodeE, 40.0, lw = 5, alpha = 0.2, color = "b")
ax.hlines(-bmaxE/2, xcodeE, 40.0, lw = 5, alpha = 0.2, color = "b")
ax.text(20, bmaxE/2+1, "ICAO Code E/ FAA Group IV", color = "b", alpha = 0.5, fontsize = 12, ha="center", va="center")
end

if codeE
ax.set_ylim(min(-27, -b/2.0), max(27, b/2.0))
elseif codeD
ax.set_ylim(min(-23, -b/2.0),max(23, b/2.0))
else
ax.set_ylim(min(-20, -2b/2.0), max(20, b/2.0))
groups, bmax = find_aerodrome_code(parg[igbmax]) #Find ICAO and FAA groups as well as max span
xcode = -2.0

if annotate_group
ax.vlines(xcode, -bmax/2, bmax/2, lw = 5, alpha = 0.2, color = "y")
ax.hlines( bmax/2, xcode, 40.0, lw = 5, alpha = 0.2, color = "y")
ax.hlines(-bmax/2, xcode, 40.0, lw = 5, alpha = 0.2, color = "y")
ax.text(20, bmax/2+1, "ICAO Code $(groups[1])/ FAA Group $(groups[2])", color = "y", alpha = 0.8, fontsize = 12, ha="center", va="center")
end
ax.set_ylim(-1.2*bmax/2, 1.2*bmax/2)

ax.set_aspect(1)
ax.set_ylabel("y[m]")
ax.set_xlabel("x[m]")
Expand All @@ -638,6 +621,25 @@ function stickfig(ac::aircraft; ax = nothing, label_fs = 16,
return ax
end

"""
find_aerodrome_code(b)
`find_aerodrome_code` finds the airport code corresponding to a given aircraft wingspan. It returns
the codes in the ICAO and FAA formats, as well as the maximum wingspan for these codes.
"""
function find_aerodrome_code(b::Float64)
max_bs = sort(collect(keys(aerodrome_codes)))
idx = 1
for cand_maxb in max_bs
if b >= cand_maxb
idx += 1
end
end
maxb = max_bs[idx]
groups = aerodrome_codes[maxb]
return groups, Float64(maxb)
end

"""
plot_details(parg, pari, para, parm; ax = nothing)
Expand Down
10 changes: 10 additions & 0 deletions src/misc/constants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,14 @@ const seat_layouts = Dict{Int64, Vector{Int64}}(
14 => [3, 4, 4, 3],
15 => [3, 5, 4, 3],
16 => [3, 5, 5, 3]
)

const aerodrome_codes = Dict{Int64, Vector{String}}(
#max_wingspan => [ICAO code, FAA code]
15 => ["A", "I"],
24 => ["B", "II"],
36 => ["C", "III"],
52 => ["D", "IV"],
65 => ["E", "V"],
80 => ["F", "VI"],
)

0 comments on commit 46dbc6e

Please sign in to comment.