Skip to content

Commit 31dac2d

Browse files
committed
fix tests, update Makie API
1 parent 6904d2b commit 31dac2d

12 files changed

Lines changed: 90 additions & 92 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ test/rotationcurve.csv
88
test/*.mp4
99

1010
docs/build
11-
docs/Manifest.toml
11+
docs/Manifest.toml
12+
test/output/

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ version = "0.1.4"
55

66
[deps]
77
AstroIO = "c85a633c-0c3f-44a2-bffe-7f9d0681b3e7"
8+
AstroSimBase = "c6a34d98-f626-4d8d-b450-a3f124eaada6"
89
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
910
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
1011
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
@@ -34,6 +35,7 @@ VideoIO = "d6d074c3-1acf-5d4c-9a43-ef38773959a2"
3435

3536
[compat]
3637
AstroIO = "0.1"
38+
AstroSimBase = "0.1"
3739
CSV = "0.10"
3840
ColorSchemes = "3"
3941
Colors = "0.12, 0.13"

src/AstroPlot.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ using LoopVectorization
2222
using Distributed
2323

2424
using ParallelOperations
25+
using AstroSimBase
2526
@reexport using PhysicalParticles
2627
@reexport using PhysicalTrees
2728
@reexport using PhysicalMeshes
@@ -101,7 +102,7 @@ export
101102

102103
# video
103104
png2video,
104-
mosaicview,
105+
mosaic,
105106

106107
jld2, gadget2, hdf5
107108

src/images.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Images.mosaicview
1+
import Images.mosaic
22

33
"""
44
$(TYPEDSIGNATURES)
@@ -10,28 +10,28 @@ $(TYPEDSIGNATURES)
1010
1111
## Examples
1212
```jl
13-
julia> mosaicview("output", "pos_", collect(0:10:490), ".png"; fillvalue=0.5, npad=5, ncol=10, rowmajor=true)
13+
julia> mosaic("output", "pos_", collect(0:10:490), ".png"; fillvalue=0.5, npad=5, ncol=10, rowmajor=true)
1414
```
1515
"""
16-
function mosaicview(folder::String, filenamebase::String, Counts::Array, suffix::String;
16+
function mosaic(folder::String, filenamebase::String, Counts::Array, suffix::String;
1717
formatstring = "%04d",
1818
kw...
1919
)
2020
imgnames = [joinpath(folder, string(filenamebase, Printf.format(Printf.Format(formatstring), i), suffix)) for i in Counts]
2121
imgs = load.(imgnames)
22-
mosaicview(imgs; kw...)
22+
mosaic(imgs; kw...)
2323
end
2424

2525
"""
2626
$(TYPEDSIGNATURES)
2727
Plot all files matching `filenamebase` and `suffix` in `folder` to mosaic view.
2828
"""
29-
function mosaicview(folder::String, filenamebase::String, suffix::String; kw...)
29+
function mosaic(folder::String, filenamebase::String, suffix::String; kw...)
3030
imgnames = filter(x->(occursin(suffix,x) && occursin(filenamebase,x)), readdir(folder)) # Populate list of all .pngs
3131
intstrings = map(x->split(split(x, filenamebase)[2], suffix)[1], imgnames) # Extract index from filenames
3232
p = sortperm(parse.(Int, intstrings)) # sort files numerically
3333
imgnames = imgnames[p]
3434
imgs = load.(imgnames)
3535

36-
mosaicview(imgs; kw...)
36+
mosaic(imgs; kw...)
3737
end

src/mesh/projection.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ $_common_keyword_aspect
8585
$_common_keyword_figure
8686
"""
8787
function projection_density(m::MeshCartesianStatic, units = nothing;
88-
size = (900, 900),
88+
resolution = (900, 900), # use keyword resolution to avoid conflict of size function
8989
xaxis = :x, yaxis = :y,
9090
xlabel = "$(xaxis)$(axisunit(getuLength(units)))", ylabel = "$(yaxis)$(axisunit(getuLength(units)))",
9191
title = "Density projection",
@@ -103,10 +103,10 @@ function projection_density(m::MeshCartesianStatic, units = nothing;
103103
pos = slice3d(m.pos, d, 1)
104104

105105
xu, yu = pack_xy(pos; xaxis, yaxis)
106-
x = ustrip.(getuLength(units), xu)
107-
y = ustrip.(getuLength(units), yu)
106+
x = ustrip.(getuLength(units), xu[:,1])
107+
y = ustrip.(getuLength(units), yu[1,:])
108108

109-
f = Figure(; size)
109+
f = Figure(; size = resolution)
110110
ax = GLMakie.Axis(f[1,1]; xlabel, ylabel, title, aspect = AxisAspect(aspect_ratio))
111111

112112
if xid > yid

src/mesh/slice.jl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Plot 2D slice of 3D data.
9191
## Keywords
9292
$_common_keyword_axis_label
9393
"""
94-
function plot_slice!(f::Figure, ax::GLMakie.Axis, pos::AbstractArray{T,3}, data::AbstractArray{S,3}, n::Int, units = nothing;
94+
function plot_slice!(f::Figure, ax::Makie.Axis, pos::AbstractArray{T,3}, data::AbstractArray{S,3}, n::Int, units = nothing;
9595
xaxis = :x,
9696
yaxis = :y,
9797
kw...
@@ -107,17 +107,17 @@ function plot_slice!(f::Figure, ax::GLMakie.Axis, pos::AbstractArray{T,3}, data:
107107
if data isa StructArray # arrows plot
108108
ux, uy = ustrip.(pack_xy(z; xaxis, yaxis))
109109
if xid > yid
110-
GLMakie.arrows!(ax, x, y, uy, ux; kw...)
110+
Makie.arrows2d!(ax, x, y, uy, ux; kw...)
111111
else
112-
GLMakie.arrows!(ax, x, y, ux, uy; kw...)
112+
Makie.arrows2d!(ax, x, y, ux, uy; kw...)
113113
end
114114
else
115115
if xid > yid
116-
ht = GLMakie.heatmap!(ax, x, y, ustrip.(Array(transpose(z))); kw...)
117-
GLMakie.Colorbar(f[1,2], ht)
116+
ht = Makie.heatmap!(ax, x, y, ustrip.(Array(transpose(z))); kw...)
117+
Makie.Colorbar(f[1,2], ht)
118118
else
119-
ht = GLMakie.heatmap!(ax, x, y, ustrip.(Array(z)); kw...)
120-
GLMakie.Colorbar(f[1,2], ht)
119+
ht = Makie.heatmap!(ax, x, y, ustrip.(Array(z)); kw...)
120+
Makie.Colorbar(f[1,2], ht)
121121
end
122122
end
123123
end
@@ -139,7 +139,7 @@ function plot_slice(m::MeshCartesianStatic, symbol::Symbol, n::Int, units = noth
139139
kw...
140140
)
141141
f = Figure(;size)
142-
ax = GLMakie.Axis(f[1,1]; xlabel, ylabel, title, aspect)
142+
ax = Makie.Axis(f[1,1]; xlabel, ylabel, title, aspect)
143143
plot_slice!(f, ax, m.pos, getfield(m, symbol), n, units; xaxis, yaxis, kw...)
144144
return f
145145
end
@@ -154,9 +154,9 @@ function plot_mesh_heatmap(d, units = nothing;
154154
kw...
155155
)
156156
f = Figure(; size)
157-
a = GLMakie.Axis(f[1, 1]; title, aspect)
158-
ht = GLMakie.heatmap!(a, ustrip.(d); kw...)
159-
GLMakie.Colorbar(f[1, 2], ht)
157+
a = Makie.Axis(f[1, 1]; title, aspect)
158+
ht = Makie.heatmap!(a, ustrip.(d); kw...)
159+
Makie.Colorbar(f[1, 2], ht)
160160
return f
161161
end
162162

@@ -173,8 +173,8 @@ function plot_mesh_heatmap(m::MeshCartesianStatic, symbol::Symbol, units = nothi
173173
y = ustrip.(getuLength(units), axis_cartesian(m.pos, :y))
174174

175175
f = Figure(; size)
176-
a = GLMakie.Axis(f[1,1]; title, aspect)
177-
ht = GLMakie.heatmap!(a, x, y, ustrip.(getfield(m, symbol)); kw...)
178-
GLMakie.Colorbar(f[1,2], ht)
176+
a = Makie.Axis(f[1,1]; title, aspect)
177+
ht = Makie.heatmap!(a, x, y, ustrip.(getfield(m, symbol)); kw...)
178+
Makie.Colorbar(f[1,2], ht)
179179
return f
180180
end

src/precompile.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
xlims = (-0.06, +0.06), ylims = (-0.06, +0.06),
5151
times = collect(0.0:0.00005:0.005) * u"Gyr",
5252
)
53-
plt = mosaicview(joinpath(foldertest, "mosaic/"), "pos_", collect(1:9:100), ".png"; fillvalue = 0.5, npad = 3, ncol = 4, rowmajor = true)
53+
plt = mosaic(joinpath(foldertest, "mosaic/"), "pos_", collect(1:9:100), ".png"; fillvalue = 0.5, npad = 3, ncol = 4, rowmajor = true)
5454

5555
png2video(joinpath(foldertest, "mosaic/"), "pos_", ".png", joinpath(foldertest, "TDE.mp4"))
5656

src/snapshots/lagrange.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ function plot_radii(folder::String, filenamebase::String,
266266
L100 = Float64[],
267267
)
268268

269-
progress = Progress(length(Counts), "Loading data and precessing: "; #=showspeed=true=#)
269+
progress = Progress(length(Counts); desc = "Loading data and precessing: ")
270270
for i in eachindex(Counts)
271271
snapshot_index = Printf.format(Printf.Format(formatstring), Counts[i])
272272
filename = joinpath(folder, string(filenamebase, snapshot_index, suffix))
@@ -348,7 +348,7 @@ function plot_radii!(AxisScale, FigLagrange, AxisLagrange, folder::String, filen
348348
L100 = Float64[],
349349
)
350350

351-
progress = Progress(length(Counts), "Loading data and precessing: "; #=showspeed=true=#)
351+
progress = Progress(length(Counts), desc = "Loading data and precessing: ")
352352
for i in eachindex(Counts)
353353
snapshot_index = Printf.format(Printf.Format(formatstring), Counts[i])
354354
filename = joinpath(folder, string(filenamebase, snapshot_index, suffix))

src/snapshots/positions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function plot_positionslice(folder::String, filenamebase::String, Counts::Array{
124124
formatstring = "%04d",
125125
type = Star,
126126
kw...)
127-
progress = Progress(length(Counts), "Loading data and plotting: "; #=showspeed=true=#)
127+
progress = Progress(length(Counts), desc = "Loading data and plotting: ")
128128
for i in eachindex(Counts)
129129
snapshot_index = Printf.format(Printf.Format(formatstring), Counts[i])
130130
filename = joinpath(folder, string(filenamebase, snapshot_index, suffix))
@@ -246,7 +246,7 @@ function plot_positionslice_adapt(folder::String, filenamebase::String, Counts::
246246
formatstring = "%04d",
247247
type = Star,
248248
kw...)
249-
progress = Progress(length(Counts), "Loading data and plotting: "; #=showspeed=true=#)
249+
progress = Progress(length(Counts), desc = "Loading data and plotting: ")
250250
for i in eachindex(Counts)
251251
snapshot_index = Printf.format(Printf.Format(formatstring), Counts[i])
252252
filename = joinpath(folder, string(filenamebase, snapshot_index, suffix))

src/snapshots/trajectory.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ function plot_trajectory(folder::String, filenamebase::String, Counts::Array{Int
140140
pos[id] = Array{AbstractPoint,1}()
141141
end
142142

143-
progress = Progress(length(Counts), "Loading data: "; #=showspeed=true=#)
143+
progress = Progress(length(Counts), desc = "Loading data: ")
144144
for i in Counts
145145
snapshot_index = Printf.format(Printf.Format(formatstring), i)
146146
filename = joinpath(folder, string(filenamebase, snapshot_index, suffix))
@@ -225,7 +225,7 @@ function plot_trajectory!(fig, ax, folder::String, filenamebase::String, Counts:
225225
pos[id] = Array{AbstractPoint,1}()
226226
end
227227

228-
progress = Progress(length(Counts), "Loading data: "; #=showspeed=true=#)
228+
progress = Progress(length(Counts), desc = "Loading data: ")
229229
for i in eachindex(Counts)
230230
snapshot_index = Printf.format(Printf.Format(formatstring), Counts[i])
231231
filename = joinpath(folder, string(filenamebase, snapshot_index, suffix))

0 commit comments

Comments
 (0)