Skip to content

Commit de370e7

Browse files
committed
fix markerscene, precompile [skip ci]
1 parent 3f74bbf commit de370e7

5 files changed

Lines changed: 74 additions & 12 deletions

File tree

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ParallelOperations = "09c1cff2-b94d-4c31-85a1-721512e21c63"
2020
PhysicalMeshes = "97d9904f-034f-4fb7-aeaa-03a173434233"
2121
PhysicalParticles = "78724250-4eb2-11e9-0f34-13a7aab864c5"
2222
PhysicalTrees = "dc5d4990-50a5-4af2-bdaa-6f78dc9b9fb2"
23+
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
2324
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
2425
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
2526
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
@@ -47,6 +48,7 @@ ParallelOperations = "0.1"
4748
PhysicalMeshes = "0.1"
4849
PhysicalParticles = "1"
4950
PhysicalTrees = "0.1"
51+
PrecompileTools = "1"
5052
ProgressMeter = "1"
5153
Reexport = "1"
5254
StructArrays = "0.6"

src/AstroPlot.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module AstroPlot
22

3+
using PrecompileTools
34
using Reexport
45
using Unitful, UnitfulAstro
56
using LaTeXStrings
@@ -137,4 +138,5 @@ include("snapshots/profiling.jl")
137138
include("video.jl")
138139
include("images.jl")
139140

141+
include("precompile.jl")
140142
end

src/PhysicalParticles.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function point3(p::PVector)
33
end
44

55
function estimate_markersize(S::Real)
6-
return 0.0001 / sqrt(S)
6+
return 0.1 / sqrt(S)
77
end
88

99
function estimate_markersize(data, u; xaxis = :x, yaxis = :y)
@@ -34,7 +34,7 @@ plot_makie(d, u"m")
3434
"""
3535
function plot_makie(data::Array{T,1}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc";
3636
markersize = estimate_markersize(data, u),
37-
markerspace=SceneSpace,
37+
markerspace=:data,
3838
size = (1000, 1000),
3939
kw...
4040
) where T<:PVector
@@ -44,7 +44,7 @@ end
4444

4545
function plot_makie(data::Array{T,1}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc";
4646
markersize = estimate_markersize(data, u),
47-
markerspace=SceneSpace,
47+
markerspace=:data,
4848
size = (1000, 1000),
4949
kw...
5050
) where T<:AbstractParticle3D
@@ -84,7 +84,7 @@ plot_makie!(fig, d, u"m")
8484
"""
8585
function plot_makie!(fig, data::Array{T,1}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc";
8686
markersize = estimate_markersize(data, u),
87-
markerspace=SceneSpace,
87+
markerspace=:data,
8888
size = (1000, 1000),
8989
kw...
9090
) where T<:PVector
@@ -94,7 +94,7 @@ end
9494

9595
function plot_makie!(fig, data::Array{T,1}, u::Union{Nothing, Unitful.FreeUnits} = u"kpc";
9696
markersize = estimate_markersize(data, u),
97-
markerspace=SceneSpace,
97+
markerspace=:data,
9898
size = (1000, 1000),
9999
kw...
100100
) where T<:AbstractParticle3D

