Skip to content

Commit

Permalink
show SpectralTransform with Legendre size
Browse files Browse the repository at this point in the history
  • Loading branch information
milankl committed Aug 4, 2023
1 parent 11ed513 commit 5bfcb8d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/SpeedyTransforms/SpeedyTransforms.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module SpeedyTransforms

using DocStringExtensions

using DocStringExtensions, Printf

# NUMERICS
import AssociatedLegendrePolynomials as Legendre
Expand Down
25 changes: 22 additions & 3 deletions src/SpeedyTransforms/show.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# stolen from BenchmarkTools.jl
function prettymemory(b)
if b < 1024
return string(b, " bytes")
elseif b < 1024^2
value, units = b / 1024, "KiB"
elseif b < 1024^3
value, units = b / 1024^2, "MiB"
else
value, units = b / 1024^3, "GiB"
end
return string(@sprintf("%.2f", value), " ", units)
end

function Base.show(io::IO,S::SpectralTransform{NF}) where NF
(;mmax,Grid,nlat_half) = S
(;lmax,mmax,Grid,nlat_half) = S

# add information about size of Legendre polynomials
s = S.recompute_legendre ? Base.summarysize(S.Λ) : Base.summarysize(S.Λs)
s_str = prettymemory(s)

println(io,"$(typeof(S))(")
println(io," Spectral: T$mmax LowerTriangularMatrix{Complex{$NF}}")
println(io," Spectral: T$mmax, $(lmax+1)x$(mmax+1) LowerTriangularMatrix{Complex{$NF}}")
println(io," Grid: $(RingGrids.get_nlat(Grid,nlat_half))-ring $Grid{$NF}")
print(io," Legendre: recompute polynomials $(S.recompute_legendre))")
print(io," Legendre: recompute polynomials $(S.recompute_legendre), $s_str)")
end

0 comments on commit 5bfcb8d

Please sign in to comment.