/
data_info.jl
149 lines (121 loc) · 4.04 KB
/
data_info.jl
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
"""
#### Get the simulation overview from RAMSES, saved in JLD2 == function getinfo
```julia
infodata(output::Int;
path::String="./",
fname = "output_",
datatype::Any=:nothing,
verbose::Bool=true)
return InfoType
```
#### Keyword Arguments
- **`output`:** timestep number
- **`path`:** the path to the output JLD2 file relative to the current folder or absolute path
- **`fname`:** "output_"-> filename = "output_***.jld2" by default, can be changed to "myname***.jld2"
- **`verbose:`:** informations are printed on the screen by default
#### Examples
```julia
# read simulation information from output `1` in current folder
julia> info = infodata(1) # filename="output_00001.jld2"
# read simulation information from output `420` in given folder (relative path to the current working folder)
julia> info = infodata(420, path="../MySimFolder/")
# or simply use
julia> info = infodata(420, "../MySimFolder/")
# get an overview of the returned field-names
julia> propertynames(info)
# a more detailed overview
julia> viewfields(info)
...
julia> viewallfields(info)
...
julia> namelist(info)
...
julia> makefile(info)
...
julia> timerfile(info)
...
julia> patchfile(info)
...
```
"""
function infodata(output::Int, datatype::Symbol;
path::String="./",
fname = "output_",
verbose::Bool=true)
return infodata(output, path=path,
fname=fname,
datatype=datatype,
verbose=verbose)
end
function infodata(output::Int, path::String, datatype::Symbol;
fname = "output_",
verbose::Bool=true)
return infodata(output, path=path,
fname=fname,
datatype=datatype,
verbose=verbose)
end
function infodata(output::Int, path::String;
fname = "output_",
datatype::Any=:nothing,
verbose::Bool=true)
return infodata(output, path=path,
fname=fname,
datatype=datatype,
verbose=verbose)
end
function infodata(output::Int;
path::String="./",
fname = "output_",
datatype::Any=:nothing,
verbose::Bool=true)
verbose = checkverbose(verbose)
printtime("",verbose)
filename = outputname(fname, output) * ".jld2"
fpath = checkpath(path, filename)
# get root-list with datatypes
#filename = fpath * "L1_Zlib_0019.jld2"
f = jldopen(fpath)
froot = f.root_group
fkeys = keys(froot.written_links)
close(f)
# check if request exists
if datatype == :nothing
find_dt_flag = true
if "hydro" in fkeys && find_dt_flag
dtype = "hydro"
find_dt_flag = false
end
if "particles" in fkeys && find_dt_flag
dtype = "particles"
find_dt_flag = false
end
if "clumps" in fkeys && find_dt_flag
dtype = "clumps"
find_dt_flag = false
end
if "gravity" in fkeys && find_dt_flag
dtype = "gravity"
find_dt_flag = false
end
if find_dt_flag
error("No datatype found...")
end
else
if string(datatype) in fkeys
dtype = string(datatype)
else
error("Datatype $datatype does not exist...")
end
end
if verbose println("Use datatype: ", dtype) end
inflink = string(dtype) * "/info"
dataobject = JLD2.load(fpath, inflink,
typemap=Dict("Mera.PhysicalUnitsType" => JLD2.Upgrade(PhysicalUnitsType001),
"Mera.ScalesType" => JLD2.Upgrade(ScalesType001)))
# update constants and scales
dataobject.constants = Mera.createconstants()
dataobject.scale = Mera.createscales(dataobject)
printsimoverview(dataobject, verbose) # print overview on screen
return dataobject
end