Data Loading API Reference
Docstrings for reading simulation output into memory. The narrative guide is Load by Selection, for the spatial and level keywords.
All of these take the InfoType returned by getinfo and accept the same selection keywords (xrange/yrange/zrange, center, range_unit, lmax), so you read only the part of the box you need rather than filtering afterwards.
loadall calls getinfo and every getter at once, and withargs derives a variant of an argument bundle. Pipelines shows both in use, with the macro forms; Bundling Arguments covers the bundle itself.
Loaders
Mera.loadall — Function
loadall(path, output; components, myargs, verbose, kwargs...) -> NamedTupleRead several components of one snapshot in a single call, and return them named.
Replaces the usual opening of an analysis, a getinfo followed by one getter per component each repeating the same selection, with one line:
(; hydro, gravity, particles) = loadall("/path/to/sim", 300)The returned NamedTuple also carries info, so nothing is lost:
d = loadall(path, 300)
d.info.levelmaxKeywords
components: which to read, as symbols, e.g.(:hydro, :particles). Defaults to every component the snapshot actually has, so a run without gravity simply returns fewer fields rather than failing.myargs: anArgumentsTypebundle, applied to every component. This is the point of pairing the two: setlmax,xrangeandcenteronce and every read honours them.verbose: passed through; defaults to Mera's global setting.- any further keyword is forwarded to each getter, so
lmax=10orxrange=[-10,10]work directly without a bundle.
Examples
# everything the snapshot has
(; hydro, gravity, particles) = loadall(path, 300)
# one bundle, applied to every component
args = ArgumentsType(lmax=10, xrange=[-10., 10.], yrange=[-10., 10.],
center=[:bc], range_unit=:kpc)
(; hydro, particles) = loadall(path, 300; components=(:hydro, :particles), myargs=args)
# or the keywords inline
d = loadall(path, 300; components=(:hydro,), lmax=9)A component that fails to read is reported and returned as nothing rather than taking the whole call down, so one missing file does not cost you the rest of the snapshot.
See also: @loadall, getinfo, ArgumentsType.
Mera.@loadall — Macro
@loadall path output component...Bind several components of one snapshot to variables of those names, in one line.
@loadall path 300 hydro gravity particles
# hydro, gravity and particles are now bound, and so is infoThis is a thin wrapper over loadall; it expands to a destructuring assignment and adds nothing of its own.
That is what makes it short, and also its cost: the variables appear without an assignment a reader can point at, and static tooling cannot follow them. Convenient at the REPL and in a notebook; in a script or a package, prefer the explicit form, which is only a few characters longer and says where each name came from:
(; hydro, gravity, particles) = loadall(path, 300)Keyword arguments are passed through:
@loadall path 300 hydro particles lmax=10 range_unit=:kpcMera.withargs — Function
withargs(args; kwargs...) -> ArgumentsTypeA copy of args with some fields changed, leaving the original untouched.
Deriving a variant of a bundle otherwise means deepcopy and then assignment, two lines and a mutable original one step away from being edited by accident:
base = ArgumentsType(lmax=10, xrange=[-10., 10.], center=[:bc], range_unit=:kpc)
coarse = withargs(base; lmax=7) # same region, fewer levels
zoom = withargs(base; xrange=[-2., 2.], yrange=[-2., 2.])base is unchanged in both cases.
See also: ArgumentsType, loadall.
Mera.gethydro — Function
gethydro(info::InfoType, var::Symbol; kwargs...)
gethydro(info::InfoType, vars::Vector{Symbol}; kwargs...)
gethydro(info::InfoType; vars=[:all], kwargs...)Load leaf-cell hydro variables from a RAMSES output described by an InfoType. Supports spatial sub-selection (xrange/yrange/zrange, center, range_unit), level restriction (lmax), variable filtering (vars or single var), basic data sanitation (smallr, smallc, negative value checks), progress + verbosity control, and explicit thread limiting (max_threads). Returns a HydroDataType containing an IndexedTable plus metadata (selected variables, scales, ranges). See extended docstring below for full argument reference and examples.
Read the leaf-cells of the hydro-data:
- select variables
- limit to a maximum level
- limit to a spatial range
- multi-threading
- set a minimum density or sound speed
- check for negative values in density and thermal pressure
- print the name of each data-file before reading it
- toggle verbose mode
- toggle progress bar
- pass a struct with arguments (myargs)
gethydro(dataobject::InfoType;
lmax::Real=dataobject.levelmax,
vars::Array{Symbol,1}=[:all],
xrange::Array{<:Any,1}=[missing, missing],
yrange::Array{<:Any,1}=[missing, missing],
zrange::Array{<:Any,1}=[missing, missing],
center::CenterType=[0., 0., 0.],
range_unit::Symbol=:standard,
smallr::Real=0.,
smallc::Real=0.,
check_negvalues::Bool=false,
print_filenames::Bool=false,
verbose::Bool=true,
show_progress::Bool=true,
myargs::ArgumentsType=ArgumentsType(),
max_threads::Int=Threads.nthreads())Returns an object of type HydroDataType, containing the hydro-data table, the selected options and the simulation ScaleType and summary of the InfoType
return HydroDataType()
# get an overview of the returned fields:
# e.g.:
julia> info = getinfo(100)
julia> gas = gethydro(info)
julia> viewfields(gas)
#or:
julia> fieldnames(gas)Arguments
Required:
dataobject: needs to be of type: "InfoType", created by the function getinfo
Predefined/Optional Keywords:
lmax: the maximum level to be read from the datavar(s): the selected hydro variables in arbitrary order: :all (default), :cpu, :rho, :vx, :vy, :vz, :p, and the passive scalars. When the output has ahydro_file_descriptor.txt, the scalars carry their descriptor names (e.g. :metallicity, :scalar00, :scalar01...); without a descriptor they are positional (:var6, :var7...). Positional :varN selectors keep working in either case.xrange: the range between [xmin, xmax] in units given by argumentrange_unitand relative to the givencenter; zero length for xmin=xmax=0. is converted to maximum possible lengthyrange: the range between [ymin, ymax] in units given by argumentrange_unitand relative to the givencenter; zero length for ymin=ymax=0. is converted to maximum possible lengthzrange: the range between [zmin, zmax] in units given by argumentrange_unitand relative to the givencenter; zero length for zmin=zmax=0. is converted to maximum possible lengthrange_unit: the units of the given ranges: :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)center: in units given by argumentrange_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..smallr: set lower limit for density; zero means inactivesmallc: set lower limit for thermal pressure; zero means inactivecheck_negvalues: check loaded data of "rho" and "p" on negative values; false by defaultprint_filenames: print on screen the current processed hydro file of each CPUverbose: print timestamp, selected vars and ranges on screen; default: trueshow_progress: print progress bar on screenmyargs: pass a struct of ArgumentsType to pass several arguments at once and to overwrite default values of lmax, xrange, yrange, zrange, center, rangeunit, verbose, showprogress- **
max_threads: give a maximum number of threads that is smaller or equal to the number of assigned threads in the running environment
Defined Methods - function defined for different arguments
- gethydro( dataobject::InfoType; ...) # no given variables -> all variables loaded
- gethydro( dataobject::InfoType, var::Symbol; ...) # one given variable -> no array needed
- gethydro( dataobject::InfoType, vars::Array{Symbol,1}; ...) # several given variables -> array needed
Examples
# read simulation information
julia> info = getinfo(420)
# Example 1:
# read hydro data of all variables, full-box, all levels
julia> gas = gethydro(info)
# Example 2:
# read hydro data of all variables up to level 8
# data range 20x20x4 kpc; ranges are given in kpc relative to the box (here: 48 kpc) center at 24 kpc
julia> gas = gethydro( info,
lmax=8,
xrange=[-10.,10.],
yrange=[-10.,10.],
zrange=[-2.,2.],
center=[24., 24., 24.],
range_unit=:kpc )
# Example 3:
# give the center of the box by simply passing: center = [:bc] or center = [:boxcenter]
# this is equivalent to center=[24.,24.,24.] in Example 2
# the following combination is also possible: e.g. center=[:bc, 12., 34.], etc.
julia> gas = gethydro( info,
lmax=8,
xrange=[-10.,10.],
yrange=[-10.,10.],
zrange=[-2.,2.],
center=[33., bc:, 10.],
range_unit=:kpc )
# Example 4:
# read hydro data of the variables density and the thermal pressure, full-box, all levels
julia> gas = gethydro( info, [:rho, :p] ) # use array for the variables
# Example 5:
# read hydro data of the single variable density, full-box, all levels
julia> gas = gethydro( info, :rho ) # no array for a single variable needed
...Mera.getparticles — Function
Read the particle-data
- select variables
- limit to a spatial range
- multi-threading
- print the name of each data-file before reading it
- toggle verbose mode
- toggle progress bar
- pass a struct with arguments (myargs)
function getparticles( dataobject::InfoType;
lmax::Real=dataobject.levelmax, # Maximum refinement level to read
vars::Array{Symbol,1}=[:all], # Variables to read (:all for all available)
stars::Bool=true, # Include star particles
xrange::Array{<:Any,1}=[missing, missing], # X spatial range [min, max]
yrange::Array{<:Any,1}=[missing, missing], # Y spatial range [min, max]
zrange::Array{<:Any,1}=[missing, missing], # Z spatial range [min, max]
center::CenterType=[0., 0., 0.], # Center point for ranges
range_unit::Symbol=:standard, # Units for ranges (:standard, :kpc, etc.)
presorted::Bool=true, # Sort output table by key variables
print_filenames::Bool=false, # Print each CPU file being read
verbose::Bool=true, # Print progress information
show_progress::Bool=true, # Show progress bar
max_threads::Int=Threads.nthreads(), # Number of threads for parallel processing
myargs::ArgumentsType=ArgumentsType() ) # Struct to override default argumentsReturns an object of type PartDataType, containing the particle-data table, the selected and the simulation ScaleType and summary of the InfoType
return PartDataType()
# get an overview of the returned fields:
# e.g.:
julia> info = getinfo(100)
julia> particles = getparticles(info)
julia> viewfields(particles)
#or:
julia> fieldnames(particles)Arguments
Required:
dataobject: needs to be of type: "InfoType", created by the function getinfo
Predefined/Optional Keywords:
lmax: maximum AMR level to load (default:info.levelmax)stars: include star particles (default:true). Setstars=falseto drop star particles from the returned table. On the new RAMSES particle format (pversion > 0) this drops rows withfamily == 2; on the legacy format (no:familycolumn) it drops rows withbirth > 0(RAMSES convention for stellar formation time). Requires the:family(new) or:birth(legacy) column to be in the loaded variable subset.var(s): the selected particle variables in arbitrary order: :all (default), :cpu, :mass, :vx, :vy, :vz, :birth :metals, ...xrange: the range between [xmin, xmax] in units given by argumentrange_unitand relative to the givencenter; zero length for xmin=xmax=0. is converted to maximum possible lengthyrange: the range between [ymin, ymax] in units given by argumentrange_unitand relative to the givencenter; zero length for ymin=ymax=0. is converted to maximum possible lengthzrange: the range between [zmin, zmax] in units given by argumentrange_unitand relative to the givencenter; zero length for zmin=zmax=0. is converted to maximum possible lengthrange_unit: the units of the given ranges: :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of typye Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)center: in units given by argumentrange_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..presorted: presort data according to the key vars (by default)print_filenames: print on screen the current processed particle file of each CPUverbose: print timestamp, selected vars and ranges on screen; default: trueshow_progress: print progress bar on screenmyargs: an ArgumentsType struct to override multiple keywords at once: lmax, xrange, yrange, zrange, center, rangeunit, verbose, showprogress- **
max_threads: give a maximum number of threads that is smaller or equal to the number of assigned threads in the running environment
Defined Methods - function defined for different arguments
- getparticles( dataobject::InfoType; ...) # no given variables -> all variables loaded
- getparticles( dataobject::InfoType, var::Symbol; ...) # one given variable -> no array needed
- getparticles( dataobject::InfoType, vars::Array{Symbol,1}; ...) # several given variables -> array needed
Examples
# read simulation information
julia> info = getinfo(420)
# Example 1:
# read particle data of all variables, full-box, all levels
julia> particles = getparticles(info)
# Example 2:
# read particle data of all variables
# data range 20x20x4 kpc; ranges are given in kpc relative to the box (here: 48 kpc) center at 24 kpc
julia> particles = getparticles( info,
xrange=[-10., 10.],
yrange=[-10., 10.],
zrange=[-2., 2.],
center=[24., 24., 24.],
range_unit=:kpc )
# Example 3:
# give the center of the box by simply passing: center = [:bc] or center = [:boxcenter]
# this is equivalent to center=[24.,24.,24.] in Example 2
# the following combination is also possible: e.g. center=[:bc, 12., 34.], etc.
julia> particles = getparticles( info,
xrange=[-10.,10.],
yrange=[-10.,10.],
zrange=[-2.,2.],
center=[33., :bc, 10.],
range_unit=:kpc )
# Example 4:
# read particle data of the variables mass and the birth-time, full-box, all levels
julia> particles = getparticles( info, [:mass, :birth] ) # use array for the variables
# Example 5:
# read particle data of the single variable mass, full-box, all levels
julia> particles = getparticles( info, :mass ) # no array for a single variable needed
...Mera.getgravity — Function
Read gravity leaf-cells with optional spatial selection and multithreading.
- Select variables (e.g., :epot, :ax, :ay, :az; include :cpu to add CPU column)
- Limit to a maximum refinement level (lmax)
- Select by spatial range around a center in a chosen unit
- Parallel file processing (configurable max_threads) with progress bar
- Verbose output with timestamps and table memory overview
- Pass an ArgumentsType struct (myargs) to override multiple keywords at once
getgravity(dataobject::InfoType;
lmax::Real=dataobject.levelmax,
vars::Array{Symbol,1}=[:all],
xrange::Array{<:Any,1}=[missing, missing],
yrange::Array{<:Any,1}=[missing, missing],
zrange::Array{<:Any,1}=[missing, missing],
center::CenterType=[0., 0., 0.],
range_unit::Symbol=:standard,
print_filenames::Bool=false,
verbose::Bool=true,
show_progress::Bool=true,
myargs::ArgumentsType=ArgumentsType(),
max_threads::Int=Threads.nthreads())Returns a GravDataType with:
- data: IndexedTable with position columns (:cx,:cy,:cz), optionally :level and/or :cpu, followed by selected variables
- info, lmin, lmax, boxlen, ranges, selectedgravvars, useddescriptors, scale
Arguments
- Required
- dataobject: InfoType from getinfo
- Keywords
- lmax: maximum refinement level to read (validated against the dataset)
- vars: gravity variables to load; default [:all]. Known names include :epot, :ax, :ay, :az. Include :cpu to add CPU column.
- xrange, yrange, zrange: [min,max] in units of range_unit relative to center; use missing to skip. Zero-length [0,0] is expanded to full box.
- center: selection center; default [0.,0.,0.]; you can use symbols like [:bc] for box center (also combinations like [val, :bc, :bc]).
- range_unit: units for ranges/center (e.g., :standard, :kpc, :pc, :Mpc, :km, :cm; Symbol)
- print_filenames: print each processed file path
- verbose: print timestamps and summaries
- show_progress: show a progress bar during reading
- myargs: ArgumentsType struct to override lmax, ranges, center, rangeunit, verbose, showprogress
- max_threads: cap threads used for table creation and column extraction (≤ available threads)
Defined methods
- getgravity(dataobject::InfoType; ...) # no vars → all variables loaded
- getgravity(dataobject::InfoType, var::Symbol; ...) # single variable (Symbol)
- getgravity(dataobject::InfoType, vars::Array{Symbol,1}; ...) # multiple variables
Examples
# Read all gravity variables at all levels, whole box
g = getgravity(info)
# Read only potential and acceleration components within a kpc-scale box around the center
g = getgravity(info, vars=[:epot, :ax, :ay, :az],
xrange=[-5,5], yrange=[-5,5], zrange=[-2,2],
center=[:bc], range_unit=:kpc)
# Include CPU column
g = getgravity(info, vars=[:cpu, :epot])
# Override several keywords at once via myargs
g = getgravity(info, myargs=ArgumentsType(lmax=12, range_unit=:kpc, verbose=false))Important notes
- Spatial selection is evaluated at cell centers (:cx,:cy,:cz).
- AMR vs uniform grid affects included columns and primary key: AMR adds :level.
- Variable names can also come from file descriptors; unknown indices are named :gravN.
Mera.getclumps — Function
Read the clump-data:
- selected variables
- limited to a spatial range
- print the name of each data-file before reading it
- toggle verbose mode
- pass a struct with arguments (myargs)
getclumps( dataobject::InfoType;
vars::Array{Symbol,1}=[:all],
xrange::Array{<:Any,1}=[missing, missing],
yrange::Array{<:Any,1}=[missing, missing],
zrange::Array{<:Any,1}=[missing, missing],
center::CenterType=[0., 0., 0.],
range_unit::Symbol=:standard,
print_filenames::Bool=false,
verbose::Bool=true,
myargs::ArgumentsType=ArgumentsType() )Returns an object of type ClumpDataType, containing the clump-data table, the selected options and the simulation ScaleType and summary of the InfoType
return ClumpDataType()
# get an overview of the returned fields:
# e.g.:
julia> info = getinfo(100)
julia> clumps = getclumps(info)
julia> viewfields(clumps)
#or:
julia> fieldnames(clumps)Arguments
Required:
dataobject: needs to be of type: "InfoType", created by the function getinfo
Predefined/Optional Keywords:
vars: Currently, the length of the loaded variable list can be modified *(see examples below).vars: List of clump columns to read; default[:all]uses the file header. The order must match the columns in the clump files. You may specify fewer names (to read a subset) or more names if the data contains more columns than listed in the header.xrange: the range between [xmin, xmax] in units given by argumentrange_unitand relative to the givencenter; zero length for xmin=xmax=0. is converted to maximum possible lengthyrange: the range between [ymin, ymax] in units given by argumentrange_unitand relative to the givencenter; zero length for ymin=ymax=0. is converted to maximum possible lengthzrange: the range between [zmin, zmax] in units given by argumentrange_unitand relative to the givencenter; zero length for zmin=zmax=0. is converted to maximum possible lengthzrange: the range between [zmin, zmax] in units given by argumentrange_unitand relative to the givencenter; zero length for zmin=zmax=0. is converted to maximum possible length Note: spatial filtering uses the columns :peakx, :peaky, :peak_z. If you set any ranges, ensure these columns are included invars(or usevars=[:all]).range_unit: the units of the given ranges: :standard (code units), :Mpc, :kpc, :pc, :mpc, :ly, :au , :km, :cm (of type Symbol) ..etc. ; see for defined length-scales viewfields(info.scale)center: in units given by argumentrange_unit; by default [0., 0., 0.]; the box-center can be selected by e.g. [:bc], [:boxcenter], [value, :bc, :bc], etc..print_filenames: print on screen the current processed clump file of each CPUverbose: print timestamp, selected vars and ranges on screen; default: truemyargs: pass a struct of ArgumentsType to pass several arguments at once and to overwrite default values of xrange, yrange, zrange, center, range_unit, verbose
Important notes
- Spatial selection is applied to the clump peak position only (columns
:peak_x,:peak_y,:peak_z). It does not test the full clump extent/volume. - All clump columns are parsed as
Float64from the text files. Cast to other types as needed after loading. - Column names with dashes in the header must be requested as symbols with quotes, e.g.
Symbol("rho-")andSymbol("rho+"). - For faster I/O, pass a smaller
varslist to read only the columns you need. - When supplying a custom
varslist, ensure the data files contain at least that many columns and that the order matches the file columns; otherwise parsing will fail.
Defined Methods - function defined for different arguments
- getclumps(dataobject::InfoType; ...) # no given variables -> all variables loaded
- getclumps(dataobject::InfoType, vars::Array{Symbol,1}; ...) # one or several given variables -> array needed
Examples
# read simulation information
julia> info = getinfo(420)
# Example 1:
# read clump data of all variables, full-box
julia> clumps = getclumps(info)
# Example 2:
# read clump data of all variables
# data range 20x20x4 kpc; ranges are given in kpc relative to the box (here: 48 kpc) center at 24 kpc
julia> clumps = getclumps( info,
xrange=[-10.,10.],
yrange=[-10.,10.],
zrange=[-2.,2.],
center=[24., 24., 24.],
range_unit=:kpc )
# Example 3:
# give the center of the box by simply passing: center = [:bc] or center = [:boxcenter]
# this is equivalent to center=[24.,24.,24.] in Example 2
# the following combination is also possible: e.g. center=[:bc, 12., 34.], etc.
julia> clumps = getclumps( info,
xrange=[-10.,10.],
yrange=[-10.,10.],
zrange=[-2.,2.],
center=[33., :bc, 10.],
range_unit=:kpc )
# Example 4:
# Load less than the found 12 columns from the header of the clump files;
# Pass an array with the variables to the keyword argument *vars*.
# The order of the variables has to be consistent with the header in the clump files:
julia> clumps = getclumps(info, [ :index, :lev, :parent, :ncell,
:peak_x, :peak_y, :peak_z ])
# Example 5:
# Load more than the found 12 columns from the header of the clump files.
# E.g. the list can be extended with more names if there are more columns
# in the data than given by the header in the files.
# The order of the variables has to be consistent with the header in the clump files:
julia> clumps = getclumps(info, [ :index, :lev, :parent, :ncell,
:peak_x, :peak_y, :peak_z,
Symbol("rho-"), Symbol("rho+"),
:rho_av, :mass_cl, :relevance,
:vx, :vy, :vz ])
...Mera.getsinks — Function
Read the RAMSES sink-particle catalogue into a SinkDataType
getsinks(dataobject::InfoType; vars::Array{Symbol,1}=[:all],
xrange::Array{<:Any,1}=[missing, missing],
yrange::Array{<:Any,1}=[missing, missing],
zrange::Array{<:Any,1}=[missing, missing],
center::CenterType=[0., 0., 0.],
range_unit::Symbol=:standard,
verbose::Bool=true) -> SinkDataTypeSink particles are RAMSES's accreting point masses (black holes, protostars, star-cluster particles). Unlike the AMR data they are written as ONE small CSV per output, sink_NNNNN.csv, not one file per CPU — the catalogue is global and short.
The file carries two header lines: the column names, and the dimensional formula of each column in terms of mass, length and time (m, l, l t**-1, m l**2 t**-1, …). Those formulas are preserved in used_descriptors[:units], so what each column means is not lost.
Returns
A SinkDataType whose data is an IndexedTable of the catalogue, one row per sink. A run with no sinks yet returns an empty table rather than failing — sinks are created during a run, so early outputs legitimately have none.
Arguments
dataobject: theInfoTypefromgetinfovars: columns to keep;[:all](default) keeps every column in the filexrange/yrange/zrange,center,range_unit: spatial selection on the sink positions (:x,:y,:z), in the same style asgetparticlesverbose: print a short summary
Notes
- Column names are taken from the file, so they follow RAMSES's spelling. Some are not valid Julia identifiers —
cs**2must be writtenSymbol("cs**2"). - All columns are parsed as
Float64, includingidandlevel; cast afterwards if needed. - Positions are in code units, as written by RAMSES. Use
getvarfor unit conversion.
Examples
info = getinfo(2, "path/to/output")
sinks = getsinks(info)
getvar(sinks, :msink, :Msol) # sink masses in solar masses
sinks.used_descriptors[:units][:msink] # "m" — the dimensional formula RAMSES recordedMera.getrt — Function
Read RAMSES radiative-transfer (RT) leaf-cells into an RtDataType.
RT data have the same AMR cell structure as hydro. Each photon group g contributes a photon number density Npgand flux componentsFxg/Fyg/Fzg (so nvarrt = 4 * nGroups). Variable names come from info.rt_variable_list.
getrt(dataobject::InfoType;
lmax::Real=dataobject.levelmax,
vars::Array{Symbol,1}=[:all],
xrange=[missing,missing], yrange=[missing,missing], zrange=[missing,missing],
center=[0.,0.,0.], range_unit::Symbol=:standard,
print_filenames::Bool=false, verbose::Bool=true, show_progress::Bool=true,
myargs::ArgumentsType=ArgumentsType(), max_threads::Int=Threads.nthreads())Returns an RtDataType with data (IndexedTable: position columns :cx,:cy,:cz, optionally :level/:cpu, then the selected RT variables), and info, lmin, lmax, boxlen, ranges, selected_rtvars, used_descriptors, scale.
info = getinfo(2, "…/rt_stromgren")
rt = getrt(info) # all RT variables
rt = getrt(info, vars=[:Np1, :Fx1]) # selectedOther simulation codes
Frontends for PLUTO, Chombo, Athena++, FLASH and the GADGET-HDF5 family (GADGET, AREPO), together with their code-specific entry points, the FoF/SUBFIND catalogue reader getgroups, and the run-time-log readers, live on the multicode branch, see Other Simulation Codes:
] add https://github.com/ManuelBehrendt/Mera.jl#multicodeThey register through the same reader registry the loaders above dispatch through, so nothing in this API changes when they are present.
Test simulations
Mera publishes eleven small RAMSES simulations as a GitHub release. Each has a known answer, so they can be used to check an installation without a large download.
Mera.download_testdata — Function
download_testdata([names]; dir, force=false, verbose=true)Download Mera's public RAMSES test simulations. They are small (a few MB each, except Bondi) and every one has a known answer, so they can be used to check that an installation behaves correctly without a large download.
Called with a single name, returns the path to that simulation, which can be handed straight to getinfo:
path = download_testdata("sedov3d_amr")
info = getinfo(path, output=7) # this run has 7 snapshots; 1 is before the blast
gas = gethydro(info)Called with several names or none at all, downloads them and returns the directory holding them. Anything already present is skipped unless force=true.
By default they land in joinpath(DEPOT_PATH[1], "mera_testdata"), alongside Julia's own package depot, so they survive between sessions. Pass dir to put them somewhere else.
The layout matches what Mera's test suite looks for, so the returned directory can be handed straight to it to run the data-backed tests:
ENV["MERA_TEST_DATA"] = download_testdata() # or a subset by name
using Pkg; Pkg.test("Mera")Available simulations, with download sizes:
| name | MB | what it is |
|---|---|---|
sedov3d_amr | 2.3 | Sedov blast on an AMR grid; the radius grows as t^(2/5) |
sedov3d_amr_mera | 0.8 | the same run as a mera-file (JLD2), no RAMSES needed |
sedov3d_grav_part | 7.6 | Sedov with self-gravity and particles |
mhdtube3d | 2.3 | MHD shock tube; a divergence-free field keeps Bx constant |
clumps3d | 26.8 | four density blobs, so the clump finder must return four |
sinks3d | 23.9 | sink particles accreting |
stromgren3d | 33.4 | Stromgren sphere; the ionisation front follows the analytic law |
legacy_particles3d | 0.1 | the pre-2017 particle format |
ramses_abc_flow | 5.7 | RAMSES's own ABC-flow test, run unchanged |
ramses_rt_dirac | 13.8 | RAMSES's own radiative-transfer test, run unchanged |
ramses_smbh_bondi | 165.4 | RAMSES's own Bondi accretion test, run unchanged |
See also: getinfo, synthetic_clumps for a data-free alternative.
Related
Spatial cuts after loading are in the Subregions API; value-based selection is in Masking & Filtering. To reload from Mera's own format instead, see the Mera-Files API.
Every docstring in the package is also on the Complete API Reference.
Covering Grid
Mera.covering_grid — Function
covering_grid(obj, var, [unit]; lmax=obj.lmax, center=[0.,0.,0.],
xrange=[missing,missing], yrange=[missing,missing], zrange=[missing,missing],
range_unit=:standard, max_bytes=4e9, pos_unit=:standard, verbose=true) -> CoveringGridResultResample AMR cell data (HydroDataType, GravDataType, or RtDataType) — or moving-mesh gas carried as particles (PartDataType with a :volume column, i.e. AREPO/GADGET PartType0) — onto a uniform Nx×Ny×Nz grid at refinement level lmax over the (optional) sub-box, every output cell sampled (not integrated). var may be a Symbol or a vector; unit likewise (defaults to code units).
For AMR cells, coarse leaves are replicated and fine leaves volume-averaged. For moving-mesh gas each output cell centre takes the value of the nearest generator that reaches it (KD-tree, capped at (√3/2)·V^(1/3) — the same ownership rule projection's weighting=:voronoi uses, so the two agree about which cell owns a point). Output cells that no cell reaches are NaN in both cases.
Point particles without a :volume column (stars, dark matter) have no extent to resample and raise an ArgumentError; use projection for those. Clumps raise a MethodError.
A uniform grid is dense and can be far larger than the AMR data — call covering_grid_memory first; this errors rather than allocate past max_bytes.
Pass periodic=true to let the window continue around a box face instead of being cut at it, which is what you want for a structure sitting on a boundary. A run that wraps in some directions only takes (x=true, y=true, z=false); getinfo reports which (info.boundaries). Without it the requested range is clamped to the box, so the grid comes back narrower than asked for.
gas = gethydro(getinfo(output, path))
covering_grid_memory(gas, [:rho, :T]; lmax=8) # check size first
cg = covering_grid(gas, [:rho, :T], [:nH, :K]; lmax=8) # then build
cg[:rho] # the 3-D arrayMera.covering_grid_memory — Function
covering_grid_memory(obj, [vars]; lmax=obj.lmax, center=[0.,0.,0.], xrange=[missing,missing],
yrange=[missing,missing], zrange=[missing,missing], range_unit=:standard,
verbose=true) -> NamedTuplePredict the size of the covering_grid before allocating it — a uniform grid is dense and can dwarf the sparse AMR data, so size it first. Returns (; level, dims, ncells, nvars, bytes_per_array, result_bytes, peak_bytes, amr_ncells, blowup): result_bytes is the returned arrays, peak_bytes the transient high-water mark during construction ((nvars+1) arrays — one shared geometric weight), and blowup = output cells ÷ AMR cells. vars only sets nvars (default 1). Pass an InfoType to size without loading data (then amr_ncells/blowup are missing).