Configuration API Reference
Functions that control Mera's global behaviour, and the constructors for the unit and constant tables that data objects carry.
Output Control
Global switches for how much Mera prints. Each one returns the current setting when called with no argument, so it can be queried as well as set.
Mera.verbose — Function
verbose(mode::Union{Bool,Nothing})
verbose()Set or show the global verbose mode for all subsequent Mera operations. verbose(false) silences Mera's text messages, verbose(true) forces them on (the per-function verbose= argument is then ignored), and verbose(nothing) reverts to each function's own argument (the neutral default). verbose() with no argument prints the current state. See also showprogress and the combined master switch output_mode.
verbose(false) # quiet
verbose() # prints "verbose_mode: false"
verbose(nothing) # back to per-function controlMera.showprogress — Function
showprogress(mode::Union{Bool,Nothing})
showprogress()Set or display the global progress-bar mode.
When called with a Bool, enables (true) or disables (false) progress bars for all subsequent Mera operations. Pass nothing to revert to each function's default behaviour. When called without arguments, prints the current setting.
Examples
showprogress(false) # suppress all progress bars
showprogress() # prints "showprogress_mode: false"
showprogress(nothing) # restore per-function defaultsMera.output_mode — Function
output_mode(mode::Union{Bool,Nothing})
output_mode()Master switch that sets both verbose and showprogress at once — so you don't toggle them separately. Same meaning as those: output_mode(false) silences all Mera text and progress bars globally, output_mode(true) forces both on, and output_mode(nothing) reverts both to each function's own verbose=/show_progress= argument (the neutral default). output_mode() with no argument prints the current state of both.
output_mode(false) # quiet: no messages, no progress bars, anywhere
output_mode(nothing) # back to per-function control
output_mode() # show current statePersistent Configuration
Settings that survive between sessions, stored in a configuration file rather than set per session.
Mera.mera_config — Function
mera_config(; reload=false) -> Dict{String,Dict{String,Any}}The merged user configuration, as section => key => value.
Sources, lowest precedence first: the legacy email.txt/zulip.txt/bell.txt, then mera_config_path's TOML, then environment variables. So a ~/.mera.toml wins over the old files when both exist, and an env var wins over everything.
mera_config()["zulip"]["server"]Results are cached; pass reload=true after editing the file in a live session. home redirects the legacy-file lookup, which exists so the resolution can be tested without reading the caller's real $HOME. See mera_config_example for a template.
Mera.mera_config_path — Function
mera_config_path() -> Union{String,Nothing}Path of the ~/.mera.toml in effect, or nothing when no TOML config exists (in which case the legacy email.txt/zulip.txt/bell.txt are still read). Checks $MERA_CONFIG, then ~/.mera.toml, then ~/.config/mera/config.toml. home redirects the last two so resolution can be tested without reading the caller's real home directory.
Mera.mera_config_example — Function
mera_config_example([io]) -> nothingPrint a complete, commented ~/.mera.toml template covering email, Zulip and the bell sound. Copy it, fill in what you use, and chmod 600 it — it holds an API key.
Constants and Scales
Every data object carries a table of physical constants and a table of scale factors that convert code units to physical units. These build them directly, which is what makes it possible to construct a working Mera object without any simulation files on disk.
Mera.createconstants — Function
createconstants() -> PhysicalUnitsTypeReturn Mera's table of physical constants in CGS units — G, c, kB, mH, Msol, pc, yr and the rest. This is what info.constants holds, and what every derived quantity is built from.
Use it to get the constants without an InfoType in hand; createconstants! fills the field on an existing info instead.
c = createconstants()
c.G # 6.6743e-8 cm³ g⁻¹ s⁻²
c.Msol # 1.9891e33 gMixing these CGS constants with code-unit quantities is the classic source of silently wrong answers — convert first, e.g. getvar(gas, :rho, :g_cm3).
See also createconstants!, createscales, getunit.
Mera.createscales — Function
createscales(info::InfoType) -> ScalesType
createscales(unit_l, unit_d, unit_t, unit_m, constants) -> ScalesTypeBuild the unit-conversion table — the object behind info.scale. Every entry is the factor that takes a code-unit quantity into that unit, so getvar(gas, :rho) .* info.scale.g_cm3 and getvar(gas, :rho, :g_cm3) agree.
The four-number form builds scales without an InfoType, which is how the unit tests check the conversions against CODATA without reading a snapshot.
Note a scale of exactly 1.0 cannot detect an inverted conversion (x*1 == x/1) — a fixture whose scale.kpc is 1 will not catch a reciprocal bug.
See also createscales!, createconstants, getunit.
Mera.createscales! — Function
Create an object with predefined scale factors from code to pysical units
function createscales!(dataobject::InfoType)
return ScalesType003Mera.setcomposition! — Function
setcomposition!(info; X_frac=0.76, mu=1/X_frac) -> InfoTypeState the gas composition of a run, and rebuild the unit table from it.
Two quantities depend on composition and no simulation format records them:
X_frac, the hydrogen mass fraction, converts a mass density to:nHmu, the mean molecular weight, converts pressure over density to a temperature in:K
The defaults are the RAMSES convention, X = 0.76 with mu = 1/X, and they are what every reader starts from. Another code will assume something else. PLUTO without a chemistry module treats the gas as fully ionised, X = 0.711 and mu = 0.614, which makes its temperatures about a factor of two lower than the default would give.
Nothing changes unless you call this, so existing results are unaffected.
info = getinfo(5, path)
setcomposition!(info; X_frac=0.711, mu=0.614) # PLUTO defaults, fully ionised
getvar(gas, :T, :K)getvar(gas, :T, :K_mu) needs no composition at all: it is Kelvin per unit mu, so you can multiply by whatever value your run implies.
Unit resolution itself goes through getunit, documented with the calculations that use it.