-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvisualize.jl
More file actions
47 lines (36 loc) · 1.39 KB
/
visualize.jl
File metadata and controls
47 lines (36 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import ADIOS2
import CairoMakie
bp_file = "gs-1MPI-1GPU-64L-F32.bp"
adios = ADIOS2.adios_init_serial()
io = ADIOS2.declare_io(adios, "reader")
reader = ADIOS2.open(io, bp_file, ADIOS2.mode_read)
# get the number of available steps in the reader, only works for bp files
steps = ADIOS2.steps(reader)
npixels = 256
local_count = 32
# Grid is 1800x1800x1800. Use Tuples () for selection
local_start = convert(Int64, ceil((npixels - local_count) / 2))
start = (local_start, local_start, convert(Int64, ceil(npixels / 2)))
count = (local_count, local_count, 1)
sliceU = Array{Float32, 2}(undef, local_count, local_count)
sliceV = Array{Float32, 2}(undef, local_count, local_count)
for step in 1:steps
ADIOS2.begin_step(reader)
varU = ADIOS2.inquire_variable(io, "U")
@assert varU isa ADIOS2.Variable string("Could not find variable U")
ADIOS2.set_selection(varU, start, count)
varV = ADIOS2.inquire_variable(io, "U")
@assert varV isa ADIOS2.Variable string("Could not find variable V")
ADIOS2.set_selection(varV, start, count)
ADIOS2.get(reader, varU, sliceU)
ADIOS2.get(reader, varV, sliceV)
ADIOS2.end_step(reader)
println("Showing step ", step)
f = CairoMakie.Figure()
CairoMakie.heatmap(f[1, 1], sliceU)
CairoMakie.heatmap(f[1, 2], sliceV)
display(f)
CairoMakie.save(string("U_V_", step, ".png"), f)
end
ADIOS2.close(reader)
ADIOS2.adios_finalize(adios)