Skip to content

Commit

Permalink
Merge pull request #408 from SpeedyWeather/mk/plot
Browse files Browse the repository at this point in the history
plot(::LowerTriangularMatrix)
  • Loading branch information
milankl authored Nov 7, 2023
2 parents b3517f4 + 34c21a2 commit 667434b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
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...)

0 comments on commit 667434b

Please sign in to comment.