Skip to content

Commit

Permalink
update Makie size keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
islent committed Aug 6, 2024
1 parent a11e7e3 commit f6ef12f
Show file tree
Hide file tree
Showing 25 changed files with 120 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
version:
- '1.7.1'
- '1.10.4'
os:
- ubuntu-latest
#- macOS-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ManuallyBuildDoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v1
- uses: julia-actions/setup-julia@latest
with:
version: '1.7.1'
version: '1.10.4'
- run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
- run: julia --project=docs -e '
using Pkg;
Expand Down
12 changes: 6 additions & 6 deletions Benchmark/DifferencingEquation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ end
function benchmark_DifferencingEquation_1D(NumData;
savefolder = "output",
title = "Benchmark of solving 1D differencing equations ($(Threads.nthreads()) CPU threads)",
resolution = (800, 600),
size = (800, 600),
kw...
)
Functions = [
Expand Down Expand Up @@ -190,7 +190,7 @@ function benchmark_DifferencingEquation_1D(NumData;

fig, df = benchmarkplot(
Functions, Names, gen, NumData;
savefolder, title, resolution,
savefolder, title, size,
legend = false,
kw...
)
Expand All @@ -210,7 +210,7 @@ end
function benchmark_DifferencingEquation_2D(NumData;
savefolder = "output",
title = "Benchmark of solving 2D differencing equations ($(Threads.nthreads()) CPU threads)",
resolution = (800, 600),
size = (800, 600),
kw...
)
Functions = [
Expand Down Expand Up @@ -242,7 +242,7 @@ function benchmark_DifferencingEquation_2D(NumData;

fig, df = benchmarkplot(
Functions, Names, gen, NumData;
savefolder, title, resolution,
savefolder, title, size,
legend = false,
kw...
)
Expand All @@ -262,7 +262,7 @@ end
function benchmark_DifferencingEquation_3D(NumData;
savefolder = "output",
title = "Benchmark of solving 3D differencing equations ($(Threads.nthreads()) CPU threads)",
resolution = (800, 600),
size = (800, 600),
kw...
)
Functions = [
Expand Down Expand Up @@ -294,7 +294,7 @@ function benchmark_DifferencingEquation_3D(NumData;

fig, df = benchmarkplot(
Functions, Names, gen, NumData;
savefolder, title, resolution,
savefolder, title, size,
legend = false,
kw...
)
Expand Down
4 changes: 2 additions & 2 deletions Benchmark/Scaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ legend = Legend(
Makie.save("output/ScalingDistributed.png", fig)

# Plot multi-threading and distributed
fig = Figure(;resolution=(800,450))
fig = Figure(;size=(800,450))
axis = GLMakie.Axis(
fig[1,1],
title = "Scaling of mean total time",
Expand Down Expand Up @@ -209,7 +209,7 @@ CSV.write("output/ScalingNumber.csv", df)
df = DataFrame(CSV.File("output/ScalingNumber.csv"))
=#

fig = Figure(; resolution=(800,450))
fig = Figure(; size=(800,450))
axis = GLMakie.Axis(
fig[1,1],
title = "Scaling of mean total time",
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
[compat]
AstroIO = "0.1"
AstroSimBase = "0.1"
BangBang = "0.3"
BangBang = "0.3, 0.4"
CSV = "0.9, 0.10"
CUDA = "4, 5"
DataFrames = "1"
DocStringExtensions = "0.8, 0.9"
FFTW = "1"
FileIO = "1"
GLMakie = "0.9"
GLMakie = "0.9, 0.10"
Images = "0.25, 0.26"
IterativeSolvers = "0.9"
LoopVectorization = "0.12"
Expand Down
14 changes: 7 additions & 7 deletions examples/01-binary/01-binary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using Unitful, UnitfulAstro
astro()
mkpathIfNotExist("output")

function plot_orbit_with_gap(sim::Simulation, title::String, gap::Int = 1; resolution = (800,800), kw...)
function plot_orbit_with_gap(sim::Simulation, title::String, gap::Int = 1; size = (800,800), kw...)
df = DataFrame(CSV.File(joinpath(sim.config.output.dir, "analysis.csv")))
x = df.x
y = df.y
Expand Down Expand Up @@ -58,7 +58,7 @@ function plot_orbit_with_gap(sim::Simulation, title::String, gap::Int = 1; resol
p = Plots.plot(plot_x, plot_y,
#title = title,
aspect_ratio = 1, legend = nothing, xlabel = "x [kpc]", ylabel = "y [kpc]",
size = resolution,
size = size,
)
savefig(p, "output/" * title * ".png")
@info "Total orbits: $(div(flip, 2))"
Expand Down Expand Up @@ -204,7 +204,7 @@ elliptic_adapt = Simulation(
OutputDir = "output/EllipticOrbitAdapt",
)
run(elliptic_adapt)
df = plot_orbit_with_gap(elliptic_adapt, "Elliptic Orbit (adaptive)", 40, resolution = (600,300))
df = plot_orbit_with_gap(elliptic_adapt, "Elliptic Orbit (adaptive)", 40, size = (600,300))

# Fixed timesteps
Δt = df.time[2:end-1] .- df.time[1:end-2]
Expand All @@ -219,7 +219,7 @@ elliptic_const = Simulation(
OutputDir = "output/EllipticOrbitConst",
)
run(elliptic_const)
df = plot_orbit_with_gap(elliptic_const, "Elliptic Orbit (const)", 40, resolution = (600,300))
df = plot_orbit_with_gap(elliptic_const, "Elliptic Orbit (const)", 40, size = (600,300))



Expand Down Expand Up @@ -268,7 +268,7 @@ run(m)

# plot the orbit with uncertainties
function plot_orbit_with_uncertainties(sim::Simulation, title::String;
resolution = (800,450),
size = (800,450),
xlabel = "x [kpc]", ylabel = "y [kpc]",
)
df = DataFrame(CSV.File(joinpath(sim.config.output.dir, "analysis.csv")))
Expand All @@ -294,15 +294,15 @@ function plot_orbit_with_uncertainties(sim::Simulation, title::String;
p = Plots.plot(x[1:flip], y[1:flip];
ribbon = yerror[1:flip], legend=nothing,
xlabel, ylabel, title,
size = resolution,
size = size,
aspect_ratio = 1,
)
Plots.plot!(p, x[flip+1:end], y[flip+1:end]; ribbon = yerror[flip+1:end])
Plots.plot!(p, [1.0; 0.92], [0.1,0.15],arrow=(2,1.0))
savefig(p, "output/" * title * ".png")
return DataFrame(time = df.time, x = xm, y = ym)
end
plot_orbit_with_uncertainties(m, "Uncertainty of elliptic orbit", resolution = (800,450))
plot_orbit_with_uncertainties(m, "Uncertainty of elliptic orbit", size = (800,450))

# autodiff?
Measurements.derivative(m.simdata.Pos[1].y.val, m.simdata.Mass[2].val)
Expand Down
2 changes: 1 addition & 1 deletion examples/02-AutodiffBackground/02-AutodiffBackground.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ run(sim)
# Plot
title = "Orbit in potential field of Plummer model"
df = DataFrame(CSV.File(joinpath(sim.config.output.dir, "analysis.csv")))
fig = Figure(resolution = (800,800))
fig = Figure(size = (800,800))
axis = GLMakie.Axis(fig[1,1]; title, xlabel = "x [kpc]", ylabel = "y [kpc]")
axis.autolimitaspect = 1
Makie.lines!(axis, df.x, df.y)
Expand Down
12 changes: 6 additions & 6 deletions examples/03-plummer/03-plummer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ using FFMPEG

function plotfigs(ds, ds_adapt, ts, ts_adapt)
@info "Plotting radii"
FigScale = Figure(resolution = (800, 800))
FigLagrange = Figure(resolution = (800, 700))
FigScale = Figure(size = (800, 800))
FigLagrange = Figure(size = (800, 700))

colors = ColorSchemes.tab10.colors

Expand Down Expand Up @@ -138,13 +138,13 @@ function plotfigs(ds, ds_adapt, ts, ts_adapt)


#@info "Plotting positions"
#plot_positionslice(ds.config.output.dir, "snapshot_", collect(0:200), ".gadget2", gadget2(), dpi = 300, resolution = (800,800),
#plot_positionslice(ds.config.output.dir, "snapshot_", collect(0:200), ".gadget2", gadget2(), size = (800,800),
# xlims = (-0.05, +0.05), ylims = (-0.05, +0.05), times = collect(0.0:0.0005:0.1) * u"Gyr")
#plot_positionslice(ds_adapt.config.output.dir, "snapshot_", collect(0:200), ".gadget2", gadget2(), dpi = 300, resolution = (800,800),
#plot_positionslice(ds_adapt.config.output.dir, "snapshot_", collect(0:200), ".gadget2", gadget2(), size = (800,800),
# xlims = (-0.05, +0.05), ylims = (-0.05, +0.05), times = collect(0.0:0.0005:0.1) * u"Gyr")
#plot_positionslice(ts.config.output.dir, "snapshot_", collect(0:200), ".gadget2", gadget2(), dpi = 300, resolution = (800,800),
#plot_positionslice(ts.config.output.dir, "snapshot_", collect(0:200), ".gadget2", gadget2(), size = (800,800),
# xlims = (-0.05, +0.05), ylims = (-0.05, +0.05), times = collect(0.0:0.0005:0.1) * u"Gyr")
#plot_positionslice(ts_adapt.config.output.dir, "snapshot_", collect(0:200), ".gadget2", gadget2(), dpi = 300, resolution = (800,800),
#plot_positionslice(ts_adapt.config.output.dir, "snapshot_", collect(0:200), ".gadget2", gadget2(), size = (800,800),
# xlims = (-0.05, +0.05), ylims = (-0.05, +0.05), times = collect(0.0:0.0005:0.1) * u"Gyr")


Expand Down
2 changes: 1 addition & 1 deletion examples/04-collisions/04-collisions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ run(gpu)

# Plot
plot_positionslice(gpu.config.output.dir, "snapshot_", collect(0:100), ".gadget2", gadget2(),
dpi = 300, resolution = (400,400),
size = (400,400),
xlims = (-200.0, +200.0), ylims = (-200.0, +200.0),
times = collect(0.0:0.03:3.0) * u"Gyr",
collection = DISK,
Expand Down
4 changes: 2 additions & 2 deletions examples/04-collisions/ParameterSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ run(sim)


#=
plot_positionslice("output/test", "snapshot_", collect(0:500), ".gadget2", gadget2(), resolution = (800, 800),
plot_positionslice("output/test", "snapshot_", collect(0:500), ".gadget2", gadget2(), size = (800, 800),
xlims = (-0.15,0.15), ylims = (-0.15,0.15), markersize = 1.0)
ffmpeg_exe(`-v error -framerate 25 -loop 0 -i output/test/pos_%04d.png output/test.mp4`)
=#
Expand Down Expand Up @@ -113,7 +113,7 @@ function galaxy_colliders(angle::Float64, vel::Number;
)
run(sim)

plot_positionslice(sim.config.output.dir, "snapshot_", collect(0:Int(TimeEnd/TimeBetweenSnapshots)), ".gadget2", gadget2(), resolution = (960, 960),
plot_positionslice(sim.config.output.dir, "snapshot_", collect(0:Int(TimeEnd/TimeBetweenSnapshots)), ".gadget2", gadget2(), size = (960, 960),
xlims = (-0.15,0.15), ylims = (-0.15,0.15), markersize = 0.1, times = collect(0.0u"Gyr":TimeBetweenSnapshots:TimeEnd))

ffmpeg_exe(`-v error -framerate 25 -loop 0 -i $(sim.config.output.dir)/pos_%04d.png output/'video - '$(simlabel).mp4`)
Expand Down
4 changes: 2 additions & 2 deletions examples/05-TDE-StarCluster/05-TDE-StarCluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ run(elliptic)
### Plot
L = ustrip(R)
plot_positionslice(elliptic.config.output.dir, "snapshot_", collect(0:100), ".gadget2", gadget2(),
dpi = 300, resolution = (400,400),
size = (400,400),
xlims = (-0.6L, +1.4L), ylims = (-L, +L),
times = collect(0:100) * TimeBetweenSnapshots,
markersize = 0.0001,
Expand All @@ -128,7 +128,7 @@ for i in 2:length(N)
end
@info "Total particles accreated: $(N[end])"

fig = Figure(; resolution = (800, 450))
fig = Figure(; size = (800, 450))
axis = GLMakie.Axis(fig[1,1],
title = "Total number of accreated particles",
xlabel = "t [Gyr]",
Expand Down
2 changes: 1 addition & 1 deletion src/PM/gravity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ function compute_force(sim::Simulation, GravSolver::Union{FDM, FFT, ML}, Device:
add_timer(sim, "FORCE", t_FORCE, time_ns())
end

function compute_force(sim::Simulation, pos::Union{Array{T,1}, T}, SoftLength::Number, GravSolver::Union{FFT,FDM}, Device::CPU) where T<:AbstractPoint3D
function compute_force(sim::Simulation, pos::Union{Array{T,N}, T}, SoftLength::Number, GravSolver::Union{FFT,FDM}, Device::CPU) where T<:AbstractPoint3D where N
return mesh2particle.(sim.simdata, pos, :acc, sim.simdata.config.mode, sim.simdata.config.assignment)
end
20 changes: 10 additions & 10 deletions src/base/Config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ mutable struct VisualizationInfo
progress::Progress

PlotData
resolution
size
fig

Realtime::Bool
Expand All @@ -879,7 +879,7 @@ $(TYPEDSIGNATURES)
function VisualizationInfo(;
Realtime::Bool = false,
RenderTime::Float64 = 0.2,
resolution = (1000, 1000),
size = (1000, 1000),
xlims = nothing,
ylims = nothing,
zlims = nothing,
Expand All @@ -889,7 +889,7 @@ function VisualizationInfo(;
Progress(0),

nothing,
resolution,
size,
nothing,

Realtime, RenderTime, 0.0,
Expand Down Expand Up @@ -975,7 +975,7 @@ function Simulation(d;
# VisualizationInfo
Realtime::Bool = false,
RenderTime::Float64 = 0.2,
resolution = (1000, 1000),
size = (1000, 1000),

xlims = nothing,
ylims = nothing,
Expand Down Expand Up @@ -1044,7 +1044,7 @@ function Simulation(d;
PhysicsInfo(),
StreamInfo(),
VisualizationInfo(;
Realtime = $Realtime, RenderTime = $RenderTime, resolution = $resolution,
Realtime = $Realtime, RenderTime = $RenderTime, size = $size,
xlims = $(xlims), ylims = $(ylims), zlims = $(zlims), markersize = $(markersize),
),
AstroNbodySim.Buffer($config),
Expand All @@ -1060,7 +1060,7 @@ function Simulation(d;
LogInfo(; timers, analysers),
PhysicsInfo(),
StreamInfo(),
VisualizationInfo(; Realtime, RenderTime, resolution, xlims, ylims, zlims, markersize),
VisualizationInfo(; Realtime, RenderTime, size, xlims, ylims, zlims, markersize),
AstroNbodySim.Buffer(config),
bgforce, bgpotential,
)
Expand All @@ -1078,7 +1078,7 @@ function Simulation(d;
LogInfo(; timers, analysers),
PhysicsInfo(),
StreamInfo(),
VisualizationInfo(; Realtime, RenderTime, resolution, xlims, ylims, zlims, markersize),
VisualizationInfo(; Realtime, RenderTime, size, xlims, ylims, zlims, markersize),
AstroNbodySim.Buffer(config),
bgforce, bgpotential,
)
Expand Down Expand Up @@ -1113,7 +1113,7 @@ function Simulation(d;
PhysicsInfo(),
StreamInfo(),
VisualizationInfo(;
Realtime = $Realtime, RenderTime = $RenderTime, resolution = $resolution,
Realtime = $Realtime, RenderTime = $RenderTime, size = $size,
xlims = $(xlims), ylims = $(ylims), zlims = $(zlims), markersize = $(markersize),
),
AstroNbodySim.Buffer($config),
Expand All @@ -1129,7 +1129,7 @@ function Simulation(d;
LogInfo(; timers, analysers),
PhysicsInfo(),
StreamInfo(),
VisualizationInfo(; Realtime, RenderTime, resolution, xlims, ylims, zlims, markersize),
VisualizationInfo(; Realtime, RenderTime, size, xlims, ylims, zlims, markersize),
AstroNbodySim.Buffer(config),
bgforce, bgpotential,
)
Expand Down Expand Up @@ -1158,7 +1158,7 @@ function Simulation(d;
LogInfo(; timers, analysers),
PhysicsInfo(),
StreamInfo(),
VisualizationInfo(; Realtime, RenderTime, resolution, xlims, ylims, zlims, markersize),
VisualizationInfo(; Realtime, RenderTime, size, xlims, ylims, zlims, markersize),
AstroNbodySim.Buffer(config),
bgforce, bgpotential,
)
Expand Down
2 changes: 1 addition & 1 deletion src/base/Plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function makie_scatter(sim::Simulation, GravSolver::Gravity, Device::DeviceType;
sim.visinfo.PlotData;
markersize = iszero(sim.visinfo.markersize) ? estimate_markersize(pos) : sim.visinfo.markersize,
markerspace=:data,
figure = (resolution = sim.visinfo.resolution,),
figure = (size = sim.visinfo.size,),
)

f,a,p = sim.visinfo.fig
Expand Down
2 changes: 1 addition & 1 deletion src/directsum/gravity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function compute_local_force_at_points(sim::Simulation, SoftLength::Number, Grav
sim.buffer.sendbuffer[1] = compute_force_at_point.(pos, sim, SoftLength)
end

function compute_force(sim::Simulation, pos::Union{Array{T,1}, T}, SoftLength::Number, GravSolver::DirectSum, Device::CPU) where T<:AbstractPoint3D
function compute_force(sim::Simulation, pos::Union{Array{T,N}, T}, SoftLength::Number, GravSolver::DirectSum, Device::CPU) where T<:AbstractPoint3D where N
bcast(sim, :buffer, :recvbuffer, Dict(1 => pos))
bcast(sim, compute_local_force_at_points, args = (SoftLength, GravSolver, Device))

Expand Down
2 changes: 1 addition & 1 deletion src/directsum/potential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function compute_local_potential_at_points(sim::Simulation, SoftLength::Number,
sim.buffer.sendbuffer[1] = compute_unit_potential_at_point.(pos, sim, SoftLength)
end

function compute_potential(sim::Simulation, pos::Union{Array{T,1}, T}, SoftLength::Number, GravSolver::DirectSum, Device::CPU) where T<:AbstractPoint3D
function compute_potential(sim::Simulation, pos::Union{Array{T,N}, T}, SoftLength::Number, GravSolver::DirectSum, Device::CPU) where T<:AbstractPoint3D where N
bcast(sim, :buffer, :recvbuffer, Dict(1 => pos))
bcast(sim, compute_local_potential_at_points, args = (SoftLength, GravSolver, Device))

Expand Down
Loading

0 comments on commit f6ef12f

Please sign in to comment.