src/precompile.jl

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
@setup_workload begin
2+
@compile_workload begin
3+
foldertest = joinpath(@__DIR__, "../test")
4+
header, data = read_gadget2(joinpath(foldertest, "plummer/snapshot_0000.gadget2"), uAstro, uGadget2, type=Star)
5+
h, d = read_gadget2(joinpath(foldertest, "plummer_unitless.gadget2"), nothing, uGadget2, type=Star)
6+
7+
c = Cube(PVector(0.0,0.0,0.0), PVector(1.0,1.0,1.0))
8+
fig = plot_makie(c, nothing)
9+
f = Figure()
10+
ax = Axis3(f[1,1])
11+
plot_makie!(ax, c, nothing)
12+
13+
m = MeshCartesianStatic(d)
14+
unicode_projection_density(m)
15+
# f = projection_density(m) #TODO
16+
unicode_slice(m, :rho, 5)
17+
f = plot_slice(m, :pos, 5)
18+
19+
#! This is breaking. Anyway, tree plot is not often used
20+
# fig = plot_peano(3)
21+
# d = randn_pvector(15)
22+
# t = octree(d)
23+
# figure, axis, plot = plot_makie(t)
24+
25+
fig = plot_profiling(joinpath(foldertest, "profiling.csv"))
26+
fig, df = plot_energy(joinpath(foldertest, "energy.csv"))
27+
fig, df = plot_energy_delta(joinpath(foldertest, "energy.csv"))
28+
fig = plot_densitycurve(data)
29+
fig = plot_rotationcurve(data)
30+
31+
#TODO: there is something wrong???
32+
plot_positionslice(
33+
joinpath(foldertest, "plummer"), "snapshot_", collect(0:20:200), ".gadget2", gadget2(),
34+
xlims = (-0.05, +0.05), ylims = (-0.05, +0.05),
35+
times = collect(0.0:0.01:0.1) * u"Gyr",
36+
)
37+
fig, pos = plot_trajectory(
38+
joinpath(foldertest, "plummer/"), "snapshot_", collect(0:20:200), [1,2,3], ".gadget2", gadget2(),
39+
)
40+
FigScale, FigLagrange, df = plot_radii(
41+
joinpath(foldertest, "plummer/"), "snapshot_", collect(0:20:200), ".gadget2", gadget2(),
42+
times = collect(0.0:0.01:0.1) * u"Gyr", title = "Direct Sum const",
43+
)
44+
45+
plot_positionslice(joinpath(foldertest, "mosaic/"), "snapshot_", collect(1:9:100), ".gadget2", gadget2(),
46+
dpi = 300, size = (800,800),
47+
xlims = (-0.06, +0.06), ylims = (-0.06, +0.06),
48+
times = collect(0.0:0.00005:0.005) * u"Gyr",
49+
)
50+
plt = mosaicview(joinpath(foldertest, "mosaic/"), "pos_", collect(1:9:100), ".png"; fillvalue = 0.5, npad = 3, ncol = 4, rowmajor = true)
51+
52+
png2video(joinpath(foldertest, "mosaic/"), "pos_", ".png", "TDE.mp4")
53+
54+
unicode_scatter(d, nothing)
55+
unicode_density(d, nothing)
56+
unicode_rotationcurve(d, nothing)
57+
end
58+
end

src/snapshots/positions.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function plot_positionslice!(fig, data, u::Union{Nothing, Unitful.FreeUnits} = n
1212
xaxis = :x,
1313
yaxis = :y,
1414
markersize = estimate_markersize(data, u; xaxis, yaxis),
15-
markerspace=SceneSpace,
15+
markerspace=:data,
1616
kw...)
1717
xu, yu = pack_xy(data; xaxis, yaxis)
1818
x = ustrip.(u, xu)
@@ -55,7 +55,7 @@ function plot_positionslice(data, u::Union{Nothing, Unitful.FreeUnits} = nothing
5555
aspect_ratio = 1.0,
5656
title = "Positions",
5757
markersize = (isnothing(xlims) && isnothing(ylims)) ? estimate_markersize(data, u; xaxis, yaxis) : estimate_markersize((xlims[2] - xlims[1]) * (ylims[2] - ylims[1])),
58-
markerspace=SceneSpace,
58+
markerspace=:data,
5959
size = (1000, 1000),
6060
kw...)
6161
xu, yu = pack_xy(data; xaxis, yaxis)
@@ -173,12 +173,12 @@ function plot_positionslice_adapt(data, u::Union{Nothing, Unitful.FreeUnits} = n
173173
yaxis = :y,
174174
xlabel = "",
175175
ylabel = "",
176-
xlen::Float64 = 1.0,
177-
ylen::Float64 = 1.0,
176+
xlen = 1.0,
177+
ylen = 1.0,
178178
aspect_ratio = 1.0,
179179
title = "Positions",
180180
markersize = estimate_markersize(xlen * ylen),
181-
markerspace=SceneSpace,
181+
markerspace=:data,
182182
size = (1000, 1000),
183183
kw...)
184184
xu, yu = pack_xy(data; xaxis, yaxis)
@@ -241,8 +241,8 @@ function plot_positionslice_adapt(folder::String, filenamebase::String, Counts::
241241
collection::Union{Nothing, Collection} = nothing,
242242
xlabel = "$(xaxis)$(axisunit(getuLength(units)))",
243243
ylabel = "$(yaxis)$(axisunit(getuLength(units)))",
244-
xlen::Float64 = 0.2,
245-
ylen::Float64 = 0.2,
244+
xlen = 0.2,
245+
ylen = 0.2,
246246
formatstring = "%04d",
247247
type = Star,
248248
kw...)

0 commit comments

Comments
 (0)