Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plot(::LowerTriangularMatrix) #408

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/LowerTriangularMatrices/LowerTriangularMatrices.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ module LowerTriangularMatrices

using DocStringExtensions
import Adapt
import UnicodePlots

export LowerTriangularMatrix, eachharmonic
# export plot

include("lower_triangular_matrix.jl")
include("plot.jl")

end
29 changes: 29 additions & 0 deletions src/LowerTriangularMatrices/plot.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function plot(L::LowerTriangularMatrix{T}; mode::Function=abs) where T

l,m = size(L)
title ="$l×$m LowerTriangularMatrix{$T}"

Lplot = similar(L,real(T))
for lm in eachharmonic(L)
Lplot[lm] = mode(L[lm])
end

# use at most 33x32 points in height x width, but fewer for smaller matrices
height = min(l,33)
width = min(m,32)

plot_kwargs = pairs(( xlabel="m",
xoffset=-1,
ylabel="ℓ",
yoffset=-1,
title=title,
colormap=:inferno,
compact=true,
colorbar=true,
zlabel=string(mode),
array=true,
width=width,
height=height))

return UnicodePlots.heatmap(Lplot;plot_kwargs...)
end
2 changes: 1 addition & 1 deletion src/RingGrids/RingGrids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interpolate,
update_locator,
update_locator!

export plot
# export plot

include("utility_functions.jl")

Expand Down
1 change: 1 addition & 0 deletions src/SpeedyWeather.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ include("dynamics/models.jl")
# OUTPUT
include("output/output.jl") # defines Output
include("output/feedback.jl") # defines Feedback
include("output/plot.jl")

# INTERFACE
include("run_speedy.jl")
Expand Down
3 changes: 3 additions & 0 deletions src/output/plot.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# to avoid ambiguity with exporting plot
plot(L::LowerTriangularMatrix{T}; kwargs...) where T = LowerTriangularMatrices.plot(L;kwargs...)
plot(G::AbstractGrid{T}; kwargs...) where T = RingGrids.plot(G;kwargs...)
Loading